use of org.I0Itec.zkclient.IDefaultNameSpace in project helix by apache.
the class ExampleHelper method startZkServer.
public static ZkServer startZkServer(String zkAddr) {
System.out.println("Start zookeeper at " + zkAddr + " in thread " + Thread.currentThread().getName());
String zkDir = zkAddr.replace(':', '_');
final String logDir = "/tmp/" + zkDir + "/logs";
final String dataDir = "/tmp/" + zkDir + "/dataDir";
try {
FileUtils.deleteDirectory(new File(dataDir));
FileUtils.deleteDirectory(new File(logDir));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
IDefaultNameSpace defaultNameSpace = new IDefaultNameSpace() {
@Override
public void createDefaultNameSpace(org.I0Itec.zkclient.ZkClient zkClient) {
// do nothing
}
};
int port = Integer.parseInt(zkAddr.substring(zkAddr.lastIndexOf(':') + 1));
ZkServer zkServer = new ZkServer(dataDir, logDir, defaultNameSpace, port);
zkServer.start();
return zkServer;
}
use of org.I0Itec.zkclient.IDefaultNameSpace in project helix by apache.
the class TaskExecutionDemo method main.
public static void main(String[] args) throws Exception {
if (args.length != 3) {
System.err.println("USAGE: java TaskExecutionDemo zkPort redisHost redisPort");
System.exit(1);
}
String redisHost = args[1];
int redisPort = Integer.parseInt(args[2]);
ZkServer server = null;
try {
String baseDir = "/tmp/TaskExecutionDemo/";
final String dataDir = baseDir + "zk/dataDir";
final String logDir = baseDir + "/tmp/logDir";
FileUtils.deleteDirectory(new File(dataDir));
FileUtils.deleteDirectory(new File(logDir));
IDefaultNameSpace defaultNameSpace = new IDefaultNameSpace() {
@Override
public void createDefaultNameSpace(ZkClient zkClient) {
}
};
int zkPort = Integer.parseInt(args[0]);
server = new ZkServer(dataDir, logDir, defaultNameSpace, zkPort);
server.start();
String zkAddr = "localhost:" + zkPort;
String clusterName = TaskCluster.DEFAULT_CLUSTER_NAME;
TaskCluster taskCluster = new TaskCluster(zkAddr, clusterName);
taskCluster.setup();
startController(zkAddr, clusterName);
TaskFactory taskFactory = new AnalyticsTaskFactory();
TaskResultStore taskResultStore = new RedisTaskResultStore(redisHost, redisPort, 1000);
populateDummyData(taskResultStore);
startWorkers(zkAddr, TaskCluster.DEFAULT_CLUSTER_NAME, taskFactory, taskResultStore);
Dag dag = getAnalyticsDag();
taskCluster.submitDag(dag);
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
if (server != null) {
// server.shutdown();
}
}
}
use of org.I0Itec.zkclient.IDefaultNameSpace in project helix by apache.
the class LockManagerDemo method startLocalZookeeper.
private static void startLocalZookeeper(int port) throws Exception {
ZkServer server = null;
String baseDir = "/tmp/IntegrationTest/";
final String dataDir = baseDir + "zk/dataDir";
final String logDir = baseDir + "/tmp/logDir";
FileUtils.deleteDirectory(new File(dataDir));
FileUtils.deleteDirectory(new File(logDir));
IDefaultNameSpace defaultNameSpace = new IDefaultNameSpace() {
@Override
public void createDefaultNameSpace(ZkClient zkClient) {
}
};
int zkPort = 2199;
final String zkAddress = "localhost:" + zkPort;
server = new ZkServer(dataDir, logDir, defaultNameSpace, zkPort);
server.start();
}
use of org.I0Itec.zkclient.IDefaultNameSpace in project helix by apache.
the class MockSpectatorProcess method setup.
private static void setup() {
IDefaultNameSpace defaultNameSpace = new IDefaultNameSpace() {
@Override
public void createDefaultNameSpace(org.I0Itec.zkclient.ZkClient client) {
client.deleteRecursive("/" + clusterName);
}
};
zkServer = new ZkServer(dataDir, logDir, defaultNameSpace, port);
zkServer.start();
ClusterSetup clusterSetup = new ClusterSetup(zkConnectString);
clusterSetup.setupTestCluster(clusterName);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
use of org.I0Itec.zkclient.IDefaultNameSpace in project helix by apache.
the class TestHelper method startZkServer.
public static ZkServer startZkServer(final String zkAddress, final List<String> rootNamespaces, boolean overwrite) throws Exception {
System.out.println("Start zookeeper at " + zkAddress + " in thread " + Thread.currentThread().getName());
String zkDir = zkAddress.replace(':', '_');
final String logDir = "/tmp/" + zkDir + "/logs";
final String dataDir = "/tmp/" + zkDir + "/dataDir";
if (overwrite) {
FileUtils.deleteDirectory(new File(dataDir));
FileUtils.deleteDirectory(new File(logDir));
}
ZKClientPool.reset();
IDefaultNameSpace defaultNameSpace = new IDefaultNameSpace() {
@Override
public void createDefaultNameSpace(org.I0Itec.zkclient.ZkClient zkClient) {
if (rootNamespaces == null) {
return;
}
for (String rootNamespace : rootNamespaces) {
try {
zkClient.deleteRecursive(rootNamespace);
} catch (Exception e) {
LOG.error("fail to deleteRecursive path:" + rootNamespace, e);
}
}
}
};
int port = Integer.parseInt(zkAddress.substring(zkAddress.lastIndexOf(':') + 1));
ZkServer zkServer = new ZkServer(dataDir, logDir, defaultNameSpace, port);
zkServer.start();
return zkServer;
}
Aggregations