use of org.apache.helix.model.CloudConfig in project helix by apache.
the class HelixPropertyFactory method getHelixManagerProperty.
/**
* Retrieve Helix manager property. It returns the property object with default values.
* Clients may override these values.
*/
public HelixManagerProperty getHelixManagerProperty(String zkAddress, String clusterName) {
CloudConfig cloudConfig = getCloudConfig(zkAddress, clusterName, null);
Properties properties = new Properties();
try {
InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(HELIX_PARTICIPANT_PROPERTY_FILE);
properties.load(stream);
} catch (IOException e) {
String errMsg = String.format("failed to open Helix participant properties file: %s", HELIX_PARTICIPANT_PROPERTY_FILE);
throw new IllegalArgumentException(errMsg, e);
}
LOG.info("HelixPropertyFactory successfully loaded helix participant properties: {}", properties);
return new HelixManagerProperty(properties, cloudConfig);
}
use of org.apache.helix.model.CloudConfig in project helix by apache.
the class TestCloudConfig method testCloudConfig.
@Test(dependsOnMethods = "testCloudConfigNull")
public void testCloudConfig() throws Exception {
String className = getShortClassName();
String clusterName = "CLUSTER_" + className;
TestHelper.setupEmptyCluster(_gZkClient, clusterName);
// Create dummy CloudConfig object
CloudConfig.Builder cloudConfigBuilder = new CloudConfig.Builder();
cloudConfigBuilder.setCloudEnabled(true);
cloudConfigBuilder.setCloudProvider(CloudProvider.AZURE);
cloudConfigBuilder.setCloudID("TestID");
List<String> infoURL = new ArrayList<String>();
infoURL.add("TestURL");
cloudConfigBuilder.setCloudInfoSources(infoURL);
cloudConfigBuilder.setCloudInfoProcessorName("TestProcessor");
CloudConfig cloudConfig = cloudConfigBuilder.build();
// Write the CloudConfig to Zookeeper
ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor(_gZkClient));
Builder keyBuilder = accessor.keyBuilder();
accessor.setProperty(keyBuilder.cloudConfig(), cloudConfig);
// Read CloudConfig from Zookeeper and check the content
ConfigAccessor _configAccessor = new ConfigAccessor(_gZkClient);
CloudConfig cloudConfigFromZk = _configAccessor.getCloudConfig(clusterName);
Assert.assertTrue(cloudConfigFromZk.isCloudEnabled());
Assert.assertEquals(cloudConfigFromZk.getCloudProvider(), CloudProvider.AZURE.name());
Assert.assertEquals(cloudConfigFromZk.getCloudID(), "TestID");
Assert.assertEquals(cloudConfigFromZk.getCloudInfoSources().size(), 1);
Assert.assertEquals(cloudConfigFromZk.getCloudInfoProcessorName(), "TestProcessor");
}
use of org.apache.helix.model.CloudConfig in project helix by apache.
the class TestCloudConfig method testUnverifiedCloudConfigBuilderEmptySources.
@Test(expectedExceptions = HelixException.class)
public void testUnverifiedCloudConfigBuilderEmptySources() {
String className = getShortClassName();
String clusterName = "CLUSTER_" + className;
CloudConfig.Builder builder = new CloudConfig.Builder();
builder.setCloudEnabled(true);
builder.setCloudProvider(CloudProvider.CUSTOMIZED);
builder.setCloudID("TestID");
List<String> emptyList = new ArrayList<String>();
builder.setCloudInfoSources(emptyList);
builder.setCloudInfoProcessorName("TestProcessor");
CloudConfig cloudConfig = builder.build();
}
use of org.apache.helix.model.CloudConfig in project helix by apache.
the class TestCloudConfig method testUnverifiedCloudConfigBuilder.
@Test(expectedExceptions = HelixException.class)
public void testUnverifiedCloudConfigBuilder() {
String className = getShortClassName();
String clusterName = "CLUSTER_" + className;
CloudConfig.Builder builder = new CloudConfig.Builder();
builder.setCloudEnabled(true);
// Verify will fail because cloudID has net been defined.
CloudConfig cloudConfig = builder.build();
}
use of org.apache.helix.model.CloudConfig in project helix by apache.
the class TestClusterSetup method testAddClusterWithValidCloudConfig.
@Test(dependsOnMethods = "testAddClusterWithInvalidCloudConfig")
public void testAddClusterWithValidCloudConfig() throws Exception {
String className = TestHelper.getTestClassName();
String methodName = TestHelper.getTestMethodName();
String clusterName = className + "_" + methodName;
CloudConfig.Builder cloudConfigInitBuilder = new CloudConfig.Builder();
cloudConfigInitBuilder.setCloudEnabled(true);
cloudConfigInitBuilder.setCloudID("TestID");
List<String> sourceList = new ArrayList<String>();
sourceList.add("TestURL");
cloudConfigInitBuilder.setCloudInfoSources(sourceList);
cloudConfigInitBuilder.setCloudInfoProcessorName("TestProcessorName");
cloudConfigInitBuilder.setCloudProvider(CloudProvider.CUSTOMIZED);
CloudConfig cloudConfigInit = cloudConfigInitBuilder.build();
_clusterSetup.addCluster(clusterName, false, cloudConfigInit);
// Read CloudConfig from Zookeeper and check the content
ConfigAccessor _configAccessor = new ConfigAccessor(_gZkClient);
CloudConfig cloudConfigFromZk = _configAccessor.getCloudConfig(clusterName);
Assert.assertTrue(cloudConfigFromZk.isCloudEnabled());
Assert.assertEquals(cloudConfigFromZk.getCloudID(), "TestID");
List<String> listUrlFromZk = cloudConfigFromZk.getCloudInfoSources();
Assert.assertEquals(listUrlFromZk.get(0), "TestURL");
Assert.assertEquals(cloudConfigFromZk.getCloudInfoProcessorName(), "TestProcessorName");
Assert.assertEquals(cloudConfigFromZk.getCloudProvider(), CloudProvider.CUSTOMIZED.name());
}
Aggregations