use of org.bboxdb.network.packages.request.DeleteDistributionGroupRequest in project bboxdb by jnidzwetzki.
the class TestNetworkClasses method encodeAndDecodeDeleteDistributionGroup.
/**
* The the encoding and decoding of an create distribution group package
* @throws IOException
* @throws PackageEncodeException
*/
@Test(timeout = 60000)
public void encodeAndDecodeDeleteDistributionGroup() throws IOException, PackageEncodeException {
final short sequenceNumber = sequenceNumberGenerator.getNextSequenceNummber();
final DeleteDistributionGroupRequest groupPackage = new DeleteDistributionGroupRequest(sequenceNumber, "test");
byte[] encodedVersion = networkPackageToByte(groupPackage);
Assert.assertNotNull(encodedVersion);
final ByteBuffer bb = NetworkPackageDecoder.encapsulateBytes(encodedVersion);
final DeleteDistributionGroupRequest decodedPackage = DeleteDistributionGroupRequest.decodeTuple(bb);
Assert.assertEquals(groupPackage.getDistributionGroup(), decodedPackage.getDistributionGroup());
Assert.assertEquals(groupPackage, decodedPackage);
Assert.assertEquals(groupPackage.hashCode(), decodedPackage.hashCode());
Assert.assertEquals(groupPackage.toString(), decodedPackage.toString());
}
use of org.bboxdb.network.packages.request.DeleteDistributionGroupRequest in project bboxdb by jnidzwetzki.
the class DeleteDistributionGroupHandler method handleRequest.
@Override
public /**
* Delete an existing distribution group
*/
boolean handleRequest(final ByteBuffer encodedPackage, final short packageSequence, final ClientConnectionHandler clientConnectionHandler) throws IOException, PackageEncodeException {
try {
final DeleteDistributionGroupRequest deletePackage = DeleteDistributionGroupRequest.decodeTuple(encodedPackage);
final String distributionGroup = deletePackage.getDistributionGroup();
logger.info("Delete distribution group: {}", distributionGroup);
// Delete in Zookeeper
final DistributionGroupAdapter distributionGroupZookeeperAdapter = ZookeeperClientFactory.getZookeeperClient().getDistributionGroupAdapter();
distributionGroupZookeeperAdapter.deleteDistributionGroup(distributionGroup);
// Delete local stored data
logger.info("Delete distribution group, delete local stored data");
clientConnectionHandler.getStorageRegistry().deleteAllTablesInDistributionGroup(distributionGroup);
// Clear cached data
TupleStoreConfigurationCache.getInstance().clear();
logger.info("Delete distribution group - DONE");
clientConnectionHandler.writeResultPackage(new SuccessResponse(packageSequence));
} catch (Exception e) {
logger.warn("Error while delete distribution group", e);
final ErrorResponse responsePackage = new ErrorResponse(packageSequence, ErrorMessages.ERROR_EXCEPTION);
clientConnectionHandler.writeResultPackage(responsePackage);
}
return true;
}
Aggregations