use of com.emc.storageos.coordinator.client.service.impl.LeaderSelectorListenerImpl in project coprhd-controller by CoprHD.
the class ControllerServiceImpl method loadCustomConfigDefaults.
private void loadCustomConfigDefaults() {
LeaderSelectorListenerImpl executor = new LeaderSelectorListenerImpl() {
@Override
protected void startLeadership() throws Exception {
customConfigHandler.loadSystemCustomConfigs();
}
@Override
protected void stopLeadership() {
}
};
LeaderSelector service = _coordinator.getLeaderSelector(CUSTOM_CONFIG_PATH, executor);
service.autoRequeue();
service.start();
}
use of com.emc.storageos.coordinator.client.service.impl.LeaderSelectorListenerImpl in project coprhd-controller by CoprHD.
the class DataCollectionJobScheduler method start.
public void start() throws Exception {
_dataCollectionExecutorService = Executors.newScheduledThreadPool(1);
for (JobIntervals intervals : JobIntervals.values()) {
// Override intervals and refresh intervals with system properties, if set.
// Requires these system props start with "controller_" and uses underscores instead of hyphens.
String prop = _coordinator.getPropertyInfo().getProperty(PROP_HEADER_CONTROLLER + intervals._interval.replace('-', '_'));
if (prop != null) {
_configInfo.put(intervals._interval, prop);
}
prop = _coordinator.getPropertyInfo().getProperty(PROP_HEADER_CONTROLLER + intervals._refreshInterval.replace('-', '_'));
if (prop != null) {
_configInfo.put(intervals._refreshInterval, prop);
}
intervals.initialize(_configInfo);
}
boolean enableAutoScan = Boolean.parseBoolean(_configInfo.get(ENABLE_AUTOSCAN));
boolean enableAutoDiscovery = Boolean.parseBoolean(_configInfo.get(ENABLE_AUTODISCOVER));
boolean enableArrayAffinityDiscovery = Boolean.parseBoolean(_configInfo.get(ENABLE_ARRAYAFFINITY_DISCOVER));
boolean enableAutoMetering = Boolean.parseBoolean(_configInfo.get(ENABLE_METERING));
// standalone, or 1+0. CoprHD are single-node deployments typically, so ignore this variable in CoprHD.
if (!PlatformUtils.isOssBuild() && (enableAutoScan || enableAutoDiscovery || enableAutoMetering)) {
String numOfNodesString = _coordinator.getPropertyInfo().getProperty(PropertyConstants.NODE_COUNT_KEY);
if (numOfNodesString != null && numOfNodesString.equals("1")) {
boolean enableAutoOpsSingleNodeString = false;
String enableAutoOpsSingleNode = _configInfo.get(ENABLE_AUTO_OPS_SINGLENODE);
if (enableAutoOpsSingleNode != null) {
enableAutoOpsSingleNodeString = Boolean.parseBoolean(enableAutoOpsSingleNode);
}
if (!enableAutoOpsSingleNodeString) {
enableAutoScan = enableAutoDiscovery = enableAutoMetering = false;
}
}
}
LeaderSelectorListenerForPeriodicTask schedulingProcessor = new LeaderSelectorListenerForPeriodicTask(_dataCollectionExecutorService);
if (enableAutoScan) {
JobIntervals intervals = JobIntervals.get(ControllerServiceImpl.SCANNER);
schedulingProcessor.addScheduledTask(new DiscoveryScheduler(ControllerServiceImpl.SCANNER), intervals.getInitialDelay(), intervals.getInterval());
} else {
_logger.info("Auto scan is disabled.");
}
if (enableAutoDiscovery) {
JobIntervals intervals = JobIntervals.get(ControllerServiceImpl.DISCOVERY);
schedulingProcessor.addScheduledTask(new DiscoveryScheduler(ControllerServiceImpl.DISCOVERY), intervals.getInitialDelay(), intervals.getInterval());
intervals = JobIntervals.get(ControllerServiceImpl.NS_DISCOVERY);
schedulingProcessor.addScheduledTask(new DiscoveryScheduler(ControllerServiceImpl.NS_DISCOVERY), intervals.getInitialDelay(), intervals.getInterval());
intervals = JobIntervals.get(ControllerServiceImpl.COMPUTE_DISCOVERY);
schedulingProcessor.addScheduledTask(new DiscoveryScheduler(ControllerServiceImpl.COMPUTE_DISCOVERY), intervals.getInitialDelay(), intervals.getInterval());
intervals = JobIntervals.get(ControllerServiceImpl.CS_DISCOVERY);
schedulingProcessor.addScheduledTask(new DiscoveryScheduler(ControllerServiceImpl.CS_DISCOVERY), intervals.getInitialDelay(), intervals.getInterval());
} else {
_logger.info("Auto discovery is disabled.");
}
if (enableArrayAffinityDiscovery) {
JobIntervals intervals = JobIntervals.get(ControllerServiceImpl.ARRAYAFFINITY_DISCOVERY);
schedulingProcessor.addScheduledTask(new DiscoveryScheduler(ControllerServiceImpl.ARRAYAFFINITY_DISCOVERY), intervals.getInitialDelay(), intervals.getInterval());
_logger.info("Array Affinity discovery is enabled with interval {}", intervals.getInterval());
} else {
_logger.info("Array Affinity discovery is disabled");
}
if (enableAutoMetering) {
JobIntervals intervals = JobIntervals.get(ControllerServiceImpl.METERING);
schedulingProcessor.addScheduledTask(new DiscoveryScheduler(ControllerServiceImpl.METERING), intervals.getInitialDelay(), intervals.getInterval());
} else {
_logger.info("Metering is disabled.");
}
discoverySchedulingSelector = _coordinator.getLeaderSelector(leaderSelectorPath, schedulingProcessor);
discoverySchedulingSelector.autoRequeue();
discoverySchedulingSelector.start();
// run provider refresh in it's own thread so we don't hold up the scheduling
// thread if it takes longer than expected
_dataCollectionExecutorService.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
try {
(new Thread(new RefreshProviderConnectionsThread())).start();
} catch (Exception e) {
_logger.error("Failed to start refresh connections thread: {}", e.getMessage());
_logger.error(e.getMessage(), e);
}
}
}, initialConnectionRefreshDelay, JobIntervals.SCAN_INTERVALS.getInterval(), TimeUnit.SECONDS);
// recompute storage ports's metrics for all storage system
// Since traverse through all storage ports in all storage systems may take a while, it best to perform the
// task in a thread. We definitely do not want all nodes in cluster to do the same task, select a leader to
// do it there.
computePortMetricsSelector = _coordinator.getLeaderSelector(leaderSelectorComputePortMetricsPath, new LeaderSelectorListenerImpl() {
@Override
protected void stopLeadership() {
}
@Override
protected void startLeadership() throws Exception {
_dataCollectionExecutorService.schedule(new Runnable() {
@Override
public void run() {
_portMetricsProcessor.computeStoragePortUsage();
}
}, 1, TimeUnit.MILLISECONDS);
}
});
computePortMetricsSelector.autoRequeue();
computePortMetricsSelector.start();
}
Aggregations