replicated leveldb test improvements

This commit is contained in:
Dejan Bosanac 2014-12-24 16:25:04 +01:00
parent c266b1069b
commit 5315389080
3 changed files with 20 additions and 12 deletions

View File

@ -277,9 +277,14 @@ class ElectingLevelDBStore extends ProxyLevelDBStore {
if(brokerService!=null && brokerService.isUseJmx){
brokerService.getManagementContext().unregisterMBean(objectName);
}
zk_group.close
zk_client.close()
zk_client = null
if (zk_group != null) {
zk_group.close
zk_group = null
}
if (zk_client != null) {
zk_client.close()
zk_client = null
}
if( master!=null ) {
val latch = new CountDownLatch(1)

View File

@ -83,13 +83,6 @@ public class ReplicatedLevelDBBrokerTest extends ZooKeeperTestSupport {
deleteDirectory("node-3");
}
protected void deleteDirectory(String s) throws IOException {
try {
FileUtils.deleteDirectory(new File(data_dir(), s));
} catch (IOException e) {
}
}
public interface Client{
public void execute(Connection connection) throws Exception;
}
@ -284,6 +277,7 @@ public class ReplicatedLevelDBBrokerTest extends ZooKeeperTestSupport {
System.out.println("======================================");
System.out.println("5. Restart the stopped node & 6. stop current master");
System.out.println("======================================");
brokers.remove(prevMaster);
prevMaster = createBrokerNode(prevMaster.getBrokerName());
startBrokerAsync(prevMaster);
stop(master);
@ -411,6 +405,7 @@ public class ReplicatedLevelDBBrokerTest extends ZooKeeperTestSupport {
}
}
brokers.clear();
resetDataDirs();
}
private BrokerService createBrokerNode(String id) throws Exception {

View File

@ -18,13 +18,12 @@ package org.apache.activemq.leveldb.test;
import org.apache.activemq.leveldb.CountDownFuture;
import org.apache.activemq.leveldb.util.FileSupport;
import org.apache.commons.io.FileUtils;
import org.apache.zookeeper.server.NIOServerCnxnFactory;
import org.apache.zookeeper.server.ZooKeeperServer;
import org.apache.zookeeper.server.persistence.FileTxnSnapLog;
import org.junit.After;
import org.junit.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.net.InetSocketAddress;
@ -62,6 +61,8 @@ public class ZooKeeperTestSupport {
connector.shutdown();
connector = null;
}
deleteDirectory("zk-log");
deleteDirectory("zk-data");
}
@ -108,4 +109,11 @@ public class ZooKeeperTestSupport {
}
}
}
protected void deleteDirectory(String s) throws java.io.IOException {
try {
FileUtils.deleteDirectory(new File(data_dir(), s));
} catch (java.io.IOException e) {
}
}
}