use of com.datatorrent.netlet.util.Slice in project apex-malhar by apache.
the class ManagedTimeUnifiedStateImplTest method testAsyncGet.
@Test
public void testAsyncGet() throws ExecutionException, InterruptedException {
Slice one = ManagedStateTestUtils.getSliceFor("1");
testMeta.managedState.setup(testMeta.operatorContext);
long time = System.currentTimeMillis();
testMeta.managedState.beginWindow(0);
testMeta.managedState.put(time, one, one);
Future<Slice> valFuture = testMeta.managedState.getAsync(time, one);
Slice value = valFuture.get();
Assert.assertEquals("value of one", one, value);
testMeta.managedState.teardown();
}
use of com.datatorrent.netlet.util.Slice in project apex-malhar by apache.
the class StateTrackerTest method testEviction.
@Test
public void testEviction() throws InterruptedException {
testMeta.managedState.latch = new CountDownLatch(1);
testMeta.managedState.setup(testMeta.operatorContext);
Slice one = ManagedStateTestUtils.getSliceFor("1");
testMeta.managedState.beginWindow(System.currentTimeMillis());
testMeta.managedState.put(1, one, one);
testMeta.managedState.endWindow();
testMeta.managedState.latch.await();
testMeta.managedState.teardown();
Assert.assertEquals("freed bucket", Sets.newHashSet(1L), testMeta.managedState.freedBuckets);
}
use of com.datatorrent.netlet.util.Slice in project apex-malhar by apache.
the class DefaultBucketTest method testGetFromReader.
@Test
public void testGetFromReader() throws IOException {
testMeta.defaultBucket.setup(testMeta.managedStateContext);
Slice one = ManagedStateTestUtils.getSliceFor("1");
Map<Slice, Bucket.BucketedValue> unsavedBucket0 = ManagedStateTestUtils.getTestBucketData(0, 100);
testMeta.managedStateContext.getBucketsFileSystem().writeBucketData(1, 1, unsavedBucket0, -1);
ManagedStateTestUtils.validateBucketOnFileSystem(testMeta.managedStateContext.getFileAccess(), 1, unsavedBucket0, 1);
Slice value = testMeta.defaultBucket.get(one, -1, Bucket.ReadSource.READERS);
Assert.assertEquals("value one", one, value);
testMeta.defaultBucket.teardown();
}
use of com.datatorrent.netlet.util.Slice in project apex-malhar by apache.
the class DefaultBucketTest method testCommitted.
@Test
public void testCommitted() {
testMeta.defaultBucket.setup(testMeta.managedStateContext);
Slice one = ManagedStateTestUtils.getSliceFor("1");
testCheckpointed();
testMeta.defaultBucket.committed(10);
Slice value = testMeta.defaultBucket.get(one, -1, Bucket.ReadSource.MEMORY);
Assert.assertEquals("value one", one, value);
testMeta.defaultBucket.teardown();
}
use of com.datatorrent.netlet.util.Slice in project apex-malhar by apache.
the class DefaultBucketTest method testPut.
@Test
public void testPut() {
testMeta.defaultBucket.setup(testMeta.managedStateContext);
Slice one = ManagedStateTestUtils.getSliceFor("1");
testMeta.defaultBucket.put(one, 1, one);
Slice value = testMeta.defaultBucket.get(one, 1, Bucket.ReadSource.MEMORY);
Assert.assertEquals("value one", one, value);
value = testMeta.defaultBucket.get(one, 1, Bucket.ReadSource.READERS);
Assert.assertNull("value not present", value);
Assert.assertEquals("size of bucket", one.length * 2 + Longs.BYTES, testMeta.defaultBucket.getSizeInBytes());
testMeta.defaultBucket.teardown();
}
Aggregations