You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2021/02/18 02:30:15 UTC

[GitHub] [incubator-pinot] jtao15 commented on a change in pull request #6586: Server `queriesDisabled` metric:

jtao15 commented on a change in pull request #6586:
URL: https://github.com/apache/incubator-pinot/pull/6586#discussion_r578083481



##########
File path: pinot-server/src/main/java/org/apache/pinot/server/starter/ServerQueriesDisabledTracker.java
##########
@@ -0,0 +1,86 @@
+/**
+ * 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.pinot.server.starter;
+
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.helix.HelixManager;
+import org.apache.helix.ZNRecord;
+import org.apache.pinot.common.metrics.ServerMetrics;
+import org.apache.pinot.common.utils.CommonConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A class to track if the server is queries disabled.
+ */
+public class ServerQueriesDisabledTracker {
+  private static final Logger LOGGER = LoggerFactory.getLogger(ServerQueriesDisabledTracker.class);
+  private static final long FETCH_INTERVAL_MINS = 10L;
+  private static ServerQueriesDisabledTracker _singletonInstance;
+
+  private final ScheduledExecutorService _executorService = Executors.newSingleThreadScheduledExecutor();
+  private final HelixManager _helixManager;
+  private final ServerMetrics _serverMetrics;
+  private final String _clusterName;
+  private final String _instanceId;
+  private AtomicBoolean _queriesDisabled = new AtomicBoolean();
+
+  private ServerQueriesDisabledTracker(
+      String helixClusterName, String instanceId, HelixManager helixManager, ServerMetrics serverMetrics) {
+    _helixManager = helixManager;
+    _serverMetrics = serverMetrics;
+    _clusterName = helixClusterName;
+    _instanceId = instanceId;
+  }
+
+  public static synchronized void init(

Review comment:
       Since we only use this in one place, I'll remove the singleton pattern, and the `synchronized` is not needed anymore.




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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org