@Test public void testCreate() throws Exception { ZooKeeperServerRunner zooKeeperServerRunner = new ZooKeeperServerRunner(0); String connectString = zooKeeperServerRunner.start(); String configFilePath = IntegrationTestHelper.createYamlConfigFile(DIR_NAME, CONFIG_FILE_NAME, createProperties(connectString, CLUSTER_ROOT)); try { String[] createCommandArgs = new String[]{ "create", "--name", CLUSTER_NAME, "--partitions", Integer.toString(NUM_PARTITIONS), "--cli-config-path", configFilePath }; ZooKeeperCli.testMain(createCommandArgs); ZooKeeperClient zkClient = new ZooKeeperClientImpl(connectString, ZK_SESSION_TIMEOUT, ZK_CONNECT_TIMEOUT); ZNode root = new ZNode(CLUSTER_ROOT); ClusterParamsSerializer serializer = new ClusterParamsSerializer(); NodeData<ClusterParams> nodeData = zkClient.getData(root, serializer); assertNotNull(nodeData.value); assertEquals(CLUSTER_NAME, nodeData.value.name); assertEquals(NUM_PARTITIONS, nodeData.value.numPartitions); ZNode storeRoot = new ZNode(root, StoreMetadata.STORE_ZNODE_NAME); NodeData<StoreParams> storeRootData = zkClient.getData(storeRoot, StoreParamsSerializer.INSTANCE); assertNotNull(storeRootData.value); assertNotNull(storeRootData.value.key); assertEquals(NUM_PARTITIONS, storeRootData.value.numPartitions); ZNode groupNode = new ZNode(storeRoot, StoreMetadata.GROUP_ZNODE_NAME); NodeData<GroupDescriptor> groupDescriptorData = zkClient.getData(groupNode, GroupDescriptorSerializer.INSTANCE); GroupDescriptor groupDescriptor = groupDescriptorData.value; assertNotNull(groupDescriptor); ZNode assignmentNode = new ZNode(storeRoot, StoreMetadata.ASSIGNMENT_ZNODE_NAME); NodeData<ReplicaAssignments> assignmentsData = zkClient.getData(assignmentNode, ReplicaAssignmentsSerializer.INSTANCE); ReplicaAssignments replicaAssignments = assignmentsData.value; assertNotNull(replicaAssignments); Map<String, int[]> replicas = assignmentsData.value.replicas; assertEquals(0, replicas.size()); } finally { zooKeeperServerRunner.stop(); zooKeeperServerRunner.clear(); } }
public static void testMain(String[] args) { new ZooKeeperCli(args, true).processCmd(); }
ZooKeeperCli extends SubcommandCli { public static void testMain(String[] args) { new ZooKeeperCli(args, true).processCmd(); } }
ZooKeeperCli extends SubcommandCli { public static void testMain(String[] args) { new ZooKeeperCli(args, true).processCmd(); } private  ZooKeeperCli(String[] args, boolean useByTest); }
ZooKeeperCli extends SubcommandCli { public static void testMain(String[] args) { new ZooKeeperCli(args, true).processCmd(); } private  ZooKeeperCli(String[] args, boolean useByTest); static void testMain(String[] args); static void main(String[] args); }
ZooKeeperCli extends SubcommandCli { public static void testMain(String[] args) { new ZooKeeperCli(args, true).processCmd(); } private  ZooKeeperCli(String[] args, boolean useByTest); static void testMain(String[] args); static void main(String[] args);  }