From issues-return-196018-archive-asf-public=cust-asf.ponee.io@flink.apache.org Fri Oct 19 11:00:04 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id CB79C180652 for ; Fri, 19 Oct 2018 11:00:03 +0200 (CEST) Received: (qmail 33937 invoked by uid 500); 19 Oct 2018 09:00:02 -0000 Mailing-List: contact issues-help@flink.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flink.apache.org Delivered-To: mailing list issues@flink.apache.org Received: (qmail 33925 invoked by uid 99); 19 Oct 2018 09:00:02 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Oct 2018 09:00:02 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 87AB91A25BA for ; Fri, 19 Oct 2018 09:00:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -109.501 X-Spam-Level: X-Spam-Status: No, score=-109.501 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id Z6S2KWzQD6Lg for ; Fri, 19 Oct 2018 09:00:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 3C03D5F300 for ; Fri, 19 Oct 2018 09:00:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id A452FE02F1 for ; Fri, 19 Oct 2018 09:00:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 52EB925290 for ; Fri, 19 Oct 2018 09:00:00 +0000 (UTC) Date: Fri, 19 Oct 2018 09:00:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@flink.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (FLINK-10423) Forward RocksDB native metrics to Flink metrics reporter MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/FLINK-10423?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D166= 56474#comment-16656474 ]=20 ASF GitHub Bot commented on FLINK-10423: ---------------------------------------- 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_r226577921 =20 =20 ########## File path: flink-state-backends/flink-statebackend-rocksdb/src/main/java/o= rg/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 { +=09private static final Logger LOG =3D LoggerFactory.getLogger(RocksDBNati= veMetricMonitor.class); + +=09private final RocksDBNativeMetricOptions options; + +=09private final MetricGroup metricGroup; + +=09private final Object lock; + +=09@GuardedBy("lock") +=09private RocksDB rocksDB; + +=09RocksDBNativeMetricMonitor( +=09=09@Nonnull RocksDB rocksDB, +=09=09@Nonnull RocksDBNativeMetricOptions options, +=09=09@Nonnull MetricGroup metricGroup +=09) { +=09=09this.options =3D options; +=09=09this.metricGroup =3D metricGroup; +=09=09this.rocksDB =3D rocksDB; + +=09=09this.lock =3D new Object(); +=09} + +=09/** +=09 * Register gauges to pull native metrics for the column family. +=09 * @param columnFamilyName group name for the new gauges +=09 * @param handle native handle to the column family +=09 */ +=09void registerColumnFamily(String columnFamilyName, ColumnFamilyHandle h= andle) { +=09=09MetricGroup group =3D metricGroup.addGroup(columnFamilyName); + +=09=09for (String property : options.getProperties()) { +=09=09=09RocksDBNativeMetricView gauge =3D new RocksDBNativeMetricView(han= dle, property); +=09=09=09group.gauge(property, gauge); +=09=09} +=09} + +=09/** +=09 * Updates the value of metricView if the reference is still valid. +=09 */ +=09private void setProperty(ColumnFamilyHandle handle, String property, Ro= cksDBNativeMetricView metricView) { +=09=09if (metricView.isClosed()) { =20 Review comment: cool, thanks for looking into it. We can leave the code as is. ---------------------------------------------------------------- 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. =20 For queries about this service, please contact Infrastructure at: users@infra.apache.org > Forward RocksDB native metrics to Flink metrics reporter=20 > --------------------------------------------------------- > > Key: FLINK-10423 > URL: https://issues.apache.org/jira/browse/FLINK-10423 > Project: Flink > Issue Type: New Feature > Components: Metrics, State Backends, Checkpointing > Reporter: Seth Wiesman > Assignee: Seth Wiesman > Priority: Major > Labels: pull-request-available > > RocksDB contains a number of metrics at the column family level about cur= rent memory usage, open memtables,=C2=A0 etc that would be useful to users = wishing greater insight what rocksdb is doing. This work is inspired heavil= y by the comments on this rocksdb issue thread (https://github.com/facebook= /rocksdb/issues/3216#issuecomment-348779233) -- This message was sent by Atlassian JIRA (v7.6.3#76005)