Skip to content

Commit dbdc612

Browse files
vivekratnavelbharatviswa504
authored andcommitted
HDDS-2163. Add 'Replication factor' to the output of list keys (#1493)
1 parent efed445 commit dbdc612

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneKey.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,25 @@ public class OzoneKey {
5252

5353
private ReplicationType replicationType;
5454

55+
private int replicationFactor;
56+
5557
/**
5658
* Constructs OzoneKey from OmKeyInfo.
5759
*
5860
*/
61+
@SuppressWarnings("parameternumber")
5962
public OzoneKey(String volumeName, String bucketName,
6063
String keyName, long size, long creationTime,
61-
long modificationTime, ReplicationType type) {
64+
long modificationTime, ReplicationType type,
65+
int replicationFactor) {
6266
this.volumeName = volumeName;
6367
this.bucketName = bucketName;
6468
this.name = keyName;
6569
this.dataSize = size;
6670
this.creationTime = creationTime;
6771
this.modificationTime = modificationTime;
6872
this.replicationType = type;
73+
this.replicationFactor = replicationFactor;
6974
}
7075

7176
/**
@@ -130,4 +135,14 @@ public long getModificationTime() {
130135
public ReplicationType getReplicationType() {
131136
return replicationType;
132137
}
138+
139+
/**
140+
* Returns the replication factor of the key.
141+
*
142+
* @return replicationFactor
143+
*/
144+
public int getReplicationFactor() {
145+
return replicationFactor;
146+
}
147+
133148
}

hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/OzoneKeyDetails.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ public OzoneKeyDetails(String volumeName, String bucketName, String keyName,
4646
long size, long creationTime, long modificationTime,
4747
List<OzoneKeyLocation> ozoneKeyLocations,
4848
ReplicationType type, Map<String, String> metadata,
49-
FileEncryptionInfo feInfo) {
49+
FileEncryptionInfo feInfo, int replicationFactor) {
5050
super(volumeName, bucketName, keyName, size, creationTime,
51-
modificationTime, type);
51+
modificationTime, type, replicationFactor);
5252
this.ozoneKeyLocations = ozoneKeyLocations;
5353
this.metadata = metadata;
5454
this.feInfo = feInfo;

hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/rpc/RpcClient.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,8 @@ public List<OzoneKey> listKeys(String volumeName, String bucketName,
684684
key.getDataSize(),
685685
key.getCreationTime(),
686686
key.getModificationTime(),
687-
ReplicationType.valueOf(key.getType().toString())))
687+
ReplicationType.valueOf(key.getType().toString()),
688+
key.getFactor().getNumber()))
688689
.collect(Collectors.toList());
689690
}
690691

@@ -712,7 +713,7 @@ public OzoneKeyDetails getKeyDetails(
712713
keyInfo.getKeyName(), keyInfo.getDataSize(), keyInfo.getCreationTime(),
713714
keyInfo.getModificationTime(), ozoneKeyLocations, ReplicationType
714715
.valueOf(keyInfo.getType().toString()), keyInfo.getMetadata(),
715-
keyInfo.getFileEncryptionInfo());
716+
keyInfo.getFileEncryptionInfo(), keyInfo.getFactor().getNumber());
716717
}
717718

718719
@Override

hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/client/OzoneBucketStub.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ public void close() throws IOException {
104104
size,
105105
System.currentTimeMillis(),
106106
System.currentTimeMillis(),
107-
new ArrayList<>(), type, metadata, null
107+
new ArrayList<>(), type, metadata, null,
108+
factor.getValue()
108109
));
109110
super.close();
110111
}

0 commit comments

Comments
 (0)