Search in sources :

Example 46 with RoutingHeader

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);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) RoutingHeader(org.bboxdb.network.routing.RoutingHeader) Test(org.junit.Test)

Example 47 with RoutingHeader

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));
}
Also used : RoutingHeader(org.bboxdb.network.routing.RoutingHeader) Test(org.junit.Test)

Example 48 with RoutingHeader

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);
}
Also used : RoutingHeader(org.bboxdb.network.routing.RoutingHeader) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 49 with RoutingHeader

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);
}
Also used : RoutingHeader(org.bboxdb.network.routing.RoutingHeader) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) ByteBuffer(java.nio.ByteBuffer) JoinedTuple(org.bboxdb.storage.entity.JoinedTuple) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) InsertTupleRequest(org.bboxdb.network.packages.request.InsertTupleRequest) Test(org.junit.Test)

Example 50 with RoutingHeader

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);
}
Also used : RoutingHeader(org.bboxdb.network.routing.RoutingHeader) InsertTupleRequest(org.bboxdb.network.packages.request.InsertTupleRequest)

Aggregations

RoutingHeader (org.bboxdb.network.routing.RoutingHeader)52 Test (org.junit.Test)18 NetworkOperationFuture (org.bboxdb.network.client.future.NetworkOperationFuture)16 RoutingHop (org.bboxdb.network.routing.RoutingHop)15 ArrayList (java.util.ArrayList)12 JoinedTupleListFuture (org.bboxdb.network.client.future.JoinedTupleListFuture)12 BBoxDBInstance (org.bboxdb.distribution.membership.BBoxDBInstance)11 PackageEncodeException (org.bboxdb.network.packages.PackageEncodeException)11 Tuple (org.bboxdb.storage.entity.Tuple)11 TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)11 List (java.util.List)10 DistributionRegion (org.bboxdb.distribution.region.DistributionRegion)10 TupleListFuture (org.bboxdb.network.client.future.TupleListFuture)10 ByteBuffer (java.nio.ByteBuffer)9 InsertTupleRequest (org.bboxdb.network.packages.request.InsertTupleRequest)9 DeletedTuple (org.bboxdb.storage.entity.DeletedTuple)9 DoNothingDuplicateResolver (org.bboxdb.storage.sstable.duplicateresolver.DoNothingDuplicateResolver)8 BoundingBox (org.bboxdb.commons.math.BoundingBox)6 BBoxDBException (org.bboxdb.misc.BBoxDBException)6 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)6