use of org.apache.pulsar.functions.api.StateStore in project pulsar by yahoo.
the class InstanceStateManager method close.
@Override
public void close() {
RuntimeException firstException = null;
for (Map.Entry<String, StateStore> entry : stores.entrySet()) {
final StateStore store = entry.getValue();
if (log.isDebugEnabled()) {
log.debug("Closing store {}", store.fqsn());
}
try {
store.close();
} catch (RuntimeException e) {
if (firstException == null) {
firstException = e;
}
log.error("Failed to close state store {}: ", store.fqsn(), e);
}
}
stores.clear();
if (null != firstException) {
throw firstException;
}
}
use of org.apache.pulsar.functions.api.StateStore in project incubator-pulsar by apache.
the class InstanceStateManager method close.
@Override
public void close() {
RuntimeException firstException = null;
for (Map.Entry<String, StateStore> entry : stores.entrySet()) {
final StateStore store = entry.getValue();
if (log.isDebugEnabled()) {
log.debug("Closing store {}", store.fqsn());
}
try {
store.close();
} catch (RuntimeException e) {
if (firstException == null) {
firstException = e;
}
log.error("Failed to close state store {}: ", store.fqsn(), e);
}
}
stores.clear();
if (null != firstException) {
throw firstException;
}
}
use of org.apache.pulsar.functions.api.StateStore in project incubator-pulsar by apache.
the class InstanceStateManagerTest method testRegisterStoreTwice.
@Test
public void testRegisterStoreTwice() {
final String fqsn = "t/ns/store";
StateStore store = mock(StateStore.class);
when(store.fqsn()).thenReturn(fqsn);
this.stateManager.registerStore(store);
try {
this.stateManager.registerStore(store);
fail("Should fail to register a store twice");
} catch (IllegalArgumentException iae) {
// expected
}
}
use of org.apache.pulsar.functions.api.StateStore in project incubator-pulsar by apache.
the class InstanceStateManagerTest method testGetStoreNull.
@Test
public void testGetStoreNull() {
final String fqsn = "t/ns/store";
StateStore getStore = stateManager.getStore("t", "ns", "store");
assertNull(getStore);
}
use of org.apache.pulsar.functions.api.StateStore in project incubator-pulsar by apache.
the class InstanceStateManagerTest method testRegisterStore.
@Test
public void testRegisterStore() {
final String fqsn = "t/ns/store";
StateStore store = mock(StateStore.class);
when(store.fqsn()).thenReturn(fqsn);
this.stateManager.registerStore(store);
StateStore getStore = stateManager.getStore("t", "ns", "store");
assertSame(getStore, store);
}
Aggregations