Skip to content

Commit 58a756b

Browse files
fix review comments
1 parent 56eef3b commit 58a756b

File tree

14 files changed

+74
-64
lines changed

14 files changed

+74
-64
lines changed

hadoop-hdds/common/src/test/java/org/apache/hadoop/ozone/audit/DummyAction.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public enum DummyAction implements AuditAction {
2424

2525
CREATE_VOLUME,
2626
CREATE_BUCKET,
27-
CREATE_KEY,
2827
READ_VOLUME,
2928
READ_BUCKET,
3029
READ_KEY,

hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/audit/OMAction.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public enum OMAction implements AuditAction {
3030
COMMIT_KEY,
3131
CREATE_VOLUME,
3232
CREATE_BUCKET,
33-
CREATE_KEY,
3433
DELETE_VOLUME,
3534
DELETE_BUCKET,
3635
DELETE_KEY,

hadoop-ozone/common/src/main/proto/OzoneManagerProtocol.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ message CreateKeyRequest {
718718
required KeyArgs keyArgs = 1;
719719
// Set in OM HA during preExecute step. This way all OM's use same ID in
720720
// OM HA.
721-
optional uint64 ID = 2;
721+
optional uint64 clientID = 2;
722722
}
723723

724724
message CreateKeyResponse {

hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,8 @@ public void commitKey(OmKeyArgs args, long clientID) throws IOException {
632632
validateBucket(volumeName, bucketName);
633633
OmKeyInfo keyInfo = metadataManager.getOpenKeyTable().get(openKey);
634634
if (keyInfo == null) {
635-
throw new OMException("Commit a key without corresponding entry " +
636-
openKey, KEY_NOT_FOUND);
635+
throw new OMException("Failed to commit key, as " + openKey + "entry " +
636+
"is not found in the openKey table", KEY_NOT_FOUND);
637637
}
638638
keyInfo.setDataSize(args.getDataSize());
639639
keyInfo.setModificationTime(Time.now());

hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmMetadataManagerImpl.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -473,10 +473,7 @@ public boolean isVolumeEmpty(String volume) throws IOException {
473473
try (TableIterator<String, ? extends KeyValue<String, OmBucketInfo>>
474474
bucketIter = bucketTable.iterator()) {
475475
KeyValue<String, OmBucketInfo> kv = bucketIter.seek(volumePrefix);
476-
// During iteration from DB, check in mean time if this bucket is not
477-
// marked for delete.
478-
if (kv != null && kv.getKey().startsWith(volumePrefix) &&
479-
bucketTable.get(kv.getKey()) != null) {
476+
if (kv != null && kv.getKey().startsWith(volumePrefix)) {
480477
return false; // we found at least one bucket with this volume prefix.
481478
}
482479
}
@@ -512,10 +509,7 @@ public boolean isBucketEmpty(String volume, String bucket)
512509
try (TableIterator<String, ? extends KeyValue<String, OmKeyInfo>> keyIter =
513510
keyTable.iterator()) {
514511
KeyValue<String, OmKeyInfo> kv = keyIter.seek(keyPrefix);
515-
// During iteration from DB, check in mean time if this key is not
516-
// marked for delete.
517-
if (kv != null && kv.getKey().startsWith(keyPrefix) &&
518-
keyTable.get(kv.getKey()) != null) {
512+
if (kv != null && kv.getKey().startsWith(keyPrefix)) {
519513
return false; // we found at least one key with this vol/bucket prefix.
520514
}
521515
}

hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ public final class OzoneManager extends ServiceRuntimeInfoImpl
289289
private final long scmBlockSize;
290290
private final int preallocateBlocksMax;
291291
private final boolean grpcBlockTokenEnabled;
292-
private final boolean useRatis;
292+
private final boolean useRatisForReplication;
293293

294294

295295
private OzoneManager(OzoneConfiguration conf) throws IOException,
@@ -431,16 +431,16 @@ private OzoneManager(OzoneConfiguration conf) throws IOException,
431431
this.grpcBlockTokenEnabled = conf.getBoolean(
432432
HDDS_BLOCK_TOKEN_ENABLED,
433433
HDDS_BLOCK_TOKEN_ENABLED_DEFAULT);
434-
this.useRatis = conf.getBoolean(DFS_CONTAINER_RATIS_ENABLED_KEY,
435-
DFS_CONTAINER_RATIS_ENABLED_DEFAULT);
434+
this.useRatisForReplication = conf.getBoolean(
435+
DFS_CONTAINER_RATIS_ENABLED_KEY, DFS_CONTAINER_RATIS_ENABLED_DEFAULT);
436436
}
437437

438438
/**
439439
* Return configuration value of
440440
* {@link OzoneConfigKeys#DFS_CONTAINER_RATIS_ENABLED_KEY}.
441441
*/
442-
public boolean isUseRatis() {
443-
return useRatis;
442+
public boolean shouldUseRatis() {
443+
return useRatisForReplication;
444444
}
445445

446446
/**

hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerRatisServer.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,13 @@ public void updateServerRole() {
569569
} else if (thisNodeRole.equals(RaftPeerRole.FOLLOWER)) {
570570
ByteString leaderNodeId = roleInfoProto.getFollowerInfo()
571571
.getLeaderInfo().getId().getId();
572-
RaftPeerId leaderPeerId = RaftPeerId.valueOf(leaderNodeId);
572+
// There may be a chance, here we get leaderNodeId as null. For
573+
// example, in 3 node OM Ratis, if 2 OM nodes are down, there will
574+
// be no leader.
575+
RaftPeerId leaderPeerId = null;
576+
if (leaderNodeId != null && !leaderNodeId.isEmpty()) {
577+
leaderPeerId = RaftPeerId.valueOf(leaderNodeId);
578+
}
573579

574580
setServerRole(thisNodeRole, leaderPeerId);
575581

hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMAllocateBlockRequest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager,
187187

188188
OMMetadataManager omMetadataManager = ozoneManager.getMetadataManager();
189189
try {
190-
validateBucket(omMetadataManager, volumeName,
190+
validateBucketAndVolume(omMetadataManager, volumeName,
191191
bucketName);
192192
} catch (IOException ex) {
193193
LOG.error("AllocateBlock failed for Key: {} in volume/bucket:{}/{}",
@@ -210,7 +210,7 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager,
210210
try {
211211
omKeyInfo = omMetadataManager.getOpenKeyTable().get(openKey);
212212
if (omKeyInfo == null) {
213-
throw new OMException("Open Key not found", KEY_NOT_FOUND);
213+
throw new OMException("Open Key not found " + openKey, KEY_NOT_FOUND);
214214
}
215215

216216
// Append new block
@@ -229,11 +229,10 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager,
229229
exception = ex;
230230
}
231231

232-
// Performing audit logging outside of the lock.
233232
auditLog(auditLogger, buildAuditMessage(OMAction.ALLOCATE_BLOCK, auditMap,
234233
exception, getOmRequest().getUserInfo()));
235234

236-
// return response after releasing lock.
235+
237236
if (exception == null) {
238237
omResponse.setAllocateBlockResponse(AllocateBlockResponse.newBuilder()
239238
.setKeyLocation(blockLocation).build());

hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyCommitRequest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,11 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager,
146146
IOException exception = null;
147147
OmKeyInfo omKeyInfo = null;
148148
try {
149-
validateBucket(omMetadataManager, volumeName, bucketName);
149+
validateBucketAndVolume(omMetadataManager, volumeName, bucketName);
150150
omKeyInfo = omMetadataManager.getOpenKeyTable().get(dbOpenKey);
151151
if (omKeyInfo == null) {
152-
throw new OMException("Commit a key without corresponding entry " +
153-
dbOpenKey, KEY_NOT_FOUND);
152+
throw new OMException("Failed to commit key, as " + dbOpenKey +
153+
"entry is not found in the openKey table", KEY_NOT_FOUND);
154154
}
155155
omKeyInfo.setDataSize(commitKeyArgs.getDataSize());
156156

hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyCreateRequest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public OMRequest preExecute(OzoneManager ozoneManager) throws IOException {
9191
// allocateBlock call happen's we shall know type and factor, as we set
9292
// the type and factor read from multipart table, and set the KeyInfo in
9393
// validateAndUpdateCache and return to the client. TODO: See if we can fix
94-
// this.
94+
// this. We do not call allocateBlock in openKey for multipart upload.
9595

9696
CreateKeyRequest.Builder newCreateKeyRequest = null;
9797
KeyArgs.Builder newKeyArgs = null;
@@ -106,7 +106,7 @@ public OMRequest preExecute(OzoneManager ozoneManager) throws IOException {
106106
final long requestedSize = keyArgs.getDataSize() > 0 ?
107107
keyArgs.getDataSize() : scmBlockSize;
108108

109-
boolean useRatis = ozoneManager.isUseRatis();
109+
boolean useRatis = ozoneManager.shouldUseRatis();
110110

111111
HddsProtos.ReplicationFactor factor = keyArgs.getFactor();
112112
if (factor == null) {
@@ -145,7 +145,7 @@ public OMRequest preExecute(OzoneManager ozoneManager) throws IOException {
145145

146146
newCreateKeyRequest =
147147
createKeyRequest.toBuilder().setKeyArgs(newKeyArgs)
148-
.setID(UniqueId.next());
148+
.setClientID(UniqueId.next());
149149

150150
return getOmRequest().toBuilder()
151151
.setCreateKeyRequest(newCreateKeyRequest).setUserInfo(getUserInfo())
@@ -196,7 +196,7 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager,
196196

197197
OMMetadataManager omMetadataManager = ozoneManager.getMetadataManager();
198198
String dbOpenKeyName = omMetadataManager.getOpenKey(volumeName,
199-
bucketName, keyName, createKeyRequest.getID());
199+
bucketName, keyName, createKeyRequest.getClientID());
200200
String dbKeyName = omMetadataManager.getOzoneKey(volumeName, bucketName,
201201
keyName);
202202
String dbBucketKey = omMetadataManager.getBucketKey(volumeName, bucketName);
@@ -208,7 +208,7 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager,
208208
IOException exception = null;
209209
omMetadataManager.getLock().acquireBucketLock(volumeName, bucketName);
210210
try {
211-
validateBucket(omMetadataManager, volumeName, bucketName);
211+
validateBucketAndVolume(omMetadataManager, volumeName, bucketName);
212212
//TODO: We can optimize this get here, if getKmsProvider is null, then
213213
// bucket encryptionInfo will be not set. If this assumption holds
214214
// true, we can avoid get from bucket table.
@@ -265,7 +265,7 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager,
265265
auditLog(auditLogger, buildAuditMessage(OMAction.ALLOCATE_KEY, auditMap,
266266
exception, getOmRequest().getUserInfo()));
267267

268-
long clientID = createKeyRequest.getID();
268+
long clientID = createKeyRequest.getClientID();
269269

270270
omResponse.setCreateKeyResponse(CreateKeyResponse.newBuilder()
271271
.setKeyInfo(omKeyInfo.getProtobuf())

0 commit comments

Comments
 (0)