use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.
the class LocatorLoadBalancingDUnitTest method checkConnectionCount.
private void checkConnectionCount(final int count) {
Cache cache = (Cache) remoteObjects.get(CACHE_KEY);
final CacheServerImpl server = (CacheServerImpl) cache.getCacheServers().get(0);
Awaitility.await().pollDelay(100, TimeUnit.MILLISECONDS).pollInterval(100, TimeUnit.MILLISECONDS).timeout(300, TimeUnit.SECONDS).until(() -> {
int sz = server.getAcceptor().getStats().getCurrentClientConnections();
if (Math.abs(sz - count) <= ALLOWABLE_ERROR_IN_COUNT) {
return true;
}
System.out.println("Found " + sz + " connections, expected " + count);
return false;
});
}
use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.
the class InternalClientMembership method getConnectedClients.
/**
* Caller must synchronize on cache.allClientServersLock
*
* @return all the clients
*/
public static Map getConnectedClients() {
// Get all clients
Map allClients = new HashMap();
for (Iterator bsii = CacheFactory.getAnyInstance().getCacheServers().iterator(); bsii.hasNext(); ) {
CacheServerImpl bsi = (CacheServerImpl) bsii.next();
AcceptorImpl ai = bsi.getAcceptor();
if (ai != null && ai.getCacheClientNotifier() != null) {
allClients.putAll(ai.getCacheClientNotifier().getAllClients());
}
}
// Fill in the missing info, if HealthMonitor started
if (ClientHealthMonitor.getInstance() != null)
ClientHealthMonitor.getInstance().fillInClientInfo(allClients);
return allClients;
}
use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.
the class InternalClientMembership method getClientQueueSizes.
public static Map getClientQueueSizes() {
Map clientQueueSizes = new HashMap();
InternalCache c = (InternalCache) CacheFactory.getAnyInstance();
if (// Add a NULL Check
c == null)
return clientQueueSizes;
for (Iterator bsii = c.getCacheServers().iterator(); bsii.hasNext(); ) {
CacheServerImpl bsi = (CacheServerImpl) bsii.next();
AcceptorImpl ai = bsi.getAcceptor();
if (ai != null && ai.getCacheClientNotifier() != null) {
clientQueueSizes.putAll(ai.getCacheClientNotifier().getClientQueueSizes());
}
}
// for
return clientQueueSizes;
}
use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.
the class BridgeServerResponse method create.
/**
* Creates a {@code BridgeServerResponse} in response to the given request.
*/
static BridgeServerResponse create(DistributionManager dm, BridgeServerRequest request) {
BridgeServerResponse m = new BridgeServerResponse();
m.setRecipient(request.getSender());
try {
InternalCache cache = (InternalCache) CacheFactory.getInstanceCloseOk(dm.getSystem());
if (request.getCacheId() != System.identityHashCode(cache)) {
m.bridgeInfo = null;
} else {
int operation = request.getOperation();
switch(operation) {
case BridgeServerRequest.ADD_OPERATION:
{
CacheServerImpl bridge = (CacheServerImpl) cache.addCacheServer();
m.bridgeInfo = new RemoteBridgeServer(bridge);
break;
}
case BridgeServerRequest.INFO_OPERATION:
{
int id = request.getBridgeId();
// it is not necessary to synchronize on allBridgeServersLock
for (CacheServer cacheServer : cache.getCacheServers()) {
CacheServerImpl bridge = (CacheServerImpl) cacheServer;
if (System.identityHashCode(bridge) == id) {
m.bridgeInfo = new RemoteBridgeServer(bridge);
break;
} else {
m.bridgeInfo = null;
}
}
break;
}
case BridgeServerRequest.START_OPERATION:
{
RemoteBridgeServer config = request.getBridgeInfo();
for (CacheServer cacheServer : cache.getCacheServers()) {
CacheServerImpl bridge = (CacheServerImpl) cacheServer;
if (System.identityHashCode(bridge) == config.getId()) {
bridge.configureFrom(config);
bridge.start();
m.bridgeInfo = new RemoteBridgeServer(bridge);
break;
} else {
m.bridgeInfo = null;
}
}
break;
}
case BridgeServerRequest.STOP_OPERATION:
{
RemoteBridgeServer config = request.getBridgeInfo();
for (CacheServer cacheServer : cache.getCacheServers()) {
CacheServerImpl bridge = (CacheServerImpl) cacheServer;
if (System.identityHashCode(bridge) == config.getId()) {
bridge.stop();
m.bridgeInfo = new RemoteBridgeServer(bridge);
break;
} else {
m.bridgeInfo = null;
}
}
break;
}
default:
Assert.assertTrue(false, "Unknown bridge server operation: " + operation);
}
}
} catch (CancelException ignore) {
m.bridgeInfo = null;
} catch (Exception ex) {
m.exception = ex;
m.bridgeInfo = null;
}
return m;
}
use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.
the class DurableClientInfoResponse method create.
/**
* Returns a {@code DurableClientInfoResponse} that will be returned to the specified recipient.
*/
public static DurableClientInfoResponse create(DistributionManager dm, InternalDistributedMember recipient, DurableClientInfoRequest request) {
DurableClientInfoResponse m = new DurableClientInfoResponse();
m.setRecipient(recipient);
try {
InternalCache c = (InternalCache) CacheFactory.getInstanceCloseOk(dm.getSystem());
if (!c.getCacheServers().isEmpty()) {
CacheServerImpl server = (CacheServerImpl) c.getCacheServers().iterator().next();
switch(request.action) {
case DurableClientInfoRequest.HAS_DURABLE_CLIENT_REQUEST:
{
m.returnVal = server.getAcceptor().getCacheClientNotifier().hasDurableClient(request.durableId);
break;
}
case DurableClientInfoRequest.IS_PRIMARY_FOR_DURABLE_CLIENT_REQUEST:
{
m.returnVal = server.getAcceptor().getCacheClientNotifier().hasPrimaryForDurableClient(request.durableId);
break;
}
}
}
} catch (CacheClosedException ignore) {
// do nothing
}
return m;
}
Aggregations