You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2019/03/22 17:26:20 UTC

[GitHub] [accumulo] mikewalch commented on a change in pull request #1046: Updating master metrics to provide FATE operational metrics.

mikewalch commented on a change in pull request #1046: Updating master metrics to provide FATE operational metrics.
URL: https://github.com/apache/accumulo/pull/1046#discussion_r268266873
 
 

 ##########
 File path: server/master/src/main/java/org/apache/accumulo/master/metrics/fate/FateMetricValues.java
 ##########
 @@ -0,0 +1,200 @@
+/*
+ * 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.accumulo.master.metrics.fate;
+
+import java.util.List;
+
+import org.apache.accumulo.core.Constants;
+import org.apache.accumulo.core.client.Instance;
+import org.apache.accumulo.core.zookeeper.ZooUtil;
+import org.apache.accumulo.fate.AdminUtil;
+import org.apache.accumulo.fate.ZooStore;
+import org.apache.accumulo.fate.zookeeper.IZooReaderWriter;
+import org.apache.accumulo.server.zookeeper.ZooReaderWriter;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.data.Stat;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Immutable class that holds a snapshot of fate metric values - use builder to instantiate
+ * instance.
+ */
+class FateMetricValues {
+
+  private static final Logger log = LoggerFactory.getLogger(FateMetrics.class);
+
+  private final long updateTime;
+  private final long currentFateOps;
+  private final long zkFateChildOpsTotal;
+  private final long zkConnectionErrors;
+
+  private FateMetricValues(final long updateTime, final long currentFateOps,
+      final long zkFateChildOpsTotal, final long zkConnectionErrors) {
+    this.updateTime = updateTime;
+    this.currentFateOps = currentFateOps;
+    this.zkFateChildOpsTotal = zkFateChildOpsTotal;
+    this.zkConnectionErrors = zkConnectionErrors;
+  }
+
+  long getCurrentFateOps() {
+    return currentFateOps;
+  }
+
+  long getZkFateChildOpsTotal() {
+    return zkFateChildOpsTotal;
+  }
+
+  long getZkConnectionErrors() {
+    return zkConnectionErrors;
+  }
+
+  /**
+   * Get the current FATE metrics values, initial values are set to 0. In the event of errors, the
+   * values may not be fully populated and the default values (0) will be returned - this form
+   * should be avoided for metric counters that expect values will be monotonically increasing - use
+   * with gauges instead.
+   *
+   * @param instance
+   *          Accumulo client instance.
+   * @return populated metrics values
+   */
+  static FateMetricValues updateFromZookeeper(final Instance instance) {
+
+    FateMetricValues.Builder builder = new FateMetricValues.Builder();
+
+    return updateFromZookeeper(instance, builder);
+
+  }
+
+  /**
+   * Update FateMetricValues, populating with current values and the overwritting new values, this
+   * preserves previous values in case an error or exception prevents the values from being
+   * completely populated, this form may be more suitable for metric counters.
+   *
+   * @param instance
+   *          Accumulo client instance
+   * @param currentValues
+   *          the current fate metrics used as default
+   * @return populated metrics values
+   */
+  static FateMetricValues updateFromZookeeper(final Instance instance,
 
 Review comment:
   Instance is deprecated in 2.0. It's OK here but when you merge this into master you'll probably need to change this.  You might want to pass the Master instead. 

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


With regards,
Apache Git Services