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/12/31 08:33:49 UTC

[GitHub] [shardingsphere] menghaoranss opened a new pull request #8846: Add cache manager for configuration changes

menghaoranss opened a new pull request #8846:
URL: https://github.com/apache/shardingsphere/pull/8846


   For #8579
   


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



[GitHub] [shardingsphere] menghaoranss commented on a change in pull request #8846: Add cache manager for configuration changes

Posted by GitBox <gi...@apache.org>.
menghaoranss commented on a change in pull request #8846:
URL: https://github.com/apache/shardingsphere/pull/8846#discussion_r550440683



##########
File path: shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/config/ConfigCacheManager.java
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.governance.core.config;
+
+import com.google.common.base.Joiner;
+import org.apache.shardingsphere.governance.repository.api.ConfigurationRepository;
+
+import java.util.UUID;
+
+/**
+ * Config cache manager.
+ */
+public final class ConfigCacheManager {
+    
+    private static final String CACHE_KEY = "cache";
+    
+    private static final String PATH_SEPARATOR = "/";
+    
+    private final ConfigurationRepository repository;
+    
+    public ConfigCacheManager(final ConfigurationRepository repository) {
+        this.repository = repository;
+    }
+    
+    /**
+     * Cache configuration.
+     * 
+     * @param key key
+     * @param configuration configuration
+     * @return cache id
+     */
+    public String cache(final String key, final String configuration) {
+        String cacheId = getCacheId();
+        repository.persist(Joiner.on(PATH_SEPARATOR).join(key, CACHE_KEY, cacheId), configuration);
+        return cacheId;
+    }
+    
+    private String getCacheId() {
+        return UUID.randomUUID().toString().replace("-", "");

Review comment:
       After the rule is modified by RDL, the scaling job needs to be triggered automatically.  The rule will be persisted to ZK  only after the scaling job is completed, so it needs to be cached in advance. After the scaling job is completed, the rule configurations will be persisted to ZK and synchronized to memory according to the cashId.(May be it's a version number)




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



[GitHub] [shardingsphere] kimmking commented on a change in pull request #8846: Add cache manager for configuration changes

Posted by GitBox <gi...@apache.org>.
kimmking commented on a change in pull request #8846:
URL: https://github.com/apache/shardingsphere/pull/8846#discussion_r550438813



##########
File path: shardingsphere-governance/shardingsphere-governance-core/src/main/java/org/apache/shardingsphere/governance/core/config/ConfigCacheManager.java
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.governance.core.config;
+
+import com.google.common.base.Joiner;
+import org.apache.shardingsphere.governance.repository.api.ConfigurationRepository;
+
+import java.util.UUID;
+
+/**
+ * Config cache manager.
+ */
+public final class ConfigCacheManager {
+    
+    private static final String CACHE_KEY = "cache";
+    
+    private static final String PATH_SEPARATOR = "/";
+    
+    private final ConfigurationRepository repository;
+    
+    public ConfigCacheManager(final ConfigurationRepository repository) {
+        this.repository = repository;
+    }
+    
+    /**
+     * Cache configuration.
+     * 
+     * @param key key
+     * @param configuration configuration
+     * @return cache id
+     */
+    public String cache(final String key, final String configuration) {
+        String cacheId = getCacheId();
+        repository.persist(Joiner.on(PATH_SEPARATOR).join(key, CACHE_KEY, cacheId), configuration);
+        return cacheId;
+    }
+    
+    private String getCacheId() {
+        return UUID.randomUUID().toString().replace("-", "");

Review comment:
       what's the meaning for cacheID and how to use it?




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



[GitHub] [shardingsphere] kimmking merged pull request #8846: Add cache manager for configuration changes

Posted by GitBox <gi...@apache.org>.
kimmking merged pull request #8846:
URL: https://github.com/apache/shardingsphere/pull/8846


   


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