From 1e9fb714b96a81df069431b778c4c17c4d58afdb Mon Sep 17 00:00:00 2001 From: casionone Date: Mon, 18 Sep 2023 15:07:48 +0800 Subject: [PATCH] fix group name may contain with _ such as APP_A --- .../scheduler/EntranceFIFOUserConsumer.java | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/scheduler/EntranceFIFOUserConsumer.java b/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/scheduler/EntranceFIFOUserConsumer.java index 387606256a..ac180d1aa3 100644 --- a/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/scheduler/EntranceFIFOUserConsumer.java +++ b/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/scheduler/EntranceFIFOUserConsumer.java @@ -40,23 +40,45 @@ public EntranceFIFOUserConsumer( public boolean runScheduleIntercept() { Consumer[] consumers = getSchedulerContext().getOrCreateConsumerManager().listConsumers(); int creatorRunningJobNum = 0; - String[] groupNames = getGroup().getGroupName().split("_"); - if (groupNames.length < 3) { + + // APP_TEST_hadoop_hive or IDE_hadoop_hive + String groupNameStr = getGroup().getGroupName(); + String[] groupNames = groupNameStr.split("_"); + int length = groupNames.length; + if (length < 3) { return true; } - String creatorName = groupNames[0]; - String ecType = groupNames[2]; + + // APP_TEST + int lastIndex = groupNameStr.lastIndexOf("_"); + int secondLastIndex = groupNameStr.lastIndexOf("_", lastIndex - 1); + String creatorName = groupNameStr.substring(0, secondLastIndex); + + // hive + String ecType = groupNames[length - 1]; + for (Consumer consumer : consumers) { String groupName = consumer.getGroup().getGroupName(); if (groupName.startsWith(creatorName) && groupName.endsWith(ecType)) { creatorRunningJobNum += consumer.getRunningEvents().length; } } + int creatorECTypeMaxRunningJobs = CreatorECTypeDefaultConf.getCreatorECTypeMaxRunningJobs(creatorName, ecType); + + if (logger.isDebugEnabled()) { + logger.debug( + "Creator: {} EC: {} there are currently:{} jobs running and maximum limit: {}", + creatorName, + ecType, + creatorRunningJobNum, + creatorECTypeMaxRunningJobs); + } + if (creatorRunningJobNum > creatorECTypeMaxRunningJobs) { logger.error( - "Creator: {} EC: {} there are currently {} jobs running that exceed the maximum limit: {}", + "Creator: {} EC: {} there are currently:{} jobs running that exceed the maximum limit: {}", creatorName, ecType, creatorRunningJobNum,