use of org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyArgs in project ozone by apache.
the class MockOmTransport method commitKey.
private CommitKeyResponse commitKey(CommitKeyRequest commitKeyRequest) {
final KeyArgs keyArgs = commitKeyRequest.getKeyArgs();
final KeyInfo remove = openKeys.get(keyArgs.getVolumeName()).get(keyArgs.getBucketName()).remove(keyArgs.getKeyName());
keys.get(keyArgs.getVolumeName()).get(keyArgs.getBucketName()).put(keyArgs.getKeyName(), remove);
return CommitKeyResponse.newBuilder().build();
}
use of org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyArgs in project ozone by apache.
the class TestOMKeyCommitRequest method doPreExecute.
/**
* This method calls preExecute and verify the modified request.
* @param originalOMRequest
* @return OMRequest - modified request returned from preExecute.
* @throws Exception
*/
private OMRequest doPreExecute(OMRequest originalOMRequest) throws Exception {
OMKeyCommitRequest omKeyCommitRequest = getOmKeyCommitRequest(originalOMRequest);
OMRequest modifiedOmRequest = omKeyCommitRequest.preExecute(ozoneManager);
Assert.assertTrue(modifiedOmRequest.hasCommitKeyRequest());
KeyArgs originalKeyArgs = originalOMRequest.getCommitKeyRequest().getKeyArgs();
KeyArgs modifiedKeyArgs = modifiedOmRequest.getCommitKeyRequest().getKeyArgs();
verifyKeyArgs(originalKeyArgs, modifiedKeyArgs);
return modifiedOmRequest;
}
use of org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyArgs in project ozone by apache.
the class TestS3MultipartRequest method setup.
@Before
public void setup() throws Exception {
ozoneManager = Mockito.mock(OzoneManager.class);
omMetrics = OMMetrics.create();
OzoneConfiguration ozoneConfiguration = new OzoneConfiguration();
ozoneConfiguration.set(OMConfigKeys.OZONE_OM_DB_DIRS, folder.newFolder().getAbsolutePath());
omMetadataManager = new OmMetadataManagerImpl(ozoneConfiguration);
when(ozoneManager.getMetrics()).thenReturn(omMetrics);
when(ozoneManager.getMetadataManager()).thenReturn(omMetadataManager);
auditLogger = Mockito.mock(AuditLogger.class);
when(ozoneManager.getAuditLogger()).thenReturn(auditLogger);
Mockito.doNothing().when(auditLogger).logWrite(any(AuditMessage.class));
when(ozoneManager.resolveBucketLink(any(KeyArgs.class), any(OMClientRequest.class))).thenAnswer(inv -> {
KeyArgs args = (KeyArgs) inv.getArguments()[0];
return new ResolvedBucket(Pair.of(args.getVolumeName(), args.getBucketName()), Pair.of(args.getVolumeName(), args.getBucketName()));
});
}
use of org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyArgs in project ozone by apache.
the class TestOMKeyCreateRequest method createKeyRequest.
private OMRequest createKeyRequest(boolean isMultipartKey, int partNumber, String keyName) {
KeyArgs.Builder keyArgs = KeyArgs.newBuilder().setVolumeName(volumeName).setBucketName(bucketName).setKeyName(keyName).setIsMultipartKey(isMultipartKey).setFactor(replicationFactor).setType(replicationType).setLatestVersionLocation(true);
if (isMultipartKey) {
keyArgs.setDataSize(dataSize).setMultipartNumber(partNumber);
}
OzoneManagerProtocolProtos.CreateKeyRequest createKeyRequest = CreateKeyRequest.newBuilder().setKeyArgs(keyArgs).build();
return OMRequest.newBuilder().setCmdType(OzoneManagerProtocolProtos.Type.CreateKey).setClientId(UUID.randomUUID().toString()).setCreateKeyRequest(createKeyRequest).build();
}
use of org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyArgs in project ozone by apache.
the class TestOMKeyRenameRequest method testValidateAndUpdateCache.
@Test
public void testValidateAndUpdateCache() throws Exception {
String toKeyName = UUID.randomUUID().toString();
OMRequest modifiedOmRequest = doPreExecute(createRenameKeyRequest(toKeyName));
OMRequestTestUtils.addVolumeAndBucketToDB(volumeName, bucketName, omMetadataManager);
OMRequestTestUtils.addKeyToTable(false, volumeName, bucketName, keyName, clientID, replicationType, replicationFactor, omMetadataManager);
OMKeyRenameRequest omKeyRenameRequest = new OMKeyRenameRequest(modifiedOmRequest);
OMClientResponse omKeyRenameResponse = omKeyRenameRequest.validateAndUpdateCache(ozoneManager, 100L, ozoneManagerDoubleBufferHelper);
Assert.assertEquals(OzoneManagerProtocolProtos.Status.OK, omKeyRenameResponse.getOMResponse().getStatus());
String key = omMetadataManager.getOzoneKey(volumeName, bucketName, keyName);
// Original key should be deleted, toKey should exist.
OmKeyInfo omKeyInfo = omMetadataManager.getKeyTable(getBucketLayout()).get(key);
Assert.assertNull(omKeyInfo);
omKeyInfo = omMetadataManager.getKeyTable(getBucketLayout()).get(omMetadataManager.getOzoneKey(volumeName, bucketName, toKeyName));
Assert.assertNotNull(omKeyInfo);
// For new key modification time should be updated.
KeyArgs keyArgs = modifiedOmRequest.getRenameKeyRequest().getKeyArgs();
Assert.assertEquals(keyArgs.getModificationTime(), omKeyInfo.getModificationTime());
// KeyName should be updated in OmKeyInfo to toKeyName.
Assert.assertEquals(omKeyInfo.getKeyName(), toKeyName);
}
Aggregations