Search in sources :

Example 1 with KeyArgs

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();
}
Also used : KeyInfo(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyInfo) KeyArgs(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyArgs)

Example 2 with KeyArgs

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;
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) KeyArgs(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyArgs)

Example 3 with KeyArgs

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()));
    });
}
Also used : OmMetadataManagerImpl(org.apache.hadoop.ozone.om.OmMetadataManagerImpl) OMClientRequest(org.apache.hadoop.ozone.om.request.OMClientRequest) AuditMessage(org.apache.hadoop.ozone.audit.AuditMessage) AuditLogger(org.apache.hadoop.ozone.audit.AuditLogger) OzoneManager(org.apache.hadoop.ozone.om.OzoneManager) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) KeyArgs(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyArgs) ResolvedBucket(org.apache.hadoop.ozone.om.ResolvedBucket) Before(org.junit.Before)

Example 4 with KeyArgs

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();
}
Also used : OzoneManagerProtocolProtos(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos) CreateKeyRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateKeyRequest) KeyArgs(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyArgs)

Example 5 with KeyArgs

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);
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) OMClientResponse(org.apache.hadoop.ozone.om.response.OMClientResponse) OmKeyInfo(org.apache.hadoop.ozone.om.helpers.OmKeyInfo) KeyArgs(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyArgs) Test(org.junit.Test)

Aggregations

KeyArgs (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyArgs)63 OmKeyInfo (org.apache.hadoop.ozone.om.helpers.OmKeyInfo)21 OMRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest)21 IOException (java.io.IOException)19 OMClientResponse (org.apache.hadoop.ozone.om.response.OMClientResponse)19 OMResponse (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse)18 OMException (org.apache.hadoop.ozone.om.exceptions.OMException)17 OmKeyArgs (org.apache.hadoop.ozone.om.helpers.OmKeyArgs)17 OmKeyLocationInfo (org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo)17 OMMetadataManager (org.apache.hadoop.ozone.om.OMMetadataManager)16 OmBucketInfo (org.apache.hadoop.ozone.om.helpers.OmBucketInfo)13 DeleteKeyArgs (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteKeyArgs)13 ArrayList (java.util.ArrayList)11 OMMetrics (org.apache.hadoop.ozone.om.OMMetrics)11 AuditLogger (org.apache.hadoop.ozone.audit.AuditLogger)9 OzoneManagerProtocolProtos (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos)8 CommitKeyRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CommitKeyRequest)8 AllocateBlockRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.AllocateBlockRequest)7 CreateKeyRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.CreateKeyRequest)7 RenameKeyRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.RenameKeyRequest)7