public void init(String dc_sync_period, String  resources_keep_alive_period, String manager_ip, String manager_port) {

        if (registryInitialized)
            throw new RuntimeException("Registry was already initialized");

        if (dc_sync_period != null) {
            CONFIG_SYNC_PERIOD = Integer.parseInt(dc_sync_period);
        }

        if (resources_keep_alive_period != null) {
            KEEP_ALIVE = Integer.parseInt(resources_keep_alive_period);
        }

        // Build metrics
        providedMetrics = buildProvidedMetrics();

        // Build the DCAgent
        dcAgent = new DCAgent(new ManagerAPI(manager_ip, Integer.parseInt(manager_port)));

        // Add observers of metrics to the DCAgent
        for (Metric metric : providedMetrics) {
            logger.debug("Added metric {} as observer of dcagent",
                    metric.getMonitoredMetric());
            dcAgent.addObserver(metric);
        }

        // Build the DCDescriptor
        DCDescriptor dcDescriptor = new DCDescriptor();

        dcDescriptor.addMonitoredResources(getProvidedMetrics(), getResources());
        dcDescriptor.addResources(getResources());

        dcDescriptor
                .setConfigSyncPeriod(CONFIG_SYNC_PERIOD != null ? CONFIG_SYNC_PERIOD
                        : DEFAULT_CONFIG_SYNC_PERIOD);

        dcDescriptor.setKeepAlive(KEEP_ALIVE != null ? KEEP_ALIVE
                : (DEFAULT_CONFIG_SYNC_PERIOD + 15));

        dcAgent.setDCDescriptor(dcDescriptor);
        registryInitialized = true;

    }
public void init ( String dc_sync_period , String resources_keep_alive_period , String manager_ip , String manager_port ) { if ( registryInitialized ) throw new RuntimeException ( "Registry was already initialized" ) ; if ( dc_sync_period != null ) { CONFIG_SYNC_PERIOD = Integer . parseInt ( dc_sync_period ) ; } if ( resources_keep_alive_period != null ) { KEEP_ALIVE = Integer . parseInt ( resources_keep_alive_period ) ; } providedMetrics = buildProvidedMetrics ( ) ; dcAgent = new DCAgent ( new ManagerAPI ( manager_ip , Integer . parseInt ( manager_port ) ) ) ; for ( Metric metric : providedMetrics ) { logger . debug ( "Added metric {} as observer of dcagent" , metric . getMonitoredMetric ( ) ) ; dcAgent . addObserver ( metric ) ; } DCDescriptor dcDescriptor = new DCDescriptor ( ) ; dcDescriptor . addMonitoredResources ( getProvidedMetrics ( ) , getResources ( ) ) ; dcDescriptor . addResources ( getResources ( ) ) ; dcDescriptor . setConfigSyncPeriod ( CONFIG_SYNC_PERIOD != null ? CONFIG_SYNC_PERIOD : DEFAULT_CONFIG_SYNC_PERIOD ) ; dcDescriptor . setKeepAlive ( KEEP_ALIVE != null ? KEEP_ALIVE : ( DEFAULT_CONFIG_SYNC_PERIOD + 15 ) ) ; dcAgent . setDCDescriptor ( dcDescriptor ) ; registryInitialized = true ; }
This method is used to initialized the collecting of each metric.
It initializes a DCAgent with the manager_ip and manager_port parameters
in order to communicate with Tower 4Clouds.
It then build a DCDescriptor with the list of all the provided metrics
and the set of monitored resources for each provided metric.
It then start the DCAgent, which enact the collecting of each metric
and communicate to Tower 4Clouds the set of monitored resources
for each provided metric.
@param dc_sync_period
@param resources_keep_alive_period
@param manager_ip
@param manager_port