You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/07/03 12:01:51 UTC

[GitHub] [shardingsphere-ui] menghaoranss commented on a change in pull request #3: Add metadata info shown in ShardingSphere-UI

menghaoranss commented on a change in pull request #3:
URL: https://github.com/apache/shardingsphere-ui/pull/3#discussion_r449543999



##########
File path: shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/MetadataCenterService.java
##########
@@ -0,0 +1,34 @@
+/*
+ * 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.shardingsphere.ui.servcie;
+
+import org.apache.shardingsphere.orchestration.core.metadatacenter.MetaDataCenterNode;
+
+/**
+ * metadata center service.

Review comment:
       Comments should start with a capital letter.

##########
File path: shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/MetadataCenterServiceImpl.java
##########
@@ -0,0 +1,49 @@
+/*
+ * 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.shardingsphere.ui.servcie.impl;
+
+import org.apache.shardingsphere.orchestration.core.metadatacenter.MetaDataCenterNode;
+import org.apache.shardingsphere.ui.common.constant.OrchestrationType;
+import org.apache.shardingsphere.ui.common.domain.CenterConfig;
+import org.apache.shardingsphere.ui.common.exception.ShardingSphereUIException;
+import org.apache.shardingsphere.ui.servcie.CenterConfigService;
+import org.apache.shardingsphere.ui.servcie.MetadataCenterService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.Optional;
+
+/**
+ * Implementation of metadata center operation service.
+ */
+@Service
+public class MetadataCenterServiceImpl implements MetadataCenterService {

Review comment:
       This class should be final.

##########
File path: shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/MetadataCenterServiceImpl.java
##########
@@ -0,0 +1,49 @@
+/*
+ * 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.shardingsphere.ui.servcie.impl;
+
+import org.apache.shardingsphere.orchestration.core.metadatacenter.MetaDataCenterNode;
+import org.apache.shardingsphere.ui.common.constant.OrchestrationType;
+import org.apache.shardingsphere.ui.common.domain.CenterConfig;
+import org.apache.shardingsphere.ui.common.exception.ShardingSphereUIException;
+import org.apache.shardingsphere.ui.servcie.CenterConfigService;
+import org.apache.shardingsphere.ui.servcie.MetadataCenterService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.Optional;
+
+/**
+ * Implementation of metadata center operation service.
+ */
+@Service
+public class MetadataCenterServiceImpl implements MetadataCenterService {
+
+    @Resource
+    private CenterConfigService centerConfigService;
+
+    @Override
+    public MetaDataCenterNode getActivateMetaDataCenterNode() {
+        Optional<CenterConfig> optional = centerConfigService.loadActivated(OrchestrationType.CONFIG_CENTER.getValue());
+        if (optional.isPresent()) {
+            return new MetaDataCenterNode(optional.get().getOrchestrationName());
+        }
+        throw new ShardingSphereUIException(ShardingSphereUIException.SERVER_ERROR, "No activated metadata center!");
+    }
+

Review comment:
       Remove the empty line.

##########
File path: shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/MetadataCenterService.java
##########
@@ -0,0 +1,34 @@
+/*
+ * 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.shardingsphere.ui.servcie;
+
+import org.apache.shardingsphere.orchestration.core.metadatacenter.MetaDataCenterNode;
+
+/**
+ * metadata center service.
+ **/
+public interface MetadataCenterService {
+
+    /**
+     * Get activated metadata center node.
+     *
+     * @return metadata center node
+     */
+    MetaDataCenterNode getActivateMetaDataCenterNode();
+

Review comment:
       Remove this empty line.

##########
File path: shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/servcie/impl/ShardingSchemaServiceImpl.java
##########
@@ -90,7 +94,13 @@ public void deleteSchemaConfiguration(final String schemaName) {
         schemaNameList.remove(schemaName);
         configCenterRepository.persist(configCenterService.getActivateConfigurationNode().getSchemaPath(), Joiner.on(",").join(schemaNameList));
     }
-    
+
+    @Override
+    public String getMetadataConfiguration(String schemaName) {

Review comment:
       The parameter should be final.

##########
File path: shardingsphere-ui-backend/src/main/java/org/apache/shardingsphere/ui/web/controller/ShardingSchemaController.java
##########
@@ -122,5 +122,15 @@ public ResponseResult updateDataSourceConfiguration(@PathVariable("schemaName")
         shardingSchemaService.updateDataSourceConfiguration(schemaName, configMap.get("dataSourceConfig"));
         return ResponseResultUtil.success();
     }
+
+    /**
+     * Load meta data configuration.

Review comment:
       Need an empty line.




----------------------------------------------------------------
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.

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