Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

bk and tso are now tasks executed with the Executor framework and ini…

…tialized/destroyed in @BeforeClass and @AfterClass methods as in OmidTestBase.java
  • Loading branch information...
commit c75737dd14419cb41651ab4ff2ddf568a53fed15 1 parent 56beb1a
Francisco Perez-Sorrosal authored
Showing with 17 additions and 16 deletions.
  1. +17 −16 src/test/java/com/yahoo/omid/tso/TSOTestBase.java
View
33 src/test/java/com/yahoo/omid/tso/TSOTestBase.java
@@ -17,6 +17,7 @@
package com.yahoo.omid.tso;
import java.io.IOException;
+import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.apache.bookkeeper.util.LocalBookKeeper;
@@ -40,9 +41,11 @@
public class TSOTestBase {
private static final Log LOG = LogFactory.getLog(TSOTestBase.class);
- private static Thread bkthread;
- private static Thread tsothread;
-
+ //private static Thread bkthread;
+ //private static Thread tsothread;
+ private static ExecutorService bkExecutor;
+ private static ExecutorService tsoExecutor;
+
protected static TestClientHandler clientHandler;
protected static TestClientHandler secondClientHandler;
private static ChannelGroup channelGroup;
@@ -102,8 +105,9 @@ public static void setupBookkeeper() throws Exception {
System.out.println("PATH : "
+ System.getProperty("java.library.path"));
- if (bkthread == null) {
- bkthread = new Thread() {
+ if (bkExecutor == null) {
+ bkExecutor = Executors.newSingleThreadExecutor();
+ Runnable bkTask = new Runnable() {
public void run() {
try {
Thread.currentThread().setName("BookKeeper");
@@ -119,16 +123,15 @@ public void run() {
}
};
- bkthread.start();
+ bkExecutor.execute(bkTask);
}
}
@AfterClass
public static void teardownBookkeeper() throws Exception {
- if (bkthread != null) {
- bkthread.interrupt();
- bkthread.join();
+ if (bkExecutor != null) {
+ bkExecutor.shutdownNow();
}
TestUtils.waitForSocketNotListening("localhost", 1234, 1000);
@@ -147,11 +150,10 @@ public void setupTSO() throws Exception {
*/
Thread.sleep(500);
- tso = new TSOServer(TSOServerConfig.configFactory(1234, 0, recoveryEnabled(), 4, 2, new String("localhost:2181")));
- tsothread = new Thread(tso);
-
LOG.info("Starting TSO");
- tsothread.start();
+ tso = new TSOServer(TSOServerConfig.configFactory(1234, 0, recoveryEnabled(), 4, 2, new String("localhost:2181")));
+ tsoExecutor = Executors.newSingleThreadExecutor();
+ tsoExecutor.execute(tso);
TestUtils.waitForSocketListening("localhost", 1234, 100);
LOG.info("Finished loading TSO");
@@ -177,9 +179,8 @@ public void teardownTSO() throws Exception {
secondClientHandler.setAutoFullAbort(true);
tso.stop();
- if (tsothread != null) {
- tsothread.interrupt();
- tsothread.join();
+ if (tsoExecutor != null) {
+ tsoExecutor.shutdownNow();
}
teardownClient();
Please sign in to comment.
Something went wrong with that request. Please try again.