Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev 1.9.0 bug fix #637

Merged
merged 14 commits into from
Nov 5, 2024
Prev Previous commit
Next Next commit
Code optimization
“v_kkhuang” committed Nov 4, 2024
commit 9e7dd1a719ac89c7a27fb55ac700d0d8ad744806
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@
import org.apache.linkis.server.BDPJettyServerHelper;
import org.apache.linkis.ujes.client.response.EmsListResult;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
@@ -108,10 +109,14 @@ public static String getJDBCConf(String user, String conf) {
.build();
KeyvalueResult result = client.getConfKeyValue(build);
Map data = MapUtils.getMap(result.getResultMap(), "data", new HashMap<>());
ArrayList arrayList =
BDPJettyServerHelper.gson().fromJson(data.get("configValues").toString(), ArrayList.class);
Map map = BDPJettyServerHelper.gson().fromJson(arrayList.get(0).toString(), Map.class);
return MapUtils.getString(map, "configValue", "");
ArrayList arrayList = (ArrayList) data.get("configValues");
if (CollectionUtils.isNotEmpty(arrayList)) {
String json = BDPJettyServerHelper.gson().toJson(arrayList.get(0));
Map map = BDPJettyServerHelper.gson().fromJson(json, Map.class);
return MapUtils.getString(map, "configValue", "");
} else {
return "";
}
}

public static Map getDatasourceConf(String user, String datasourceName) {
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@
package org.apache.linkis.monitor.jobhistory.jobtime

import org.apache.linkis.common.utils.Logging
import org.apache.linkis.monitor.config.MonitorConfig
import org.apache.linkis.monitor.constants.Constants
import org.apache.linkis.monitor.core.ob.Observer
import org.apache.linkis.monitor.core.pac.{AbstractScanRule, ScannedData}
@@ -26,7 +27,7 @@ import org.apache.linkis.monitor.jobhistory.exception.AnomalyScannerException
import org.apache.linkis.monitor.until.CacheUtils

import java.util
import java.util.Locale
import java.util.{Locale, Optional}

import scala.collection.JavaConverters._

@@ -72,6 +73,7 @@ class JobTimeExceedRule(thresholds: util.Set[String], hitObserver: Observer)
val alertData: util.List[JobHistory] = new util.ArrayList[JobHistory]()
for (sd <- data.asScala) {
if (sd != null && sd.getData() != null) {
var idLong = 0L
for (d <- sd.getData().asScala) {
if (d.isInstanceOf[JobHistory]) {
val jobHistory = d.asInstanceOf[JobHistory]
@@ -82,11 +84,24 @@ class JobTimeExceedRule(thresholds: util.Set[String], hitObserver: Observer)
alertData.add(d.asInstanceOf[JobHistory])
}
}
scanRuleList.put("jobhistoryScan", jobHistory.getId)
if (idLong == 0L || jobHistory.getId < idLong) {
idLong = jobHistory.getId
}
} else {
logger.warn("Ignored wrong input data Type : " + d + ", " + d.getClass.getCanonicalName)
}
}
if (idLong > 0L) {
val id = Optional
.ofNullable(CacheUtils.cacheBuilder.getIfPresent("jobhistoryScan"))
.orElse(MonitorConfig.JOB_HISTORY_TIME_EXCEED.getValue)
if (id == 0) {
scanRuleList.put("jobhistoryScan", idLong)
}
if (id > idLong) {
scanRuleList.put("jobhistoryScan", idLong)
}
}
} else {
logger.warn("Ignored null scanned data")
}