use of org.bboxdb.network.packages.request.DeleteTableRequest in project bboxdb by jnidzwetzki.
the class DeleteTableHandler method handleRequest.
@Override
public /**
* Handle the delete table call
*/
boolean handleRequest(final ByteBuffer encodedPackage, final short packageSequence, final ClientConnectionHandler clientConnectionHandler) throws IOException, PackageEncodeException {
try {
final DeleteTableRequest deletePackage = DeleteTableRequest.decodeTuple(encodedPackage);
final TupleStoreName requestTable = deletePackage.getTable();
logger.info("Got delete call for table: {}", requestTable);
// Delete zookeeper configuration
final TupleStoreAdapter tupleStoreAdapter = ZookeeperClientFactory.getZookeeperClient().getTupleStoreAdapter();
tupleStoreAdapter.deleteTable(requestTable);
// Clear cached data
TupleStoreConfigurationCache.getInstance().clear();
clientConnectionHandler.writeResultPackage(new SuccessResponse(packageSequence));
} catch (Exception e) {
logger.warn("Error while delete tuple", e);
final ErrorResponse responsePackage = new ErrorResponse(packageSequence, ErrorMessages.ERROR_EXCEPTION);
clientConnectionHandler.writeResultPackage(responsePackage);
}
return true;
}
use of org.bboxdb.network.packages.request.DeleteTableRequest in project bboxdb by jnidzwetzki.
the class TestNetworkClasses method encodeAndDecodeDeleteTable.
/**
* The the encoding and decoding of an delete table package
* @throws IOException
* @throws PackageEncodeException
*/
@Test(timeout = 60000)
public void encodeAndDecodeDeleteTable() throws IOException, PackageEncodeException {
final short sequenceNumber = sequenceNumberGenerator.getNextSequenceNummber();
final DeleteTableRequest deletePackage = new DeleteTableRequest(sequenceNumber, "test");
byte[] encodedVersion = networkPackageToByte(deletePackage);
Assert.assertNotNull(encodedVersion);
final ByteBuffer bb = NetworkPackageDecoder.encapsulateBytes(encodedVersion);
final DeleteTableRequest decodedPackage = DeleteTableRequest.decodeTuple(bb);
Assert.assertEquals(deletePackage.getTable(), decodedPackage.getTable());
Assert.assertEquals(deletePackage, decodedPackage);
Assert.assertEquals(decodedPackage.hashCode(), decodedPackage.hashCode());
Assert.assertEquals(deletePackage.toString(), decodedPackage.toString());
}
Aggregations