use of com.emc.storageos.isilon.restapi.IsilonSyncJob in project coprhd-controller by CoprHD.
the class IsilonMirrorOperations method doStartReplicationPolicy.
/**
* Call to isilon to start replication session
*
* @param system
* @param policyName
* @return
*/
public BiosCommandResult doStartReplicationPolicy(StorageSystem system, String policyName, TaskCompleter taskCompleter) {
_log.info("IsilonMirrorOperations - doStartReplicationPolicy started on storagesystem {}", system.getLabel());
try {
IsilonApi isi = getIsilonDevice(system);
IsilonSyncPolicy policy = isi.getReplicationPolicy(policyName);
IsilonSyncPolicy.JobState policyState = policy.getLastJobState();
if (!policy.getEnabled()) {
policy = doEnableReplicationPolicy(isi, policyName);
if (policy.getEnabled()) {
_log.info("Replication Policy - {} ENABLED successfully", policy.toString());
}
}
if (!policyState.equals(JobState.running) || !policyState.equals(JobState.paused) || !policyState.equals(JobState.resumed)) {
IsilonSyncJob job = new IsilonSyncJob();
job.setId(policyName);
isi.modifyReplicationJob(job);
policy = isi.getReplicationPolicy(policyName);
IsilonSyncJobStart isiSyncJobStart = new IsilonSyncJobStart(policyName, system.getId(), taskCompleter, policyName);
try {
ControllerServiceImpl.enqueueJob(new QueueJob(isiSyncJobStart));
return BiosCommandResult.createPendingResult();
} catch (Exception ex) {
_log.error("Start Replication Job Failed ", ex);
ServiceError error = DeviceControllerErrors.isilon.jobFailed("Start Replication Job Failed as:" + ex.getMessage());
if (taskCompleter != null) {
taskCompleter.error(_dbClient, error);
}
return BiosCommandResult.createErrorResult(error);
}
} else {
_log.error("Replication Policy - {} can't be STARTED because policy is in {} state", policyName, policyState);
ServiceError error = DeviceControllerErrors.isilon.jobFailed("doStartReplicationPolicy as : Replication Policy can't be STARTED because " + "policy is already in Active state");
return BiosCommandResult.createErrorResult(error);
}
} catch (IsilonException e) {
_log.error("doStartReplicationPolicy failed.", e);
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.isilon.restapi.IsilonSyncJob in project coprhd-controller by CoprHD.
the class IsilonMirrorOperations method doResyncPrep.
/**
* Call to resync-prep
*
* @param system
* @param policyName
* @param completer
* @return
* @throws IsilonException
*/
public BiosCommandResult doResyncPrep(StorageSystem system, String policyName, TaskCompleter completer) throws IsilonException {
try {
_log.info("resync-prep between source file system to target file system started and device ip:", system.getIpAddress());
IsilonApi isi = getIsilonDevice(system);
IsilonSyncPolicy syncPolicy = isi.getReplicationPolicy(policyName);
// Before 'resync-prep' operation, Original source to target policy should be enabled.
if (!syncPolicy.getEnabled()) {
_log.info("Policy {} is in disabled state, enabling the policy before do resync-prep", policyName);
syncPolicy = doEnableReplicationPolicy(isi, policyName);
_log.info("Sleeping for 40 seconds for cancel operation to complete...");
TimeUnit.SECONDS.sleep(40);
syncPolicy = isi.getReplicationPolicy(policyName);
_log.info("Replication Policy -{} Enabled successfully.", syncPolicy.toString());
}
IsilonSyncJob job = new IsilonSyncJob();
job.setId(policyName);
job.setAction(Action.resync_prep);
isi.modifyReplicationJob(job);
IsilonSyncJobResync isilonSyncJobResync = new IsilonSyncJobResync(policyName, system.getId(), completer);
ControllerServiceImpl.enqueueJob(new QueueJob(isilonSyncJobResync));
return BiosCommandResult.createPendingResult();
} catch (Exception ex) {
_log.error("Resync-Prep Failed", ex);
ServiceError error = DeviceControllerErrors.isilon.jobFailed("Resync-Prep FAILED as : " + ex.getMessage());
if (completer != null) {
completer.error(_dbClient, error);
}
return BiosCommandResult.createErrorResult(error);
}
}
use of com.emc.storageos.isilon.restapi.IsilonSyncJob in project coprhd-controller by CoprHD.
the class IsilonMirrorOperations method doFailover.
/**
* Call to device to failover the policy
*
* @param system
* @param policyName
* @param taskCompleter
* @return
*/
public BiosCommandResult doFailover(StorageSystem system, String policyName, TaskCompleter taskCompleter) {
_log.info("IsilonMirrorOperations - doFailover started ");
try {
IsilonApi isi = getIsilonDevice(system);
IsilonSyncTargetPolicy syncTargetPolicy = isi.getTargetReplicationPolicy(policyName);
if (syncTargetPolicy.getFoFbState().equals(FOFB_STATES.writes_enabled)) {
_log.info("can't perform failover operation on policy: {} because failover is done already", syncTargetPolicy.getName());
return BiosCommandResult.createSuccessfulResult();
}
IsilonSyncJob job = new IsilonSyncJob();
job.setId(policyName);
job.setAction(Action.allow_write);
isi.modifyReplicationJob(job);
IsilonSyncJobFailover isiSyncJobFailover = new IsilonSyncJobFailover(policyName, system.getId(), taskCompleter, policyName);
try {
ControllerServiceImpl.enqueueJob(new QueueJob(isiSyncJobFailover));
return BiosCommandResult.createPendingResult();
} catch (Exception ex) {
_log.error("Failover to Secondary Cluster Failed", ex);
ServiceError error = DeviceControllerErrors.isilon.jobFailed("Failover to Secondary Cluster Failed as :" + ex.getMessage());
if (taskCompleter != null) {
taskCompleter.error(_dbClient, error);
}
return BiosCommandResult.createErrorResult(error);
}
} catch (IsilonException e) {
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.isilon.restapi.IsilonSyncJob in project coprhd-controller by CoprHD.
the class IsilonMirrorOperations method doCancelReplicationPolicy.
/**
* Cancel the replication policy
*
* @param isi
* @param policyName
* @return
*/
public BiosCommandResult doCancelReplicationPolicy(IsilonApi isi, String policyName) {
try {
_log.info("Canceling Replication Policy -{} because policy is in running state ", policyName);
IsilonSyncJob syncJob = new IsilonSyncJob();
syncJob.setState(JobState.canceled.name());
isi.modifyReplicationJob(policyName, syncJob);
_log.info("Sleeping for 40 seconds for cancel operation to complete...");
TimeUnit.SECONDS.sleep(40);
return BiosCommandResult.createSuccessfulResult();
} catch (IsilonException e) {
return BiosCommandResult.createErrorResult(e);
} catch (InterruptedException ex) {
_log.warn("Canceling ReplicationPolicy - {} Interrupted", policyName);
ServiceError error = DeviceControllerErrors.isilon.jobFailed("Canceling ReplicationPolicy is Failed with Interrupt exception and message :" + ex.getMessage());
return BiosCommandResult.createErrorResult(error);
}
}
Aggregations