Unverified Commit fa2d5a4d authored by Zzm0809's avatar Zzm0809 Committed by GitHub

[Fix] fix array out of bounds (#3279)

parent c6f4a851
...@@ -35,6 +35,7 @@ import org.dinky.gateway.result.SavePointResult; ...@@ -35,6 +35,7 @@ import org.dinky.gateway.result.SavePointResult;
import org.dinky.gateway.result.TestResult; import org.dinky.gateway.result.TestResult;
import org.dinky.gateway.result.YarnResult; import org.dinky.gateway.result.YarnResult;
import org.dinky.utils.FlinkJsonUtil; import org.dinky.utils.FlinkJsonUtil;
import org.dinky.utils.ThreadUtil;
import org.apache.flink.client.deployment.ClusterRetrieveException; import org.apache.flink.client.deployment.ClusterRetrieveException;
import org.apache.flink.client.program.ClusterClient; import org.apache.flink.client.program.ClusterClient;
...@@ -58,6 +59,7 @@ import org.apache.hadoop.security.UserGroupInformation; ...@@ -58,6 +59,7 @@ import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.service.Service; import org.apache.hadoop.service.Service;
import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.ApplicationReport; import org.apache.hadoop.yarn.api.records.ApplicationReport;
import org.apache.hadoop.yarn.api.records.ContainerReport;
import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
import org.apache.hadoop.yarn.api.records.YarnApplicationState; import org.apache.hadoop.yarn.api.records.YarnApplicationState;
import org.apache.hadoop.yarn.client.api.YarnClient; import org.apache.hadoop.yarn.client.api.YarnClient;
...@@ -384,13 +386,20 @@ public abstract class YarnGateway extends AbstractGateway { ...@@ -384,13 +386,20 @@ public abstract class YarnGateway extends AbstractGateway {
} }
protected String getYarnContainerLog(ApplicationReport applicationReport) throws YarnException, IOException { protected String getYarnContainerLog(ApplicationReport applicationReport) throws YarnException, IOException {
String logUrl = yarnClient // Wait for up to 2.5 s. If the history log is not found yet, a prompt message will be returned.
int counts = 5;
while (yarnClient
.getContainers(applicationReport.getCurrentApplicationAttemptId()) .getContainers(applicationReport.getCurrentApplicationAttemptId())
.get(0) .isEmpty()
.getLogUrl(); && counts-- > 0) {
ThreadUtil.sleep(500);
}
List<ContainerReport> containers = yarnClient.getContainers(applicationReport.getCurrentApplicationAttemptId());
if (CollUtil.isNotEmpty(containers)) {
String logUrl = containers.get(0).getLogUrl();
String content = HttpUtil.get(logUrl + "/jobmanager.log?start=-10000"); String content = HttpUtil.get(logUrl + "/jobmanager.log?start=-10000");
String log = ReUtil.getGroup1(HTML_TAG_REGEX, content); return ReUtil.getGroup1(HTML_TAG_REGEX, content);
logger.info("\n\nHistory log url is: {}\n\n ", logUrl); }
return log; return "No history log found yet. so can't get log url, please check yarn cluster status or check if the flink job is running in yarn cluster or please go to yarn interface to view the log.";
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment