You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@uniffle.apache.org by "advancedxy (via GitHub)" <gi...@apache.org> on 2023/02/09 09:12:54 UTC
[GitHub] [incubator-uniffle] advancedxy commented on a diff in pull request #572: [#410] feat: support the hot reload of coordinator's configuration
advancedxy commented on code in PR #572:
URL: https://github.com/apache/incubator-uniffle/pull/572#discussion_r1101154710
##########
common/src/main/java/org/apache/uniffle/common/config/Reconfigurable.java:
##########
@@ -0,0 +1,26 @@
+/*
+ * 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;
+
+public interface Reconfigurable {
+
+ void reconfigure(RssConf conf);
+
+ boolean isPropertyReconfigurable(String property);
Review Comment:
is it possible to mark the properties is reloadable or not in the ConfigOptionBuilder, which seems more nature.
Also, for this PR, I didn't see this method is used anywhere?
##########
common/src/main/java/org/apache/uniffle/common/config/ReconfigurableBase.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * 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 ScheduledExecutorService scheduledExecutorService;
+ private long checkIntervalSec;
+ private 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);
+ }
+
+ public void stopReconfigureThread() {
+ scheduledExecutorService.shutdown();
+ }
+
+ private void checkConfiguration() {
+ long newLastModify = new File(rssConf.getString(RECONFIGURABLE_FILE_NAME, "")).lastModified();
Review Comment:
If reconfigurable_file_name is not set, we should skip this check.
Otherwise, it may cause some problems?
##########
common/src/main/java/org/apache/uniffle/common/config/ReconfigurableBase.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * 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 ScheduledExecutorService scheduledExecutorService;
+ private long checkIntervalSec;
+ private 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);
+ }
+
+ public void stopReconfigureThread() {
+ scheduledExecutorService.shutdown();
+ }
+
+ private void checkConfiguration() {
+ long newLastModify = new File(rssConf.getString(RECONFIGURABLE_FILE_NAME, "")).lastModified();
+ if (lastModify.get() == 0) {
+ lastModify.set(newLastModify);
+ return;
+ }
+ if (newLastModify != lastModify.get()) {
Review Comment:
```suggestion
if (newLastModify > lastModify.get()) {
LOG.warn("Server detect the modification of file %s, we start to reconfigure", configuration_file_name);
```
##########
coordinator/src/main/java/org/apache/uniffle/coordinator/SimpleClusterManager.java:
##########
@@ -58,7 +60,7 @@ public class SimpleClusterManager implements ClusterManager {
private Map<String, Set<ServerNode>> tagToNodes = Maps.newConcurrentMap();
private AtomicLong excludeLastModify = new AtomicLong(0L);
private long heartbeatTimeout;
- private int shuffleNodesMax;
+ private AtomicInteger shuffleNodesMax;
Review Comment:
can we just use volatile?
##########
coordinator/src/main/java/org/apache/uniffle/coordinator/AccessManager.java:
##########
@@ -107,4 +109,22 @@ public void close() throws IOException {
checker.close();
}
}
+
+ public boolean isPropertyReconfigurable(String property) {
+ for (AccessChecker checker : accessCheckers) {
+ if (checker instanceof Reconfigurable
+ && ((Reconfigurable) checker).isPropertyReconfigurable(property)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void reconfigure(RssConf conf) {
Review Comment:
why `AccessManager` doesn't implements `Reconfigurable`?
##########
common/src/main/java/org/apache/uniffle/common/config/Reconfigurable.java:
##########
@@ -0,0 +1,26 @@
+/*
+ * 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;
+
+public interface Reconfigurable {
+
+ void reconfigure(RssConf conf);
Review Comment:
could we add some java doc for this and related method?
--
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