use of org.apache.apex.malhar.lib.state.managed.Bucket.DefaultBucket in project apex-malhar by apache.
the class ManagedTimeStateImplTest method testRecovery.
@Test
public void testRecovery() throws ExecutionException, InterruptedException {
Slice one = ManagedStateTestUtils.getSliceFor("1");
testMeta.managedState.setup(testMeta.operatorContext);
long time = System.currentTimeMillis();
testMeta.managedState.beginWindow(0);
testMeta.managedState.put(0, time, one, one);
testMeta.managedState.endWindow();
testMeta.managedState.beforeCheckpoint(0);
testMeta.managedState.teardown();
// there is a failure and the operator is re-deployed.
testMeta.managedState.setStateTracker(new StateTracker());
Attribute.AttributeMap.DefaultAttributeMap attributes = new Attribute.AttributeMap.DefaultAttributeMap();
attributes.put(DAG.APPLICATION_PATH, testMeta.applicationPath);
attributes.put(Context.OperatorContext.ACTIVATION_WINDOW_ID, 0L);
OperatorContext operatorContext = mockOperatorContext(1, attributes);
testMeta.managedState.setup(operatorContext);
Bucket.DefaultBucket defaultBucket = (Bucket.DefaultBucket) testMeta.managedState.getBucket(0);
Assert.assertEquals("value of one", one, defaultBucket.get(one, time, Bucket.ReadSource.MEMORY));
}
Aggregations