You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@uniffle.apache.org by "kaijchen (via GitHub)" <gi...@apache.org> on 2023/02/09 15:57:05 UTC

[GitHub] [incubator-uniffle] kaijchen commented on a diff in pull request #572: [#410] feat: support the hot reload of coordinator's configuration

kaijchen commented on code in PR #572:
URL: https://github.com/apache/incubator-uniffle/pull/572#discussion_r1101673914


##########
common/src/main/java/org/apache/uniffle/common/config/ReconfigurableBase.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.uniffle.common.config;
+
+import java.io.File;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.uniffle.common.util.ThreadUtils;
+
+public abstract class ReconfigurableBase implements Reconfigurable {
+
+  private static final Logger LOG = LoggerFactory.getLogger(ReconfigurableBase.class);
+  public static final String RECONFIGURABLE_FILE_NAME = "reconfigurable.file.name";
+
+  private final RssConf rssConf;
+
+  private final ScheduledExecutorService scheduledExecutorService;
+  private long checkIntervalSec;
+  private final AtomicLong lastModify = new AtomicLong(0L);
+
+  public ReconfigurableBase(RssConf rssConf) {
+    this.rssConf = rssConf;
+    scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(
+        ThreadUtils.getThreadFactory("ReconfigurableThread-%d"));
+    checkIntervalSec = rssConf.getLong(RssBaseConf.RSS_RECONFIGURE_INTERVAL_SEC);
+  }
+
+  public void startReconfigureThread() {
+    scheduledExecutorService.scheduleAtFixedRate(
+        () -> checkConfiguration(), checkIntervalSec, checkIntervalSec, TimeUnit.SECONDS);

Review Comment:
   ```suggestion
           this::checkConfiguration, checkIntervalSec, checkIntervalSec, TimeUnit.SECONDS);
   ```



##########
integration-test/common/src/test/java/org/apache/uniffle/test/CoordinatorAssignmentTest.java:
##########
@@ -142,4 +152,28 @@ public void testAssignmentServerNodesNumber() throws Exception {
     info = shuffleWriteClient.getShuffleAssignments("app1", 0, 10, 1, TAGS, SERVER_NUM - 1, -1);
     assertEquals(SHUFFLE_NODES_MAX - 1, info.getServerToPartitionRanges().keySet().size());
   }
+
+  @Test
+  public void testReconfigureNodeMax() throws Exception {
+    String fileName = coordinators.get(0).getCoordinatorConf()
+        .getString(ReconfigurableBase.RECONFIGURABLE_FILE_NAME,"");
+    new File(fileName).createNewFile();

Review Comment:
   ```suggestion
       assertTrue(new File(fileName).createNewFile());
   ```



##########
common/src/main/java/org/apache/uniffle/common/config/ReconfigurableBase.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.uniffle.common.config;
+
+import java.io.File;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.uniffle.common.util.ThreadUtils;
+
+public abstract class ReconfigurableBase implements Reconfigurable {
+
+  private static final Logger LOG = LoggerFactory.getLogger(ReconfigurableBase.class);
+  public static final String RECONFIGURABLE_FILE_NAME = "reconfigurable.file.name";
+
+  private final RssConf rssConf;
+
+  private final ScheduledExecutorService scheduledExecutorService;
+  private long checkIntervalSec;

Review Comment:
   ```suggestion
     private final long checkIntervalSec;
   ```



-- 
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: issues-unsubscribe@uniffle.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@uniffle.apache.org
For additional commands, e-mail: issues-help@uniffle.apache.org