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();
}
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);
}
}
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();
}
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));
}
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));
}
Aggregations