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 E0142200C24 for ; Thu, 9 Feb 2017 01:07:52 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id DED0B160B67; Thu, 9 Feb 2017 00:07:52 +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 0CE1C160B49 for ; Thu, 9 Feb 2017 01:07:51 +0100 (CET) Received: (qmail 94444 invoked by uid 500); 9 Feb 2017 00:07: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 94433 invoked by uid 99); 9 Feb 2017 00:07:51 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Feb 2017 00:07:51 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id D2CADC25B9 for ; Thu, 9 Feb 2017 00:07:50 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-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 (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id LlVCnFqx6zFX 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-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id B58925F589 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 E5DD9E0611 for ; Thu, 9 Feb 2017 00:07:42 +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 0DB042529B 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:53 -0000 [ https://issues.apache.org/jira/browse/TEPHRA-215?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15858734#comment-15858734 ] 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_r100203117 --- Diff: tephra-hbase-compat-1.1-base/src/test/java/org/apache/tephra/hbase/txprune/PruneUpperBoundWriterSupplierTest.java --- @@ -0,0 +1,105 @@ +/* + * 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 org.junit.Assert; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * Tests to verify the behavior of {@link PruneUpperBoundWriterSupplier}. + */ +public class PruneUpperBoundWriterSupplierTest { + private static final int NUM_OPS = 10; + + @Test + public void testSupplier() throws Exception { + final PruneUpperBoundWriterSupplier supplier = new PruneUpperBoundWriterSupplier(null, null, 10L); + final PruneUpperBoundWriter writer = supplier.get(); + final AtomicInteger numOps = new AtomicInteger(NUM_OPS); + final Random random = new Random(System.currentTimeMillis()); + + // Start threads that will 'get' PruneUpperBoundWriters + ExecutorService executor = Executors.newFixedThreadPool(3); + List futureList = new ArrayList<>(); + for (int i = 0; i < 3; i++) { + futureList.add(executor.submit(new Callable() { + + @Override + public Void call() throws Exception { + // Since we already got one PruneUpperBoundWriter, we need to get NUM_OPS - 1 + while (numOps.decrementAndGet() > 0) { + PruneUpperBoundWriter newWriter = supplier.get(); + Assert.assertTrue(newWriter == writer); + int waitTime = random.nextInt(10); + TimeUnit.MICROSECONDS.sleep(waitTime); + } + return null; + } + })); + } + + for (Future future : futureList) { + future.get(5, TimeUnit.SECONDS); + } + executor.shutdown(); + executor.awaitTermination(2, TimeUnit.SECONDS); + + futureList.clear(); + numOps.set(NUM_OPS); + // Start thread that release PruneUpperBoundWriters + executor = Executors.newFixedThreadPool(3); + for (int i = 0; i < 3; i++) { + futureList.add(executor.submit(new Callable() { + + @Override + public Void call() throws Exception { + // We need to release all NUM_OPS 'gets' that were executed to trigger shutdown of the single instance of + // PruneUpperBoundWriter + while (numOps.decrementAndGet() >= 0) { --- End diff -- Can we change this to leave one instance out, so that we can assert that that instance is still running after the n-1 instances were released back. We can later release it separately and then assert that it is not running. > 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)