use of org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteKeyArgs in project ozone by apache.
the class TestOMKeysDeleteRequest method testKeysDeleteRequest.
@Test
public void testKeysDeleteRequest() throws Exception {
createPreRequisites();
OMKeysDeleteRequest omKeysDeleteRequest = new OMKeysDeleteRequest(omRequest);
OMClientResponse omClientResponse = omKeysDeleteRequest.validateAndUpdateCache(ozoneManager, 0L, ozoneManagerDoubleBufferHelper);
Assert.assertTrue(omClientResponse.getOMResponse().getSuccess());
Assert.assertEquals(OzoneManagerProtocolProtos.Status.OK, omClientResponse.getOMResponse().getStatus());
Assert.assertTrue(omClientResponse.getOMResponse().getDeleteKeysResponse().getStatus());
DeleteKeyArgs unDeletedKeys = omClientResponse.getOMResponse().getDeleteKeysResponse().getUnDeletedKeys();
Assert.assertEquals(0, unDeletedKeys.getKeysCount());
// Check all keys are deleted.
for (String deleteKey : deleteKeyList) {
Assert.assertNull(omMetadataManager.getKeyTable(getBucketLayout()).get(omMetadataManager.getOzoneKey(volumeName, bucketName, deleteKey)));
}
}
use of org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteKeyArgs in project ozone by apache.
the class OzoneManagerProtocolClientSideTranslatorPB method deleteKeys.
/**
* Deletes existing key/keys. This interface supports delete
* multiple keys and a single key.
*
* @param deleteKeys
* @throws IOException
*/
@Override
public void deleteKeys(OmDeleteKeys deleteKeys) throws IOException {
DeleteKeysRequest.Builder req = DeleteKeysRequest.newBuilder();
DeleteKeyArgs deletedKeys = DeleteKeyArgs.newBuilder().setBucketName(deleteKeys.getBucket()).setVolumeName(deleteKeys.getVolume()).addAllKeys(deleteKeys.getKeyNames()).build();
req.setDeleteKeys(deletedKeys);
OMRequest omRequest = createOMRequest(Type.DeleteKeys).setDeleteKeysRequest(req).build();
handleError(submitRequest(omRequest));
}
use of org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteKeyArgs in project ozone by apache.
the class TestOMKeysDeleteRequest method testKeysDeleteRequestFail.
@Test
public void testKeysDeleteRequestFail() throws Exception {
createPreRequisites();
// Add a key which not exist, which causes batch delete to fail.
omRequest = omRequest.toBuilder().setDeleteKeysRequest(DeleteKeysRequest.newBuilder().setDeleteKeys(DeleteKeyArgs.newBuilder().setBucketName(bucketName).setVolumeName(volumeName).addAllKeys(deleteKeyList).addKeys("dummy"))).build();
OMKeysDeleteRequest omKeysDeleteRequest = new OMKeysDeleteRequest(omRequest);
OMClientResponse omClientResponse = omKeysDeleteRequest.validateAndUpdateCache(ozoneManager, 0L, ozoneManagerDoubleBufferHelper);
Assert.assertFalse(omClientResponse.getOMResponse().getSuccess());
Assert.assertEquals(PARTIAL_DELETE, omClientResponse.getOMResponse().getStatus());
Assert.assertFalse(omClientResponse.getOMResponse().getDeleteKeysResponse().getStatus());
// Check keys are deleted and in response check unDeletedKey.
for (String deleteKey : deleteKeyList) {
Assert.assertNull(omMetadataManager.getKeyTable(getBucketLayout()).get(omMetadataManager.getOzoneKey(volumeName, bucketName, deleteKey)));
}
DeleteKeyArgs unDeletedKeys = omClientResponse.getOMResponse().getDeleteKeysResponse().getUnDeletedKeys();
Assert.assertEquals(1, unDeletedKeys.getKeysCount());
Assert.assertEquals("dummy", unDeletedKeys.getKeys(0));
}
Aggregations