use of com.emc.storageos.coordinator.client.service.LeaderSelectorListenerForPeriodicTask in project coprhd-controller by CoprHD.
the class DistributedLockQueueScheduler method start.
public void start() {
listener = new LeaderSelectorListenerForPeriodicTask(new LockQueuePeriodicTask(), INITIAL_DELAY, INTERVAL);
leaderSelector = coordinator.getLeaderSelector(LOCKQUEUE_LEADER_PATH, listener);
leaderSelector.autoRequeue();
leaderSelector.start();
}
use of com.emc.storageos.coordinator.client.service.LeaderSelectorListenerForPeriodicTask in project coprhd-controller by CoprHD.
the class ControllerServiceImpl method startCapacityService.
private void startCapacityService() {
long delay = DEFAULT_CAPACITY_COMPUTE_DELAY;
String delay_str = _configInfo.get(CAPACITY_COMPUTE_DELAY);
if (delay_str != null) {
delay = Long.parseLong(delay_str);
}
long interval = DEFAULT_CAPACITY_COMPUTE_INTERVAL;
String interval_str = _configInfo.get(CAPACITY_COMPUTE_INTERVAL);
if (interval_str != null) {
interval = Long.parseLong(interval_str);
}
LeaderSelectorListenerForPeriodicTask executor = new LeaderSelectorListenerForPeriodicTask(_capacityCompute, delay, interval);
_capacityService = _coordinator.getLeaderSelector(CAPACITY_LEADER_PATH, executor);
_capacityService.autoRequeue();
_capacityService.start();
}
use of com.emc.storageos.coordinator.client.service.LeaderSelectorListenerForPeriodicTask 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