From dev-return-873-apmail-tephra-dev-archive=tephra.apache.org@tephra.incubator.apache.org Wed Feb 8 11:51:51 2017 Return-Path: X-Original-To: apmail-tephra-dev-archive@minotaur.apache.org Delivered-To: apmail-tephra-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A3A0B19582 for ; Wed, 8 Feb 2017 11:51:51 +0000 (UTC) Received: (qmail 39837 invoked by uid 500); 8 Feb 2017 11:51:51 -0000 Delivered-To: apmail-tephra-dev-archive@tephra.apache.org Received: (qmail 39800 invoked by uid 500); 8 Feb 2017 11:51:51 -0000 Mailing-List: contact dev-help@tephra.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tephra.incubator.apache.org Delivered-To: mailing list dev@tephra.incubator.apache.org Received: (qmail 39788 invoked by uid 99); 8 Feb 2017 11:51:51 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Feb 2017 11:51:51 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 17D14C05D7 for ; Wed, 8 Feb 2017 11:51:51 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.199 X-Spam-Level: X-Spam-Status: No, score=-1.199 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id s_DIU1WHjQZX for ; Wed, 8 Feb 2017 11:51:50 +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 E2B0760DC0 for ; Wed, 8 Feb 2017 11:51:44 +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 1BF74E0629 for ; Wed, 8 Feb 2017 11:51:43 +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 2F45A252A2 for ; Wed, 8 Feb 2017 11:51:42 +0000 (UTC) Date: Wed, 8 Feb 2017 11:51:42 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: dev@tephra.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (TEPHRA-215) Share PruneUpperBoundWriter across all TransactionProcessors on the same region server MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/TEPHRA-215?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15857882#comment-15857882 ] ASF GitHub Bot commented on TEPHRA-215: --------------------------------------- Github user poornachandra commented on a diff in the pull request: https://github.com/apache/incubator-tephra/pull/32#discussion_r100042435 --- Diff: tephra-hbase-compat-1.1-base/src/main/java/org/apache/tephra/hbase/txprune/PruneUpperBoundWriterSupplier.java --- @@ -0,0 +1,78 @@ +/* + * 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.tephra.hbase.txprune; + + +import com.google.common.base.Supplier; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Supplies instances of {@link PruneUpperBoundWriter} implementations. + */ +public class PruneUpperBoundWriterSupplier implements Supplier { + private static final Log LOG = LogFactory.getLog(PruneUpperBoundWriterSupplier.class); + + private static volatile PruneUpperBoundWriter instance; + private static volatile int refCount = 0; + private static final Object lock = new Object(); + + private final DataJanitorState dataJanitorState; + private final long pruneFlushInterval; + + public PruneUpperBoundWriterSupplier(DataJanitorState dataJanitorState, long pruneFlushInterval) { + this.dataJanitorState = dataJanitorState; + this.pruneFlushInterval = pruneFlushInterval; + } + + @Override + public PruneUpperBoundWriter get() { + synchronized (lock) { --- End diff -- We can make an `instance == null` check outside the lock. In case instance is not null just increment refCount and return. > Share PruneUpperBoundWriter across all TransactionProcessors on the same region server > -------------------------------------------------------------------------------------- > > Key: TEPHRA-215 > URL: https://issues.apache.org/jira/browse/TEPHRA-215 > Project: Tephra > Issue Type: Improvement > Affects Versions: 0.11.0-incubating > Reporter: Gokul Gunasekaran > Assignee: Gokul Gunasekaran > Fix For: 0.11.0-incubating > > > Currently we start one prune upperbound writer thread per TransactionProcessor coprocessor. Instead we should be able to share only one thread that flushes writes to the prune state table periodically. -- This message was sent by Atlassian JIRA (v6.3.15#6346)