/** * Extract all service records under a list of stat operations...this * non-atomic action skips entries that are too short or simply not matching. * <p> * @param operations operation support for fetches * @param parentpath path of the parent of all the entries * @return a possibly empty map of fullpath:record. * @throws IOException for any IO Operation that wasn't ignored. */ public static Map<String, ServiceRecord> extractServiceRecords( RegistryOperations operations, String parentpath) throws IOException { return extractServiceRecords(operations, parentpath, statChildren(operations, parentpath).values()); }
/** * Extract all service records under a list of stat operations...this * non-atomic action skips entries that are too short or simply not matching. * <p> * @param operations operation support for fetches * @param parentpath path of the parent of all the entries * @return a possibly empty map of fullpath:record. * @throws IOException for any IO Operation that wasn't ignored. */ public static Map<String, ServiceRecord> extractServiceRecords( RegistryOperations operations, String parentpath) throws IOException { return extractServiceRecords(operations, parentpath, statChildren(operations, parentpath).values()); }
/** * List service records directly under a path * @param registryOperations registry operations instance * @param path path to list * @return a mapping of the service records that were resolved, indexed * by their full path * @throws IOException */ public static Map<String, ServiceRecord> listServiceRecords( RegistryOperations registryOperations, String path) throws IOException { Map<String, RegistryPathStatus> children = statChildren(registryOperations, path); return extractServiceRecords(registryOperations, path, children.values()); }
/** * List service records directly under a path * @param registryOperations registry operations instance * @param path path to list * @return a mapping of the service records that were resolved, indexed * by their full path * @throws IOException */ public static Map<String, ServiceRecord> listServiceRecords( RegistryOperations registryOperations, String path) throws IOException { Map<String, RegistryPathStatus> children = statChildren(registryOperations, path); return extractServiceRecords(registryOperations, path, children.values()); }
try { childEntries = RegistryUtils.statChildren(this, path); entries = childEntries.values(); } catch (PathNotFoundException e) {
try { childEntries = RegistryUtils.statChildren(this, path); entries = childEntries.values(); } catch (PathNotFoundException e) {
Map<String, RegistryPathStatus> znodes; try { znodes = statChildren(registryOperations, path); recordMap = extractServiceRecords(registryOperations, path,
Map<String, RegistryPathStatus> znodes; try { znodes = statChildren(registryOperations, path); recordMap = extractServiceRecords(registryOperations, path,
@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); }
@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); }
RegistryUtils.statChildren(operations, path); assertEquals("Wrong no. of children", 2, stats.size()); assertEquals(r1stat, stats.get("r1"));
RegistryUtils.statChildren(operations, path); assertEquals("Wrong no. of children", 2, stats.size()); assertEquals(r1stat, stats.get("r1"));
RegistryUtils.statChildren(operations, componentsPath); assertEquals(2, children.size()); Collection<RegistryPathStatus> RegistryUtils.statChildren(operations, componentsPath); assertEquals(3, childrenUpdated.size());