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);
}
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);
}
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");
}
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);
}
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");
}
Aggregations