3,
"MasterSlave",
true);
ConfigAccessor configAccessor = new ConfigAccessor(_gZkClient);
HelixConfigScope clusterScope = new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER)
.forCluster(clusterName)
.build();
// cluster scope config
String clusterConfigValue = configAccessor.get(clusterScope, "clusterConfigKey");
Assert.assertNull(clusterConfigValue);
configAccessor.set(clusterScope, "clusterConfigKey", "clusterConfigValue");
clusterConfigValue = configAccessor.get(clusterScope, "clusterConfigKey");
Assert.assertEquals(clusterConfigValue, "clusterConfigValue");
// resource scope config
HelixConfigScope resourceScope = new HelixConfigScopeBuilder(ConfigScopeProperty.RESOURCE)
.forCluster(clusterName)
.forResource("testResource")
.build();
configAccessor.set(resourceScope, "resourceConfigKey", "resourceConfigValue");
String resourceConfigValue = configAccessor.get(resourceScope, "resourceConfigKey");
Assert.assertEquals(resourceConfigValue, "resourceConfigValue");
// partition scope config
HelixConfigScope partitionScope = new HelixConfigScopeBuilder(ConfigScopeProperty.PARTITION)
.forCluster(clusterName)
.forResource("testResource")
.forPartition("testPartition")
.build();
configAccessor.set(partitionScope, "partitionConfigKey", "partitionConfigValue");
String partitionConfigValue = configAccessor.get(partitionScope, "partitionConfigKey");
Assert.assertEquals(partitionConfigValue, "partitionConfigValue");
// participant scope config
HelixConfigScope participantScope = new HelixConfigScopeBuilder(ConfigScopeProperty.PARTICIPANT)
.forCluster(clusterName)
.forParticipant("localhost_12918")
.build();
configAccessor.set(participantScope, "participantConfigKey", "participantConfigValue");
String participantConfigValue = configAccessor.get(participantScope, "participantConfigKey");