本文整理了Java中org.apache.helix.manager.zk.ZkCacheBaseDataAccessor
类的一些代码示例,展示了ZkCacheBaseDataAccessor
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkCacheBaseDataAccessor
类的具体详情如下:
包路径:org.apache.helix.manager.zk.ZkCacheBaseDataAccessor
类名称:ZkCacheBaseDataAccessor
暂无
代码示例来源:origin: apache/incubator-pinot
/**
* Check if an Instance exists in the Helix cluster.
*
* @param instanceName: Name of instance to check.
* @return True if instance exists in the Helix cluster, False otherwise.
*/
public boolean instanceExists(String instanceName) {
ZNRecord znRecord = _cacheInstanceConfigsDataAccessor.get("/" + instanceName, null, AccessOption.PERSISTENT);
return (znRecord != null);
}
代码示例来源:origin: apache/incubator-pinot
/**
* Get all instance Ids.
*
* @return List of instance Ids
*/
@Nonnull
public List<String> getAllInstances() {
return _cacheInstanceConfigsDataAccessor.getChildNames("/", AccessOption.PERSISTENT);
}
代码示例来源:origin: apache/incubator-pinot
/**
* Returns the config for all the Helix instances in the cluster.
*/
public List<InstanceConfig> getAllHelixInstanceConfigs() {
List<ZNRecord> znRecords = _cacheInstanceConfigsDataAccessor.getChildren("/", null, AccessOption.PERSISTENT);
List<InstanceConfig> instanceConfigs = new ArrayList<>(znRecords.size());
znRecords.forEach(znRecord -> instanceConfigs.add(new InstanceConfig(znRecord)));
return instanceConfigs;
}
代码示例来源:origin: apache/helix
new ZkCacheBaseDataAccessor<ZNRecord>(baseAccessor, null, cachePaths, null);
boolean[] success = accessor.createChildren(paths, records, AccessOption.PERSISTENT);
for (int i = 0; i < 10; i++) {
Assert.assertTrue(success[i], "Should succeed in create: " + paths.get(i));
updaters.add(updater);
success = accessor.updateChildren(paths, updaters, AccessOption.PERSISTENT);
records.add(record);
success = accessor.setChildren(paths, records, AccessOption.PERSISTENT);
for (int i = 0; i < 10; i++) {
Assert.assertTrue(success[i], "Should succeed in set: " + paths.get(i));
records = accessor.get(paths, null, 0);
for (int i = 0; i < 10; i++) {
Assert.assertEquals(records.get(i).getId(), "TestDB" + i);
records = accessor.getChildren(extViewPath, null, 0);
for (int i = 0; i < 10; i++) {
Assert.assertEquals(records.get(i).getId(), "TestDB" + i);
success = accessor.exists(paths, 0);
for (int i = 0; i < 10; i++) {
Assert.assertTrue(success[i], "Should exits: TestDB" + i);
代码示例来源:origin: apache/helix
new ZkCacheBaseDataAccessor<ZNRecord>(baseAccessor, null, cachePaths, null);
boolean success = accessor.create(path, new ZNRecord("TestDB" + i), AccessOption.PERSISTENT);
Assert.assertTrue(success, "Should succeed in create: " + path);
newRecord.setSimpleField("" + j, "" + j);
boolean success =
accessor.update(path, new ZNRecordUpdater(newRecord), AccessOption.PERSISTENT);
Assert.assertTrue(success, "Should succeed in update: " + path);
boolean success = accessor.set(path, new ZNRecord("TestDB" + i), AccessOption.PERSISTENT);
Assert.assertTrue(success, "Should succeed in set: " + path);
ZNRecord record = accessor.get(path, null, 0);
Assert.assertEquals(record.getId(), "TestDB" + i);
List<String> childNames = accessor.getChildNames(extViewPath, 0);
String path = PropertyPathBuilder.instanceCurrentState(clusterName, "localhost_8901", "session_0", "TestDB" + i);
Assert.assertTrue(accessor.exists(path, 0));
代码示例来源:origin: org.apache.helix/helix-core
@Override
public List<T> getChildren(String parentPath, List<Stat> stats, int options) {
List<String> childNames = getChildNames(parentPath, options);
if (childNames == null) {
return null;
}
List<String> paths = new ArrayList<>();
for (String childName : childNames) {
String path = parentPath.equals("/") ? "/" + childName : parentPath + "/" + childName;
paths.add(path);
}
return get(paths, stats, options);
}
代码示例来源:origin: apache/helix
new ZkCacheBaseDataAccessor<ZNRecord>(baseAccessor, null, null, cachePaths);
accessor.subscribe(curStatePath, listener);
newRecord.setSimpleField("" + j, "" + j);
boolean success =
accessor.update(path, new ZNRecordUpdater(newRecord), AccessOption.PERSISTENT);
Assert.assertTrue(success, "Should succeed in update: " + path);
String path = curStatePath + "/session_0/TestDB" + i;
removePaths.add(path);
boolean success = accessor.remove(path, AccessOption.PERSISTENT);
Assert.assertTrue(success, "Should succeed in remove: " + path);
代码示例来源:origin: apache/incubator-pinot
/**
* Create Helix cluster if needed, and then start a Pinot controller instance.
*/
public synchronized void start() {
_helixZkManager = HelixSetupUtils
.setup(_helixClusterName, _helixZkURL, _instanceId, _isUpdateStateModel, _enableBatchMessageMode);
Preconditions.checkNotNull(_helixZkManager);
_helixAdmin = _helixZkManager.getClusterManagmentTool();
_propertyStore = _helixZkManager.getHelixPropertyStore();
_helixDataAccessor = _helixZkManager.getHelixDataAccessor();
// Cache instance zk paths.
BaseDataAccessor<ZNRecord> baseDataAccessor = _helixDataAccessor.getBaseDataAccessor();
String instanceConfigs = PropertyPathBuilder.instanceConfig(_helixClusterName);
_cacheInstanceConfigsDataAccessor =
new ZkCacheBaseDataAccessor<>((ZkBaseDataAccessor<ZNRecord>) baseDataAccessor, instanceConfigs, null,
Collections.singletonList(instanceConfigs));
_keyBuilder = _helixDataAccessor.keyBuilder();
_segmentDeletionManager = new SegmentDeletionManager(_dataDir, _helixAdmin, _helixClusterName, _propertyStore);
ZKMetadataProvider.setClusterTenantIsolationEnabled(_propertyStore, _isSingleTenantCluster);
_tableRebalancer = new TableRebalancer(_helixZkManager, _helixAdmin, _helixClusterName);
}
代码示例来源:origin: apache/helix
new ZkCacheBaseDataAccessor<ZNRecord>(baseAccessor, null, Arrays.asList(curStatePath), null);
boolean success = accessor.create(path, new ZNRecord("TestDB" + i), AccessOption.PERSISTENT);
Assert.assertTrue(success, "Should succeed in create: " + path);
boolean success = accessor.create(path, new ZNRecord("TestDB" + i), AccessOption.PERSISTENT);
Assert.assertFalse(success, "Should fail in create due to NodeExists: " + path);
代码示例来源:origin: apache/helix
new ZkCacheBaseDataAccessor<ZNRecord>(baseAccessor, null, Arrays.asList(curStatePath,
extViewPath), null);
boolean[] success = accessor.createChildren(paths, records, AccessOption.PERSISTENT);
for (int i = 0; i < 10; i++) {
Assert.assertTrue(success[i], "Should succeed in create: " + paths.get(i));
success = accessor.createChildren(paths, records, AccessOption.PERSISTENT);
代码示例来源:origin: apache/helix
@Override
public boolean[] exists(List<String> paths, int options) {
final int size = paths.size();
boolean exists[] = new boolean[size];
for (int i = 0; i < size; i++) {
exists[i] = exists(paths.get(i), options);
}
return exists;
}
代码示例来源:origin: apache/helix
@Override
public boolean set(String path, T data, int options) {
return set(path, data, -1, options);
}
代码示例来源:origin: org.apache.helix/helix-core
private void updateCache(Cache<T> cache, List<String> createPaths, boolean success,
String updatePath, T data, Stat stat) {
if (createPaths == null || createPaths.isEmpty()) {
if (success) {
cache.update(updatePath, data, stat);
}
} else {
String firstPath = firstCachePath(createPaths);
if (firstPath != null) {
cache.updateRecursive(firstPath);
}
}
}
代码示例来源:origin: apache/helix
boolean[] success = _accessor.createChildren(paths, records, AccessOption.PERSISTENT);
代码示例来源:origin: apache/helix
new ZkCacheBaseDataAccessor<ZNRecord>(baseAccessor, null, null, zkCacheInitPaths);
boolean[] success = accessor.createChildren(paths, records, AccessOption.PERSISTENT);
for (int i = 0; i < 10; i++) {
Assert.assertTrue(success[i], "Should succeed in create: " + paths.get(i));
updaters.add(updater);
success = accessor.updateChildren(paths, updaters, AccessOption.PERSISTENT);
records.add(record);
success = accessor.setChildren(paths, records, AccessOption.PERSISTENT);
for (int i = 0; i < 10; i++) {
Assert.assertTrue(success[i], "Should succeed in set: " + paths.get(i));
records = accessor.get(paths, null, 0);
for (int i = 0; i < 10; i++) {
Assert.assertEquals(records.get(i).getId(), "TestDB" + i);
records = accessor.getChildren(extViewPath, null, 0);
for (int i = 0; i < 10; i++) {
Assert.assertEquals(records.get(i).getId(), "TestDB" + i);
success = accessor.exists(paths, 0);
for (int i = 0; i < 10; i++) {
Assert.assertTrue(success[i], "Should exits: " + paths.get(i));
代码示例来源:origin: apache/helix
@Override
public List<T> getChildren(String parentPath, List<Stat> stats, int options) {
List<String> childNames = getChildNames(parentPath, options);
if (childNames == null) {
return null;
}
List<String> paths = new ArrayList<>();
for (String childName : childNames) {
String path = parentPath.equals("/") ? "/" + childName : parentPath + "/" + childName;
paths.add(path);
}
return get(paths, stats, options);
}
代码示例来源:origin: apache/helix
new ZkCacheBaseDataAccessor<ZNRecord>(baseAccessor, null, cachePaths, null);
代码示例来源:origin: org.apache.helix/helix-core
@Override
public boolean[] exists(List<String> paths, int options) {
final int size = paths.size();
boolean exists[] = new boolean[size];
for (int i = 0; i < size; i++) {
exists[i] = exists(paths.get(i), options);
}
return exists;
}
代码示例来源:origin: org.apache.helix/helix-core
@Override
public boolean set(String path, T data, int options) {
return set(path, data, -1, options);
}
代码示例来源:origin: apache/helix
private void updateCache(Cache<T> cache, List<String> createPaths, boolean success,
String updatePath, T data, Stat stat) {
if (createPaths == null || createPaths.isEmpty()) {
if (success) {
cache.update(updatePath, data, stat);
}
} else {
String firstPath = firstCachePath(createPaths);
if (firstPath != null) {
cache.updateRecursive(firstPath);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!