@Test(expected = RedirectorDataSourceException.class) public void testGetNodeIdToDataMapDoNotUseCacheException() throws Exception { testee = new ZkPathChildrenCacheWrapper(client, "/test", true, null); when(client.getChildren("/test")).thenThrow(new RedirectorDataSourceException("test")); testee.getNodeIdToDataMap(); }
@Override public Map<String, byte[]> getNodeIdToDataMap() throws DataSourceConnectorException { Map<String, byte[]> result = new HashMap<>(); if (isCacheUsageAllowed()) { for (ChildData childData : cache.getCurrentData()) { String nodeId = getRuleId(childData.getPath()); result.put(nodeId, childData.getData()); } } else { List<String> children = connector.getChildren(path); for ( String child : children ) { String fullPath = ZKPaths.makePath(path, child); String nodeId = getRuleId(fullPath); byte[] bytes = getBytesForPath(fullPath); if (bytes != null) { result.put(nodeId, bytes); } else { log.info("ignoring null data for zkPath={}", fullPath); } } } return result; }
ZkPathChildrenCacheWrapper extends BaseCacheWrapper implements IPathChildrenCacheWrapper { @Override public Map<String, byte[]> getNodeIdToDataMap() throws DataSourceConnectorException { Map<String, byte[]> result = new HashMap<>(); if (isCacheUsageAllowed()) { for (ChildData childData : cache.getCurrentData()) { String nodeId = getRuleId(childData.getPath()); result.put(nodeId, childData.getData()); } } else { List<String> children = connector.getChildren(path); for ( String child : children ) { String fullPath = ZKPaths.makePath(path, child); String nodeId = getRuleId(fullPath); byte[] bytes = getBytesForPath(fullPath); if (bytes != null) { result.put(nodeId, bytes); } else { log.info("ignoring null data for zkPath={}", fullPath); } } } return result; } }
ZkPathChildrenCacheWrapper extends BaseCacheWrapper implements IPathChildrenCacheWrapper { @Override public Map<String, byte[]> getNodeIdToDataMap() throws DataSourceConnectorException { Map<String, byte[]> result = new HashMap<>(); if (isCacheUsageAllowed()) { for (ChildData childData : cache.getCurrentData()) { String nodeId = getRuleId(childData.getPath()); result.put(nodeId, childData.getData()); } } else { List<String> children = connector.getChildren(path); for ( String child : children ) { String fullPath = ZKPaths.makePath(path, child); String nodeId = getRuleId(fullPath); byte[] bytes = getBytesForPath(fullPath); if (bytes != null) { result.put(nodeId, bytes); } else { log.info("ignoring null data for zkPath={}", fullPath); } } } return result; } ZkPathChildrenCacheWrapper(IDataSourceConnector connector,
                                      String path,
                                      boolean dataIsCompressed,
                                      PathChildrenCache cache); }
ZkPathChildrenCacheWrapper extends BaseCacheWrapper implements IPathChildrenCacheWrapper { @Override public Map<String, byte[]> getNodeIdToDataMap() throws DataSourceConnectorException { Map<String, byte[]> result = new HashMap<>(); if (isCacheUsageAllowed()) { for (ChildData childData : cache.getCurrentData()) { String nodeId = getRuleId(childData.getPath()); result.put(nodeId, childData.getData()); } } else { List<String> children = connector.getChildren(path); for ( String child : children ) { String fullPath = ZKPaths.makePath(path, child); String nodeId = getRuleId(fullPath); byte[] bytes = getBytesForPath(fullPath); if (bytes != null) { result.put(nodeId, bytes); } else { log.info("ignoring null data for zkPath={}", fullPath); } } } return result; } ZkPathChildrenCacheWrapper(IDataSourceConnector connector,
                                      String path,
                                      boolean dataIsCompressed,
                                      PathChildrenCache cache); @Override void start(final PathChildrenCache.StartMode startMode); @Override void addListener(PathChildrenCacheListener listener); @Override void rebuild(); @Override void close(); @Override void rebuildNode(final String path); @Override Map<String, byte[]> getNodeIdToDataMap(); @Override byte[] getCurrentData(String fullPath); boolean isUseCache(); }
ZkPathChildrenCacheWrapper extends BaseCacheWrapper implements IPathChildrenCacheWrapper { @Override public Map<String, byte[]> getNodeIdToDataMap() throws DataSourceConnectorException { Map<String, byte[]> result = new HashMap<>(); if (isCacheUsageAllowed()) { for (ChildData childData : cache.getCurrentData()) { String nodeId = getRuleId(childData.getPath()); result.put(nodeId, childData.getData()); } } else { List<String> children = connector.getChildren(path); for ( String child : children ) { String fullPath = ZKPaths.makePath(path, child); String nodeId = getRuleId(fullPath); byte[] bytes = getBytesForPath(fullPath); if (bytes != null) { result.put(nodeId, bytes); } else { log.info("ignoring null data for zkPath={}", fullPath); } } } return result; } ZkPathChildrenCacheWrapper(IDataSourceConnector connector,
                                      String path,
                                      boolean dataIsCompressed,
                                      PathChildrenCache cache); @Override void start(final PathChildrenCache.StartMode startMode); @Override void addListener(PathChildrenCacheListener listener); @Override void rebuild(); @Override void close(); @Override void rebuildNode(final String path); @Override Map<String, byte[]> getNodeIdToDataMap(); @Override byte[] getCurrentData(String fullPath); boolean isUseCache();  }