private void prepare() { PreparingEnlistment enlistment = new PreparingEnlistment(context); enlistment.getPreparedEvent().addListener((ev, sender, args) -> preparedHandler()); enlistment.getRollbackEvent().addListener((ev, sender, args) -> rollbackHandler()); enlistment.getDoneEvent().addListener((ev, sender, args) -> doneOnPrepareHandler()); IEnlistmentNotification notification = notifications.get(prepareIndex); notification.prepare(enlistment); }
private void prepare7() { PreparingEnlistment enlistment = (PreparingEnlistment) context.enlistment; ActionReturnValue returnValue = context.removeStorageServerConnectionReturnValue; context.enlistment = null; // ReturnValue not equals null means remove connection occurred. if (returnValue != null) { // Don't rollback. enlistment.done(); } else { enlistment.prepared(); } }
private void prepare3() { PreparingEnlistment enlistment = (PreparingEnlistment) context.enlistment; EnlistmentContext enlistmentContext = (EnlistmentContext) enlistment.getContext(); ActionReturnValue returnValue = context.addDataCenterReturnValue; context.enlistment = null; if (returnValue != null && returnValue.getSucceeded()) { enlistmentContext.setDataCenterId((Guid) returnValue.getActionReturnValue()); enlistment.prepared(); } else { enlistment.forceRollback(); } }
public void prepare2() { PreparingEnlistment enlistment = (PreparingEnlistment) context.enlistment; ActionReturnValue returnValue = context.changeVDSClusterReturnValue; context.enlistment = null; if (returnValue != null && returnValue.getSucceeded()) { enlistment.prepared(); } else { enlistment.forceRollback(); } }
private void prepare2() { EnlistmentContext enlistmentContext = (EnlistmentContext) enlistment.getContext(); HostListModel<?> model = enlistmentContext.getModel(); ConfigureLocalStorageModel configureModel = (ConfigureLocalStorageModel) model.getWindow(); enlistment.prepared(); } else { enlistment.prepared();
private void prepare3() { PreparingEnlistment enlistment = (PreparingEnlistment) context.enlistment; EnlistmentContext enlistmentContext = (EnlistmentContext) enlistment.getContext(); HostListModel<?> model = enlistmentContext.getModel(); VDS host = model.getSelectedItem(); if (context.waitTries < MaxWaitTries) { context.waitTries++; AsyncDataProvider.getInstance().getHostById(new AsyncQuery<>( returnValue -> { context.host = returnValue; timer = new Timer() { @Override public void run() { prepare4(); } }; timer.scheduleRepeating(WaitInterval); }), host.getId()); } else { context.enlistment = null; enlistment.forceRollback(); } }
private void prepare5() { PreparingEnlistment enlistment = (PreparingEnlistment) context.enlistment; EnlistmentContext enlistmentContext = (EnlistmentContext) enlistment.getContext(); HostListModel<?> model = enlistmentContext.getModel(); ConfigureLocalStorageModel configureModel = (ConfigureLocalStorageModel) model.getWindow(); ActionReturnValue returnValue = context.addStorageServerConnectionReturnValue; if (returnValue == null || !returnValue.getSucceeded()) { // Don't rollback. context.enlistment = null; enlistment.done(); } else { StorageDomainStatic storage = new StorageDomainStatic(); storage.setStorageType(StorageType.LOCALFS); storage.setStorageDomainType(StorageDomainType.Data); storage.setStorageName(configureModel.getFormattedStorageName().getEntity()); storage.setStorage((String) returnValue.getActionReturnValue()); StorageDomainManagementParameter parameters = new StorageDomainManagementParameter(storage); parameters.setVdsId(context.host.getId()); parameters.setCorrelationId(getCorrelationId()); Frontend.getInstance().runAction(ActionType.AddLocalStorageDomain, parameters, result -> { ActionReturnValue returnValue1 = result.getReturnValue(); context.addLocalStorageDomainReturnValue = returnValue1; prepare6(); }); } }
public void forceRollback() { getRollbackEvent().raise(this, EventArgs.EMPTY); } }
public void prepared() { getPreparedEvent().raise(this, EventArgs.EMPTY); }
private void prepare2() { PreparingEnlistment enlistment = (PreparingEnlistment) context.enlistment; ActionReturnValue returnValue = context.activateVdsReturnValue; if (returnValue == null || !returnValue.getSucceeded()) { context.enlistment = null; enlistment.forceRollback(); } else { prepare3(); } }
public void prepare1() { PreparingEnlistment enlistment = (PreparingEnlistment) context.enlistment; EnlistmentContext enlistmentContext = (EnlistmentContext) context.enlistment.getContext(); HostListModel<?> model = enlistmentContext.getModel(); VDS host = model.getSelectedItem(); if (!enlistmentContext.getClusterId().equals(host.getClusterId())) { enlistmentContext.setOldClusterId(host.getClusterId()); ChangeVDSClusterParameters parameters = new ChangeVDSClusterParameters(enlistmentContext.getClusterId(), host.getId()); parameters.setCorrelationId(getCorrelationId()); Frontend.getInstance().runAction(ActionType.ChangeVDSCluster, parameters, result -> { ActionReturnValue returnValue = result.getReturnValue(); context.changeVDSClusterReturnValue = returnValue; prepare2(); }); } else { context.enlistment = null; enlistment.prepared(); } }
private void prepare4() { if (timer != null) { timer.cancel(); timer = null; } PreparingEnlistment enlistment = (PreparingEnlistment) context.enlistment; EnlistmentContext enlistmentContext = (EnlistmentContext) enlistment.getContext(); HostListModel<?> model = enlistmentContext.getModel(); ConfigureLocalStorageModel configureModel = (ConfigureLocalStorageModel) model.getWindow(); if (context.host.getStatus() != VDSStatus.Up) { prepare3(); } else { // Add storage domain. StorageServerConnections connection = new StorageServerConnections(); connection.setConnection(configureModel.getStorage().getPath().getEntity()); connection.setStorageType(StorageType.LOCALFS); context.connection = connection; StorageServerConnectionParametersBase parameters = new StorageServerConnectionParametersBase(connection, context.host.getId(), false); parameters.setCorrelationId(getCorrelationId()); Frontend.getInstance().runAction(ActionType.AddStorageServerConnection, parameters, result -> { ActionReturnValue returnValue = result.getReturnValue(); context.addStorageServerConnectionReturnValue = returnValue; prepare5(); }); } }
public void prepare2() { EnlistmentContext enlistmentContext = (EnlistmentContext) enlistment.getContext(); HostListModel<?> model = enlistmentContext.getModel(); ConfigureLocalStorageModel configureModel = (ConfigureLocalStorageModel) model.getWindow(); enlistment.prepared(); } else { enlistment.prepared();
private void prepare3() { PreparingEnlistment enlistment = (PreparingEnlistment) context.enlistment; EnlistmentContext enlistmentContext = (EnlistmentContext) enlistment.getContext(); ActionReturnValue returnValue = context.addClusterReturnValue; context.enlistment = null; if (returnValue != null && returnValue.getSucceeded()) { enlistmentContext.setClusterId((Guid) returnValue.getActionReturnValue()); context.enlistment = null; enlistment.prepared(); } else { enlistment.forceRollback(); } }