Search in sources :

Example 1 with OzoneClient

use of org.apache.hadoop.ozone.client.OzoneClient in project ozone by apache.

the class TestReplicatedFileChecksumHelper method init.

@Before
public void init() throws IOException {
    ConfigurationSource config = new InMemoryConfiguration();
    rpcClient = new RpcClient(config, null) {

        @Override
        protected OmTransport createOmTransport(String omServiceId) throws IOException {
            return new MockOmTransport();
        }

        @NotNull
        @Override
        protected XceiverClientFactory createXceiverClientFactory(List<X509Certificate> x509Certificates) throws IOException {
            return new MockXceiverClientFactory();
        }
    };
    client = new OzoneClient(config, rpcClient);
    store = client.getObjectStore();
}
Also used : ConfigurationSource(org.apache.hadoop.hdds.conf.ConfigurationSource) MockOmTransport(org.apache.hadoop.ozone.client.MockOmTransport) MockOmTransport(org.apache.hadoop.ozone.client.MockOmTransport) OmTransport(org.apache.hadoop.ozone.om.protocolPB.OmTransport) ByteString(org.apache.ratis.thirdparty.com.google.protobuf.ByteString) IOException(java.io.IOException) OzoneClient(org.apache.hadoop.ozone.client.OzoneClient) MockXceiverClientFactory(org.apache.hadoop.ozone.client.MockXceiverClientFactory) XceiverClientFactory(org.apache.hadoop.hdds.scm.XceiverClientFactory) NotNull(org.jetbrains.annotations.NotNull) X509Certificate(java.security.cert.X509Certificate) MockXceiverClientFactory(org.apache.hadoop.ozone.client.MockXceiverClientFactory) InMemoryConfiguration(org.apache.hadoop.hdds.conf.InMemoryConfiguration) RpcClient(org.apache.hadoop.ozone.client.rpc.RpcClient) Before(org.junit.Before)

Example 2 with OzoneClient

use of org.apache.hadoop.ozone.client.OzoneClient in project ozone by apache.

the class TestOzoneManagerHAMetadataOnly method testOMProxyProviderInitialization.

/**
 * Test that OMFailoverProxyProvider creates an OM proxy for each OM in the
 * cluster.
 */
@Test
public void testOMProxyProviderInitialization() throws Exception {
    OzoneClient rpcClient = getCluster().getRpcClient();
    OMFailoverProxyProvider omFailoverProxyProvider = OmFailoverProxyUtil.getFailoverProxyProvider(rpcClient.getObjectStore().getClientProxy());
    List<OMProxyInfo> omProxies = omFailoverProxyProvider.getOMProxyInfos();
    Assert.assertEquals(getNumOfOMs(), omProxies.size());
    for (int i = 0; i < getNumOfOMs(); i++) {
        InetSocketAddress omRpcServerAddr = getCluster().getOzoneManager(i).getOmRpcServerAddr();
        boolean omClientProxyExists = false;
        for (OMProxyInfo omProxyInfo : omProxies) {
            if (omProxyInfo.getAddress().equals(omRpcServerAddr)) {
                omClientProxyExists = true;
                break;
            }
        }
        Assert.assertTrue("There is no OM Client Proxy corresponding to OM " + "node" + getCluster().getOzoneManager(i).getOMNodeId(), omClientProxyExists);
    }
}
Also used : OMFailoverProxyProvider(org.apache.hadoop.ozone.om.ha.OMFailoverProxyProvider) OMProxyInfo(org.apache.hadoop.ozone.om.ha.OMProxyInfo) InetSocketAddress(java.net.InetSocketAddress) OzoneClient(org.apache.hadoop.ozone.client.OzoneClient) Test(org.junit.Test)

Example 3 with OzoneClient

use of org.apache.hadoop.ozone.client.OzoneClient in project ozone by apache.

the class TestOzoneManagerListVolumes method setupClass.

/**
 * Create a MiniDFSCluster for testing.
 */
@BeforeClass
public static void setupClass() throws InterruptedException, TimeoutException, IOException {
    OzoneConfiguration conf = new OzoneConfiguration();
    UserGroupInformation.setLoginUser(adminUser);
    String clusterId = UUID.randomUUID().toString();
    String scmId = UUID.randomUUID().toString();
    String omId = UUID.randomUUID().toString();
    conf.setInt(OZONE_OPEN_KEY_EXPIRE_THRESHOLD_SECONDS, 2);
    conf.setInt(OZONE_SCM_RATIS_PIPELINE_LIMIT, 10);
    // Use native impl here, default impl doesn't do actual checks
    conf.set(OZONE_ACL_AUTHORIZER_CLASS, OZONE_ACL_AUTHORIZER_CLASS_NATIVE);
    cluster = MiniOzoneCluster.newBuilder(conf).withoutDatanodes().setClusterId(clusterId).setScmId(scmId).setOmId(omId).build();
    cluster.waitForClusterToBeReady();
    // Create volumes with non-default owners and ACLs
    OzoneClient client = cluster.getClient();
    ObjectStore objectStore = client.getObjectStore();
    /* r = READ, w = WRITE, c = CREATE, d = DELETE
       l = LIST, a = ALL, n = NONE, x = READ_ACL, y = WRITE_ACL */
    String aclUser1All = "user:user1:a";
    String aclUser2All = "user:user2:a";
    String aclWorldAll = "world::a";
    createVolumeWithOwnerAndAcl(objectStore, "volume1", "user1", aclUser1All);
    createVolumeWithOwnerAndAcl(objectStore, "volume2", "user2", aclUser2All);
    createVolumeWithOwnerAndAcl(objectStore, "volume3", "user1", aclUser2All);
    createVolumeWithOwnerAndAcl(objectStore, "volume4", "user2", aclUser1All);
    createVolumeWithOwnerAndAcl(objectStore, "volume5", "user1", aclWorldAll);
    OzoneManager om = cluster.getOzoneManager();
    om.stop();
    om.join();
}
Also used : ObjectStore(org.apache.hadoop.ozone.client.ObjectStore) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) OzoneClient(org.apache.hadoop.ozone.client.OzoneClient) BeforeClass(org.junit.BeforeClass)

Example 4 with OzoneClient

use of org.apache.hadoop.ozone.client.OzoneClient in project ozone by apache.

the class TestOzoneManagerRestart method testRestartOMWithVolumeOperation.

@Test
public void testRestartOMWithVolumeOperation() throws Exception {
    String volumeName = "volume" + RandomStringUtils.randomNumeric(5);
    OzoneClient client = cluster.getClient();
    ObjectStore objectStore = client.getObjectStore();
    objectStore.createVolume(volumeName);
    OzoneVolume ozoneVolume = objectStore.getVolume(volumeName);
    Assert.assertTrue(ozoneVolume.getName().equals(volumeName));
    cluster.restartOzoneManager();
    cluster.restartStorageContainerManager(true);
    // After restart, try to create same volume again, it should fail.
    try {
        objectStore.createVolume(volumeName);
        fail("testRestartOM failed");
    } catch (IOException ex) {
        GenericTestUtils.assertExceptionContains("VOLUME_ALREADY_EXISTS", ex);
    }
    // Get Volume.
    ozoneVolume = objectStore.getVolume(volumeName);
    Assert.assertTrue(ozoneVolume.getName().equals(volumeName));
}
Also used : OzoneVolume(org.apache.hadoop.ozone.client.OzoneVolume) ObjectStore(org.apache.hadoop.ozone.client.ObjectStore) OzoneClient(org.apache.hadoop.ozone.client.OzoneClient) IOException(java.io.IOException) Test(org.junit.Test)

Example 5 with OzoneClient

use of org.apache.hadoop.ozone.client.OzoneClient in project ozone by apache.

the class TestOzoneManagerRestart method testRestartOMWithBucketOperation.

@Test
public void testRestartOMWithBucketOperation() throws Exception {
    String volumeName = "volume" + RandomStringUtils.randomNumeric(5);
    String bucketName = "bucket" + RandomStringUtils.randomNumeric(5);
    OzoneClient client = cluster.getClient();
    ObjectStore objectStore = client.getObjectStore();
    objectStore.createVolume(volumeName);
    OzoneVolume ozoneVolume = objectStore.getVolume(volumeName);
    Assert.assertTrue(ozoneVolume.getName().equals(volumeName));
    ozoneVolume.createBucket(bucketName);
    OzoneBucket ozoneBucket = ozoneVolume.getBucket(bucketName);
    Assert.assertTrue(ozoneBucket.getName().equals(bucketName));
    cluster.restartOzoneManager();
    cluster.restartStorageContainerManager(true);
    // After restart, try to create same bucket again, it should fail.
    try {
        ozoneVolume.createBucket(bucketName);
        fail("testRestartOMWithBucketOperation failed");
    } catch (IOException ex) {
        GenericTestUtils.assertExceptionContains("BUCKET_ALREADY_EXISTS", ex);
    }
    // Get bucket.
    ozoneBucket = ozoneVolume.getBucket(bucketName);
    Assert.assertTrue(ozoneBucket.getName().equals(bucketName));
}
Also used : OzoneVolume(org.apache.hadoop.ozone.client.OzoneVolume) OzoneBucket(org.apache.hadoop.ozone.client.OzoneBucket) ObjectStore(org.apache.hadoop.ozone.client.ObjectStore) OzoneClient(org.apache.hadoop.ozone.client.OzoneClient) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

OzoneClient (org.apache.hadoop.ozone.client.OzoneClient)62 Test (org.junit.Test)43 ObjectStore (org.apache.hadoop.ozone.client.ObjectStore)30 OzoneVolume (org.apache.hadoop.ozone.client.OzoneVolume)23 OzoneBucket (org.apache.hadoop.ozone.client.OzoneBucket)22 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)17 OzoneOutputStream (org.apache.hadoop.ozone.client.io.OzoneOutputStream)11 OzoneClientStub (org.apache.hadoop.ozone.client.OzoneClientStub)10 OMException (org.apache.hadoop.ozone.om.exceptions.OMException)9 BucketArgs (org.apache.hadoop.ozone.client.BucketArgs)6 IOException (java.io.IOException)5 HttpHeaders (javax.ws.rs.core.HttpHeaders)5 Response (javax.ws.rs.core.Response)4 OmKeyArgs (org.apache.hadoop.ozone.om.helpers.OmKeyArgs)4 OmKeyInfo (org.apache.hadoop.ozone.om.helpers.OmKeyInfo)4 BeforeClass (org.junit.BeforeClass)4 OzoneKey (org.apache.hadoop.ozone.client.OzoneKey)3 Before (org.junit.Before)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 File (java.io.File)2