use of org.bboxdb.network.routing.RoutingHeader in project bboxdb by jnidzwetzki.
the class TestRoutingHeader method testRoutedPackageHeader2.
/**
* Test the encoding and the decoding of an routed package
* @throws IOException
* @throws PackageEncodeException
*/
@Test(timeout = 60000)
public void testRoutedPackageHeader2() throws IOException, PackageEncodeException {
final RoutingHeader routingHeader = new RoutingHeader((short) 10, "");
final byte[] encodedBytes = RoutingHeaderParser.encodeHeader(routingHeader);
final ByteArrayInputStream bis = new ByteArrayInputStream(encodedBytes);
final RoutingHeader resultRoutingHeader = RoutingHeaderParser.decodeRoutingHeader(bis);
Assert.assertEquals(routingHeader, resultRoutingHeader);
}
use of org.bboxdb.network.routing.RoutingHeader in project bboxdb by jnidzwetzki.
the class TestRoutingHeader method testRoutingHopParser4.
/**
* Test the routing hop parser
*/
@Test(timeout = 60000)
public void testRoutingHopParser4() {
final RoutingHeader routingHeader = new RoutingHeader((short) 10, "node1:12,1,2,3;node2:23,2");
Assert.assertEquals(2, routingHeader.getRoutingList().size());
Assert.assertEquals(3, routingHeader.getRoutingList().get(0).getDistributionRegions().size());
Assert.assertEquals(1, routingHeader.getRoutingList().get(1).getDistributionRegions().size());
Assert.assertTrue(routingHeader.getRoutingList().get(0).getDistributionRegions().contains(1l));
Assert.assertTrue(routingHeader.getRoutingList().get(0).getDistributionRegions().contains(2l));
Assert.assertTrue(routingHeader.getRoutingList().get(0).getDistributionRegions().contains(3l));
Assert.assertTrue(routingHeader.getRoutingList().get(1).getDistributionRegions().contains(2l));
}
use of org.bboxdb.network.routing.RoutingHeader in project bboxdb by jnidzwetzki.
the class TestRoutingHeader method testRoutedPackageHeader4.
/**
* Test the encoding and the decoding of an routed package
* @throws IOException
* @throws PackageEncodeException
*/
@Test(timeout = 60000)
public void testRoutedPackageHeader4() throws IOException, PackageEncodeException {
final RoutingHeader routingHeader = new RoutingHeader((short) 10, "");
final byte[] encodedBytes = RoutingHeaderParser.encodeHeader(routingHeader);
final ByteBuffer bb = ByteBuffer.wrap(encodedBytes);
bb.order(Const.APPLICATION_BYTE_ORDER);
Assert.assertEquals(0, bb.position());
final RoutingHeader resultRoutingHeader = RoutingHeaderParser.decodeRoutingHeader(bb);
Assert.assertEquals(0, bb.remaining());
Assert.assertEquals(routingHeader, resultRoutingHeader);
}
use of org.bboxdb.network.routing.RoutingHeader in project bboxdb by jnidzwetzki.
the class TestNetworkClasses method encodeAndDecodeInsertTuple1.
/**
* The the encoding and decoding of an insert tuple package
* @throws IOException
* @throws PackageEncodeException
*/
@Test(timeout = 60000)
public void encodeAndDecodeInsertTuple1() throws IOException, PackageEncodeException {
final Tuple tuple = new Tuple("key", BoundingBox.FULL_SPACE, "abc".getBytes(), 12);
final short sequenceNumber = sequenceNumberGenerator.getNextSequenceNummber();
final InsertTupleRequest insertPackage = new InsertTupleRequest(sequenceNumber, ROUTING_HEADER_UNROUTED, new TupleStoreName("test"), tuple);
byte[] encodedVersion = networkPackageToByte(insertPackage);
Assert.assertNotNull(encodedVersion);
final ByteBuffer bb = NetworkPackageDecoder.encapsulateBytes(encodedVersion);
final InsertTupleRequest decodedPackage = InsertTupleRequest.decodeTuple(bb);
Assert.assertEquals(insertPackage.getTuple(), decodedPackage.getTuple());
Assert.assertEquals(insertPackage.getTable(), decodedPackage.getTable());
Assert.assertEquals(insertPackage.getRoutingHeader(), new RoutingHeader(false));
Assert.assertEquals(insertPackage, decodedPackage);
Assert.assertEquals(insertPackage.hashCode(), decodedPackage.hashCode());
Assert.assertTrue(insertPackage.toString().length() > 10);
}
use of org.bboxdb.network.routing.RoutingHeader in project bboxdb by jnidzwetzki.
the class TestCompressionRatio method handleUncompressedData.
/**
* Handle the uncompressed version
* @param tableName
* @return
*/
protected long handleUncompressedData(final TupleStoreName tableName, final Tuple tuple) {
final RoutingHeader routingHeader = new RoutingHeader(false);
final InsertTupleRequest insertTupleRequest = new InsertTupleRequest((short) 4, routingHeader, tableName, tuple);
return packageToBytes(insertTupleRequest);
}
Aggregations