use of org.voltcore.utils.DeferredSerialization in project voltdb by VoltDB.
the class TestRateLimitedClientNotifier method testNode.
/*
* Check that equality and hash code work as expected
* where nodes that are heads of identical lists are identical
* and nodes that have the same supplier and next node are also
* equal
*/
@Test
public void testNode() throws Exception {
Supplier<DeferredSerialization> sup = getSupplier(null);
Node n = new Node(sup, null);
Node n2 = new Node(sup, null);
Node diffSup = new Node(getSupplier(null), null);
assertFalse(n.equals(null));
assertTrue(n.equals(n2));
assertEquals(n.hashCode(), n2.hashCode());
assertTrue(n2.equals(n));
assertTrue(n.equals(n));
assertFalse(n.equals(diffSup));
assertFalse(n.hashCode() == diffSup.hashCode());
Supplier<DeferredSerialization> sup2 = getSupplier(null);
Node n3 = new Node(sup2, n);
assertFalse(n3.equals(n2));
assertFalse(n3.hashCode() == n2.hashCode());
Node n3_2 = new Node(sup2, n);
Supplier<DeferredSerialization> sup3 = getSupplier(null);
Node n4 = new Node(sup3, n3);
Node n4_2 = new Node(sup3, n3_2);
assertTrue(n4.equals(n4_2));
assertTrue(n4.hashCode() == n4_2.hashCode());
}
use of org.voltcore.utils.DeferredSerialization in project voltdb by VoltDB.
the class TestRateLimitedClientNotifier method testNodeCaching.
/*
* Check caching postfixes of nodes works
*/
@Test
public void testNodeCaching() throws Exception {
Supplier<DeferredSerialization> sup = getSupplier(null);
Node n = getNode(sup, null);
Node n2 = getNode(sup, null);
Node diffSup = getNode(getSupplier(null), null);
assertFalse(n.equals(null));
assertTrue(n.equals(n2));
assertEquals(n.hashCode(), n2.hashCode());
assertTrue(n2.equals(n));
assertTrue(n.equals(n));
assertFalse(n.equals(diffSup));
assertFalse(n.hashCode() == diffSup.hashCode());
Supplier<DeferredSerialization> sup2 = getSupplier(null);
Node n3 = getNode(sup2, n);
assertFalse(n3.equals(n2));
assertFalse(n3.hashCode() == n2.hashCode());
Node n3_2 = getNode(sup2, n);
Supplier<DeferredSerialization> sup3 = getSupplier(null);
Node n4 = getNode(sup3, n3);
Node n4_2 = getNode(sup3, n3_2);
assertTrue(n4.equals(n4_2));
assertTrue(n4.hashCode() == n4_2.hashCode());
assertEquals(cache.size(), 4);
}
use of org.voltcore.utils.DeferredSerialization in project voltdb by VoltDB.
the class TestRateLimitedClientNotifier method testDedupeMultiple.
/*
* Test that submitting a dupe of a second notification is skipped
*/
@Test
public void testDedupeMultiple() throws Exception {
ByteBuffer buf = ByteBuffer.allocate(1);
Supplier<DeferredSerialization> sup = getSupplier(buf);
Supplier<DeferredSerialization> sup2 = getSupplier(buf);
notifier.queueNotification(ImmutableList.of(cihm), sup, Predicates.<ClientInterfaceHandleManager>alwaysTrue());
notifier.queueNotification(ImmutableList.of(cihm), sup2, Predicates.<ClientInterfaceHandleManager>alwaysTrue());
notifier.queueNotification(ImmutableList.of(cihm), sup2, Predicates.<ClientInterfaceHandleManager>alwaysTrue());
notifier.start();
messages.take();
messages.take();
assertNull(mws.m_messages.poll(50, TimeUnit.MILLISECONDS));
}
use of org.voltcore.utils.DeferredSerialization in project voltdb by VoltDB.
the class TestRateLimitedClientNotifier method testDedupe.
/*
* Test that submitting a dupe notification is skipped
* Multiple dedupe tests follow that cover different internal code paths
* for deduping
*/
@Test
public void testDedupe() throws Exception {
ByteBuffer buf = ByteBuffer.allocate(1);
Supplier<DeferredSerialization> sup = getSupplier(buf);
notifier.queueNotification(ImmutableList.of(cihm), sup, Predicates.<ClientInterfaceHandleManager>alwaysTrue());
notifier.queueNotification(ImmutableList.of(cihm), sup, Predicates.<ClientInterfaceHandleManager>alwaysTrue());
notifier.start();
mws.m_messages.take();
assertNull(mws.m_messages.poll(50, TimeUnit.MILLISECONDS));
}
use of org.voltcore.utils.DeferredSerialization in project voltdb by VoltDB.
the class TestClientInterface method testGC.
@Test
public void testGC() throws Exception {
ByteBuffer msg = createMsg("@GC");
ClientResponseImpl resp = m_ci.handleRead(msg, m_handler, m_cxn);
assertNull(resp);
DeferredSerialization ds = responsesDS.take();
ByteBuffer b = ByteBuffer.allocate(ds.getSerializedSize());
ds.serialize(b);
resp = new ClientResponseImpl();
b.position(4);
resp.initFromBuffer(b);
assertEquals(ClientResponse.SUCCESS, resp.getStatus());
VoltTable vt = resp.getResults()[0];
assertTrue(vt.advanceRow());
//System.gc() should take at least a little time
assertTrue(resp.getResults()[0].getLong(0) > 10000);
}
Aggregations