本文整理汇总了Java中org.hive2hive.processframework.exceptions.ProcessRollbackException类的典型用法代码示例。如果您正苦于以下问题:Java ProcessRollbackException类的具体用法?Java ProcessRollbackException怎么用?Java ProcessRollbackException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProcessRollbackException类属于org.hive2hive.processframework.exceptions包,在下文中一共展示了ProcessRollbackException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testOnRollbacking
import org.hive2hive.processframework.exceptions.ProcessRollbackException; //导入依赖的package包/类
@Test
public void testOnRollbacking() throws InvalidProcessStateException, ProcessExecutionException,
ProcessRollbackException {
TestProcessComponentListener listener = new TestProcessComponentListener();
IProcessComponent<?> comp = TestUtil.executionSuccessComponent(true);
comp.attachListener(listener);
comp.execute();
comp.rollback();
assertFalse(listener.isExecuting());
assertTrue(listener.isRollbacking());
assertFalse(listener.isPaused());
}
示例2: testOnRollbackFailed
import org.hive2hive.processframework.exceptions.ProcessRollbackException; //导入依赖的package包/类
@Test
public void testOnRollbackFailed() throws InvalidProcessStateException, ProcessExecutionException {
TestProcessComponentListener listener = new TestProcessComponentListener();
IProcessComponent<?> comp = TestUtil.rollbackFailComponent();
comp.attachListener(listener);
comp.execute();
try {
comp.rollback();
} catch (ProcessRollbackException ex) {
// expected
}
assertFalse(listener.hasRollbackSucceeded());
assertTrue(listener.hasRollbackFailed());
}
示例3: testAwaitAsyncRollbackSuccess
import org.hive2hive.processframework.exceptions.ProcessRollbackException; //导入依赖的package包/类
@Test
public void testAwaitAsyncRollbackSuccess() throws InvalidProcessStateException, ProcessExecutionException {
SyncProcess proc = TestUtil.executionSuccessSyncProcess();
IProcessComponent<Void> busyComp = new BusyComponent(TestUtil.rollbackSuccessComponent());
IProcessComponent<?> asyncComp = new AsyncComponent<Void>(busyComp);
proc.add(asyncComp);
proc.execute();
try {
proc.rollback();
} catch (ProcessRollbackException ex) {
fail("Should execute successfully.");
}
assertTrue(proc.getState() == ProcessState.ROLLBACK_SUCCEEDED);
assertTrue(asyncComp.getState() == ProcessState.ROLLBACK_SUCCEEDED);
}
示例4: testAwaitAsyncRollbackFail
import org.hive2hive.processframework.exceptions.ProcessRollbackException; //导入依赖的package包/类
@Test
public void testAwaitAsyncRollbackFail() throws InvalidProcessStateException, ProcessExecutionException {
SyncProcess proc = TestUtil.executionSuccessSyncProcess();
IProcessComponent<Void> busyComp = new BusyComponent(TestUtil.rollbackFailComponent());
IProcessComponent<?> asyncComp = new AsyncComponent<Void>(busyComp);
proc.add(asyncComp);
proc.execute();
try {
proc.rollback();
fail("ProcessRollbackException should have been thrown.");
} catch (ProcessRollbackException ex) {
// expected
}
assertTrue(proc.getState() == ProcessState.ROLLBACK_FAILED);
assertTrue(asyncComp.getState() == ProcessState.ROLLBACK_FAILED);
}
示例5: executionSuccessComponent
import org.hive2hive.processframework.exceptions.ProcessRollbackException; //导入依赖的package包/类
/**
* Creates an anonymous sample {@link ProcessComponent} that succeeds execution for testing purposes.
*
* @return An anonymous {@link ProcessComponent} for testing purposes.
*/
public static ProcessComponent<Void> executionSuccessComponent(final boolean requiresRollback) {
return new ProcessComponent<Void>() {
@Override
protected Void doExecute() throws InvalidProcessStateException, ProcessExecutionException {
setRequiresRollback(requiresRollback);
return null;
}
@Override
protected Void doRollback() throws InvalidProcessStateException, ProcessRollbackException {
// do nothing
return null;
}
@Override
public double getProgress() {
return 0;
}
};
}
示例6: executionFailComponent
import org.hive2hive.processframework.exceptions.ProcessRollbackException; //导入依赖的package包/类
/**
* Creates an anonymous sample {@link ProcessComponent} that fails execution for testing purposes.
*
* @return An anonymous {@link ProcessComponent} for testing purposes.
*/
public static ProcessComponent<Void> executionFailComponent(final boolean requiresRollback) {
return new ProcessComponent<Void>() {
@Override
protected Void doExecute() throws InvalidProcessStateException, ProcessExecutionException {
setRequiresRollback(requiresRollback);
throw new ProcessExecutionException(this, "Failing execution for testing purposes.");
}
@Override
protected Void doRollback() throws InvalidProcessStateException, ProcessRollbackException {
// do nothing
return null;
}
@Override
public double getProgress() {
return 0;
}
};
}
示例7: rollbackSuccessComponent
import org.hive2hive.processframework.exceptions.ProcessRollbackException; //导入依赖的package包/类
/**
* Creates an anonymous sample {@link ProcessComponent} that succeeds rollback for testing purposes.
*
* @return An anonymous {@link ProcessComponent} for testing purposes.
*/
public static ProcessComponent<Void> rollbackSuccessComponent() {
return new ProcessComponent<Void>() {
@Override
protected Void doExecute() throws InvalidProcessStateException, ProcessExecutionException {
setRequiresRollback(true);
return null;
}
@Override
protected Void doRollback() throws InvalidProcessStateException, ProcessRollbackException {
// do nothing
return null;
}
@Override
public double getProgress() {
return 0;
}
};
}
示例8: rollbackFailComponent
import org.hive2hive.processframework.exceptions.ProcessRollbackException; //导入依赖的package包/类
/**
* Creates an anonymous sample {@link ProcessComponent} that succeeds execution for testing purposes.
*
* @return An anonymous {@link ProcessComponent} for testing purposes.
*/
public static ProcessComponent<Void> rollbackFailComponent() {
return new ProcessComponent<Void>() {
@Override
protected Void doExecute() throws InvalidProcessStateException, ProcessExecutionException {
setRequiresRollback(true);
return null;
}
@Override
protected Void doRollback() throws InvalidProcessStateException, ProcessRollbackException {
throw new ProcessRollbackException(this, "Failing rollback for testing purposes.");
}
@Override
public double getProgress() {
return 0;
}
};
}
示例9: doRollback
import org.hive2hive.processframework.exceptions.ProcessRollbackException; //导入依赖的package包/类
@Override
protected Void doRollback() throws InvalidProcessStateException, ProcessRollbackException {
logger.debug("Rollbacking change of content protection key. '{}'", parameters.toString());
Parameters rollbackParameters = new Parameters().setLocationKey(parameters.getLocationKey())
.setContentKey(parameters.getContentKey()).setVersionKey(parameters.getVersionKey())
.setTTL(parameters.getTTL()).setHash(parameters.getHash());
// switch the content protection keys
rollbackParameters.setProtectionKeys(parameters.getNewProtectionKeys()).setNewProtectionKeys(
parameters.getProtectionKeys());
boolean success = dataManager.changeProtectionKey(rollbackParameters);
if (success) {
logger.debug("Rollback of change protection key succeeded. '{}'", parameters.toString());
setRequiresRollback(false);
} else {
throw new ProcessRollbackException(this, String.format(
"Rollback of change protection key failed. Remove failed. Parameters; '%s'", parameters.toString()));
}
return null;
}
示例10: doRollback
import org.hive2hive.processframework.exceptions.ProcessRollbackException; //导入依赖的package包/类
@Override
protected Void doRollback() throws InvalidProcessStateException, ProcessRollbackException {
// TODO ugly bug fix
if (parameters.getNetworkContent() == null) {
throw new ProcessRollbackException(this, String.format("Rollback of remove failed. No content to re-put. Parameters: '%s'.", parameters.toString()));
}
H2HPutStatus status = dataManager.put(parameters);
if (status.equals(H2HPutStatus.OK)) {
logger.debug("Rollback of remove succeeded. '{}'", parameters.toString());
setRequiresRollback(false);
} else {
throw new ProcessRollbackException(this, String.format("Rollback of remove failed. Re-put failed. Parameters: '%s'.", parameters.toString()));
}
return null;
}
示例11: doRollback
import org.hive2hive.processframework.exceptions.ProcessRollbackException; //导入依赖的package包/类
@Override
protected final Void doRollback() throws InvalidProcessStateException, ProcessRollbackException {
Locations locations;
try {
locations = locationsManager.get();
} catch (GetFailedException ex) {
throw new ProcessRollbackException(this, ex);
}
rollback(locations);
try {
putLocations(locations);
} catch (PutFailedException e) {
throw new ProcessRollbackException(this, e);
}
return null;
}
示例12: doRollback
import org.hive2hive.processframework.exceptions.ProcessRollbackException; //导入依赖的package包/类
@Override
protected Void doRollback() throws InvalidProcessStateException, ProcessRollbackException {
DataManager dataManager;
try {
dataManager = networkManager.getDataManager();
} catch (NoPeerConnectionException ex) {
throw new ProcessRollbackException(this, ex, String.format(
"Rollback of UserProfileTask put failed. No connection. User = '%s', Content Key = '%s'.", userId,
contentKey));
}
boolean success = dataManager.removeUserProfileTask(userId, contentKey, protectionKey);
if (success) {
logger.debug("Rollback of user profile task put succeeded. User = '{}', Content Key = '{}'.", userId, contentKey);
setRequiresRollback(false);
} else {
throw new ProcessRollbackException(this, String.format(
"Rollback of user profile put failed. Remove failed. User = '%s', Content Key = '%s'.", userId,
contentKey));
}
return null;
}
示例13: doRollback
import org.hive2hive.processframework.exceptions.ProcessRollbackException; //导入依赖的package包/类
@Override
protected Void doRollback() throws InvalidProcessStateException, ProcessRollbackException {
H2HSession session;
try {
session = networkManager.getSession();
} catch (NoSessionException ex) {
throw new ProcessRollbackException(this, ex, "Couldn't redo folder creation. No user seems to be logged in.");
}
File folder = context.consumeIndex().asFile(session.getRootFile());
if (!folder.delete()) {
throw new ProcessRollbackException(this, "Couldn't delete created folder.");
}
// reset flag
setRequiresRollback(false);
return null;
}
示例14: testPut
import org.hive2hive.processframework.exceptions.ProcessRollbackException; //导入依赖的package包/类
@Test
public void testPut() throws NoPeerConnectionException, InvalidProcessStateException, ProcessRollbackException {
UserCredentials credentials = generateRandomCredentials();
TestUserProfileTask userProfileTask = new TestUserProfileTask(generateRSAKeyPair(H2HConstants.KEYLENGTH_PROTECTION));
KeyPair key = generateRSAKeyPair(H2HConstants.KEYLENGTH_USER_KEYS);
NetworkManager node = NetworkTestUtil.getRandomNode(network);
TestPutUserProfileTaskStep putStep = new TestPutUserProfileTaskStep(credentials.getUserId(), userProfileTask,
key.getPublic(), node);
TestExecutionUtil.executeProcessTillSucceded(putStep);
// check if user profile task has been put into network
Parameters parameters = new Parameters().setLocationKey(credentials.getUserId())
.setDomainKey(H2HConstants.USER_PROFILE_TASK_DOMAIN).setContentKey(userProfileTask.getContentKey());
assertNotNull(node.getDataManager().get(parameters));
// manually trigger roll back
putStep.rollback();
// check if user profile task has been removed from network
assertNull(node.getDataManager().get(parameters));
}
示例15: doRollback
import org.hive2hive.processframework.exceptions.ProcessRollbackException; //导入依赖的package包/类
@Override
protected Future<T> doRollback() throws InvalidProcessStateException, ProcessRollbackException {
ExecutorService executor = Executors.newSingleThreadExecutor();
RollbackRunner rollbackRunner = new RollbackRunner();
try {
// immediate return, since rollback is async
return executor.submit(rollbackRunner);
} catch (RejectedExecutionException ex) {
throw new ProcessRollbackException(this, ex);
} finally {
// already shutdown the executor, does not disturb the already running thread
executor.shutdown();
}
}