Search in sources :

Example 1 with DeleteKeyArgs

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)));
    }
}
Also used : OMClientResponse(org.apache.hadoop.ozone.om.response.OMClientResponse) DeleteKeyArgs(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteKeyArgs) Test(org.junit.Test)

Example 2 with DeleteKeyArgs

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));
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) DeleteKeysRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteKeysRequest) DeleteKeyArgs(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteKeyArgs)

Example 3 with DeleteKeyArgs

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));
}
Also used : OMClientResponse(org.apache.hadoop.ozone.om.response.OMClientResponse) DeleteKeyArgs(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteKeyArgs) Test(org.junit.Test)

Aggregations

DeleteKeyArgs (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteKeyArgs)3 OMClientResponse (org.apache.hadoop.ozone.om.response.OMClientResponse)2 Test (org.junit.Test)2 DeleteKeysRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteKeysRequest)1 OMRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest)1