当前位置: 首页>>代码示例>>Java>>正文


Java ProcessRollbackException类代码示例

本文整理汇总了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());
}
 
开发者ID:Hive2Hive,项目名称:ProcessFramework,代码行数:17,代码来源:ProcessComponentListenerTest.java

示例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());
}
 
开发者ID:Hive2Hive,项目名称:ProcessFramework,代码行数:19,代码来源:ProcessComponentListenerTest.java

示例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);
}
 
开发者ID:Hive2Hive,项目名称:ProcessFramework,代码行数:21,代码来源:SyncProcessTest.java

示例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);
}
 
开发者ID:Hive2Hive,项目名称:ProcessFramework,代码行数:22,代码来源:SyncProcessTest.java

示例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;
		}
	};
}
 
开发者ID:Hive2Hive,项目名称:ProcessFramework,代码行数:28,代码来源:TestUtil.java

示例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;
		}
	};
}
 
开发者ID:Hive2Hive,项目名称:ProcessFramework,代码行数:28,代码来源:TestUtil.java

示例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;
		}
	};
}
 
开发者ID:Hive2Hive,项目名称:ProcessFramework,代码行数:28,代码来源:TestUtil.java

示例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;
		}
	};
}
 
开发者ID:Hive2Hive,项目名称:ProcessFramework,代码行数:27,代码来源:TestUtil.java

示例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;
}
 
开发者ID:Hive2Hive,项目名称:Hive2Hive,代码行数:24,代码来源:ChangeProtectionKeysStep.java

示例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;
}
 
开发者ID:Hive2Hive,项目名称:Hive2Hive,代码行数:19,代码来源:BaseRemoveProcessStep.java

示例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;
}
 
开发者ID:Hive2Hive,项目名称:Hive2Hive,代码行数:20,代码来源:BaseModifyLocationsStep.java

示例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;
}
 
开发者ID:Hive2Hive,项目名称:Hive2Hive,代码行数:25,代码来源:PutUserProfileTaskStep.java

示例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;
}
 
开发者ID:Hive2Hive,项目名称:Hive2Hive,代码行数:21,代码来源:CreateFolderStep.java

示例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));
}
 
开发者ID:Hive2Hive,项目名称:Hive2Hive,代码行数:23,代码来源:UserProfileTaskQueueTest.java

示例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();
	}
}
 
开发者ID:Hive2Hive,项目名称:ProcessFramework,代码行数:16,代码来源:AsyncComponent.java


注:本文中的org.hive2hive.processframework.exceptions.ProcessRollbackException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。