本文整理了Java中com.palantir.atlasdb.transaction.api.TransactionManager.close()
方法的一些代码示例,展示了TransactionManager.close()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TransactionManager.close()
方法的具体详情如下:
包路径:com.palantir.atlasdb.transaction.api.TransactionManager
类名称:TransactionManager
方法名:close
[英]Frees resources used by this TransactionManager, and invokes any callbacks registered to run on close. This includes the cleaner, the key value service (and attendant thread pools), and possibly the lock service. All callbacks will execute in the reverse order of registration, regardless of any exceptions thrown. If any exceptions occur, they will be collected and rethrown as a new exception with any exceptions that occurred set as suppressed exceptions. Concurrency: If this method races with registerClosingCallback(closingCallback), then closingCallback may be called (but is not necessarily called). Callbacks registered before the invocation of close() are guaranteed to be executed.
[中]释放此TransactionManager使用的资源,并调用注册为在close上运行的所有回调。这包括清理器、键值服务(和助理线程池),可能还有锁服务。所有回调都将按注册的相反顺序执行,而不管抛出任何异常。如果发生任何异常,它们将被收集并作为一个新异常重新发布,而发生的任何异常都将被设置为抑制异常。并发性:如果此方法与registerClosingCallback(closingCallback)竞争,则可以调用closingCallback(但不一定要调用)。在调用close()之前注册的回调保证执行。
代码示例来源:origin: palantir/atlasdb
@After
public void closeTransactionManager() {
txManager.close();
}
代码示例来源:origin: palantir/atlasdb
private void closeInternal(State newStatus) {
if (checkAndSetStatus(ImmutableSet.of(State.INITIALIZING, State.READY), newStatus)) {
callback.blockUntilSafeToShutdown();
executorService.shutdown();
txManager.close();
}
}
代码示例来源:origin: palantir/atlasdb
@Test
public void shouldSuccessfullyCloseTransactionManagerMultipleTimes() {
txMgr.close();
txMgr.close();
}
代码示例来源:origin: palantir/atlasdb
@After
public void after() throws Exception {
txnMgr.close();
}
代码示例来源:origin: palantir/atlasdb
@Test
public void shouldNotRunTaskWithRetryWithClosedTransactionManager() {
txMgr.close();
assertThatThrownBy(() -> txMgr.runTaskWithRetry((TransactionTask<Void, RuntimeException>) txn -> {
put(txn, "row1", "col1", "v1");
return null;
}))
.isInstanceOf(IllegalStateException.class)
.hasMessage("Operations cannot be performed on closed TransactionManager.");
}
代码示例来源:origin: palantir/atlasdb
@Test
public void shouldNotRunTaskThrowOnConflictWithClosedTransactionManager() {
txMgr.close();
assertThatThrownBy(() -> txMgr.runTaskThrowOnConflict((TransactionTask<Void, RuntimeException>) txn -> {
put(txn, "row1", "col1", "v1");
return null;
}))
.isInstanceOf(IllegalStateException.class)
.hasMessage("Operations cannot be performed on closed TransactionManager.");
}
代码示例来源:origin: palantir/atlasdb
@Test
public void shouldNotRunTaskReadOnlyWithClosedTransactionManager() {
txMgr.close();
assertThatThrownBy(() -> txMgr.runTaskReadOnly((TransactionTask<Void, RuntimeException>) txn -> {
put(txn, "row1", "col1", "v1");
return null;
}))
.isInstanceOf(IllegalStateException.class)
.hasMessage("Operations cannot be performed on closed TransactionManager.");
}
代码示例来源:origin: palantir/atlasdb
@Test
public void closePreventsInitializationAndCallbacksEvenIfExecutorStillTicks() {
manager.close();
everythingInitialized();
tickInitializingThread();
verify(mockCallback, never()).runWithRetry(any(SerializableTransactionManager.class));
assertThatThrownBy(() -> manager.runTaskWithRetry(ignore -> null)).isInstanceOf(IllegalStateException.class);
assertTrue(((SerializableTransactionManager.InitializeCheckingWrapper) manager).isClosedByClose());
}
代码示例来源:origin: palantir/atlasdb
@Test
public void closeShutsDownInitializingExecutorAndClosesTransactionManager() {
manager.close();
assertTrue(executorService.isShutdown());
assertThatThrownBy(() -> manager.runTaskWithRetry(ignore -> null)).isInstanceOf(IllegalStateException.class);
assertTrue(((SerializableTransactionManager.InitializeCheckingWrapper) manager).isClosedByClose());
}
代码示例来源:origin: palantir/atlasdb
@Test
public void testStoreGetDataThrowsAfterTransactionManagerIsClosedThrows() throws Exception {
txnMgr.close();
exception.expect(IllegalStateException.class);
exception.expectMessage("Operations cannot be performed on closed TransactionManager.");
testStore();
}
代码示例来源:origin: palantir/atlasdb
@Test
public void testStoreImageThrowsAfterTransactionManagerIsClosedThrows() throws Exception {
txnMgr.close();
exception.expect(IllegalStateException.class);
exception.expectMessage("Operations cannot be performed on closed TransactionManager.");
testStoreImage();
}
代码示例来源:origin: palantir/atlasdb
@Test
public void testDeleteImageThrowsAfterTransactionManagerIsClosedThrows() throws Exception {
txnMgr.close();
exception.expect(IllegalStateException.class);
exception.expectMessage("Operations cannot be performed on closed TransactionManager.");
testDeleteImage();
}
代码示例来源:origin: palantir/atlasdb
@Test
public void testBirthdayIndexThrowsAfterTransactionManagerIsClosedThrows() throws Exception {
txnMgr.close();
exception.expect(IllegalStateException.class);
exception.expectMessage("Operations cannot be performed on closed TransactionManager.");
testDeleteImage();
}
代码示例来源:origin: palantir/atlasdb
@Test
public void runsClosingCallbackOnShutdown() throws Exception {
AtlasDbConfig atlasDbConfig = ImmutableAtlasDbConfig.builder()
.keyValueService(new InMemoryAtlasDbConfig())
.defaultLockTimeoutSeconds(120)
.build();
Runnable callback = mock(Runnable.class);
TransactionManager manager = TransactionManagers.builder()
.config(atlasDbConfig)
.userAgent("test")
.globalMetricsRegistry(new MetricRegistry())
.globalTaggedMetricRegistry(DefaultTaggedMetricRegistry.getDefault())
.registrar(environment)
.build()
.serializable();
manager.registerClosingCallback(callback);
manager.close();
verify(callback, times(1)).run();
}
代码示例来源:origin: com.palantir.atlasdb/atlasdb-tests-shared
@After
public void closeTransactionManager() {
txManager.close();
}
代码示例来源:origin: com.palantir.atlasdb/atlasdb-impl-shared
private void closeInternal(State newStatus) {
if (checkAndSetStatus(ImmutableSet.of(State.INITIALIZING, State.READY), newStatus)) {
callback.blockUntilSafeToShutdown();
executorService.shutdown();
txManager.close();
}
}
内容来源于网络,如有侵权,请联系作者删除!