Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id B4458200C24 for ; Thu, 9 Feb 2017 01:07:54 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id B2ECD160B49; Thu, 9 Feb 2017 00:07:54 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 7B7FA160B67 for ; Thu, 9 Feb 2017 01:07:53 +0100 (CET) Received: (qmail 94576 invoked by uid 500); 9 Feb 2017 00:07:52 -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 94565 invoked by uid 99); 9 Feb 2017 00:07:52 -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; Thu, 09 Feb 2017 00:07:52 +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 39708C05D7 for ; Thu, 9 Feb 2017 00:07:52 +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-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id pxKOtfazclpY for ; Thu, 9 Feb 2017 00:07:50 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id F39575F24C for ; Thu, 9 Feb 2017 00:07:49 +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 06F00E0627 for ; Thu, 9 Feb 2017 00:07: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 16337252A0 for ; Thu, 9 Feb 2017 00:07:42 +0000 (UTC) Date: Thu, 9 Feb 2017 00:07: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 archived-at: Thu, 09 Feb 2017 00:07:54 -0000 [ https://issues.apache.org/jira/browse/TEPHRA-215?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15858737#comment-15858737 ] 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_r100201530 --- Diff: tephra-hbase-compat-1.1-base/src/main/java/org/apache/tephra/hbase/txprune/PruneUpperBoundWriter.java --- @@ -18,77 +18,85 @@ package org.apache.tephra.hbase.txprune; +import com.google.common.util.concurrent.AbstractIdleService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.hbase.TableName; -import org.apache.tephra.hbase.coprocessor.TransactionProcessor; import java.io.IOException; +import java.nio.ByteBuffer; +import java.util.Map; +import java.util.concurrent.ConcurrentSkipListMap; import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicLong; /** * Thread that will write the the prune upper bound */ -public class PruneUpperBoundWriter { - private static final Log LOG = LogFactory.getLog(TransactionProcessor.class); +public class PruneUpperBoundWriter extends AbstractIdleService { + private static final Log LOG = LogFactory.getLog(PruneUpperBoundWriter.class); - private final TableName pruneStateTable; + private final TableName tableName; private final DataJanitorState dataJanitorState; - private final byte[] regionName; - private final String regionNameAsString; private final long pruneFlushInterval; - private final AtomicLong pruneUpperBound; - private final AtomicBoolean shouldFlush; + private final ConcurrentSkipListMap pruneEntries; + + private volatile boolean stopped; + private volatile Thread flushThread; - private Thread flushThread; private long lastChecked; - public PruneUpperBoundWriter(DataJanitorState dataJanitorState, TableName pruneStateTable, String regionNameAsString, - byte[] regionName, long pruneFlushInterval) { - this.pruneStateTable = pruneStateTable; + public PruneUpperBoundWriter(TableName tableName, DataJanitorState dataJanitorState, long pruneFlushInterval) { + this.tableName = tableName; this.dataJanitorState = dataJanitorState; - this.regionName = regionName; - this.regionNameAsString = regionNameAsString; this.pruneFlushInterval = pruneFlushInterval; - this.pruneUpperBound = new AtomicLong(); - this.shouldFlush = new AtomicBoolean(false); - startFlushThread(); + this.pruneEntries = new ConcurrentSkipListMap<>(); + } + + public void persistPruneEntry(byte[] regionName, long pruneUpperBound) { + // The number of entries in this map is bound by the number of regions in this region server and thus it will not + // grow indefinitely + pruneEntries.put(ByteBuffer.wrap(regionName), pruneUpperBound); } public boolean isAlive() { - return flushThread.isAlive(); + return flushThread != null && flushThread.isAlive(); } - public void persistPruneEntry(long pruneUpperBound) { - this.pruneUpperBound.set(pruneUpperBound); - this.shouldFlush.set(true); + @Override + protected void startUp() throws Exception { + LOG.info("Starting PruneUpperBoundWriter Thread."); + startFlushThread(); } - public void stop() { + @Override + protected void shutDown() throws Exception { if (flushThread != null) { + stopped = true; + LOG.info("Stopping PruneUpperBoundWriter Thread."); --- End diff -- It would be good to move this log message outside the if condition > 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)