use of org.apache.hadoop.ozone.client.OzoneKeyDetails in project ozone by apache.
the class TestSCMPipelineBytesWrittenMetrics method writeNumBytes.
private void writeNumBytes(int numBytes) throws Exception {
ObjectStore store = OzoneClientFactory.getRpcClient(conf).getObjectStore();
String volumeName = UUID.randomUUID().toString();
String bucketName = UUID.randomUUID().toString();
String value = RandomStringUtils.randomAlphabetic(numBytes);
store.createVolume(volumeName);
OzoneVolume volume = store.getVolume(volumeName);
volume.createBucket(bucketName);
OzoneBucket bucket = volume.getBucket(bucketName);
String keyName = UUID.randomUUID().toString();
OzoneOutputStream out = bucket.createKey(keyName, value.getBytes(UTF_8).length, ReplicationType.RATIS, ReplicationFactor.THREE, new HashMap<>());
out.write(value.getBytes(UTF_8));
out.close();
OmKeyArgs.Builder builder = new OmKeyArgs.Builder();
builder.setVolumeName(volumeName).setBucketName(bucketName).setKeyName(keyName).setRefreshPipeline(true);
OzoneKeyDetails keyDetails = bucket.getKey(keyName);
Assert.assertEquals(keyName, keyDetails.getName());
Assert.assertEquals(value.getBytes(UTF_8).length, keyDetails.getOzoneKeyLocations().get(0).getLength());
}
Aggregations