Search in sources :

Example 36 with ServiceRecord

use of org.apache.hadoop.registry.client.types.ServiceRecord in project hadoop by apache.

the class TestRegistryOperations method testResolvePathThatHasNoEntry.

@Test
public void testResolvePathThatHasNoEntry() throws Throwable {
    String empty = "/empty2";
    operations.mknode(empty, false);
    try {
        ServiceRecord record = operations.resolve(empty);
        fail("expected an exception, got " + record);
    } catch (NoRecordException expected) {
    // expected
    }
}
Also used : NoRecordException(org.apache.hadoop.registry.client.exceptions.NoRecordException) ServiceRecord(org.apache.hadoop.registry.client.types.ServiceRecord) Test(org.junit.Test) AbstractRegistryTest(org.apache.hadoop.registry.AbstractRegistryTest)

Example 37 with ServiceRecord

use of org.apache.hadoop.registry.client.types.ServiceRecord in project hadoop by apache.

the class TestRegistryOperations method testPutGetContainerPersistenceServiceEntry.

@Test
public void testPutGetContainerPersistenceServiceEntry() throws Throwable {
    String path = ENTRY_PATH;
    ServiceRecord written = buildExampleServiceEntry(PersistencePolicies.CONTAINER);
    operations.mknode(RegistryPathUtils.parentOf(path), true);
    operations.bind(path, written, BindFlags.CREATE);
    ServiceRecord resolved = operations.resolve(path);
    validateEntry(resolved);
    assertMatches(written, resolved);
}
Also used : ServiceRecord(org.apache.hadoop.registry.client.types.ServiceRecord) Test(org.junit.Test) AbstractRegistryTest(org.apache.hadoop.registry.AbstractRegistryTest)

Example 38 with ServiceRecord

use of org.apache.hadoop.registry.client.types.ServiceRecord in project hadoop by apache.

the class TestRegistryOperations method testListListFully.

@Test
public void testListListFully() throws Throwable {
    ServiceRecord r1 = new ServiceRecord();
    ServiceRecord r2 = createRecord("i", PersistencePolicies.PERMANENT, "r2");
    String path = USERPATH + SC_HADOOP + "/listing";
    operations.mknode(path, true);
    String r1path = path + "/r1";
    operations.bind(r1path, r1, 0);
    String r2path = path + "/r2";
    operations.bind(r2path, r2, 0);
    RegistryPathStatus r1stat = operations.stat(r1path);
    assertEquals("r1", r1stat.path);
    RegistryPathStatus r2stat = operations.stat(r2path);
    assertEquals("r2", r2stat.path);
    assertNotEquals(r1stat, r2stat);
    // listings now
    List<String> list = operations.list(path);
    assertEquals("Wrong no. of children", 2, list.size());
    // there's no order here, so create one
    Map<String, String> names = new HashMap<String, String>();
    String entries = "";
    for (String child : list) {
        names.put(child, child);
        entries += child + " ";
    }
    assertTrue("No 'r1' in " + entries, names.containsKey("r1"));
    assertTrue("No 'r2' in " + entries, names.containsKey("r2"));
    Map<String, RegistryPathStatus> stats = RegistryUtils.statChildren(operations, path);
    assertEquals("Wrong no. of children", 2, stats.size());
    assertEquals(r1stat, stats.get("r1"));
    assertEquals(r2stat, stats.get("r2"));
}
Also used : RegistryPathStatus(org.apache.hadoop.registry.client.types.RegistryPathStatus) HashMap(java.util.HashMap) ServiceRecord(org.apache.hadoop.registry.client.types.ServiceRecord) Test(org.junit.Test) AbstractRegistryTest(org.apache.hadoop.registry.AbstractRegistryTest)

Example 39 with ServiceRecord

use of org.apache.hadoop.registry.client.types.ServiceRecord in project hadoop by apache.

the class TestRegistryOperations method testPutNoParent.

@Test
public void testPutNoParent() throws Throwable {
    ServiceRecord record = new ServiceRecord();
    record.set(YarnRegistryAttributes.YARN_ID, "testPutNoParent");
    String path = "/path/without/parent";
    try {
        operations.bind(path, record, 0);
        // didn't get a failure
        // trouble
        RegistryPathStatus stat = operations.stat(path);
        fail("Got a status " + stat);
    } catch (PathNotFoundException expected) {
    // expected
    }
}
Also used : RegistryPathStatus(org.apache.hadoop.registry.client.types.RegistryPathStatus) PathNotFoundException(org.apache.hadoop.fs.PathNotFoundException) ServiceRecord(org.apache.hadoop.registry.client.types.ServiceRecord) Test(org.junit.Test) AbstractRegistryTest(org.apache.hadoop.registry.AbstractRegistryTest)

Example 40 with ServiceRecord

use of org.apache.hadoop.registry.client.types.ServiceRecord in project hadoop by apache.

the class TestRegistryOperations method testPutMinimalRecord.

@Test
public void testPutMinimalRecord() throws Throwable {
    String path = "/path/with/minimal";
    operations.mknode(path, true);
    ServiceRecord record = new ServiceRecord();
    operations.bind(path, record, BindFlags.OVERWRITE);
    ServiceRecord resolve = operations.resolve(path);
    assertMatches(record, resolve);
}
Also used : ServiceRecord(org.apache.hadoop.registry.client.types.ServiceRecord) Test(org.junit.Test) AbstractRegistryTest(org.apache.hadoop.registry.AbstractRegistryTest)

Aggregations

ServiceRecord (org.apache.hadoop.registry.client.types.ServiceRecord)42 Test (org.junit.Test)21 AbstractRegistryTest (org.apache.hadoop.registry.AbstractRegistryTest)14 IOException (java.io.IOException)10 RegistryPathStatus (org.apache.hadoop.registry.client.types.RegistryPathStatus)6 NoRecordException (org.apache.hadoop.registry.client.exceptions.NoRecordException)5 Endpoint (org.apache.hadoop.registry.client.types.Endpoint)5 HashMap (java.util.HashMap)4 ParseException (org.apache.commons.cli.ParseException)4 PathNotFoundException (org.apache.hadoop.fs.PathNotFoundException)4 RegistryTypeUtils.inetAddrEndpoint (org.apache.hadoop.registry.client.binding.RegistryTypeUtils.inetAddrEndpoint)4 RegistryTypeUtils.restEndpoint (org.apache.hadoop.registry.client.binding.RegistryTypeUtils.restEndpoint)4 InvalidRecordException (org.apache.hadoop.registry.client.exceptions.InvalidRecordException)4 URISyntaxException (java.net.URISyntaxException)3 Map (java.util.Map)3 PathIsNotEmptyDirectoryException (org.apache.hadoop.fs.PathIsNotEmptyDirectoryException)3 ZKPathDumper (org.apache.hadoop.registry.client.impl.zk.ZKPathDumper)3 EOFException (java.io.EOFException)2 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)2 URI (java.net.URI)2