You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by pe...@apache.org on 2022/08/17 10:51:36 UTC
[incubator-linkis] branch dev-1.2.0 updated: fix the exception of java.util.NoSuchElementException: None.get (#2848)
This is an automated email from the ASF dual-hosted git repository.
peacewong pushed a commit to branch dev-1.2.0
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git
The following commit(s) were added to refs/heads/dev-1.2.0 by this push:
new d4d469c33 fix the exception of java.util.NoSuchElementException: None.get (#2848)
d4d469c33 is described below
commit d4d469c3310251cfc7efb8bd775f216a8699787d
Author: Casion <ca...@gmail.com>
AuthorDate: Wed Aug 17 18:51:32 2022 +0800
fix the exception of java.util.NoSuchElementException: None.get (#2848)
---
.../linkis/manager/rm/restful/RMMonitorRest.scala | 48 ++++++++++++----------
1 file changed, 26 insertions(+), 22 deletions(-)
diff --git a/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/scala/org/apache/linkis/manager/rm/restful/RMMonitorRest.scala b/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/scala/org/apache/linkis/manager/rm/restful/RMMonitorRest.scala
index 55b8a58ad..b565e96ca 100644
--- a/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/scala/org/apache/linkis/manager/rm/restful/RMMonitorRest.scala
+++ b/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/scala/org/apache/linkis/manager/rm/restful/RMMonitorRest.scala
@@ -501,28 +501,32 @@ class RMMonitorRest extends Logging {
} else {
metrics.get(node.getServiceInstance.toString).foreach(metricsConverter.fillMetricsToNode(node, _))
if (withResource) {
- val userCreatorLabel = node.getLabels.asScala.find(_.isInstanceOf[UserCreatorLabel]).get.asInstanceOf[UserCreatorLabel]
- val engineTypeLabel = node.getLabels.asScala.find(_.isInstanceOf[EngineTypeLabel]).get.asInstanceOf[EngineTypeLabel]
- val engineInstanceLabel = node.getLabels.asScala.find(_.isInstanceOf[EngineInstanceLabel]).get.asInstanceOf[EngineInstanceLabel]
- engineInstanceLabel.setServiceName(node.getServiceInstance.getApplicationName)
- engineInstanceLabel.setInstance(node.getServiceInstance.getInstance)
- val nodeResource = labelResourceService.getLabelResource(engineInstanceLabel)
- val configurationKey = getUserCreator(userCreatorLabel) + getEngineType(engineTypeLabel)
- val configuredResource = configurationMap.get(configurationKey) match {
- case Some(resource) => resource
- case None =>
- if (nodeResource != null) {
- val resource = UserConfiguration.getUserConfiguredResource(nodeResource.getResourceType, userCreatorLabel, engineTypeLabel)
- configurationMap.put(configurationKey, resource)
- resource
- } else null
- }
- if(nodeResource != null) {
- nodeResource.setMaxResource(configuredResource)
- if(null == nodeResource.getUsedResource) nodeResource.setUsedResource(nodeResource.getLockedResource)
- if(null == nodeResource.getMinResource) nodeResource.setMinResource(Resource.initResource(nodeResource.getResourceType))
-// node.setNodeResource(ResourceUtils.convertTo(nodeResource, ResourceType.LoadInstance))
- node.setNodeResource(nodeResource)
+ val userCreatorLabelOption = node.getLabels.asScala.find(_.isInstanceOf[UserCreatorLabel])
+ val engineTypeLabelOption = node.getLabels.asScala.find(_.isInstanceOf[EngineTypeLabel])
+ val engineInstanceOption = node.getLabels.asScala.find(_.isInstanceOf[EngineInstanceLabel])
+ if (userCreatorLabelOption.isDefined && engineTypeLabelOption.isDefined && engineInstanceOption.isDefined) {
+ val userCreatorLabel = userCreatorLabelOption.get.asInstanceOf[UserCreatorLabel]
+ val engineTypeLabel = engineTypeLabelOption.get.asInstanceOf[EngineTypeLabel]
+ val engineInstanceLabel = engineInstanceOption.get.asInstanceOf[EngineInstanceLabel]
+ engineInstanceLabel.setServiceName(node.getServiceInstance.getApplicationName)
+ engineInstanceLabel.setInstance(node.getServiceInstance.getInstance)
+ val nodeResource = labelResourceService.getLabelResource(engineInstanceLabel)
+ val configurationKey = getUserCreator(userCreatorLabel) + getEngineType(engineTypeLabel)
+ val configuredResource = configurationMap.get(configurationKey) match {
+ case Some(resource) => resource
+ case None =>
+ if (nodeResource != null) {
+ val resource = UserConfiguration.getUserConfiguredResource(nodeResource.getResourceType, userCreatorLabel, engineTypeLabel)
+ configurationMap.put(configurationKey, resource)
+ resource
+ } else null
+ }
+ if (nodeResource != null) {
+ nodeResource.setMaxResource(configuredResource)
+ if (null == nodeResource.getUsedResource) nodeResource.setUsedResource(nodeResource.getLockedResource)
+ if (null == nodeResource.getMinResource) nodeResource.setMinResource(Resource.initResource(nodeResource.getResourceType))
+ node.setNodeResource(nodeResource)
+ }
}
}
node
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org