Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0cc9063
HDDS-3900. Fix OMKeyDeletesRequest.
bharatviswa504 Jul 7, 2020
d7e052b
revert not required
bharatviswa504 Jul 7, 2020
19f8971
revert not needed
bharatviswa504 Jul 7, 2020
48bf7d5
use trxnLogIndex
bharatviswa504 Jul 7, 2020
9b1a4c4
fix
bharatviswa504 Jul 7, 2020
8311ea9
fix
bharatviswa504 Jul 7, 2020
a0a8914
fix
bharatviswa504 Jul 7, 2020
bbb5986
remove unneeded
bharatviswa504 Jul 7, 2020
22e4b79
add back
bharatviswa504 Jul 7, 2020
258dd0b
fix review bug
bharatviswa504 Jul 8, 2020
400068d
Add tests
bharatviswa504 Jul 8, 2020
f12d32b
fix sonar issue
bharatviswa504 Jul 8, 2020
d1601b1
fix review comments
bharatviswa504 Jul 10, 2020
d32f858
rat check
bharatviswa504 Jul 10, 2020
f883cd9
fix checkstyle
bharatviswa504 Jul 10, 2020
769a4ef
fix issue in deletekey
bharatviswa504 Jul 10, 2020
8ecb356
handle partial delete in response class"
bharatviswa504 Jul 10, 2020
ff294b6
fix TestResultCodes"
bharatviswa504 Jul 10, 2020
3191768
revert imports
bharatviswa504 Jul 10, 2020
e2c2bcf
fix checkstyle
bharatviswa504 Jul 10, 2020
b26df38
remove intellij optimize import changes
bharatviswa504 Jul 10, 2020
9384196
import change
bharatviswa504 Jul 10, 2020
4eb9f74
remove unchanged file
bharatviswa504 Jul 10, 2020
5eac583
cs
bharatviswa504 Jul 10, 2020
3d65b7d
fix tests
bharatviswa504 Jul 10, 2020
077348e
fix cs
bharatviswa504 Jul 10, 2020
3a34292
address review comments
bharatviswa504 Jul 10, 2020
006814a
fix metric mistake
bharatviswa504 Jul 10, 2020
4c4ff0d
fix cs
bharatviswa504 Jul 10, 2020
7ae63c6
fix review comments
bharatviswa504 Jul 13, 2020
41bce6f
trigger new CI check
adoroszlai Jul 14, 2020
2b13bd2
trigger new CI check
adoroszlai Jul 14, 2020
2144af7
trigger new CI check
adoroszlai Jul 14, 2020
25a902e
trigger new CI check
adoroszlai Jul 14, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ private OzoneConsts() {
public static final String MULTIPART_UPLOAD_PART_NUMBER = "partNumber";
public static final String MULTIPART_UPLOAD_PART_NAME = "partName";
public static final String BUCKET_ENCRYPTION_KEY = "bucketEncryptionKey";
public static final String DELETED_KEYS_LIST = "deletedKeysList";
public static final String UNDELETED_KEYS_LIST = "unDeletedKeysList";



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
import org.apache.hadoop.ozone.om.helpers.BucketEncryptionKeyInfo;
import org.apache.hadoop.ozone.om.helpers.OmBucketArgs;
import org.apache.hadoop.ozone.om.helpers.OmBucketInfo;
import org.apache.hadoop.ozone.om.helpers.OmDeleteKeys;
import org.apache.hadoop.ozone.om.helpers.OmKeyArgs;
import org.apache.hadoop.ozone.om.helpers.OmKeyInfo;
import org.apache.hadoop.ozone.om.helpers.OmMultipartInfo;
Expand Down Expand Up @@ -730,16 +731,9 @@ public void deleteKeys(
throws IOException {
HddsClientUtils.verifyResourceName(volumeName, bucketName);
Preconditions.checkNotNull(keyNameList);
List<OmKeyArgs> keyArgsList = new ArrayList<>();
for (String keyName: keyNameList) {
OmKeyArgs keyArgs = new OmKeyArgs.Builder()
.setVolumeName(volumeName)
.setBucketName(bucketName)
.setKeyName(keyName)
.build();
keyArgsList.add(keyArgs);
}
ozoneManagerClient.deleteKeys(keyArgsList);
OmDeleteKeys omDeleteKeys = new OmDeleteKeys(volumeName, bucketName,
keyNameList);
ozoneManagerClient.deleteKeys(omDeleteKeys);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public enum OMAction implements AuditAction {
UPDATE_BUCKET,
UPDATE_KEY,
PURGE_KEYS,
DELETE_KEYS,

// S3 Bucket
CREATE_S3_BUCKET,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,5 +222,7 @@ public enum ResultCodes {
DIRECTORY_ALREADY_EXISTS,

INVALID_VOLUME_NAME,

PARTIAL_DELETE
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.hadoop.ozone.om.helpers;

import java.util.List;

/**
* Represent class which has info of Keys to be deleted from Client.
*/
public class OmDeleteKeys {

private String volume;
private String bucket;

private List<String> keyNames;


public OmDeleteKeys(String volume, String bucket, List<String> keyNames) {
this.volume = volume;
this.bucket = bucket;
this.keyNames = keyNames;
}

public String getVolume() {
return volume;
}

public String getBucket() {
return bucket;
}

public List< String > getKeyNames() {
return keyNames;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.hadoop.ozone.om.helpers.DBUpdates;
import org.apache.hadoop.ozone.om.helpers.OmBucketArgs;
import org.apache.hadoop.ozone.om.helpers.OmBucketInfo;
import org.apache.hadoop.ozone.om.helpers.OmDeleteKeys;
import org.apache.hadoop.ozone.om.helpers.OmKeyArgs;
import org.apache.hadoop.ozone.om.helpers.OmKeyInfo;
import org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo;
Expand Down Expand Up @@ -229,10 +230,10 @@ OmKeyLocationInfo allocateBlock(OmKeyArgs args, long clientID,
* multiple keys and a single key. Used by deleting files
* through OzoneFileSystem.
*
* @param args the list args of the key.
* @param deleteKeys
* @throws IOException
*/
void deleteKeys(List<OmKeyArgs> args) throws IOException;
void deleteKeys(OmDeleteKeys deleteKeys) throws IOException;

/**
* Deletes an existing empty bucket from volume.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.apache.hadoop.ozone.om.helpers.KeyValueUtil;
import org.apache.hadoop.ozone.om.helpers.OmBucketArgs;
import org.apache.hadoop.ozone.om.helpers.OmBucketInfo;
import org.apache.hadoop.ozone.om.helpers.OmDeleteKeys;
import org.apache.hadoop.ozone.om.helpers.OmKeyArgs;
import org.apache.hadoop.ozone.om.helpers.OmKeyInfo;
import org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo;
Expand Down Expand Up @@ -71,8 +72,9 @@
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DBUpdatesRequest;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DBUpdatesResponse;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteBucketRequest;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteKeysRequest;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteKeyArgs;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteKeyRequest;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteKeysRequest;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteVolumeRequest;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.GetAclRequest;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.GetAclResponse;
Expand Down Expand Up @@ -141,6 +143,7 @@
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.protobuf.ByteString;

import static org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes;
import static org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.TOKEN_ERROR_OTHER;
import static org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Status.ACCESS_DENIED;
Expand Down Expand Up @@ -717,22 +720,17 @@ public void deleteKey(OmKeyArgs args) throws IOException {
* Deletes existing key/keys. This interface supports delete
* multiple keys and a single key.
*
* @param args the list args of the key.
* @param deleteKeys
* @throws IOException
*/
@Override
public void deleteKeys(List<OmKeyArgs> args) throws IOException {
public void deleteKeys(OmDeleteKeys deleteKeys) throws IOException {
DeleteKeysRequest.Builder req = DeleteKeysRequest.newBuilder();
List <KeyArgs> keyArgsList = new ArrayList<KeyArgs>();
for (OmKeyArgs omKeyArgs : args) {
KeyArgs keyArgs = KeyArgs.newBuilder()
.setVolumeName(omKeyArgs.getVolumeName())
.setBucketName(omKeyArgs.getBucketName())
.setKeyName(omKeyArgs.getKeyName()).build();
keyArgsList.add(keyArgs);
}
req.addAllKeyArgs(keyArgsList);

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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@
public class TestOzoneFileSystem {

/**
* Set a timeout for each test.
*/
* Set a timeout for each test.
*/
@Rule
public Timeout timeout = new Timeout(300000);

Expand All @@ -89,7 +89,7 @@ public class TestOzoneFileSystem {

@Test(timeout = 300_000)
public void testCreateFileShouldCheckExistenceOfDirWithSameName()
throws Exception {
throws Exception {
/*
* Op 1. create file -> /d1/d2/d3/d4/key2
* Op 2. create dir -> /d1/d2/d3/d4/key2
Expand Down Expand Up @@ -195,20 +195,20 @@ public void tearDown() {
}

private void setupOzoneFileSystem()
throws IOException, TimeoutException, InterruptedException {
throws IOException, TimeoutException, InterruptedException {
OzoneConfiguration conf = new OzoneConfiguration();
cluster = MiniOzoneCluster.newBuilder(conf)
.setNumDatanodes(3)
.build();
.setNumDatanodes(3)
.build();
cluster.waitForClusterToBeReady();
// create a volume and a bucket to be used by OzoneFileSystem
OzoneBucket bucket = TestDataUtil.createVolumeAndBucket(cluster);
volumeName = bucket.getVolumeName();
bucketName = bucket.getName();

String rootPath = String.format("%s://%s.%s/",
OzoneConsts.OZONE_URI_SCHEME, bucket.getName(),
bucket.getVolumeName());
OzoneConsts.OZONE_URI_SCHEME, bucket.getName(),
bucket.getVolumeName());

// Set the fs.defaultFS and start the filesystem
conf.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY, rootPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import static org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.DIRECTORY_NOT_FOUND;
import static org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.FILE_ALREADY_EXISTS;
import static org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.NOT_A_FILE;
import static org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.KEY_NOT_FOUND;
import static org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.PARTIAL_DELETE;
import static org.junit.Assert.fail;

/**
Expand Down Expand Up @@ -187,8 +187,9 @@ public void testKeysDelete() throws Exception {
ozoneBucket.deleteKeys(keyList2);
fail("testFilesDelete");
} catch (OMException ex) {
// The expected exception KEY_NOT_FOUND.
Assert.assertEquals(KEY_NOT_FOUND, ex.getResult());
// The expected exception PARTIAL_DELETE, as if not able to delete, we
// return error codee PARTIAL_DElETE.
Assert.assertEquals(PARTIAL_DELETE, ex.getResult());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ enum Status {
DIRECTORY_ALREADY_EXISTS = 60;

INVALID_VOLUME_NAME = 61;

PARTIAL_DELETE = 62;
}

/**
Expand Down Expand Up @@ -845,7 +847,18 @@ message DeleteKeyRequest {
}

message DeleteKeysRequest {
repeated KeyArgs keyArgs = 1;
optional DeleteKeyArgs deleteKeys = 1;
}

message DeleteKeyArgs {
required string volumeName = 1;
required string bucketName = 2;
repeated string keys = 3;
}

message DeleteKeysResponse {
optional DeleteKeyArgs unDeletedKeys = 1;
optional bool status = 2;
}

message DeleteKeyResponse {
Expand All @@ -863,10 +876,7 @@ message DeletedKeys {
repeated string keys = 3;
}

message DeleteKeysResponse {
repeated KeyInfo deletedKeys = 1;
repeated KeyInfo unDeletedKeys = 2;
}


message PurgeKeysRequest {
repeated DeletedKeys deletedKeys = 1;
Expand Down
60 changes: 41 additions & 19 deletions hadoop-ozone/interface-client/src/main/proto/proto.lock
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,10 @@
{
"name": "INVALID_VOLUME_NAME",
"integer": 61
},
{
"name": "PARTIAL_DELETE",
"integer": 62
}
]
},
Expand Down Expand Up @@ -2430,12 +2434,47 @@
"fields": [
{
"id": 1,
"name": "keyArgs",
"type": "KeyArgs",
"name": "deleteKeys",
"type": "DeleteKeyArgs"
}
]
},
{
"name": "DeleteKeyArgs",
"fields": [
{
"id": 1,
"name": "volumeName",
"type": "string"
},
{
"id": 2,
"name": "bucketName",
"type": "string"
},
{
"id": 3,
"name": "keys",
"type": "string",
"is_repeated": true
}
]
},
{
"name": "DeleteKeysResponse",
"fields": [
{
"id": 1,
"name": "unDeletedKeys",
"type": "DeleteKeyArgs"
},
{
"id": 2,
"name": "status",
"type": "bool"
}
]
},
{
"name": "DeleteKeyResponse",
"fields": [
Expand Down Expand Up @@ -2477,23 +2516,6 @@
}
]
},
{
"name": "DeleteKeysResponse",
"fields": [
{
"id": 1,
"name": "deletedKeys",
"type": "KeyInfo",
"is_repeated": true
},
{
"id": 2,
"name": "unDeletedKeys",
"type": "KeyInfo",
"is_repeated": true
}
]
},
{
"name": "PurgeKeysRequest",
"fields": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ public void setNumKeys(long val) {
this.numKeys.incr(val- oldVal);
}

public void decNumKeys(long val) {
this.numKeys.incr(-val);
}

public long getNumVolumes() {
return numVolumes.value();
}
Expand Down
Loading