Java Code Examples for org.apache.hadoop.registry.client.binding.RegistryUtils#statChildren()
The following examples show how to use
org.apache.hadoop.registry.client.binding.RegistryUtils#statChildren() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestRegistryOperations.java From hadoop with Apache License 2.0 | 6 votes |
@Test public void testLsParent() throws Throwable { ServiceRecord written = putExampleServiceEntry(ENTRY_PATH, 0); RegistryPathStatus stat = operations.stat(ENTRY_PATH); List<String> children = operations.list(PARENT_PATH); assertEquals(1, children.size()); assertEquals(NAME, children.get(0)); Map<String, RegistryPathStatus> childStats = RegistryUtils.statChildren(operations, PARENT_PATH); assertEquals(1, childStats.size()); assertEquals(stat, childStats.get(NAME)); Map<String, ServiceRecord> records = RegistryUtils.extractServiceRecords(operations, PARENT_PATH, childStats.values()); assertEquals(1, records.size()); ServiceRecord record = records.get(ENTRY_PATH); RegistryTypeUtils.validateServiceRecord(ENTRY_PATH, record); assertMatches(written, record); }
Example 2
Source File: TestRegistryOperations.java From big-c with Apache License 2.0 | 6 votes |
@Test public void testLsParent() throws Throwable { ServiceRecord written = putExampleServiceEntry(ENTRY_PATH, 0); RegistryPathStatus stat = operations.stat(ENTRY_PATH); List<String> children = operations.list(PARENT_PATH); assertEquals(1, children.size()); assertEquals(NAME, children.get(0)); Map<String, RegistryPathStatus> childStats = RegistryUtils.statChildren(operations, PARENT_PATH); assertEquals(1, childStats.size()); assertEquals(stat, childStats.get(NAME)); Map<String, ServiceRecord> records = RegistryUtils.extractServiceRecords(operations, PARENT_PATH, childStats.values()); assertEquals(1, records.size()); ServiceRecord record = records.get(ENTRY_PATH); RegistryTypeUtils.validateServiceRecord(ENTRY_PATH, record); assertMatches(written, record); }
Example 3
Source File: TestRegistryOperations.java From hadoop with Apache License 2.0 | 5 votes |
@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")); }
Example 4
Source File: TestRegistryOperations.java From big-c with Apache License 2.0 | 5 votes |
@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")); }