Search in sources :

Example 31 with TupleStoreConfiguration

use of org.bboxdb.storage.entity.TupleStoreConfiguration 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)

Example 32 with TupleStoreConfiguration

use of org.bboxdb.storage.entity.TupleStoreConfiguration in project bboxdb by jnidzwetzki.

the class TestTupleStoreAdapter method testDeleteDistributionGroup.

@Test(timeout = 60000)
public void testDeleteDistributionGroup() throws ZookeeperException {
    final TupleStoreConfiguration tupleStoreConfiguration = TupleStoreConfigurationBuilder.create().build();
    final TupleStoreName tupleStoreName1 = new TupleStoreName("dg_table1");
    final TupleStoreName tupleStoreName2 = new TupleStoreName("dg_table2");
    tupleStoreAdapter.deleteTable(tupleStoreName1);
    tupleStoreAdapter.deleteTable(tupleStoreName2);
    Assert.assertFalse(tupleStoreAdapter.isTableKnown(tupleStoreName1));
    Assert.assertFalse(tupleStoreAdapter.isTableKnown(tupleStoreName2));
    tupleStoreAdapter.writeTuplestoreConfiguration(tupleStoreName1, tupleStoreConfiguration);
    tupleStoreAdapter.writeTuplestoreConfiguration(tupleStoreName2, tupleStoreConfiguration);
    Assert.assertTrue(tupleStoreAdapter.isTableKnown(tupleStoreName1));
    Assert.assertTrue(tupleStoreAdapter.isTableKnown(tupleStoreName2));
}
Also used : TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) Test(org.junit.Test)

Example 33 with TupleStoreConfiguration

use of org.bboxdb.storage.entity.TupleStoreConfiguration in project bboxdb by jnidzwetzki.

the class TestTupleStoreAdapter method deleteAndCreateTable.

/**
 * Test the tuplestore creation and deletion
 * @throws ZookeeperException
 */
@Test(timeout = 60000)
public void deleteAndCreateTable() throws ZookeeperException {
    final TupleStoreName tupleStoreName1 = new TupleStoreName("dg_table1");
    final TupleStoreName tupleStoreName2 = new TupleStoreName("dg_table2");
    tupleStoreAdapter.deleteTable(tupleStoreName1);
    tupleStoreAdapter.deleteTable(tupleStoreName2);
    Assert.assertFalse(tupleStoreAdapter.isTableKnown(tupleStoreName1));
    Assert.assertFalse(tupleStoreAdapter.isTableKnown(tupleStoreName2));
    final TupleStoreConfiguration tupleStoreConfiguration = TupleStoreConfigurationBuilder.create().build();
    tupleStoreAdapter.writeTuplestoreConfiguration(tupleStoreName1, tupleStoreConfiguration);
    Assert.assertTrue(tupleStoreAdapter.isTableKnown(tupleStoreName1));
    Assert.assertFalse(tupleStoreAdapter.isTableKnown(tupleStoreName2));
    tupleStoreAdapter.writeTuplestoreConfiguration(tupleStoreName2, tupleStoreConfiguration);
    Assert.assertTrue(tupleStoreAdapter.isTableKnown(tupleStoreName1));
    Assert.assertTrue(tupleStoreAdapter.isTableKnown(tupleStoreName2));
    tupleStoreAdapter.deleteTable(tupleStoreName1);
    tupleStoreAdapter.deleteTable(tupleStoreName2);
    Assert.assertFalse(tupleStoreAdapter.isTableKnown(tupleStoreName1));
    Assert.assertFalse(tupleStoreAdapter.isTableKnown(tupleStoreName2));
}
Also used : TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) Test(org.junit.Test)

Example 34 with TupleStoreConfiguration

use of org.bboxdb.storage.entity.TupleStoreConfiguration in project bboxdb by jnidzwetzki.

the class TestTupleStoreAdapter method testTupleStoreConfig2.

/**
 * Test configuration 2
 * @throws ZookeeperException
 */
@Test(timeout = 60000)
public void testTupleStoreConfig2() throws ZookeeperException {
    final TupleStoreConfiguration tupleStoreConfiguration = TupleStoreConfigurationBuilder.create().allowDuplicates(true).withTTL(10000, TimeUnit.MILLISECONDS).withVersions(100).build();
    final TupleStoreName tupleStoreName = new TupleStoreName("dg_table1");
    tupleStoreAdapter.deleteTable(tupleStoreName);
    Assert.assertFalse(tupleStoreAdapter.isTableKnown(tupleStoreName));
    tupleStoreAdapter.writeTuplestoreConfiguration(tupleStoreName, tupleStoreConfiguration);
    final TupleStoreConfiguration readConfig = tupleStoreAdapter.readTuplestoreConfiguration(tupleStoreName);
    Assert.assertEquals(tupleStoreConfiguration, readConfig);
    Assert.assertTrue(tupleStoreAdapter.isTableKnown(tupleStoreName));
}
Also used : TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) TupleStoreName(org.bboxdb.storage.entity.TupleStoreName) Test(org.junit.Test)

Example 35 with TupleStoreConfiguration

use of org.bboxdb.storage.entity.TupleStoreConfiguration in project bboxdb by jnidzwetzki.

the class TestStorageManager method testTTLDuplicates.

/**
 * Test the storage manager with duplicates - ttl version
 * @throws StorageManagerException
 * @throws RejectedException
 * @throws InterruptedException
 */
@Test(timeout = 60000)
public void testTTLDuplicates() throws StorageManagerException, RejectedException, InterruptedException {
    // The TTL
    final int TTL_IN_MS = 5000;
    // Delete the old table
    storageRegistry.deleteTable(TEST_RELATION, true);
    // Create a new table
    final TupleStoreConfiguration tupleStoreConfiguration = TupleStoreConfigurationBuilder.create().allowDuplicates(true).withTTL(TTL_IN_MS, TimeUnit.MILLISECONDS).build();
    storageRegistry.createTable(TEST_RELATION, tupleStoreConfiguration);
    // Assure table is created successfully
    storageManager = storageRegistry.getTupleStoreManager(TEST_RELATION);
    Assert.assertTrue(storageManager.getServiceState().isInRunningState());
    final Tuple tuple1 = new Tuple("abc", BoundingBox.FULL_SPACE, "abc1".getBytes());
    storageManager.put(tuple1);
    final Tuple tuple2 = new Tuple("abc", BoundingBox.FULL_SPACE, "abc2".getBytes());
    storageManager.put(tuple2);
    final Tuple tuple3 = new Tuple("abc", BoundingBox.FULL_SPACE, "abc3".getBytes());
    storageManager.put(tuple3);
    final Tuple tuple4 = new Tuple("abc", BoundingBox.FULL_SPACE, "abc4".getBytes());
    storageManager.put(tuple4);
    final Tuple tuple5 = new Tuple("abc", BoundingBox.FULL_SPACE, "abc5".getBytes());
    storageManager.put(tuple5);
    final List<Tuple> readTuples = storageManager.get("abc");
    Assert.assertFalse(readTuples.isEmpty());
    // Sleep longer than TTL
    Thread.sleep(TTL_IN_MS * 2);
    final List<Tuple> readTuples2 = storageManager.get("abc");
    Assert.assertTrue(readTuples2.isEmpty());
}
Also used : TupleStoreConfiguration(org.bboxdb.storage.entity.TupleStoreConfiguration) Tuple(org.bboxdb.storage.entity.Tuple) DeletedTuple(org.bboxdb.storage.entity.DeletedTuple) Test(org.junit.Test)

Aggregations

TupleStoreConfiguration (org.bboxdb.storage.entity.TupleStoreConfiguration)44 Test (org.junit.Test)23 Tuple (org.bboxdb.storage.entity.Tuple)21 EmptyResultFuture (org.bboxdb.network.client.future.EmptyResultFuture)15 TupleStoreName (org.bboxdb.storage.entity.TupleStoreName)13 BoundingBox (org.bboxdb.commons.math.BoundingBox)12 TupleListFuture (org.bboxdb.network.client.future.TupleListFuture)10 TupleStoreAdapter (org.bboxdb.distribution.zookeeper.TupleStoreAdapter)7 JoinedTupleListFuture (org.bboxdb.network.client.future.JoinedTupleListFuture)7 DeletedTuple (org.bboxdb.storage.entity.DeletedTuple)7 JoinedTuple (org.bboxdb.storage.entity.JoinedTuple)7 TupleStoreManager (org.bboxdb.storage.tuplestore.manager.TupleStoreManager)7 BBoxDBConnection (org.bboxdb.network.client.BBoxDBConnection)5 ArrayList (java.util.ArrayList)4 BBoxDBException (org.bboxdb.misc.BBoxDBException)4 BBoxDBClient (org.bboxdb.network.client.BBoxDBClient)4 DistributionRegion (org.bboxdb.distribution.region.DistributionRegion)3 DistributionGroupConfiguration (org.bboxdb.storage.entity.DistributionGroupConfiguration)3 SSTableWriter (org.bboxdb.storage.sstable.SSTableWriter)3 SSTableCompactor (org.bboxdb.storage.sstable.compact.SSTableCompactor)3