use of com.emc.storageos.volumecontroller.JobContext in project coprhd-controller by CoprHD.
the class SmisCommandHelper method waitForAsyncSmisJob.
private void waitForAsyncSmisJob(StorageSystem storageDevice, CIMObjectPath cimJobPath, SmisJob job) throws SmisException {
if (job == null) {
TaskCompleter taskCompleter = new TaskCompleter() {
@Override
public void ready(DbClient dbClient) throws DeviceControllerException {
}
@Override
public void error(DbClient dbClient, ServiceCoded serviceCoded) throws DeviceControllerException {
}
@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
}
};
job = new SmisJob(cimJobPath, storageDevice.getId(), taskCompleter, "");
} else {
job.setCimJob(cimJobPath);
}
JobContext jobContext = new JobContext(_dbClient, _cimConnection, null, null, null, null, this);
long startTime = System.currentTimeMillis();
Long sync_wrapper_time_out = InvokeTestFailure.internalOnlyOverrideSyncWrapperTimeOut(DEFAULT_SYNC_WRAPPER_TIME_OUT);
boolean usesConfigTimeoutValue = false;
if (StorageSystem.Type.vmax.name().equalsIgnoreCase(storageDevice.getSystemType())) {
Long syncWrapperTimeoutInInMilliSeconds = ControllerUtils.MINUTE_TO_MILLISECONDS * Long.valueOf(ControllerUtils.getPropertyValueFromCoordinator(_coordinator, SYNC_WRAPPER_TIMEOUT_WRAPPER_CONFIG_KEY));
usesConfigTimeoutValue = true;
sync_wrapper_time_out = InvokeTestFailure.internalOnlyOverrideSyncWrapperTimeOut(syncWrapperTimeoutInInMilliSeconds);
_log.info("SMIS job Sync timeout in ms: {}", sync_wrapper_time_out);
}
while (true) {
JobPollResult result = job.poll(jobContext, SYNC_WRAPPER_WAIT);
if (!result.isJobInTerminalState()) {
if (System.currentTimeMillis() - startTime > sync_wrapper_time_out) {
String timeoutMessage = "Timed out waiting on smis job to complete after " + (System.currentTimeMillis() - startTime) + " milliseconds.";
if (usesConfigTimeoutValue) {
timeoutMessage = timeoutMessage + " Please retry this operation after increasing the value of 'Task timeout for VMAX SMIS job in minutes' in the configuration: System > General Configuration > Controller section.";
}
throw new SmisException(timeoutMessage);
} else {
try {
Thread.sleep(SYNC_WRAPPER_WAIT);
} catch (InterruptedException e) {
_log.error("Thread waiting for smis job to complete was interrupted and " + "will be resumed");
}
}
} else {
if (result.isJobInTerminalFailedState()) {
throw new SmisException("Smis job failed: " + result.getErrorDescription());
}
break;
}
}
}
use of com.emc.storageos.volumecontroller.JobContext in project coprhd-controller by CoprHD.
the class HDSMetaVolumeOperations method waitForAsyncHDSJob.
/**
* Waits the thread to till the operation completes.
*
* @param storageDeviceURI
* @param messageId
* @param job
* @param hdsApiFactory
* @return
* @throws HDSException
*/
private JobStatus waitForAsyncHDSJob(URI storageDeviceURI, String messageId, HDSJob job, HDSApiFactory hdsApiFactory) throws HDSException {
JobStatus status = JobStatus.IN_PROGRESS;
if (job == null) {
TaskCompleter taskCompleter = new TaskCompleter() {
@Override
public void ready(DbClient dbClient) throws DeviceControllerException {
}
@Override
public void error(DbClient dbClient, ServiceCoded serviceCoded) throws DeviceControllerException {
}
@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
}
};
job = new HDSJob(messageId, storageDeviceURI, taskCompleter, "");
} else {
job.setHDSJob(messageId);
}
JobContext jobContext = new JobContext(dbClient, null, null, hdsApiFactory, null, null, null, null);
long startTime = System.currentTimeMillis();
while (true) {
JobPollResult result = job.poll(jobContext, SYNC_WRAPPER_WAIT);
if (result.getJobStatus().equals(JobStatus.IN_PROGRESS) || result.getJobStatus().equals(JobStatus.ERROR)) {
if (System.currentTimeMillis() - startTime > SYNC_WRAPPER_TIME_OUT) {
HDSException.exceptions.asyncTaskFailedTimeout(System.currentTimeMillis() - startTime);
} else {
try {
Thread.sleep(SYNC_WRAPPER_WAIT);
} catch (InterruptedException e) {
log.error("Thread waiting for hds job to complete was interrupted and " + "will be resumed");
}
}
} else {
status = result.getJobStatus();
if (!status.equals(JobStatus.SUCCESS)) {
HDSException.exceptions.asyncTaskFailedWithErrorResponseWithoutErrorCode(messageId, result.getErrorDescription());
}
break;
}
}
return status;
}
use of com.emc.storageos.volumecontroller.JobContext in project coprhd-controller by CoprHD.
the class XIVSmisCommandHelper method waitForSmisJob.
private JobStatus waitForSmisJob(StorageSystem storageDevice, SmisJob job, int pollCycleLimit) throws SmisException {
JobStatus status = JobStatus.IN_PROGRESS;
JobContext jobContext = new JobContext(_dbClient, _cimConnection, null, null, null, null, null, this);
long startTime = System.currentTimeMillis();
int pollCycleCount = 0;
while (true) {
JobPollResult result = job.poll(jobContext, SYNC_WRAPPER_WAIT);
pollCycleCount++;
if (result.getJobStatus().equals(JobStatus.IN_PROGRESS)) {
if (pollCycleCount > pollCycleLimit) {
throw new SmisException("Reached maximum number of poll " + pollCycleLimit);
} else if (System.currentTimeMillis() - startTime > SYNC_WRAPPER_TIME_OUT) {
throw new SmisException("Timed out waiting on smis job to complete after " + (System.currentTimeMillis() - startTime) + " milliseconds");
} else {
try {
Thread.sleep(SYNC_WRAPPER_WAIT);
} catch (InterruptedException e) {
_log.error("Thread waiting for smis job to complete was interrupted and will be resumed");
}
}
} else {
status = result.getJobStatus();
if (!status.equals(JobStatus.SUCCESS)) {
throw new SmisException("Smis job failed: " + result.getErrorDescription());
}
break;
}
}
return status;
}
use of com.emc.storageos.volumecontroller.JobContext in project coprhd-controller by CoprHD.
the class ControllerServiceImpl method start.
@Override
public void start() throws Exception {
_log.info("Starting controller service");
_dbClient.start();
// Without this delay, my testing for Workflow functionality indicated
// that when a Bourne node is restarted with operations that have not
// completed in the dispatcher, Zookeeper will often come up first,
// and the Dispatcher will start running tasks (from before the restart)
// before Cassandra has come up. Those tasks then generally fail again
// because the first thing they often do is try to retrieve some record(s)
// from Cassandra, and since it is not up yet, they take a Connection Exception.
// Watson
// wait 30 seconds for database to connect
Thread.sleep(30000);
_log.info("Waiting done");
initDriverInfo();
_drQueueCleanupHandler.run();
_dispatcher.start();
_jobTracker.setJobContext(new JobContext(_dbClient, _cimConnectionFactory, _vplexApiFactory, hdsApiFactory, cinderApiFactory, _vnxeApiClientFactory, _helper, _xivSmisCommandHelper, isilonApiFactory));
// Set system-wide default timeout for QueueJobTracker. Can be overridden by specific jobs.
_jobTracker.setTrackingTimeout(ControllerUtils.MINUTE_TO_MILLISECONDS * Long.valueOf(ControllerUtils.getPropertyValueFromCoordinator(_coordinator, CONTROLLER_JOB_QUEUE_EXECUTION_TIMEOUT_MINUTES)));
_jobTracker.start();
_jobQueue = _coordinator.getQueue(JOB_QUEUE_NAME, _jobTracker, new QueueJobSerializer(), DEFAULT_MAX_THREADS);
Long wbemClientHTTPTimeoutInMilliSeconds = ControllerUtils.MINUTE_TO_MILLISECONDS * Long.valueOf(ControllerUtils.getPropertyValueFromCoordinator(_coordinator, WBEM_CLIENT_HTTP_TIMEOUT_MINUTES));
_log.info("Setting value of {} to {} ms as system property. This will be used by WBEM Client.", WBEM_CLIENT_HTTP_TIMEOUT_PROPERTY_NAME, wbemClientHTTPTimeoutInMilliSeconds);
System.setProperty(WBEM_CLIENT_HTTP_TIMEOUT_PROPERTY_NAME, String.valueOf(wbemClientHTTPTimeoutInMilliSeconds));
_workflowService.start();
_distributedOwnerLockService.start();
/**
* Lock used in making Scanning/Discovery mutually exclusive.
*/
for (Lock lock : Lock.values()) {
lock.setLock(_coordinator.getLock(lock.toString()));
}
/**
* Discovery Queue, an instance of DistributedQueueImpl in
* CoordinatorService,which holds Discovery Jobs. On starting
* discoveryConsumer, a new ScheduledExecutorService is instantiated,
* which schedules Loading Devices from DB every X minutes.
*/
_discoverJobConsumer.start();
_arrayAffinityDiscoverJobConsumer.start();
_computeDiscoverJobConsumer.start();
_scanJobConsumer.start();
_meteringJobConsumer.start();
_discoverJobQueue = _coordinator.getQueue(DISCOVER_JOB_QUEUE_NAME, _discoverJobConsumer, new DataCollectionJobSerializer(), Integer.parseInt(_configInfo.get(DISCOVERY_COREPOOLSIZE)), 200);
_arrayAffinityDiscoverJobQueue = _coordinator.getQueue(ARRAYAFFINITY_DISCOVER_JOB_QUEUE_NAME, _arrayAffinityDiscoverJobConsumer, new DataCollectionJobSerializer(), ARRAYAFFINITY_DISCOVERY_COREPOOLSIZE, 200);
_computeDiscoverJobQueue = _coordinator.getQueue(COMPUTE_DISCOVER_JOB_QUEUE_NAME, _computeDiscoverJobConsumer, new DataCollectionJobSerializer(), Integer.parseInt(_configInfo.get(COMPUTE_DISCOVERY_COREPOOLSIZE)), 50000);
_meteringJobQueue = _coordinator.getQueue(METERING_JOB_QUEUE_NAME, _meteringJobConsumer, new DataCollectionJobSerializer(), Integer.parseInt(_configInfo.get(METERING_COREPOOLSIZE)), 200);
_scanJobQueue = _coordinator.getQueue(SCAN_JOB_QUEUE_NAME, _scanJobConsumer, new DataCollectionJobSerializer(), 1, 50);
/**
* Monitoring use cases starts here
*/
_monitoringJobQueue = _coordinator.getQueue(MONITORING_JOB_QUEUE_NAME, _monitoringJobConsumer, new DataCollectionJobSerializer(), DEFAULT_MAX_THREADS);
/**
* Adds listener class for zk connection state change.
* This listener will release local CACHE while zk connection RECONNECT.
*/
_coordinator.setConnectionListener(zkConnectionStateListenerForMonitoring);
/**
* Starts Monitoring scheduled thread
*/
_monitoringJobConsumer.start();
startLockQueueService();
_drWorkflowCleanupHandler.run();
_jobScheduler.start();
_svcBeacon.start();
startCapacityService();
loadCustomConfigDefaults();
}
use of com.emc.storageos.volumecontroller.JobContext in project coprhd-controller by CoprHD.
the class HDSCommandHelper method waitForAsyncHDSJob.
/**
* wait for hds async job.
*
* @param job {@link HDSJob}
*/
public void waitForAsyncHDSJob(HDSJob job) throws HDSException {
JobContext jobContext = new JobContext(dbClient, null, null, hdsApiFactory, null, null, null);
long startTime = System.currentTimeMillis();
while (true) {
JobPollResult result = job.poll(jobContext, trackingPeriodInMillis);
if (!job.isJobInTerminalState()) {
if (System.currentTimeMillis() - startTime > HDSJob.ERROR_TRACKING_LIMIT) {
log.error("Timed out waiting on hds job to complete after {} milliseconds", System.currentTimeMillis() - startTime);
throw HDSException.exceptions.asyncTaskFailedTimeout(HDSJob.ERROR_TRACKING_LIMIT);
} else {
try {
Thread.sleep(trackingPeriodInMillis);
} catch (InterruptedException e) {
log.error("Thread waiting for hds job to complete was interrupted and " + "will be resumed");
}
}
} else {
if (job.isJobInTerminalFailedState()) {
throw HDSException.exceptions.asyncTaskFailed(result.getErrorDescription());
}
break;
}
}
}
Aggregations