You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/11/10 07:23:58 UTC

[GitHub] [inlong] vernedeng opened a new pull request, #6501: [INLONG-6497][Manager] Support Elasticsearch cluster

vernedeng opened a new pull request, #6501:
URL: https://github.com/apache/inlong/pull/6501

   - Fixes #6497 
   
   ### Motivation
   
   Support Elasticsearch cluster
   
   ### Modifications
   
   *Describe the modifications you've done.*
   
   ### Verifying this change
   
   *(Please pick either of the following options)*
   
   - [ ] This change is a trivial rework/code cleanup without any test coverage.
   
   ### Documentation
   
     - Does this pull request introduce a new feature? yes 
     - If yes, how is the feature documented? JavaDocs
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] ciscozhou commented on a diff in pull request #6501: [INLONG-6497][Manager] Support Elasticsearch cluster

Posted by GitBox <gi...@apache.org>.
ciscozhou commented on code in PR #6501:
URL: https://github.com/apache/inlong/pull/6501#discussion_r1019172894


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/cluster/ElasticsearchClusterOperator.java:
##########
@@ -0,0 +1,85 @@
+/*
+ * 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.inlong.manager.service.cluster;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.inlong.manager.common.enums.ClusterType;
+import org.apache.inlong.manager.common.enums.ErrorCodeEnum;
+import org.apache.inlong.manager.common.exceptions.BusinessException;
+import org.apache.inlong.manager.common.util.CommonBeanUtils;
+import org.apache.inlong.manager.dao.entity.InlongClusterEntity;
+import org.apache.inlong.manager.pojo.cluster.ClusterInfo;
+import org.apache.inlong.manager.pojo.cluster.ClusterRequest;
+import org.apache.inlong.manager.pojo.cluster.es.ElasticsearchClusterInfo;
+import org.apache.inlong.manager.pojo.cluster.es.ElasticsearchClusterRequest;
+import org.apache.inlong.manager.pojo.cluster.es.ElasticsearchClusterDTO;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * Elasticsearch cluster operator.
+ */
+@Service
+public class ElasticsearchClusterOperator extends AbstractClusterOperator {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(ElasticsearchClusterOperator.class);
+
+    @Autowired
+    private ObjectMapper mapper;
+
+    @Override
+    public Boolean accept(String clusterType) {
+        return clusterType.equals(ClusterType.ES);

Review Comment:
   getClusterType().equals(clusterType);
   It might be better to change it this way.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] healchow commented on a diff in pull request #6501: [INLONG-6497][Manager] Support Elasticsearch cluster

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #6501:
URL: https://github.com/apache/inlong/pull/6501#discussion_r1027063819


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/cluster/ElasticsearchClusterOperator.java:
##########
@@ -0,0 +1,85 @@
+/*
+ * 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.inlong.manager.service.cluster;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.inlong.manager.common.enums.ClusterType;
+import org.apache.inlong.manager.common.enums.ErrorCodeEnum;
+import org.apache.inlong.manager.common.exceptions.BusinessException;
+import org.apache.inlong.manager.common.util.CommonBeanUtils;
+import org.apache.inlong.manager.dao.entity.InlongClusterEntity;
+import org.apache.inlong.manager.pojo.cluster.ClusterInfo;
+import org.apache.inlong.manager.pojo.cluster.ClusterRequest;
+import org.apache.inlong.manager.pojo.cluster.es.ElasticsearchClusterInfo;
+import org.apache.inlong.manager.pojo.cluster.es.ElasticsearchClusterRequest;
+import org.apache.inlong.manager.pojo.cluster.es.ElasticsearchClusterDTO;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * Elasticsearch cluster operator.
+ */
+@Service
+public class ElasticsearchClusterOperator extends AbstractClusterOperator {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(ElasticsearchClusterOperator.class);
+
+    @Autowired
+    private ObjectMapper mapper;
+
+    @Override
+    public Boolean accept(String clusterType) {
+        return getClusterType().equals(clusterType);
+    }
+
+    @Override
+    public String getClusterType() {
+        return ClusterType.ELASTICSEARCH;
+    }
+
+    @Override
+    protected void setTargetEntity(ClusterRequest request, InlongClusterEntity targetEntity) {
+        ElasticsearchClusterRequest esRequest = (ElasticsearchClusterRequest) request;
+        CommonBeanUtils.copyProperties(esRequest, targetEntity, true);
+        try {
+            ElasticsearchClusterDTO dto = ElasticsearchClusterDTO.getFromRequest(esRequest);
+            targetEntity.setExtParams(mapper.writeValueAsString(dto));
+            LOGGER.info("success to set entity for es cluster");
+        } catch (Exception e) {
+            throw new BusinessException(ErrorCodeEnum.SOURCE_INFO_INCORRECT.getMessage() + ": " + e.getMessage());
+        }
+    }
+
+    @Override
+    public ClusterInfo getFromEntity(InlongClusterEntity entity) {
+        if (entity == null) {
+            throw new BusinessException(ErrorCodeEnum.CLUSTER_NOT_FOUND);
+        }
+        ElasticsearchClusterInfo info = new ElasticsearchClusterInfo();
+        CommonBeanUtils.copyProperties(entity, info);
+        if (StringUtils.isNotBlank(entity.getExtParams())) {
+            ElasticsearchClusterDTO dto = ElasticsearchClusterDTO.getFromJson(entity.getExtParams());
+            CommonBeanUtils.copyProperties(dto, info);
+        }
+        LOGGER.info("success to get es cluster info from entity");

Review Comment:
   Ditto.



##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/cluster/ElasticsearchClusterOperator.java:
##########
@@ -0,0 +1,85 @@
+/*
+ * 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.inlong.manager.service.cluster;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.inlong.manager.common.enums.ClusterType;
+import org.apache.inlong.manager.common.enums.ErrorCodeEnum;
+import org.apache.inlong.manager.common.exceptions.BusinessException;
+import org.apache.inlong.manager.common.util.CommonBeanUtils;
+import org.apache.inlong.manager.dao.entity.InlongClusterEntity;
+import org.apache.inlong.manager.pojo.cluster.ClusterInfo;
+import org.apache.inlong.manager.pojo.cluster.ClusterRequest;
+import org.apache.inlong.manager.pojo.cluster.es.ElasticsearchClusterInfo;
+import org.apache.inlong.manager.pojo.cluster.es.ElasticsearchClusterRequest;
+import org.apache.inlong.manager.pojo.cluster.es.ElasticsearchClusterDTO;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * Elasticsearch cluster operator.
+ */
+@Service
+public class ElasticsearchClusterOperator extends AbstractClusterOperator {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(ElasticsearchClusterOperator.class);
+
+    @Autowired
+    private ObjectMapper mapper;
+
+    @Override
+    public Boolean accept(String clusterType) {
+        return getClusterType().equals(clusterType);
+    }
+
+    @Override
+    public String getClusterType() {
+        return ClusterType.ELASTICSEARCH;
+    }
+
+    @Override
+    protected void setTargetEntity(ClusterRequest request, InlongClusterEntity targetEntity) {
+        ElasticsearchClusterRequest esRequest = (ElasticsearchClusterRequest) request;
+        CommonBeanUtils.copyProperties(esRequest, targetEntity, true);
+        try {
+            ElasticsearchClusterDTO dto = ElasticsearchClusterDTO.getFromRequest(esRequest);
+            targetEntity.setExtParams(mapper.writeValueAsString(dto));
+            LOGGER.info("success to set entity for es cluster");

Review Comment:
   This is a high-frequency method and is not prone to errors. Even if errors occur, there will be exception information. Therefore, it is not recommended to print operation logs.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] vernedeng commented on a diff in pull request #6501: [INLONG-6497][Manager] Support Elasticsearch cluster

Posted by GitBox <gi...@apache.org>.
vernedeng commented on code in PR #6501:
URL: https://github.com/apache/inlong/pull/6501#discussion_r1020919361


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/cluster/ElasticsearchClusterOperator.java:
##########
@@ -0,0 +1,85 @@
+/*
+ * 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.inlong.manager.service.cluster;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.inlong.manager.common.enums.ClusterType;
+import org.apache.inlong.manager.common.enums.ErrorCodeEnum;
+import org.apache.inlong.manager.common.exceptions.BusinessException;
+import org.apache.inlong.manager.common.util.CommonBeanUtils;
+import org.apache.inlong.manager.dao.entity.InlongClusterEntity;
+import org.apache.inlong.manager.pojo.cluster.ClusterInfo;
+import org.apache.inlong.manager.pojo.cluster.ClusterRequest;
+import org.apache.inlong.manager.pojo.cluster.es.ElasticsearchClusterInfo;
+import org.apache.inlong.manager.pojo.cluster.es.ElasticsearchClusterRequest;
+import org.apache.inlong.manager.pojo.cluster.es.ElasticsearchClusterDTO;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * Elasticsearch cluster operator.
+ */
+@Service
+public class ElasticsearchClusterOperator extends AbstractClusterOperator {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(ElasticsearchClusterOperator.class);
+
+    @Autowired
+    private ObjectMapper mapper;
+
+    @Override
+    public Boolean accept(String clusterType) {
+        return clusterType.equals(ClusterType.ES);

Review Comment:
   fxied, thx



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] healchow merged pull request #6501: [INLONG-6497][Manager] Support Elasticsearch cluster

Posted by GitBox <gi...@apache.org>.
healchow merged PR #6501:
URL: https://github.com/apache/inlong/pull/6501


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org