use of org.apache.hadoop.ozone.client.OzoneKey in project ozone by apache.
the class TestListKeysWithFSO method checkKeyList.
private void checkKeyList(String keyPrefix, String startKey, List<String> keys) throws Exception {
Iterator<? extends OzoneKey> ozoneKeyIterator = fsoOzoneBucket.listKeys(keyPrefix, startKey);
TreeSet<String> outputKeys = new TreeSet<>();
while (ozoneKeyIterator.hasNext()) {
OzoneKey ozoneKey = ozoneKeyIterator.next();
outputKeys.add(ozoneKey.getName());
}
LinkedList outputKeysList = new LinkedList(outputKeys);
System.out.println("BEGIN:::keyPrefix---> " + keyPrefix + ":::---> " + startKey);
for (String key : keys) {
System.out.println(" " + key);
}
System.out.println("END:::keyPrefix---> " + keyPrefix + ":::---> " + startKey);
Assert.assertEquals(keys, outputKeysList);
}
use of org.apache.hadoop.ozone.client.OzoneKey in project ozone by apache.
the class TestListKeysWithFSO method getExpectedKeyList.
private static List<String> getExpectedKeyList(String keyPrefix, String startKey) throws Exception {
Iterator<? extends OzoneKey> ozoneKeyIterator = legacyOzoneBucket.listKeys(keyPrefix, startKey);
List<String> keys = new LinkedList<>();
while (ozoneKeyIterator.hasNext()) {
OzoneKey ozoneKey = ozoneKeyIterator.next();
keys.add(ozoneKey.getName());
}
return keys;
}
use of org.apache.hadoop.ozone.client.OzoneKey in project ozone by apache.
the class TestObjectStoreWithFSO method checkKeyList.
private void checkKeyList(Iterator<? extends OzoneKey> ozoneKeyIterator, List<String> keys) {
LinkedList<String> outputKeys = new LinkedList<>();
while (ozoneKeyIterator.hasNext()) {
OzoneKey ozoneKey = ozoneKeyIterator.next();
outputKeys.add(ozoneKey.getName());
}
Assert.assertEquals(keys, outputKeys);
}
use of org.apache.hadoop.ozone.client.OzoneKey in project ozone by apache.
the class TestObjectStoreWithFSO method testRenameKey.
@Test
public void testRenameKey() throws IOException {
String fromKeyName = UUID.randomUUID().toString();
String value = "sample value";
OzoneClient client = cluster.getClient();
ObjectStore objectStore = client.getObjectStore();
OzoneVolume volume = objectStore.getVolume(volumeName);
OzoneBucket bucket = volume.getBucket(bucketName);
createTestKey(bucket, fromKeyName, value);
// Rename to empty string should fail.
String toKeyName = "";
try {
bucket.renameKey(fromKeyName, toKeyName);
fail("Rename to empty string should fail!");
} catch (OMException ome) {
Assert.assertEquals(OMException.ResultCodes.INVALID_KEY_NAME, ome.getResult());
}
toKeyName = UUID.randomUUID().toString();
bucket.renameKey(fromKeyName, toKeyName);
// Lookup for old key should fail.
try {
bucket.getKey(fromKeyName);
fail("Lookup for old from key name should fail!");
} catch (OMException ome) {
Assert.assertEquals(KEY_NOT_FOUND, ome.getResult());
}
OzoneKey key = bucket.getKey(toKeyName);
Assert.assertEquals(toKeyName, key.getName());
}
use of org.apache.hadoop.ozone.client.OzoneKey in project ozone by apache.
the class TestObjectStoreWithFSO method createTestKey.
private void createTestKey(OzoneBucket bucket, String keyName, String keyValue) throws IOException {
OzoneOutputStream out = bucket.createKey(keyName, keyValue.getBytes(StandardCharsets.UTF_8).length, RATIS, ONE, new HashMap<>());
out.write(keyValue.getBytes(StandardCharsets.UTF_8));
out.close();
OzoneKey key = bucket.getKey(keyName);
Assert.assertEquals(keyName, key.getName());
}
Aggregations