@Override public DatabaseClient getPrimaryClient() { return getMoveMgr().getPrimaryClient(); }
@Override public DatabaseClient getPrimaryClient() { return ((DataMovementManagerImpl) getMoveMgr()).getPrimaryClient(); }
private synchronized void calucluateDeltas(Set<Forest> oldForests, Forest[] forests) { // the forests we haven't known about yet Set<Forest> addedForests = new HashSet<>(); // the forests that we knew about but they were black-listed and are no longer black-listed Set<Forest> restartedForests = new HashSet<>(); // any known forest might now be black-listed Set<Forest> blackListedForests = new HashSet<>(oldForests); for ( Forest forest : forests ) { if ( ! oldForests.contains(forest) ) { // we need to do special handling since we're adding this new forest after we're started addedForests.add(forest); } // if we have blackListedTasks for this forest, let's restart them if ( blackListedTasks.get(forest) != null ) restartedForests.add(forest); // this forest is not black-listed blackListedForests.remove(forest); } if ( blackListedForests.size() > 0 ) { DataMovementManagerImpl moveMgrImpl = getMoveMgr(); String primaryHost = moveMgrImpl.getPrimaryClient().getHost(); if ( getHostNames(blackListedForests).contains(primaryHost) ) { int randomPos = Math.abs(primaryHost.hashCode()) % clientList.get().size(); moveMgrImpl.setPrimaryClient(clientList.get().get(randomPos)); } } cleanupExistingTasks(addedForests, restartedForests, blackListedForests); }
public DatabaseClient getForestClient(Forest forest) { if ( forest == null ) throw new IllegalArgumentException("forest must not be null"); if (getConnectionType() == DatabaseClient.ConnectionType.GATEWAY) { return getPrimaryClient(); } String hostName = forest.getPreferredHost(); String key = hostName; DatabaseClient client = clientMap.get(key); if ( client != null ) return client; // since this is shared across threads, let's get an exclusive lock on it before updating it synchronized(clientMap) { // just to avoid creating unnecessary DatabaseClient instances, let's check one more time if // another thread just barely inserted an instance that matches client = clientMap.get(key); if ( client != null ) return client; client = DatabaseClientFactory.newClient( hostName, primaryClient.getPort(), forest.getDatabaseName(), primaryClient.getSecurityContext() ); clientMap.put(key, client); } return client; }
String primaryHost = moveMgrImpl.getPrimaryClient().getHost(); if ( removedHostInfos.containsKey(primaryHost) ) { int randomPos = Math.abs(primaryHost.hashCode()) % newHostInfos.length;