Search in sources :

Example 1 with IDefaultNameSpace

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;
}
Also used : IDefaultNameSpace(org.I0Itec.zkclient.IDefaultNameSpace) IOException(java.io.IOException) File(java.io.File) ZkServer(org.I0Itec.zkclient.ZkServer)

Example 2 with IDefaultNameSpace

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();
        }
    }
}
Also used : ZkClient(org.I0Itec.zkclient.ZkClient) IDefaultNameSpace(org.I0Itec.zkclient.IDefaultNameSpace) File(java.io.File) ZkServer(org.I0Itec.zkclient.ZkServer)

Example 3 with IDefaultNameSpace

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();
}
Also used : ZkClient(org.I0Itec.zkclient.ZkClient) IDefaultNameSpace(org.I0Itec.zkclient.IDefaultNameSpace) File(java.io.File) ZkServer(org.I0Itec.zkclient.ZkServer)

Example 4 with IDefaultNameSpace

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();
    }
}
Also used : IDefaultNameSpace(org.I0Itec.zkclient.IDefaultNameSpace) ClusterSetup(org.apache.helix.tools.ClusterSetup) ZkServer(org.I0Itec.zkclient.ZkServer)

Example 5 with IDefaultNameSpace

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;
}
Also used : ZkClient(org.apache.helix.manager.zk.ZkClient) IDefaultNameSpace(org.I0Itec.zkclient.IDefaultNameSpace) File(java.io.File) IOException(java.io.IOException) ZkNoNodeException(org.I0Itec.zkclient.exception.ZkNoNodeException) ZkServer(org.I0Itec.zkclient.ZkServer)

Aggregations

IDefaultNameSpace (org.I0Itec.zkclient.IDefaultNameSpace)12 ZkServer (org.I0Itec.zkclient.ZkServer)11 File (java.io.File)9 ZkClient (org.I0Itec.zkclient.ZkClient)7 IOException (java.io.IOException)3 ClusterSetup (org.apache.helix.tools.ClusterSetup)2 ZkNoNodeException (org.I0Itec.zkclient.exception.ZkNoNodeException)1 HelixManager (org.apache.helix.HelixManager)1 ZkClient (org.apache.helix.manager.zk.ZkClient)1