You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by el...@apache.org on 2015/01/23 20:48:32 UTC

[1/2] accumulo git commit: ACCUMULO-1311 ACCUMULO-3511 Remove Daemon from fate and use ExecutorService

Repository: accumulo
Updated Branches:
  refs/heads/master 45a027c9c -> 888263236


ACCUMULO-1311 ACCUMULO-3511 Remove Daemon from fate and use ExecutorService

The Daemon class was only used in a single location by FATE which
is easily achieved with a ThreadFactory instead. Also changes from
manually creating and starting threads to using a fixed-size executor
service instead.


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/f6129602
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/f6129602
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/f6129602

Branch: refs/heads/master
Commit: f6129602ae2a88da3bd78bb7ae0479c241bc0a4f
Parents: 45a027c
Author: Josh Elser <el...@apache.org>
Authored: Fri Jan 23 13:13:54 2015 -0500
Committer: Josh Elser <el...@apache.org>
Committed: Fri Jan 23 14:43:28 2015 -0500

----------------------------------------------------------------------
 .../java/org/apache/accumulo/fate/Fate.java     | 22 +++++--
 .../org/apache/accumulo/fate/util/Daemon.java   | 60 --------------------
 2 files changed, 18 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/f6129602/fate/src/main/java/org/apache/accumulo/fate/Fate.java
----------------------------------------------------------------------
diff --git a/fate/src/main/java/org/apache/accumulo/fate/Fate.java b/fate/src/main/java/org/apache/accumulo/fate/Fate.java
index f9c1ed0..aa9c456 100644
--- a/fate/src/main/java/org/apache/accumulo/fate/Fate.java
+++ b/fate/src/main/java/org/apache/accumulo/fate/Fate.java
@@ -17,10 +17,13 @@
 package org.apache.accumulo.fate;
 
 import java.util.EnumSet;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.accumulo.fate.ReadOnlyTStore.TStatus;
-import org.apache.accumulo.fate.util.Daemon;
 import org.apache.accumulo.fate.util.LoggingRunnable;
 import org.apache.log4j.Logger;
 
@@ -41,6 +44,7 @@ public class Fate<T> {
 
   private TStore<T> store;
   private T environment;
+  private ExecutorService executor;
 
   private static final EnumSet<TStatus> FINISHED_STATES = EnumSet.of(TStatus.FAILED, TStatus.SUCCESSFUL, TStatus.UNKNOWN);
 
@@ -154,10 +158,19 @@ public class Fate<T> {
    * Launches the specified number of worker threads.
    */
   public void startTransactionRunners(int numThreads) {
+    final AtomicInteger runnerCount = new AtomicInteger(0);
+    executor = Executors.newFixedThreadPool(numThreads, new ThreadFactory() {
+
+      @Override
+      public Thread newThread(Runnable r) {
+        Thread t = new Thread(new LoggingRunnable(log, r), "Repo runner " + runnerCount.getAndIncrement());
+        t.setDaemon(true);
+        return t;
+      }
+
+    });
     for (int i = 0; i < numThreads; i++) {
-      // TODO: use an ExecutorService, maybe a utility to do these steps throughout the server packages - ACCUMULO-1311
-      Thread thread = new Daemon(new LoggingRunnable(log, new TransactionRunner()), "Repo runner " + i);
-      thread.start();
+      executor.execute(new TransactionRunner());
     }
   }
 
@@ -250,6 +263,7 @@ public class Fate<T> {
    */
   public void shutdown() {
     keepRunning.set(false);
+    executor.shutdown();
   }
 
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/f6129602/fate/src/main/java/org/apache/accumulo/fate/util/Daemon.java
----------------------------------------------------------------------
diff --git a/fate/src/main/java/org/apache/accumulo/fate/util/Daemon.java b/fate/src/main/java/org/apache/accumulo/fate/util/Daemon.java
deleted file mode 100644
index da7c41c..0000000
--- a/fate/src/main/java/org/apache/accumulo/fate/util/Daemon.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.accumulo.fate.util;
-
-public class Daemon extends Thread {
-
-  public Daemon() {
-    setDaemon(true);
-  }
-
-  public Daemon(Runnable target) {
-    super(target);
-    setDaemon(true);
-  }
-
-  public Daemon(String name) {
-    super(name);
-    setDaemon(true);
-  }
-
-  public Daemon(ThreadGroup group, Runnable target) {
-    super(group, target);
-    setDaemon(true);
-  }
-
-  public Daemon(ThreadGroup group, String name) {
-    super(group, name);
-    setDaemon(true);
-  }
-
-  public Daemon(Runnable target, String name) {
-    super(target, name);
-    setDaemon(true);
-  }
-
-  public Daemon(ThreadGroup group, Runnable target, String name) {
-    super(group, target, name);
-    setDaemon(true);
-  }
-
-  public Daemon(ThreadGroup group, Runnable target, String name, long stackSize) {
-    super(group, target, name, stackSize);
-    setDaemon(true);
-  }
-
-}


[2/2] accumulo git commit: ACCUMULO-3452 Another missed timeout

Posted by el...@apache.org.
ACCUMULO-3452 Another missed timeout


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/88826323
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/88826323
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/88826323

Branch: refs/heads/master
Commit: 888263236b535ad40c7d22314c2223620bc34eec
Parents: f612960
Author: Josh Elser <el...@apache.org>
Authored: Fri Jan 23 14:48:06 2015 -0500
Committer: Josh Elser <el...@apache.org>
Committed: Fri Jan 23 14:48:06 2015 -0500

----------------------------------------------------------------------
 .../java/org/apache/accumulo/test/functional/KerberosIT.java    | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/88826323/test/src/test/java/org/apache/accumulo/test/functional/KerberosIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/functional/KerberosIT.java b/test/src/test/java/org/apache/accumulo/test/functional/KerberosIT.java
index e3da6eb..3d48657 100644
--- a/test/src/test/java/org/apache/accumulo/test/functional/KerberosIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/functional/KerberosIT.java
@@ -94,6 +94,11 @@ public class KerberosIT extends AccumuloIT {
     }
   }
 
+  @Override
+  public int defaultTimeoutSeconds() {
+    return 60 * 5;
+  }
+
   private MiniAccumuloClusterImpl mac;
 
   @Before