diff --git a/linkis-commons/linkis-scheduler/src/test/scala/org/apache/linkis/scheduler/queue/PriorityLoopArrayQueueTest.java b/linkis-commons/linkis-scheduler/src/test/scala/org/apache/linkis/scheduler/queue/PriorityLoopArrayQueueTest.java index f0a8c82696..e050e03f4b 100644 --- a/linkis-commons/linkis-scheduler/src/test/scala/org/apache/linkis/scheduler/queue/PriorityLoopArrayQueueTest.java +++ b/linkis-commons/linkis-scheduler/src/test/scala/org/apache/linkis/scheduler/queue/PriorityLoopArrayQueueTest.java @@ -29,6 +29,7 @@ class PriorityLoopArrayQueueTest { AtomicInteger productCounter = new AtomicInteger(); AtomicInteger consumerCounter = new AtomicInteger(); + Random rand = new Random(); @Test public void testConcurrentPutAndTake() throws Exception { @@ -39,7 +40,7 @@ public void testConcurrentPutAndTake() throws Exception { // 获取开始时间的毫秒数 long startTime = System.currentTimeMillis(); // 三分钟的毫秒数 - long threeMinutesInMillis = 1 * 30 * 1000; + long threeMinutesInMillis = 30 * 1000L; int genLen = 5; int getLen = 7; final CountDownLatch latch = new CountDownLatch(genLen + getLen + 1); @@ -48,7 +49,7 @@ public void testConcurrentPutAndTake() throws Exception { final int id = i; new Thread(() -> { try{ - Thread.sleep(100 * id); + Thread.sleep(100L * id); latch.countDown(); latch.await(); } catch (InterruptedException e){ @@ -193,7 +194,6 @@ private void printEvent(String opt, SchedulerEvent event) { System.out.println("【" + Thread.currentThread().getName() + "】" + opt + ":" + event.getId() + ", priority: " + event.getPriority() + ", index: " + event.getIndex()); } private int getRandom(int bound){ - Random rand = new Random(); int res = rand.nextInt(bound); return res; } diff --git a/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/org/apache/linkis/manager/am/pointer/AbstractNodePointer.java b/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/org/apache/linkis/manager/am/pointer/AbstractNodePointer.java index fc0a1fca24..1c6f810033 100644 --- a/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/org/apache/linkis/manager/am/pointer/AbstractNodePointer.java +++ b/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/org/apache/linkis/manager/am/pointer/AbstractNodePointer.java @@ -85,4 +85,9 @@ public boolean equals(Object obj) { } return false; } + + @Override + public int hashCode() { + return getNode().getServiceInstance().hashCode(); + } } diff --git a/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/org/apache/linkis/manager/rm/external/yarn/YarnResourceRequester.java b/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/org/apache/linkis/manager/rm/external/yarn/YarnResourceRequester.java index 048dc96e97..6dffa6cfbc 100644 --- a/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/org/apache/linkis/manager/rm/external/yarn/YarnResourceRequester.java +++ b/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/org/apache/linkis/manager/rm/external/yarn/YarnResourceRequester.java @@ -219,7 +219,7 @@ public YarnQueueInfo getResources( realQueueName = queueName; JsonNode childQueues = getChildQueuesOfCapacity(schedulerInfo); Optional queue = getQueueOfCapacity(childQueues, realQueueName); - if (queue == null || !queue.isPresent()) { + if (!queue.isPresent()) { logger.debug( "cannot find any information about queue " + queueName + ", response: " + resp); throw new RMWarnException( @@ -241,7 +241,7 @@ public YarnQueueInfo getResources( JsonNode childQueues = getChildQueues(schedulerInfo.path("rootQueue")); queue = getQueue(childQueues, realQueueName); } - if (queue == null || !queue.isPresent()) { + if (!queue.isPresent()) { logger.debug( "cannot find any information about queue " + queueName + ", response: " + resp); throw new RMWarnException( @@ -414,7 +414,7 @@ public String getAndUpdateActiveRmWebAddress(ExternalResourceProvider provider) String haAddress = (String) provider.getConfigMap().get("rmWebAddress"); String activeAddress = rmAddressMap.get(haAddress); if (StringUtils.isBlank(activeAddress)) { - synchronized (haAddress.intern()) { + synchronized (haAddress.intern()) { // NOSONAR if (StringUtils.isBlank(activeAddress)) { if (logger.isDebugEnabled()) { logger.debug( diff --git a/linkis-computation-governance/linkis-manager/linkis-label-common/src/main/java/org/apache/linkis/manager/label/entity/cluster/ClusterLabel.java b/linkis-computation-governance/linkis-manager/linkis-label-common/src/main/java/org/apache/linkis/manager/label/entity/cluster/ClusterLabel.java index b07c77f4d8..06fbfd6293 100644 --- a/linkis-computation-governance/linkis-manager/linkis-label-common/src/main/java/org/apache/linkis/manager/label/entity/cluster/ClusterLabel.java +++ b/linkis-computation-governance/linkis-manager/linkis-label-common/src/main/java/org/apache/linkis/manager/label/entity/cluster/ClusterLabel.java @@ -84,6 +84,11 @@ public boolean equals(Object other) { } } + @Override + public int hashCode() { + return getClusterName().hashCode() + getClusterType().hashCode(); + } + @Override public void valueCheck(String stringValue) throws LabelErrorException { if (!StringUtils.isEmpty(stringValue)) { diff --git a/linkis-computation-governance/linkis-manager/linkis-manager-common/src/main/java/org/apache/linkis/manager/common/entity/resource/SpecialResource.java b/linkis-computation-governance/linkis-manager/linkis-manager-common/src/main/java/org/apache/linkis/manager/common/entity/resource/SpecialResource.java index 80b3bc5729..f7934b0bc4 100644 --- a/linkis-computation-governance/linkis-manager/linkis-manager-common/src/main/java/org/apache/linkis/manager/common/entity/resource/SpecialResource.java +++ b/linkis-computation-governance/linkis-manager/linkis-manager-common/src/main/java/org/apache/linkis/manager/common/entity/resource/SpecialResource.java @@ -19,6 +19,7 @@ import org.apache.linkis.manager.common.exception.ResourceWarnException; +import java.math.BigDecimal; import java.text.MessageFormat; import java.util.AbstractMap; import java.util.HashMap; @@ -292,11 +293,11 @@ public boolean equalsTo(Resource r) { if (v instanceof Integer && rsV instanceof Integer) { return (int) v != (int) rsV; } else if (v instanceof Double && rsV instanceof Double) { - return (double) v != (double) rsV; + return !BigDecimal.valueOf((double) v).equals(BigDecimal.valueOf((double) rsV)); } else if (v instanceof Long && rsV instanceof Long) { return (long) v != (long) rsV; } else if (v instanceof Float && rsV instanceof Float) { - return (float) v != (float) rsV; + return !BigDecimal.valueOf((float) v).equals(BigDecimal.valueOf((float) rsV)); } else if (v instanceof Short && rsV instanceof Short) { return (short) v != (short) rsV; } else { diff --git a/linkis-engineconn-plugins/spark/src/main/java/org/apache/linkis/engineplugin/spark/client/deployment/util/FileUtils.java b/linkis-engineconn-plugins/spark/src/main/java/org/apache/linkis/engineplugin/spark/client/deployment/util/FileUtils.java index 2b311b91bd..57c375c804 100644 --- a/linkis-engineconn-plugins/spark/src/main/java/org/apache/linkis/engineplugin/spark/client/deployment/util/FileUtils.java +++ b/linkis-engineconn-plugins/spark/src/main/java/org/apache/linkis/engineplugin/spark/client/deployment/util/FileUtils.java @@ -63,6 +63,8 @@ public final class FileUtils { public static final String PACKAGE_SEPARATOR = "."; + public static final Random rnd = new Random(); + // ------------------------------------------------------------------------ public static void writeCompletely(WritableByteChannel channel, ByteBuffer src) @@ -91,7 +93,6 @@ public static Path[] listDirectory(Path directory) throws IOException { * @return the generated random filename with the given prefix */ public static String getRandomFilename(final String prefix) { - final Random rnd = new Random(); final StringBuilder stringBuilder = new StringBuilder(prefix); for (int i = 0; i < RANDOM_FILE_NAME_LENGTH; i++) { diff --git a/linkis-engineconn-plugins/spark/src/main/java/org/apache/linkis/engineplugin/spark/client/deployment/util/KubernetesHelper.java b/linkis-engineconn-plugins/spark/src/main/java/org/apache/linkis/engineplugin/spark/client/deployment/util/KubernetesHelper.java index 709308d084..fe58e7bfd2 100644 --- a/linkis-engineconn-plugins/spark/src/main/java/org/apache/linkis/engineplugin/spark/client/deployment/util/KubernetesHelper.java +++ b/linkis-engineconn-plugins/spark/src/main/java/org/apache/linkis/engineplugin/spark/client/deployment/util/KubernetesHelper.java @@ -60,7 +60,7 @@ public static KubernetesClient getKubernetesClient( kubeConfigFile, k8sMasterUrl); - if (StringUtils.isBlank(kubeConfigFile) && StringUtils.isBlank(kubeConfigFile)) { + if (StringUtils.isBlank(kubeConfigFile)) { throw new KubernetesClientException( "Both kubeConfigFile and k8sMasterUrl are empty. Initializing KubernetesClient failed."); } diff --git a/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scheduled/JobHistoryMonitor.java b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scheduled/JobHistoryMonitor.java index 08dca4214b..c1a7a16d06 100644 --- a/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scheduled/JobHistoryMonitor.java +++ b/linkis-extensions/linkis-et-monitor/src/main/java/org/apache/linkis/monitor/scheduled/JobHistoryMonitor.java @@ -231,7 +231,7 @@ public void jdbcUnfinishedAlertScan() { long id = Optional.ofNullable(CacheUtils.cacheBuilder.getIfPresent("jdbcUnfinishedAlertScan")) .orElse(MonitorConfig.JOB_HISTORY_TIME_EXCEED.getValue()); - long intervalMs = 7200 * 1000; + long intervalMs = 7200 * 1000L; long maxIntervalMs = Constants.ERRORCODE_MAX_INTERVALS_SECONDS() * 1000; long endTime = System.currentTimeMillis(); long startTime = endTime - intervalMs; @@ -254,7 +254,7 @@ public void jdbcUnfinishedKillScan() { long id = Optional.ofNullable(CacheUtils.cacheBuilder.getIfPresent("jdbcUnfinishedKillScan")) .orElse(MonitorConfig.JOB_HISTORY_TIME_EXCEED.getValue()); - long intervalMs = 7200 * 1000; + long intervalMs = 7200 * 1000L; long maxIntervalMs = Constants.ERRORCODE_MAX_INTERVALS_SECONDS() * 1000; long endTime = System.currentTimeMillis(); long startTime = endTime - intervalMs;