You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by le...@apache.org on 2022/06/22 14:46:05 UTC

[incubator-linkis] branch dev-1.2.0 updated (f8cbf458a -> b2f1efbfc)

This is an automated email from the ASF dual-hosted git repository.

legendtkl pushed a change to branch dev-1.2.0
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git


    from f8cbf458a Add built-in variables run_today_h and run_today_h_std (#2299)
     new 61e99b8dd Entrance adds restful interface to support modifying routelabel #2320
     new 25d9bb10f fix build error
     new b2f1efbfc Fix rpc protocol

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../conf/linkis-cg-entrance.properties             |  2 +
 .../assembly-combined/conf/linkis.properties       |  2 +-
 .../protocol/label/InsLabelRefreshRequest.java     | 28 ++++++++-
 .../entrance/restful/EntranceLabelRestfulApi.java  | 69 ++++++++++++++++++++++
 .../label/client/EurekaInstanceLabelClient.scala   | 20 +++----
 .../label/client/InstanceLabelClient.scala         | 10 +++-
 6 files changed, 115 insertions(+), 16 deletions(-)
 create mode 100644 linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/restful/EntranceLabelRestfulApi.java


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org


[incubator-linkis] 01/03: Entrance adds restful interface to support modifying routelabel #2320

Posted by le...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

legendtkl pushed a commit to branch dev-1.2.0
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git

commit 61e99b8ddd401d39daca030c523082ad7c1ffc3f
Author: peacewong <wp...@gmail.com>
AuthorDate: Wed Jun 22 17:18:36 2022 +0800

    Entrance adds restful interface to support modifying routelabel #2320
---
 .../conf/linkis-cg-entrance.properties             |  2 +
 .../assembly-combined/conf/linkis.properties       |  2 +-
 .../protocol/label/InsLabelRefreshRequest.java     | 28 ++++++++-
 .../entrance/restful/EntranceLabelRestfulApi.java  | 69 ++++++++++++++++++++++
 .../label/client/EurekaInstanceLabelClient.scala   | 20 +++----
 .../label/client/InstanceLabelClient.scala         | 10 +++-
 6 files changed, 115 insertions(+), 16 deletions(-)

diff --git a/assembly-combined-package/assembly-combined/conf/linkis-cg-entrance.properties b/assembly-combined-package/assembly-combined/conf/linkis-cg-entrance.properties
index cfba4b7b7..6ef5b538d 100644
--- a/assembly-combined-package/assembly-combined/conf/linkis-cg-entrance.properties
+++ b/assembly-combined-package/assembly-combined/conf/linkis-cg-entrance.properties
@@ -20,6 +20,8 @@ wds.linkis.server.socket.mode=false
 #wds.linkis.entrance.config.log.path=hdfs:///tmp/linkis/
 wds.linkis.resultSet.store.path=hdfs:///tmp/linkis
 
+wds.linkis.server.user.restful.uri.pass.auth=/actuator/prometheus,/api/rest_j/v1/offline,/api/rest_j/v1/entrance/operation
+
 ## enable entrance label registration
 #spring.eureka.instance.metadata-map.route=et1
 ##Spring
diff --git a/assembly-combined-package/assembly-combined/conf/linkis.properties b/assembly-combined-package/assembly-combined/conf/linkis.properties
index 073407a82..f39b022fb 100644
--- a/assembly-combined-package/assembly-combined/conf/linkis.properties
+++ b/assembly-combined-package/assembly-combined/conf/linkis.properties
@@ -51,7 +51,7 @@ wds.linkis.home=/appcom/Install/LinkisInstall
 #Linkis governance station administrators
 wds.linkis.governance.station.admin=hadoop
 wds.linkis.gateway.conf.publicservice.list=query,jobhistory,application,configuration,filesystem,udf,variable,microservice,errorcode,bml,datasource
-wds.linkis.server.user.restful.uri.pass.auth=/actuator/prometheus,/api/rest_j/v1/offline,/api/rest_j/v1/entrance/api/metrics/runningtask
+wds.linkis.server.user.restful.uri.pass.auth=/actuator/prometheus,/api/rest_j/v1/offline
 
 wds.linkis.gateway.conf.metadataquery.list=metadatamanager,metadataquery
 spring.spring.servlet.multipart.max-file-size=500MB
diff --git a/linkis-commons/linkis-protocol/src/main/java/org/apache/linkis/protocol/label/InsLabelRefreshRequest.java b/linkis-commons/linkis-protocol/src/main/java/org/apache/linkis/protocol/label/InsLabelRefreshRequest.java
index 9a38e9f15..9ef972ff6 100644
--- a/linkis-commons/linkis-protocol/src/main/java/org/apache/linkis/protocol/label/InsLabelRefreshRequest.java
+++ b/linkis-commons/linkis-protocol/src/main/java/org/apache/linkis/protocol/label/InsLabelRefreshRequest.java
@@ -19,13 +19,37 @@ package org.apache.linkis.protocol.label;
 
 import org.apache.linkis.common.ServiceInstance;
 
+import java.util.HashMap;
 import java.util.Map;
 
-public class InsLabelRefreshRequest extends InsLabelAttachRequest {
+public class InsLabelRefreshRequest {
+
+    /** Service instance */
+    private ServiceInstance serviceInstance;
+
+    /** Labels stored as map structure */
+    private Map<String, Object> labels = new HashMap<>();
 
     public InsLabelRefreshRequest() {}
 
     public InsLabelRefreshRequest(ServiceInstance serviceInstance, Map<String, Object> labels) {
-        super(serviceInstance, labels);
+        this.serviceInstance = serviceInstance;
+        this.labels = labels;
+    }
+
+    public ServiceInstance getServiceInstance() {
+        return serviceInstance;
+    }
+
+    public void setServiceInstance(ServiceInstance serviceInstance) {
+        this.serviceInstance = serviceInstance;
+    }
+
+    public Map<String, Object> getLabels() {
+        return labels;
+    }
+
+    public void setLabels(Map<String, Object> labels) {
+        this.labels = labels;
     }
 }
diff --git a/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/restful/EntranceLabelRestfulApi.java b/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/restful/EntranceLabelRestfulApi.java
new file mode 100644
index 000000000..051574de0
--- /dev/null
+++ b/linkis-computation-governance/linkis-entrance/src/main/java/org/apache/linkis/entrance/restful/EntranceLabelRestfulApi.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.entrance.restful;
+
+import org.apache.linkis.instance.label.client.InstanceLabelClient;
+import org.apache.linkis.manager.label.constant.LabelKeyConstant;
+import org.apache.linkis.protocol.label.InsLabelRefreshRequest;
+import org.apache.linkis.rpc.Sender;
+import org.apache.linkis.server.Message;
+
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@RestController
+@RequestMapping(path = "/entrance/operation/label")
+public class EntranceLabelRestfulApi {
+
+    private static final Logger logger = LoggerFactory.getLogger(EntranceLabelRestfulApi.class);
+
+    @RequestMapping(path = "/update", method = RequestMethod.POST)
+    public Message updateRouteLabel(HttpServletRequest req, @RequestBody JsonNode jsonNode) {
+        String routeLabel = jsonNode.get("routeLabel").textValue();
+        Map<String, Object> labels = new HashMap<String, Object>();
+        logger.info("Prepare to update entrance label {}", routeLabel);
+        labels.put(LabelKeyConstant.ROUTE_KEY, routeLabel);
+        InsLabelRefreshRequest insLabelRefreshRequest = new InsLabelRefreshRequest();
+        insLabelRefreshRequest.setLabels(labels);
+        insLabelRefreshRequest.setServiceInstance(Sender.getThisServiceInstance());
+        InstanceLabelClient.getInstance().refreshLabelsToInstance(insLabelRefreshRequest);
+        logger.info("Finished to update entrance label {}", routeLabel);
+        return Message.ok();
+    }
+
+    @RequestMapping(path = "/markoffline", method = RequestMethod.GET)
+    public Message updateRouteLabel(HttpServletRequest req) {
+        Map<String, Object> labels = new HashMap<String, Object>();
+        logger.info("Prepare to modify the routelabel of entry to offline");
+        labels.put(LabelKeyConstant.ROUTE_KEY, "offline");
+        InsLabelRefreshRequest insLabelRefreshRequest = new InsLabelRefreshRequest();
+        insLabelRefreshRequest.setLabels(labels);
+        insLabelRefreshRequest.setServiceInstance(Sender.getThisServiceInstance());
+        InstanceLabelClient.getInstance().refreshLabelsToInstance(insLabelRefreshRequest);
+        logger.info("Finished to modify the routelabel of entry to offline");
+        return Message.ok();
+    }
+}
diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-instance-label/linkis-instance-label-client/src/main/scala/org/apache/linkis/instance/label/client/EurekaInstanceLabelClient.scala b/linkis-public-enhancements/linkis-publicservice/linkis-instance-label/linkis-instance-label-client/src/main/scala/org/apache/linkis/instance/label/client/EurekaInstanceLabelClient.scala
index dc9f71648..d9b780514 100644
--- a/linkis-public-enhancements/linkis-publicservice/linkis-instance-label/linkis-instance-label-client/src/main/scala/org/apache/linkis/instance/label/client/EurekaInstanceLabelClient.scala
+++ b/linkis-public-enhancements/linkis-publicservice/linkis-instance-label/linkis-instance-label-client/src/main/scala/org/apache/linkis/instance/label/client/EurekaInstanceLabelClient.scala
@@ -17,19 +17,19 @@
  
 package org.apache.linkis.instance.label.client
 
-import java.util
-
-import org.apache.linkis.common.utils.Logging
-import org.apache.linkis.protocol.label.{InsLabelAttachRequest, InsLabelRemoveRequest}
-import org.apache.linkis.rpc.Sender
-import javax.annotation.PostConstruct
 import org.apache.commons.lang3.StringUtils
+import org.apache.linkis.common.utils.Logging
 import org.apache.linkis.manager.label.constant.LabelKeyConstant
+import org.apache.linkis.protocol.label.{InsLabelRefreshRequest, InsLabelRemoveRequest}
+import org.apache.linkis.rpc.Sender
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.cloud.client.serviceregistry.Registration
 import org.springframework.context.event.{ContextClosedEvent, EventListener}
 import org.springframework.stereotype.Component
 
+import java.util
+import javax.annotation.PostConstruct
+
 
 @Component
 class EurekaInstanceLabelClient extends Logging {
@@ -48,10 +48,10 @@ class EurekaInstanceLabelClient extends Logging {
       info(s"Start to register label for instance $metadata")
       val labels = new util.HashMap[String, Object]()
       labels.put(LabelKeyConstant.ROUTE_KEY, metadata.get(LabelKeyConstant.ROUTE_KEY))
-      val insLabelAttachRequest = new InsLabelAttachRequest
-      insLabelAttachRequest.setLabels(metadata.asInstanceOf[java.util.Map[String, Object]])
-      insLabelAttachRequest.setServiceInstance(Sender.getThisServiceInstance)
-      InstanceLabelClient.getInstance.attachLabelsToInstance(insLabelAttachRequest)
+      val insLabelRefreshRequest = new InsLabelRefreshRequest
+      insLabelRefreshRequest.setLabels(metadata.asInstanceOf[java.util.Map[String, Object]])
+      insLabelRefreshRequest.setServiceInstance(Sender.getThisServiceInstance)
+      InstanceLabelClient.getInstance.attachLabelsToInstance(insLabelRefreshRequest)
     }
   }
 
diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-instance-label/linkis-instance-label-client/src/main/scala/org/apache/linkis/instance/label/client/InstanceLabelClient.scala b/linkis-public-enhancements/linkis-publicservice/linkis-instance-label/linkis-instance-label-client/src/main/scala/org/apache/linkis/instance/label/client/InstanceLabelClient.scala
index bab74f309..ca28c145f 100644
--- a/linkis-public-enhancements/linkis-publicservice/linkis-instance-label/linkis-instance-label-client/src/main/scala/org/apache/linkis/instance/label/client/InstanceLabelClient.scala
+++ b/linkis-public-enhancements/linkis-publicservice/linkis-instance-label/linkis-instance-label-client/src/main/scala/org/apache/linkis/instance/label/client/InstanceLabelClient.scala
@@ -23,7 +23,7 @@ import org.apache.linkis.common.utils.{Logging, Utils}
 import org.apache.linkis.manager.label.builder.factory.LabelBuilderFactoryContext
 import org.apache.linkis.manager.label.entity.Label
 import org.apache.linkis.manager.label.utils.LabelUtils
-import org.apache.linkis.protocol.label.{InsLabelAttachRequest, InsLabelQueryRequest, InsLabelQueryResponse, InsLabelRemoveRequest, LabelInsQueryRequest, LabelInsQueryResponse}
+import org.apache.linkis.protocol.label.{InsLabelAttachRequest, InsLabelQueryRequest, InsLabelQueryResponse, InsLabelRefreshRequest, InsLabelRemoveRequest, LabelInsQueryRequest, LabelInsQueryResponse}
 import org.apache.linkis.rpc.Sender
 import org.apache.linkis.rpc.conf.RPCConfiguration.PUBLIC_SERVICE_APPLICATION_NAME
 import org.apache.linkis.server.BDPJettyServerHelper
@@ -36,14 +36,18 @@ class InstanceLabelClient extends Logging {
 
   val labelBuilderFactory = LabelBuilderFactoryContext.getLabelBuilderFactory
 
-  def attachLabelsToInstance(insLabelAttachRequest: InsLabelAttachRequest): Unit = {
-    getSender().send(insLabelAttachRequest)
+  def refreshLabelsToInstance(insLabelRefreshRequest: InsLabelRefreshRequest): Unit = {
+    getSender().send(insLabelRefreshRequest)
   }
 
   def removeLabelsFromInstance(insLabelRemoveRequest: InsLabelRemoveRequest): Unit = {
     getSender().send(insLabelRemoveRequest)
   }
 
+  def attachLabelsToInstance(insLabelAttachRequest: InsLabelAttachRequest): Unit = {
+    getSender().send(insLabelAttachRequest)
+  }
+
   def getSender(): Sender = {
     Sender.getSender(InstanceLabelClient.INSTANCE_LABEL_SERVER_NAME.getValue)
   }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org


[incubator-linkis] 03/03: Fix rpc protocol

Posted by le...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

legendtkl pushed a commit to branch dev-1.2.0
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git

commit b2f1efbfcf304f04f6990e24e25923825147ec03
Author: peacewong <wp...@gmail.com>
AuthorDate: Wed Jun 22 20:23:04 2022 +0800

    Fix rpc protocol
---
 .../java/org/apache/linkis/protocol/label/InsLabelRefreshRequest.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linkis-commons/linkis-protocol/src/main/java/org/apache/linkis/protocol/label/InsLabelRefreshRequest.java b/linkis-commons/linkis-protocol/src/main/java/org/apache/linkis/protocol/label/InsLabelRefreshRequest.java
index 9ef972ff6..c8f889380 100644
--- a/linkis-commons/linkis-protocol/src/main/java/org/apache/linkis/protocol/label/InsLabelRefreshRequest.java
+++ b/linkis-commons/linkis-protocol/src/main/java/org/apache/linkis/protocol/label/InsLabelRefreshRequest.java
@@ -22,7 +22,7 @@ import org.apache.linkis.common.ServiceInstance;
 import java.util.HashMap;
 import java.util.Map;
 
-public class InsLabelRefreshRequest {
+public class InsLabelRefreshRequest implements LabelRequest {
 
     /** Service instance */
     private ServiceInstance serviceInstance;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org


[incubator-linkis] 02/03: fix build error

Posted by le...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

legendtkl pushed a commit to branch dev-1.2.0
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git

commit 25d9bb10f39c02943c00db0a606c5d5f4ef8397e
Author: peacewong <wp...@gmail.com>
AuthorDate: Wed Jun 22 17:35:39 2022 +0800

    fix build error
---
 .../apache/linkis/instance/label/client/EurekaInstanceLabelClient.scala | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-instance-label/linkis-instance-label-client/src/main/scala/org/apache/linkis/instance/label/client/EurekaInstanceLabelClient.scala b/linkis-public-enhancements/linkis-publicservice/linkis-instance-label/linkis-instance-label-client/src/main/scala/org/apache/linkis/instance/label/client/EurekaInstanceLabelClient.scala
index d9b780514..968f38d02 100644
--- a/linkis-public-enhancements/linkis-publicservice/linkis-instance-label/linkis-instance-label-client/src/main/scala/org/apache/linkis/instance/label/client/EurekaInstanceLabelClient.scala
+++ b/linkis-public-enhancements/linkis-publicservice/linkis-instance-label/linkis-instance-label-client/src/main/scala/org/apache/linkis/instance/label/client/EurekaInstanceLabelClient.scala
@@ -51,7 +51,7 @@ class EurekaInstanceLabelClient extends Logging {
       val insLabelRefreshRequest = new InsLabelRefreshRequest
       insLabelRefreshRequest.setLabels(metadata.asInstanceOf[java.util.Map[String, Object]])
       insLabelRefreshRequest.setServiceInstance(Sender.getThisServiceInstance)
-      InstanceLabelClient.getInstance.attachLabelsToInstance(insLabelRefreshRequest)
+      InstanceLabelClient.getInstance.refreshLabelsToInstance(insLabelRefreshRequest)
     }
   }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org