flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] zentol commented on a change in pull request #6814: [FLINK-10423][rocksdb][metrics] rocksdb native metrics monitor
Date Wed, 17 Oct 2018 10:20:16 GMT
zentol commented on a change in pull request #6814: [FLINK-10423][rocksdb][metrics] rocksdb
native metrics monitor
URL: https://github.com/apache/flink/pull/6814#discussion_r225865415
 
 

 ##########
 File path: flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/RocksDBNativeMetricMonitor.java
 ##########
 @@ -0,0 +1,170 @@
+/*
+ * 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.flink.contrib.streaming.state;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.metrics.Gauge;
+import org.apache.flink.metrics.MetricGroup;
+import org.apache.flink.metrics.View;
+
+import org.rocksdb.ColumnFamilyHandle;
+import org.rocksdb.RocksDB;
+import org.rocksdb.RocksDBException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nonnull;
+import javax.annotation.concurrent.GuardedBy;
+
+import java.io.Closeable;
+import java.math.BigInteger;
+
+/**
+ * A monitor which pulls {{@link RocksDB}} native metrics
+ * and forwards them to Flink's metric group. All metrics are
+ * unsigned longs and are reported at the column family level.
+ */
+@Internal
+public class RocksDBNativeMetricMonitor implements Closeable {
+	private static final Logger LOG = LoggerFactory.getLogger(RocksDBNativeMetricMonitor.class);
+
+	private final RocksDBNativeMetricOptions options;
+
+	private final MetricGroup metricGroup;
+
+	private final Object lock;
+
+	@GuardedBy("lock")
+	private RocksDB rocksDB;
+
+	RocksDBNativeMetricMonitor(
+		@Nonnull RocksDB rocksDB,
+		@Nonnull RocksDBNativeMetricOptions options,
+		@Nonnull MetricGroup metricGroup
+	) {
+		this.options = options;
+		this.metricGroup = metricGroup;
+		this.rocksDB = rocksDB;
+
+		this.lock = new Object();
+	}
+
+	/**
+	 * Register gauges to pull native metrics for the column family.
+	 * @param columnFamilyName group name for the new gauges
+	 * @param handle native handle to the column family
+	 */
+	void registerColumnFamily(String columnFamilyName, ColumnFamilyHandle handle) {
+		MetricGroup group = metricGroup.addGroup(columnFamilyName);
+
+		for (String property : options.getProperties()) {
+			RocksDBNativeMetricView gauge = new RocksDBNativeMetricView(handle, property);
+			group.gauge(property, gauge);
+		}
+	}
+
+	/**
+	 * Updates the value of metricView if the reference is still valid.
+	 */
+	private void setProperty(ColumnFamilyHandle handle, String property, RocksDBNativeMetricView
metricView) {
+		if (metricView.isClosed()) {
 
 Review comment:
   ah. hmm...
   
   Let's say that an exception occurs when retrieving the value from RocksDB. How likely is
it that this exception happens again? I.e. how reliable are failure-cases? Currently, if there
is any intermittent failure the metric is disabled forever.
   
   If this is more of an all-or-nothing kind of thing we could try it out once before registering
the metric and skipping the registration if it fails, and only skip repeated logging in the
metric.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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

Mime
View raw message