Search in sources :

Example 11 with CloudConfig

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);
}
Also used : InputStream(java.io.InputStream) CloudConfig(org.apache.helix.model.CloudConfig) IOException(java.io.IOException) Properties(java.util.Properties)

Example 12 with 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");
}
Also used : ZkBaseDataAccessor(org.apache.helix.manager.zk.ZkBaseDataAccessor) Builder(org.apache.helix.PropertyKey.Builder) CloudConfig(org.apache.helix.model.CloudConfig) ArrayList(java.util.ArrayList) ConfigAccessor(org.apache.helix.ConfigAccessor) ZKHelixDataAccessor(org.apache.helix.manager.zk.ZKHelixDataAccessor) Test(org.testng.annotations.Test)

Example 13 with CloudConfig

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();
}
Also used : Builder(org.apache.helix.PropertyKey.Builder) CloudConfig(org.apache.helix.model.CloudConfig) ArrayList(java.util.ArrayList) Test(org.testng.annotations.Test)

Example 14 with CloudConfig

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();
}
Also used : Builder(org.apache.helix.PropertyKey.Builder) CloudConfig(org.apache.helix.model.CloudConfig) Test(org.testng.annotations.Test)

Example 15 with CloudConfig

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());
}
Also used : Builder(org.apache.helix.PropertyKey.Builder) PropertyPathBuilder(org.apache.helix.PropertyPathBuilder) CloudConfig(org.apache.helix.model.CloudConfig) ArrayList(java.util.ArrayList) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ConfigAccessor(org.apache.helix.ConfigAccessor) Test(org.testng.annotations.Test)

Aggregations

CloudConfig (org.apache.helix.model.CloudConfig)42 Test (org.testng.annotations.Test)26 ConfigAccessor (org.apache.helix.ConfigAccessor)18 ZNRecord (org.apache.helix.zookeeper.datamodel.ZNRecord)15 ArrayList (java.util.ArrayList)14 Builder (org.apache.helix.PropertyKey.Builder)10 IOException (java.io.IOException)8 PropertyPathBuilder (org.apache.helix.PropertyPathBuilder)8 HashMap (java.util.HashMap)7 HelixConfigScopeBuilder (org.apache.helix.model.builder.HelixConfigScopeBuilder)7 RealmAwareZkClient (org.apache.helix.zookeeper.api.client.RealmAwareZkClient)7 HelixException (org.apache.helix.HelixException)6 HelixAdmin (org.apache.helix.HelixAdmin)5 ResponseMetered (com.codahale.metrics.annotation.ResponseMetered)4 Timed (com.codahale.metrics.annotation.Timed)4 Properties (java.util.Properties)4 Path (javax.ws.rs.Path)4 ZKHelixDataAccessor (org.apache.helix.manager.zk.ZKHelixDataAccessor)4 InstanceConfig (org.apache.helix.model.InstanceConfig)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4