diff --git a/linkis-computation-governance/linkis-manager/label-manager/src/main/scala/org/apache/linkis/manager/label/service/impl/DefaultNodeLabelService.scala b/linkis-computation-governance/linkis-manager/label-manager/src/main/scala/org/apache/linkis/manager/label/service/impl/DefaultNodeLabelService.scala
index 765c630393..85014ab6aa 100644
--- a/linkis-computation-governance/linkis-manager/label-manager/src/main/scala/org/apache/linkis/manager/label/service/impl/DefaultNodeLabelService.scala
+++ b/linkis-computation-governance/linkis-manager/label-manager/src/main/scala/org/apache/linkis/manager/label/service/impl/DefaultNodeLabelService.scala
@@ -17,8 +17,6 @@
package org.apache.linkis.manager.label.service.impl
-import java.util
-
import org.apache.linkis.common.ServiceInstance
import org.apache.linkis.common.utils.{Logging, Utils}
import org.apache.linkis.manager.common.entity.node.ScoreServiceInstance
@@ -27,8 +25,7 @@ import org.apache.linkis.manager.common.utils.ManagerUtils
import org.apache.linkis.manager.label.LabelManagerUtils
import org.apache.linkis.manager.label.builder.factory.LabelBuilderFactoryContext
import org.apache.linkis.manager.label.conf.LabelManagerConf
-import org.apache.linkis.manager.label.entity.Label.ValueRelation
-import org.apache.linkis.manager.label.entity.{Feature, Label, UserModifiable}
+import org.apache.linkis.manager.label.entity.{Feature, Label}
import org.apache.linkis.manager.label.score.NodeLabelScorer
import org.apache.linkis.manager.label.service.NodeLabelService
import org.apache.linkis.manager.label.utils.LabelUtils
@@ -38,6 +35,7 @@ import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import org.springframework.util.CollectionUtils
+import java.util
import scala.collection.JavaConversions._
import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer
@@ -179,13 +177,6 @@ class DefaultNodeLabelService extends NodeLabelService with Logging {
labelManagerPersistence.removeNodeLabels(instance, removeLabels.map(_.getId))
}
- @Transactional(rollbackFor = Array(classOf[Exception]))
- override def removeLabelsFromNodeWithoutPermanent(instance: ServiceInstance, permanentLabel: Array[String] = Array()): Unit = {
- val labels = labelManagerPersistence.getLabelByServiceInstance(instance)
- val lowerCasePermanentLabels = permanentLabel.map(_.toLowerCase())
- val withoutPermanentLabel = labels.filterNot(label => lowerCasePermanentLabels.contains(label.getLabelKey.toLowerCase)).map(_.getId)
- labelManagerPersistence.removeNodeLabels(instance, withoutPermanentLabel)
- }
/**
* Get node instances by labels
diff --git a/linkis-computation-governance/linkis-manager/linkis-manager-persistence/src/main/java/org/apache/linkis/manager/dao/LabelManagerMapper.java b/linkis-computation-governance/linkis-manager/linkis-manager-persistence/src/main/java/org/apache/linkis/manager/dao/LabelManagerMapper.java
index edccfec522..f21cf4a80a 100644
--- a/linkis-computation-governance/linkis-manager/linkis-manager-persistence/src/main/java/org/apache/linkis/manager/dao/LabelManagerMapper.java
+++ b/linkis-computation-governance/linkis-manager/linkis-manager-persistence/src/main/java/org/apache/linkis/manager/dao/LabelManagerMapper.java
@@ -20,9 +20,11 @@
import org.apache.linkis.common.ServiceInstance;
import org.apache.linkis.manager.common.entity.label.LabelKeyValue;
import org.apache.linkis.manager.common.entity.persistence.PersistenceLabel;
+import org.apache.linkis.manager.common.entity.persistence.PersistenceLabelRel;
import org.apache.linkis.manager.common.entity.persistence.PersistenceNode;
import org.apache.linkis.manager.common.entity.persistence.PersistenceResource;
import org.apache.ibatis.annotations.*;
+import org.apache.linkis.manager.label.entity.Label;
import java.util.List;
import java.util.Map;
@@ -30,275 +32,65 @@
@Mapper
public interface LabelManagerMapper {
- @Options(useGeneratedKeys = true, keyProperty = "persistenceLabel.id", keyColumn = "id")
- @Insert("INSERT INTO linkis_cg_manager_label (label_key,label_value,label_feature,label_value_size,update_time,create_time) VALUES" +
- "(#{persistenceLabel.labelKey},#{persistenceLabel.stringValue},#{persistenceLabel.feature},#{persistenceLabel.labelValueSize},now(), now())")
+
void registerLabel(@Param("persistenceLabel") PersistenceLabel persistenceLabel);
- @Insert({""})
void registerLabelKeyValues(@Param("labelValueKeyAndContent") Map labelValueKeyAndContent, @Param("labelId") int labelId);
- @Select("select * from linkis_cg_manager_label where id=#{id}")
- @Results({
- @Result(property = "labelKey", column = "label_key"),
- @Result(property = "feature", column = "label_feature"),
- @Result(property = "labelValueSize", column = "label_value_size"),
- @Result(property = "updateTime", column = "update_time"),
- @Result(property = "createTime", column = "create_time"),
- @Result(property = "stringValue", column = "label_value")
- })
PersistenceLabel getLabel(@Param("id") int id);
- @Delete("delete from linkis_cg_manager_label where id =#{id}")
+
void deleteLabel(@Param("id") int id);
- @Delete("delete from linkis_cg_manager_label where label_key =#{labelKey} and label_value=#{labelStringValue} ")
void deleteByLabel(@Param("labelKey") String labelKey, @Param("labelStringValue") String labelStringValue);
- @Delete("delete from linkis_cg_manager_label_value_relation where label_id =#{id}")
void deleteLabelKeyVaules(@Param("id") int id);
- @Update("update linkis_cg_manager_label set label_key = #{persistenceLabel.labelKey},label_value = #{persistenceLabel.stringValue}," +
- "label_feature=#{persistenceLabel.feature},label_value_size=#{persistenceLabel.labelValueSize},update_time=#{persistenceLabel.updateTime} where id=#{id}")
void updateLabel(@Param("id") int id, @Param("persistenceLabel") PersistenceLabel persistenceLabel);
-
- @Insert({
- ""
- })
void addLabelServiceInstance(@Param("instance") String instance, @Param("labelIds") List labelIds);
- @Select("")
- @Results({
- @Result(property = "labelKey", column = "label_key"),
- @Result(property = "feature", column = "label_feature"),
- @Result(property = "labelValueSize", column = "label_value_size"),
- @Result(property = "updateTime", column = "update_time"),
- @Result(property = "createTime", column = "create_time"),
- @Result(property = "stringValue", column = "label_value")
- })
- List getLabelsByLabelKeyValues(@Param("labelKeyValues") Map labelKeyValues);
-
-
- @Select("")
- @Results({
- @Result(property = "labelKey", column = "label_key"),
- @Result(property = "feature", column = "label_feature"),
- @Result(property = "labelValueSize", column = "label_value_size"),
- @Result(property = "updateTime", column = "update_time"),
- @Result(property = "createTime", column = "create_time"),
- @Result(property = "stringValue", column = "label_value")
- })
- PersistenceLabel getLabelByLabelKeyValues(@Param("labelKey") String labelKey, @Param("labelKeyValues") Map labelKeyValues);
-
- @Select("select * from linkis_cg_manager_label where id in (select label_id from linkis_cg_manager_label_service_instance where service_instance=#{instance})")
- @Results({
- @Result(property = "labelKey", column = "label_key"),
- @Result(property = "feature", column = "label_feature"),
- @Result(property = "labelValueSize", column = "label_value_size"),
- @Result(property = "updateTime", column = "update_time"),
- @Result(property = "createTime", column = "create_time"),
- @Result(property = "stringValue", column = "label_value")
- })
List getLabelByServiceInstance(@Param("instance") String instance);
- @Select("")
- List getLabelByLabelKeyValuesOverload(@Param("labelKeyValues") Map labelKeyValues);
-
-
- @Select("select * from linkis_cg_manager_label where id in (select label_id from linkis_cg_manager_label_resource A join linkis_cg_manager_linkis_resources B on A.resource_id = B.id where A.resource_id = #{persistenceResource.id} )")
- @Results({
- @Result(property = "labelKey", column = "label_key"),
- @Result(property = "feature", column = "label_feature"),
- @Result(property = "labelValueSize", column = "label_value_size"),
- @Result(property = "updateTime", column = "update_time"),
- @Result(property = "createTime", column = "create_time"),
- @Result(property = "stringValue", column = "label_value")
- })
List getLabelByResource(@Param("persistenceResource") PersistenceResource persistenceResource);
-// @Insert("insert into linkis_cg_manager_label_resource (label_id, resource_id, update_time, create_time)" +
-// "values(#{labelId}, #{resourceId}, now(), now())")
-// void addLabelResource(@Param("labelId")int labelId,@Param("resourceId")int resourceId);
-
- @Insert({
- ""
- })
void addLabelsAndResource(@Param("resourceId") int resourceId, @Param("labelIds") List labelIds);
-// @Insert({
-// ""
-// })
-// void addLabelAndResources(@Param("labelId")int labelId,@Param("resourceIds")List resourceIds);
-
-// @Select("select id from linkis_cg_manager_label where creator = #{creator}")
-// List getLabelIds (@Param("creator") String creator);
-//
-// @Select("select resource_id from linkis_cg_manager_label_resource where label_id = #{labelId}")
-// List getResourceIdsByLabelId (@Param("labelId") int labelId);
-//
-// @Select("")
-// List getResourcesByLabels (@Param("labelIds") List labelIds);
-
- @Select("select * from linkis_cg_manager_linkis_resources A join linkis_cg_manager_label_resource B on A.id = B.resource_id " +
- "and B.label_id in (select id from linkis_cg_manager_label where label_key=#{labelKey} and label_value=#{stringValue})")
- @Results({
- @Result(property = "maxResource", column = "max_resource"),
- @Result(property = "minResource", column = "min_resource"),
- @Result(property = "usedResource", column = "used_resource"),
- @Result(property = "leftResource", column = "left_resource"),
- @Result(property = "expectedResource", column = "expected_resource"),
- @Result(property = "lockedResource", column = "locked_resource"),
- @Result(property = "updateTime", column = "update_time"),
- @Result(property = "createTime", column = "create_time")
- })
List getResourcesByLabel(@Param("labelKey") String labelKey, @Param("stringValue") String stringValue);
- @Select("select label_id from linkis_cg_manager_label_service_instance where service_instance = #{instance}")
+
List getLabelIdsByInstance(@Param("instance") String instance);
- @Select("select * from linkis_cg_manager_label A join linkis_cg_manager_label_service_instance B on A.id = B.label_id where B.service_instance = #{instance}")
List getLabelsByInstance(@Param("instance") String instance);
- @Select("select * from linkis_cg_manager_service_instance A join linkis_cg_manager_label_service_instance B on A.instance = B.service_instance where B.label_id=#{labelId}")
- @Results({
- @Result(property = "updateTime", column = "update_time"),
- @Result(property = "createTime", column = "create_time")
- })
List getInstanceByLabelId(@Param("labelId") int labelId);
+ List getResourcesByLabels(@Param("labels") List extends Label> labels);
+
- @Select("")
List getInstanceIdsByLabelIds(@Param("labelIds") List labelIds);
- @Select("")
- @Results({
- @Result(property = "labelKey", column = "label_key"),
- @Result(property = "feature", column = "label_feature"),
- @Result(property = "labelValueSize", column = "label_value_size"),
- @Result(property = "updateTime", column = "update_time"),
- @Result(property = "createTime", column = "create_time"),
- @Result(property = "stringValue", column = "label_value")
- })
List getLabelsByLabelIds(@Param("labelIds") List labelIds);
- @Insert({
- ""
- })
+
void addLabelsByUser(@Param("userName") String userName, @Param("labelIds") List labelIds);
- @Select("select username from linkis_cg_manager_label_user where label_id = #{labelId}")
+
List getUserNameByLabelId(@Param("labelId") int labelId);
- @Select("")
List getUserNamesByLabelIds(@Param("labelIds") List labelIds);
- @Select("select * from linkis_cg_manager_label A join linkis_cg_manager_label_user B on A.id = B.label_id and B.username = #{userName}")
- @Results({
- @Result(property = "labelKey", column = "label_key"),
- @Result(property = "feature", column = "label_feature"),
- @Result(property = "labelValueSize", column = "label_value_size"),
- @Result(property = "updateTime", column = "update_time"),
- @Result(property = "createTime", column = "create_time"),
- @Result(property = "stringValue", column = "label_value")
- })
List getLabelsByUser(@Param("userName") String userName);
- @Select("select * from linkis_cg_manager_label where label_key = #{labelKey}")
- @Results({
- @Result(property = "labelKey", column = "label_key"),
- @Result(property = "feature", column = "label_feature"),
- @Result(property = "labelValueSize", column = "label_value_size"),
- @Result(property = "updateTime", column = "update_time"),
- @Result(property = "createTime", column = "create_time"),
- @Result(property = "stringValue", column = "label_value")
- })
List getLabelsByLabelKey(@Param("labelKey") String labelKey);
- @Delete("delete from linkis_cg_manager_label_resource A join linkis_cg_manager_linkis_resources B on A.resource_id = B.id and B.ticketId=#{ticketId}")
void deleteLabelResourceByByTicketId(@Param("ticketId") String ticketId);
-
- @Delete({""
- })
void deleteLabelIdsAndInstance(@Param("instance") String instance, @Param("labelIds") List labelIds);
- @Delete({""
- })
void deleteLabelIdsByUser(@Param("userName") String userName, @Param("labelIds") List labelIds);
- @Delete("delete from linkis_cg_manager_label_user where label_id=#{labelId}")
void deleteUserById(int labelId);
/**
@@ -309,6 +101,8 @@ public interface LabelManagerMapper {
*/
List