use of org.apache.geode.distributed.internal.ServerLocation in project geode by apache.
the class PutAllOp method constructAndGetPutAllTasks.
static List constructAndGetPutAllTasks(Region region, final Map map, final EventID eventId, boolean skipCallbacks, final Map<ServerLocation, HashSet> serverToFilterMap, final PoolImpl pool, Object callbackArg) {
final List<SingleHopOperationCallable> tasks = new ArrayList<SingleHopOperationCallable>();
ArrayList<ServerLocation> servers = new ArrayList<ServerLocation>(serverToFilterMap.keySet());
if (logger.isDebugEnabled()) {
logger.debug("Constructing tasks for the servers {}", servers);
}
for (ServerLocation server : servers) {
Set filterSet = serverToFilterMap.get(server);
Map newKeysValuesMap = new LinkedHashMap();
// iterator 1: for single hop, both iterator filterSet and newKeysValuesMap
for (Object key : filterSet) {
newKeysValuesMap.put(key, map.get(key));
}
AbstractOp putAllOp = new PutAllOpImpl(region, newKeysValuesMap, eventId, true, skipCallbacks, callbackArg);
SingleHopOperationCallable task = new SingleHopOperationCallable(new ServerLocation(server.getHostName(), server.getPort()), pool, putAllOp, UserAttributes.userAttributes.get());
tasks.add(task);
}
return tasks;
}
use of org.apache.geode.distributed.internal.ServerLocation in project geode by apache.
the class QueueManagerImpl method start.
public void start(ScheduledExecutorService background) {
try {
blackList.start(background);
endpointManager.addListener(endpointListener);
// Use a separate timer for queue management tasks
// We don't want primary recovery (and therefore user threads) to wait for
// things like pinging connections for health checks.
// this.background = background;
final String name = "queueTimer-" + this.pool.getName();
this.recoveryThread = new ScheduledThreadPoolExecutor(1, new ThreadFactory() {
public Thread newThread(Runnable r) {
Thread result = new Thread(r, name);
result.setDaemon(true);
return result;
}
});
recoveryThread.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
// TODO - use yet another Timer or the like for these tasks? We know
// we don't want them in the recoveryThread, because the ThreadIdToSequenceIdExpiryTask
// will wait for primary recovery.
getState().start(background, getPool().getSubscriptionAckInterval());
// initialize connections
initializeConnections();
scheduleRedundancySatisfierIfNeeded(redundancyRetryInterval);
// When a server is removed from the blacklist, try again
// to establish redundancy (if we need to)
BlackListListener blackListListener = new BlackListListenerAdapter() {
@Override
public void serverRemoved(ServerLocation location) {
QueueManagerImpl.this.scheduleRedundancySatisfierIfNeeded(0);
}
};
blackList.addListener(blackListListener);
factory.getBlackList().addListener(blackListListener);
} finally {
initializedLatch.countDown();
}
}
use of org.apache.geode.distributed.internal.ServerLocation in project geode by apache.
the class PoolImpl method getRedundantNames.
/**
* Test hook that returns a list of strings. Each string consists of the host name and port of a
* redundant server. An empty list is returned if we have no redundant servers.
*/
public List<String> getRedundantNames() {
List result = Collections.emptyList();
if (this.queueManager != null) {
QueueManager.QueueConnections cons = this.queueManager.getAllConnections();
List<Connection> backupCons = cons.getBackups();
if (backupCons.size() > 0) {
result = new ArrayList(backupCons.size());
Iterator<Connection> it = backupCons.iterator();
while (it.hasNext()) {
Connection con = it.next();
ServerLocation sl = con.getServer();
result.add(sl.getHostName() + sl.getPort());
}
}
}
return result;
}
use of org.apache.geode.distributed.internal.ServerLocation in project geode by apache.
the class PoolImpl method getCurrentServerNames.
/**
* Test hook that returns a list of server names (host+port); one for each server we are currently
* connected to.
*/
public List<String> getCurrentServerNames() {
List<ServerLocation> servers = getCurrentServers();
ArrayList<String> result = new ArrayList(servers.size());
Iterator it = servers.iterator();
while (it.hasNext()) {
ServerLocation sl = (ServerLocation) it.next();
String name = sl.getHostName() + sl.getPort();
result.add(name);
}
return result;
}
use of org.apache.geode.distributed.internal.ServerLocation in project geode by apache.
the class ProxyCache method close.
public void close(boolean keepAlive) {
if (this.isClosed) {
return;
}
// them to clean-up its entry from their auth-data structures.
try {
if (this.proxyQueryService != null) {
this.proxyQueryService.closeCqs(keepAlive);
}
UserAttributes.userAttributes.set(this.userAttributes);
for (final ServerLocation serverLocation : this.userAttributes.getServerToId().keySet()) {
ProxyCacheCloseOp.executeOn(serverLocation, (ExecutablePool) this.userAttributes.getPool(), this.userAttributes.getCredentials(), keepAlive);
}
List<ProxyCache> proxyCache = ((PoolImpl) this.userAttributes.getPool()).getProxyCacheList();
synchronized (proxyCache) {
proxyCache.remove(this);
}
} finally {
// TODO: I think some NPE will be caused by this code.
// It would be safer to not null things out.
// It is really bad that we null out and then set isClosed true.
this.isClosed = true;
this.proxyQueryService = null;
this.userAttributes.setCredentials(null);
this.userAttributes = null;
UserAttributes.userAttributes.set(null);
}
}
Aggregations