Search in sources :

Example 31 with EmptyResultFuture

use of org.bboxdb.network.client.future.EmptyResultFuture in project bboxdb by jnidzwetzki.

the class TestNetworkCommunication method testCreateDistributionGroupTwoTimes.

/**
 * Test create a distribution group two times
 * @throws BBoxDBException
 * @throws InterruptedException
 */
@Test(timeout = 60000)
public void testCreateDistributionGroupTwoTimes() throws BBoxDBException, InterruptedException {
    final BBoxDBConnection bboxdbConnection = connectToServer();
    final BBoxDBClient bboxDBClient = bboxdbConnection.getBboxDBClient();
    // Create distribution group
    final DistributionGroupConfiguration configuration = DistributionGroupConfigurationBuilder.create(2).withReplicationFactor((short) 1).build();
    final EmptyResultFuture resultCreate = bboxDBClient.createDistributionGroup(DISTRIBUTION_GROUP, configuration);
    // Prevent retries
    resultCreate.setRetryPolicy(FutureRetryPolicy.RETRY_POLICY_NONE);
    resultCreate.waitForAll();
    Assert.assertTrue(resultCreate.isFailed());
    Assert.assertEquals(ErrorMessages.ERROR_DGROUP_EXISTS, resultCreate.getMessage(0));
    Assert.assertTrue(bboxdbConnection.getConnectionState().isInRunningState());
    disconnect(bboxDBClient);
}
Also used : BBoxDBClient(org.bboxdb.network.client.BBoxDBClient) DistributionGroupConfiguration(org.bboxdb.storage.entity.DistributionGroupConfiguration) BBoxDBConnection(org.bboxdb.network.client.BBoxDBConnection) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture) Test(org.junit.Test)

Example 32 with EmptyResultFuture

use of org.bboxdb.network.client.future.EmptyResultFuture in project bboxdb by jnidzwetzki.

the class TestNetworkCommunication method testCreateTableTwoTimes.

/**
 * Test create a table two times
 * @throws BBoxDBException
 * @throws InterruptedException
 */
@Test(timeout = 60000)
public void testCreateTableTwoTimes() throws BBoxDBException, InterruptedException {
    final BBoxDBConnection bboxdbConnection = connectToServer();
    final BBoxDBClient bboxDBClient = bboxdbConnection.getBboxDBClient();
    final String table = DISTRIBUTION_GROUP + "_mytable";
    final EmptyResultFuture resultCreateTable1 = bboxDBClient.createTable(table, new TupleStoreConfiguration());
    resultCreateTable1.waitForAll();
    Assert.assertFalse(resultCreateTable1.isFailed());
    final EmptyResultFuture resultCreateTable2 = bboxDBClient.createTable(table, new TupleStoreConfiguration());
    // Prevent retries
    resultCreateTable2.setRetryPolicy(FutureRetryPolicy.RETRY_POLICY_NONE);
    resultCreateTable2.waitForAll();
    Assert.assertTrue(resultCreateTable2.isFailed());
    Assert.assertEquals(ErrorMessages.ERROR_TABLE_EXISTS, resultCreateTable2.getMessage(0));
    Assert.assertTrue(bboxdbConnection.getConnectionState().isInRunningState());
    disconnect(bboxDBClient);
}
Also used : BBoxDBClient(org.bboxdb.network.client.BBoxDBClient) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) BBoxDBConnection(org.bboxdb.network.client.BBoxDBConnection) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture) Test(org.junit.Test)

Example 33 with EmptyResultFuture

use of org.bboxdb.network.client.future.EmptyResultFuture in project bboxdb by jnidzwetzki.

the class TestNetworkCommunication method testInsertIntoNonExstingTable.

/**
 * Test insert into non existing table
 * @throws BBoxDBException
 * @throws InterruptedException
 */
@Test(timeout = 60000)
public void testInsertIntoNonExstingTable() throws BBoxDBException, InterruptedException {
    System.out.println("=== Running testInsertIntoNonExstingTable");
    final BBoxDBConnection bboxdbConnection = connectToServer();
    final BBoxDBClient bboxDBClient = bboxdbConnection.getBboxDBClient();
    final String table = DISTRIBUTION_GROUP + "_relationnonexsting";
    final String key = "key12";
    System.out.println("Insert tuple");
    final Tuple tuple = new Tuple(key, BoundingBox.FULL_SPACE, "abc".getBytes());
    final EmptyResultFuture insertResult = bboxDBClient.insertTuple(table, tuple);
    // Prevent retries
    insertResult.setRetryPolicy(FutureRetryPolicy.RETRY_POLICY_NONE);
    insertResult.waitForAll();
    Assert.assertTrue(insertResult.isFailed());
    Assert.assertTrue(insertResult.isDone());
    System.out.println(insertResult.getMessage(0));
    bboxDBClient.disconnect();
    System.out.println("=== End testInsertIntoNonExstingTable");
}
Also used : BBoxDBClient(org.bboxdb.network.client.BBoxDBClient) BBoxDBConnection(org.bboxdb.network.client.BBoxDBConnection) Tuple(org.bboxdb.storage.entity.Tuple) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture) Test(org.junit.Test)

Example 34 with EmptyResultFuture

use of org.bboxdb.network.client.future.EmptyResultFuture in project bboxdb by jnidzwetzki.

the class TestNetworkCommunication method testSendKeepAlivePackage.

/**
 * Send a keep alive package to the server
 * @throws InterruptedException
 * @throws ExecutionException
 */
@Test(timeout = 60000)
public void testSendKeepAlivePackage() throws InterruptedException, ExecutionException {
    System.out.println("=== Running sendKeepAlivePackage");
    final BBoxDBConnection bboxdbConnection = connectToServer();
    final BBoxDBClient bboxDBClient = bboxdbConnection.getBboxDBClient();
    final EmptyResultFuture result = bboxDBClient.sendKeepAlivePackage();
    result.waitForAll();
    Assert.assertTrue(result.isDone());
    Assert.assertFalse(result.isFailed());
    Assert.assertTrue(bboxdbConnection.getConnectionState().isInRunningState());
    disconnect(bboxDBClient);
    Assert.assertFalse(bboxDBClient.isConnected());
    System.out.println("=== End sendKeepAlivePackage");
    disconnect(bboxDBClient);
}
Also used : BBoxDBClient(org.bboxdb.network.client.BBoxDBClient) BBoxDBConnection(org.bboxdb.network.client.BBoxDBConnection) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture) Test(org.junit.Test)

Example 35 with EmptyResultFuture

use of org.bboxdb.network.client.future.EmptyResultFuture in project bboxdb by jnidzwetzki.

the class TestNetworkCommunication method testSendDeletePackage.

/**
 * Send a delete package to the server
 * @throws InterruptedException
 * @throws ExecutionException
 * @throws ZookeeperException
 * @throws BBoxDBException
 */
@Test(timeout = 60000)
public void testSendDeletePackage() throws InterruptedException, ExecutionException, ZookeeperException, BBoxDBException {
    System.out.println("=== Running sendDeletePackage");
    final BBoxDBConnection bboxdbConnection = connectToServer();
    final BBoxDBClient bboxDBClient = bboxdbConnection.getBboxDBClient();
    final String tableName = DISTRIBUTION_GROUP + "_relation3";
    final TupleStoreName tupleStoreName = new TupleStoreName(tableName);
    final ZookeeperClient zookeeperClient = ZookeeperClientFactory.getZookeeperClient();
    final TupleStoreAdapter tupleStoreAdapter = zookeeperClient.getTupleStoreAdapter();
    Assert.assertFalse(tupleStoreAdapter.isTableKnown(tupleStoreName));
    // Create table
    final TupleStoreConfiguration configuration = TupleStoreConfigurationBuilder.create().build();
    final EmptyResultFuture createFuture = bboxDBClient.createTable(tableName, configuration);
    createFuture.waitForAll();
    Assert.assertTrue(createFuture.isDone());
    Assert.assertFalse(createFuture.isFailed());
    Assert.assertTrue(tupleStoreAdapter.isTableKnown(tupleStoreName));
    // Delete table
    final EmptyResultFuture deleteResult1 = bboxDBClient.deleteTable(tableName);
    deleteResult1.waitForAll();
    Assert.assertTrue(deleteResult1.isDone());
    Assert.assertFalse(deleteResult1.isFailed());
    Assert.assertTrue(bboxdbConnection.getConnectionState().isInRunningState());
    Assert.assertFalse(tupleStoreAdapter.isTableKnown(tupleStoreName));
    // Second call
    final EmptyResultFuture deleteResult2 = bboxDBClient.deleteTable(tableName);
    deleteResult2.waitForAll();
    Assert.assertTrue(deleteResult2.isDone());
    Assert.assertFalse(deleteResult2.isFailed());
    Assert.assertTrue(bboxdbConnection.getConnectionState().isInRunningState());
    Assert.assertFalse(tupleStoreAdapter.isTableKnown(tupleStoreName));
    // Disconnect
    disconnect(bboxDBClient);
    Assert.assertFalse(bboxDBClient.isConnected());
    System.out.println("=== End sendDeletePackage");
}
Also used : ZookeeperClient(org.bboxdb.distribution.zookeeper.ZookeeperClient) BBoxDBClient(org.bboxdb.network.client.BBoxDBClient) TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) TupleStoreAdapter(org.bboxdb.distribution.zookeeper.TupleStoreAdapter) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) BBoxDBConnection(org.bboxdb.network.client.BBoxDBConnection) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture) Test(org.junit.Test)

Aggregations

EmptyResultFuture (org.bboxdb.network.client.future.EmptyResultFuture)43 Tuple (org.bboxdb.storage.entity.Tuple)17 TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)15 BoundingBox (org.bboxdb.commons.math.BoundingBox)11 BBoxDBException (org.bboxdb.misc.BBoxDBException)11 Test (org.junit.Test)11 TupleListFuture (org.bboxdb.network.client.future.TupleListFuture)10 DistributionGroupConfiguration (org.bboxdb.storage.entity.DistributionGroupConfiguration)9 BBoxDBClient (org.bboxdb.network.client.BBoxDBClient)8 BBoxDBConnection (org.bboxdb.network.client.BBoxDBConnection)8 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)8 JoinedTupleListFuture (org.bboxdb.network.client.future.JoinedTupleListFuture)7 NetworkOperationFuture (org.bboxdb.network.client.future.NetworkOperationFuture)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 BBoxDBInstance (org.bboxdb.distribution.membership.BBoxDBInstance)3 FixedSizeFutureStore (org.bboxdb.network.client.tools.FixedSizeFutureStore)3 RoutingHeader (org.bboxdb.network.routing.RoutingHeader)3 List (java.util.List)2