@Test public void createHelixPropertyStoreTest() throws IOException { Properties storeProps = new Properties(); storeProps.setProperty("helix.property.store.root.path", "/Ambry-Test/" + ClusterMapUtils.PROPERTYSTORE_STR); HelixPropertyStoreConfig propertyStoreConfig = new HelixPropertyStoreConfig(new VerifiableProperties(storeProps)); String tempDirPath = getTempDir("clusterMapUtils-"); ZkInfo zkInfo = new ZkInfo(tempDirPath, "DC1", (byte) 0, 2200, true); try { CommonUtils.createHelixPropertyStore(null, propertyStoreConfig, Collections.emptyList()); fail("create HelixPropertyStore with invalid arguments should fail"); } catch (IllegalArgumentException e) { } try { CommonUtils.createHelixPropertyStore("", propertyStoreConfig, Collections.emptyList()); fail("create HelixPropertyStore with invalid arguments should fail"); } catch (IllegalArgumentException e) { } try { CommonUtils.createHelixPropertyStore("localhost:" + zkInfo.getPort(), (HelixPropertyStoreConfig) null, Collections.emptyList()); fail("create HelixPropertyStore with invalid arguments should fail"); } catch (IllegalArgumentException e) { } HelixPropertyStore<ZNRecord> propertyStore = CommonUtils.createHelixPropertyStore("localhost:" + zkInfo.getPort(), propertyStoreConfig, Collections.singletonList(propertyStoreConfig.rootPath)); assertNotNull(propertyStore); List<String> list = Arrays.asList("first", "second", "third"); String path = propertyStoreConfig.rootPath + ClusterMapUtils.PARTITION_OVERRIDE_ZNODE_PATH; ZNRecord znRecord = new ZNRecord(ClusterMapUtils.PARTITION_OVERRIDE_STR); znRecord.setListField("AmbryList", list); if (!propertyStore.set(path, znRecord, AccessOption.PERSISTENT)) { fail("Failed to set HelixPropertyStore"); } assertTrue("The record path doesn't exist", propertyStore.exists(path, AccessOption.PERSISTENT)); ZNRecord result = propertyStore.get(path, null, AccessOption.PERSISTENT); assertEquals("Mismatch in list content", new HashSet<>(list), new HashSet<>(result.getListField("AmbryList"))); zkInfo.shutdown(); }
public static HelixPropertyStore<ZNRecord> createHelixPropertyStore(String zkServers, HelixPropertyStoreConfig propertyStoreConfig, List<String> subscribedPaths) { if (zkServers == null || zkServers.isEmpty() || propertyStoreConfig == null) { throw new IllegalArgumentException("Invalid arguments, cannot create HelixPropertyStore"); } ZkClient zkClient = new ZkClient(zkServers, propertyStoreConfig.zkClientSessionTimeoutMs, propertyStoreConfig.zkClientConnectionTimeoutMs, new ZNRecordSerializer()); return new ZkHelixPropertyStore<>(new ZkBaseDataAccessor<>(zkClient), propertyStoreConfig.rootPath, subscribedPaths); }
CommonUtils { public static HelixPropertyStore<ZNRecord> createHelixPropertyStore(String zkServers, HelixPropertyStoreConfig propertyStoreConfig, List<String> subscribedPaths) { if (zkServers == null || zkServers.isEmpty() || propertyStoreConfig == null) { throw new IllegalArgumentException("Invalid arguments, cannot create HelixPropertyStore"); } ZkClient zkClient = new ZkClient(zkServers, propertyStoreConfig.zkClientSessionTimeoutMs, propertyStoreConfig.zkClientConnectionTimeoutMs, new ZNRecordSerializer()); return new ZkHelixPropertyStore<>(new ZkBaseDataAccessor<>(zkClient), propertyStoreConfig.rootPath, subscribedPaths); } }
CommonUtils { public static HelixPropertyStore<ZNRecord> createHelixPropertyStore(String zkServers, HelixPropertyStoreConfig propertyStoreConfig, List<String> subscribedPaths) { if (zkServers == null || zkServers.isEmpty() || propertyStoreConfig == null) { throw new IllegalArgumentException("Invalid arguments, cannot create HelixPropertyStore"); } ZkClient zkClient = new ZkClient(zkServers, propertyStoreConfig.zkClientSessionTimeoutMs, propertyStoreConfig.zkClientConnectionTimeoutMs, new ZNRecordSerializer()); return new ZkHelixPropertyStore<>(new ZkBaseDataAccessor<>(zkClient), propertyStoreConfig.rootPath, subscribedPaths); }  }
CommonUtils { public static HelixPropertyStore<ZNRecord> createHelixPropertyStore(String zkServers, HelixPropertyStoreConfig propertyStoreConfig, List<String> subscribedPaths) { if (zkServers == null || zkServers.isEmpty() || propertyStoreConfig == null) { throw new IllegalArgumentException("Invalid arguments, cannot create HelixPropertyStore"); } ZkClient zkClient = new ZkClient(zkServers, propertyStoreConfig.zkClientSessionTimeoutMs, propertyStoreConfig.zkClientConnectionTimeoutMs, new ZNRecordSerializer()); return new ZkHelixPropertyStore<>(new ZkBaseDataAccessor<>(zkClient), propertyStoreConfig.rootPath, subscribedPaths); }  static HelixPropertyStore<ZNRecord> createHelixPropertyStore(String zkServers,
      HelixPropertyStoreConfig propertyStoreConfig, List<String> subscribedPaths); static HelixPropertyStore<ZNRecord> createHelixPropertyStore(String zkAddress, String rootPath,
      List<String> subscribedPaths); }
CommonUtils { public static HelixPropertyStore<ZNRecord> createHelixPropertyStore(String zkServers, HelixPropertyStoreConfig propertyStoreConfig, List<String> subscribedPaths) { if (zkServers == null || zkServers.isEmpty() || propertyStoreConfig == null) { throw new IllegalArgumentException("Invalid arguments, cannot create HelixPropertyStore"); } ZkClient zkClient = new ZkClient(zkServers, propertyStoreConfig.zkClientSessionTimeoutMs, propertyStoreConfig.zkClientConnectionTimeoutMs, new ZNRecordSerializer()); return new ZkHelixPropertyStore<>(new ZkBaseDataAccessor<>(zkClient), propertyStoreConfig.rootPath, subscribedPaths); }  static HelixPropertyStore<ZNRecord> createHelixPropertyStore(String zkServers,
      HelixPropertyStoreConfig propertyStoreConfig, List<String> subscribedPaths); static HelixPropertyStore<ZNRecord> createHelixPropertyStore(String zkAddress, String rootPath,
      List<String> subscribedPaths);  }