Search in sources :

Example 1 with CloudInstanceInformationProcessor

use of org.apache.helix.api.cloud.CloudInstanceInformationProcessor in project helix by apache.

the class ParticipantManager method getCloudInstanceInformation.

private CloudInstanceInformation getCloudInstanceInformation() {
    String cloudInstanceInformationProcessorName = _helixManagerProperty.getHelixCloudProperty().getCloudInfoProcessorName();
    try {
        // fetch cloud instance information for the instance
        String cloudInstanceInformationProcessorClassName = CLOUD_PROCESSOR_PATH_PREFIX + _helixManagerProperty.getHelixCloudProperty().getCloudProvider().toLowerCase() + "." + cloudInstanceInformationProcessorName;
        Class processorClass = Class.forName(cloudInstanceInformationProcessorClassName);
        Constructor constructor = processorClass.getConstructor(HelixCloudProperty.class);
        CloudInstanceInformationProcessor processor = (CloudInstanceInformationProcessor) constructor.newInstance(_helixManagerProperty.getHelixCloudProperty());
        List<String> responses = processor.fetchCloudInstanceInformation();
        // parse cloud instance information for the participant
        CloudInstanceInformation cloudInstanceInformation = processor.parseCloudInstanceInformation(responses);
        return cloudInstanceInformation;
    } catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException ex) {
        throw new HelixException("Failed to create a new instance for the class: " + cloudInstanceInformationProcessorName, ex);
    }
}
Also used : Constructor(java.lang.reflect.Constructor) CloudInstanceInformation(org.apache.helix.api.cloud.CloudInstanceInformation) CloudInstanceInformationProcessor(org.apache.helix.api.cloud.CloudInstanceInformationProcessor) InvocationTargetException(java.lang.reflect.InvocationTargetException) HelixException(org.apache.helix.HelixException)

Aggregations

Constructor (java.lang.reflect.Constructor)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 HelixException (org.apache.helix.HelixException)1 CloudInstanceInformation (org.apache.helix.api.cloud.CloudInstanceInformation)1 CloudInstanceInformationProcessor (org.apache.helix.api.cloud.CloudInstanceInformationProcessor)1