@Test public void testGetDummyClusterManagerValidInstance() throws Exception { ClusterType type = ClusterType.TEST_CLUSTER_MANAGER; ClusterManager manager = bookKeeper.getClusterManagerInstance(type, conf); assertTrue(manager instanceof DummyClusterManager, " Didn't initialize the correct cluster manager class." + " Expected : " + DummyClusterManager.class + " Got : " + manager.getClass()); }
@VisibleForTesting public ClusterManager getClusterManagerInstance(ClusterType clusterType, Configuration config) throws ClusterManagerInitilizationException { String clusterManagerClassName = CacheConfig.getClusterManagerClass(conf, clusterType); log.debug("Initializing cluster manager : " + clusterManagerClassName); ClusterManager manager = null; try { Class clusterManagerClass = conf.getClassByName(clusterManagerClassName); Constructor constructor = clusterManagerClass.getConstructor(); manager = (ClusterManager) constructor.newInstance(); } catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException ex) { String errorMessage = String.format("Not able to initialize ClusterManager class : %s ", clusterManagerClassName); log.error(errorMessage); throw new ClusterManagerInitilizationException(errorMessage, ex); } return manager; }
BookKeeper implements BookKeeperService.Iface { @VisibleForTesting public ClusterManager getClusterManagerInstance(ClusterType clusterType, Configuration config) throws ClusterManagerInitilizationException { String clusterManagerClassName = CacheConfig.getClusterManagerClass(conf, clusterType); log.debug("Initializing cluster manager : " + clusterManagerClassName); ClusterManager manager = null; try { Class clusterManagerClass = conf.getClassByName(clusterManagerClassName); Constructor constructor = clusterManagerClass.getConstructor(); manager = (ClusterManager) constructor.newInstance(); } catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException ex) { String errorMessage = String.format("Not able to initialize ClusterManager class : %s ", clusterManagerClassName); log.error(errorMessage); throw new ClusterManagerInitilizationException(errorMessage, ex); } return manager; } }
BookKeeper implements BookKeeperService.Iface { @VisibleForTesting public ClusterManager getClusterManagerInstance(ClusterType clusterType, Configuration config) throws ClusterManagerInitilizationException { String clusterManagerClassName = CacheConfig.getClusterManagerClass(conf, clusterType); log.debug("Initializing cluster manager : " + clusterManagerClassName); ClusterManager manager = null; try { Class clusterManagerClass = conf.getClassByName(clusterManagerClassName); Constructor constructor = clusterManagerClass.getConstructor(); manager = (ClusterManager) constructor.newInstance(); } catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException ex) { String errorMessage = String.format("Not able to initialize ClusterManager class : %s ", clusterManagerClassName); log.error(errorMessage); throw new ClusterManagerInitilizationException(errorMessage, ex); } return manager; } BookKeeper(Configuration conf, BookKeeperMetrics bookKeeperMetrics); @VisibleForTesting  BookKeeper(Configuration conf, BookKeeperMetrics bookKeeperMetrics, Ticker ticker); }
BookKeeper implements BookKeeperService.Iface { @VisibleForTesting public ClusterManager getClusterManagerInstance(ClusterType clusterType, Configuration config) throws ClusterManagerInitilizationException { String clusterManagerClassName = CacheConfig.getClusterManagerClass(conf, clusterType); log.debug("Initializing cluster manager : " + clusterManagerClassName); ClusterManager manager = null; try { Class clusterManagerClass = conf.getClassByName(clusterManagerClassName); Constructor constructor = clusterManagerClass.getConstructor(); manager = (ClusterManager) constructor.newInstance(); } catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException ex) { String errorMessage = String.format("Not able to initialize ClusterManager class : %s ", clusterManagerClassName); log.error(errorMessage); throw new ClusterManagerInitilizationException(errorMessage, ex); } return manager; } BookKeeper(Configuration conf, BookKeeperMetrics bookKeeperMetrics); @VisibleForTesting  BookKeeper(Configuration conf, BookKeeperMetrics bookKeeperMetrics, Ticker ticker); @Override boolean isBookKeeperAlive(); @Override CacheStatusResponse getCacheStatus(CacheStatusRequest request); boolean isInitialized(); @VisibleForTesting void initializeClusterManager(int clusterType); @VisibleForTesting ClusterManager getClusterManagerInstance(ClusterType clusterType, Configuration config); @Override void setAllCached(String remotePath, long fileLength, long lastModified, long startBlock, long endBlock, int generationNumber); @VisibleForTesting long getTotalCacheWeight(); @Override Map<String, Double> getCacheMetrics(); @Override Map<String, Long> getReadRequestChainStats(); @Override ReadResponse readData(String remotePath, long offset, int length, long fileSize, long lastModified, int clusterType); @Override FileInfo getFileInfo(String remotePath); @VisibleForTesting FileMetadata getFileMetadata(String key); @Override void invalidateFileMetadata(String key); }
BookKeeper implements BookKeeperService.Iface { @VisibleForTesting public ClusterManager getClusterManagerInstance(ClusterType clusterType, Configuration config) throws ClusterManagerInitilizationException { String clusterManagerClassName = CacheConfig.getClusterManagerClass(conf, clusterType); log.debug("Initializing cluster manager : " + clusterManagerClassName); ClusterManager manager = null; try { Class clusterManagerClass = conf.getClassByName(clusterManagerClassName); Constructor constructor = clusterManagerClass.getConstructor(); manager = (ClusterManager) constructor.newInstance(); } catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException ex) { String errorMessage = String.format("Not able to initialize ClusterManager class : %s ", clusterManagerClassName); log.error(errorMessage); throw new ClusterManagerInitilizationException(errorMessage, ex); } return manager; } BookKeeper(Configuration conf, BookKeeperMetrics bookKeeperMetrics); @VisibleForTesting  BookKeeper(Configuration conf, BookKeeperMetrics bookKeeperMetrics, Ticker ticker); @Override boolean isBookKeeperAlive(); @Override CacheStatusResponse getCacheStatus(CacheStatusRequest request); boolean isInitialized(); @VisibleForTesting void initializeClusterManager(int clusterType); @VisibleForTesting ClusterManager getClusterManagerInstance(ClusterType clusterType, Configuration config); @Override void setAllCached(String remotePath, long fileLength, long lastModified, long startBlock, long endBlock, int generationNumber); @VisibleForTesting long getTotalCacheWeight(); @Override Map<String, Double> getCacheMetrics(); @Override Map<String, Long> getReadRequestChainStats(); @Override ReadResponse readData(String remotePath, long offset, int length, long fileSize, long lastModified, int clusterType); @Override FileInfo getFileInfo(String remotePath); @VisibleForTesting FileMetadata getFileMetadata(String key); @Override void invalidateFileMetadata(String key);  }