Search in sources :

Example 21 with BBoxDBConnection

use of org.bboxdb.network.client.BBoxDBConnection 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 22 with BBoxDBConnection

use of org.bboxdb.network.client.BBoxDBConnection in project bboxdb by jnidzwetzki.

the class TestNetworkCommunication method before.

/**
 * Re-create distribution group for each test
 * @throws InterruptedException
 * @throws BBoxDBException
 */
@Before
public void before() throws InterruptedException, BBoxDBException {
    final BBoxDBConnection bboxdbConnection = connectToServer();
    final BBoxDBClient bboxDBClient = bboxdbConnection.getBboxDBClient();
    TestHelper.recreateDistributionGroup(bboxDBClient, DISTRIBUTION_GROUP);
    disconnect(bboxDBClient);
}
Also used : BBoxDBClient(org.bboxdb.network.client.BBoxDBClient) BBoxDBConnection(org.bboxdb.network.client.BBoxDBConnection) Before(org.junit.Before)

Example 23 with BBoxDBConnection

use of org.bboxdb.network.client.BBoxDBConnection 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 24 with BBoxDBConnection

use of org.bboxdb.network.client.BBoxDBConnection 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 25 with BBoxDBConnection

use of org.bboxdb.network.client.BBoxDBConnection in project bboxdb by jnidzwetzki.

the class TestNetworkCommunication method testInsertAndBoundingBoxTimeQuery.

/**
 * Insert some tuples and start a bounding box query afterwards
 * @throws ExecutionException
 * @throws InterruptedException
 * @throws BBoxDBException
 */
@Test(timeout = 60000)
public void testInsertAndBoundingBoxTimeQuery() throws InterruptedException, ExecutionException, BBoxDBException {
    System.out.println("=== Running testInsertAndBoundingBoxTimeQuery");
    final BBoxDBConnection bboxdbConnection = connectToServer();
    final BBoxDBClient bboxDBClient = bboxdbConnection.getBboxDBClient();
    NetworkQueryHelper.executeBoudingboxAndTimeQuery(bboxDBClient, DISTRIBUTION_GROUP);
    System.out.println("=== End testInsertAndBoundingBoxTimeQuery");
    disconnect(bboxDBClient);
}
Also used : BBoxDBClient(org.bboxdb.network.client.BBoxDBClient) BBoxDBConnection(org.bboxdb.network.client.BBoxDBConnection) Test(org.junit.Test)

Aggregations

BBoxDBConnection (org.bboxdb.network.client.BBoxDBConnection)37 BBoxDBClient (org.bboxdb.network.client.BBoxDBClient)26 Test (org.junit.Test)24 EmptyResultFuture (org.bboxdb.network.client.future.EmptyResultFuture)8 TupleListFuture (org.bboxdb.network.client.future.TupleListFuture)5 Tuple (org.bboxdb.storage.entity.Tuple)5 TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)5 BoundingBox (org.bboxdb.commons.math.BoundingBox)4 InetSocketAddress (java.net.InetSocketAddress)3 BBoxDBInstance (org.bboxdb.distribution.membership.BBoxDBInstance)3 NetworkRequestPackage (org.bboxdb.network.packages.NetworkRequestPackage)3 TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)3 ExecutionException (java.util.concurrent.ExecutionException)2 TupleStoreAdapter (org.bboxdb.distribution.zookeeper.TupleStoreAdapter)2 NetworkOperationFuture (org.bboxdb.network.client.future.NetworkOperationFuture)2 StorageManagerException (org.bboxdb.storage.StorageManagerException)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 TimeoutException (java.util.concurrent.TimeoutException)1 RejectedException (org.bboxdb.commons.RejectedException)1