use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.
the class InternalDistributedSystem method createAndStartCacheServers.
/**
* after an auto-reconnect we may need to recreate a cache server and start it
*/
public void createAndStartCacheServers(List<CacheServerCreation> cacheServerCreation, InternalCache cache) {
List<CacheServer> servers = cache.getCacheServers();
// to recreate it.
if (servers.isEmpty() && cacheServerCreation != null) {
for (CacheServerCreation bridge : cacheServerCreation) {
CacheServerImpl impl = (CacheServerImpl) cache.addCacheServer();
impl.configureFrom(bridge);
}
}
servers = cache.getCacheServers();
for (CacheServer server : servers) {
try {
if (!server.isRunning()) {
server.start();
}
} catch (IOException ex) {
throw new GemFireIOException(LocalizedStrings.CacheCreation_WHILE_STARTING_CACHE_SERVER_0.toLocalizedString(server), ex);
}
}
}
use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.
the class InternalClientMembership method getConnectedClients.
/**
* Returns a map of client memberIds to count of connections to that client. The map entry key is
* a String representation of the client memberId, and the map entry value is an Integer count of
* connections to that client. Since a single client can have multiple ConnectionProxy objects,
* this map will contain all the Connection objects across the ConnectionProxies
*
* @param onlyClientsNotifiedByThisServer true will return only those clients that are actively
* being updated by this server
* @return map of client memberIds to count of connections to that client
*
*
*/
public static Map getConnectedClients(boolean onlyClientsNotifiedByThisServer) {
ClientHealthMonitor chMon = ClientHealthMonitor.getInstance();
Set filterProxyIDs = null;
if (onlyClientsNotifiedByThisServer) {
// since this is only a status (snapshot) of the system.
for (Iterator bsii = CacheFactory.getAnyInstance().getCacheServers().iterator(); bsii.hasNext(); ) {
CacheServerImpl bsi = (CacheServerImpl) bsii.next();
AcceptorImpl ai = bsi.getAcceptor();
if (ai != null && ai.getCacheClientNotifier() != null) {
if (filterProxyIDs != null) {
// notifierClients is a copy set from CacheClientNotifier
filterProxyIDs.addAll(ai.getCacheClientNotifier().getActiveClients());
} else {
// notifierClients is a copy set from CacheClientNotifier
filterProxyIDs = ai.getCacheClientNotifier().getActiveClients();
}
}
}
}
Map map = chMon.getConnectedClients(filterProxyIDs);
/*
* if (onlyClientsNotifiedByThisServer) { Map notifyMap = new HashMap();
*
* for (Iterator iter = map.keySet().iterator(); iter.hasNext();) { String memberId = (String)
* iter.next(); if (notifierClients.contains(memberId)) { // found memberId that is notified by
* this server notifyMap.put(memberId, map.get(memberId)); } } map = notifyMap; }
*/
return map;
}
use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.
the class CacheServerBridge method getClientVersion.
public Version getClientVersion(ClientConnInfo connInfo) {
InternalCache cache = (InternalCache) CacheFactory.getAnyInstance();
if (cache.getCacheServers().size() == 0) {
return null;
}
CacheServerImpl server = (CacheServerImpl) cache.getCacheServers().iterator().next();
if (server == null) {
return null;
}
AcceptorImpl acceptorImpl = server.getAcceptor();
if (acceptorImpl == null) {
return null;
}
ServerConnection[] serverConnections = acceptorImpl.getAllServerConnectionList();
boolean flag = false;
if (connInfo.toString().contains("primary=true")) {
flag = true;
}
for (ServerConnection conn : serverConnections) {
ClientProxyMembershipID cliIdFrmProxy = conn.getProxyID();
ClientConnInfo cci = new ClientConnInfo(conn.getProxyID(), conn.getSocketHost(), conn.getSocketPort(), flag);
if (connInfo.toString().equals(cci.toString())) {
return cliIdFrmProxy.getClientVersion();
}
}
// check form ccp
ClientProxyMembershipID proxyId = connInfo.getClientId();
CacheClientProxy proxy = CacheClientNotifier.getInstance().getClientProxy(proxyId);
if (proxy != null) {
return proxy.getVersion();
} else {
return null;
}
}
use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.
the class GatewayReceiverMBeanBridge method getConnectedGatewaySenders.
public String[] getConnectedGatewaySenders() {
Set<String> uniqueIds = null;
AcceptorImpl acceptor = ((CacheServerImpl) rcv.getServer()).getAcceptor();
Set<ServerConnection> serverConnections = acceptor.getAllServerConnections();
if (serverConnections != null && serverConnections.size() > 0) {
uniqueIds = new HashSet<String>();
for (ServerConnection conn : serverConnections) {
uniqueIds.add(conn.getMembershipID());
}
String[] allConnectedClientStr = new String[uniqueIds.size()];
return uniqueIds.toArray(allConnectedClientStr);
}
return new String[0];
}
use of org.apache.geode.internal.cache.CacheServerImpl in project geode by apache.
the class ContunuousQueryFunction method execute.
@Override
public void execute(FunctionContext context) {
try {
String clientID = (String) context.getArguments();
InternalCache cache = getCache();
if (cache.getCacheServers().size() > 0) {
CacheServerImpl server = (CacheServerImpl) cache.getCacheServers().iterator().next();
if (server != null) {
AcceptorImpl acceptorImpl = server.getAcceptor();
if (acceptorImpl != null) {
CacheClientNotifier cacheClientNotifier = acceptorImpl.getCacheClientNotifier();
if (cacheClientNotifier != null) {
Collection<CacheClientProxy> cacheClientProxySet = cacheClientNotifier.getClientProxies();
ClientInfo clientInfo = null;
boolean foundClientinCCP = false;
Iterator<CacheClientProxy> it = cacheClientProxySet.iterator();
while (it.hasNext()) {
CacheClientProxy ccp = it.next();
if (ccp != null) {
String clientIdFromProxy = ccp.getProxyID().getDSMembership();
if (clientIdFromProxy != null && clientIdFromProxy.equals(clientID)) {
foundClientinCCP = true;
String durableId = ccp.getProxyID().getDurableId();
boolean isPrimary = ccp.isPrimary();
clientInfo = new ClientInfo((durableId != null && durableId.length() > 0 ? "Yes" : "No"), (isPrimary == true ? cache.getDistributedSystem().getDistributedMember().getId() : ""), (isPrimary == false ? cache.getDistributedSystem().getDistributedMember().getId() : ""));
break;
}
}
}
// try getting from server connections
if (foundClientinCCP == false) {
ServerConnection[] serverConnections = acceptorImpl.getAllServerConnectionList();
for (ServerConnection conn : serverConnections) {
ClientProxyMembershipID cliIdFrmProxy = conn.getProxyID();
if (clientID.equals(cliIdFrmProxy.getDSMembership())) {
String durableId = cliIdFrmProxy.getDurableId();
clientInfo = new ClientInfo((durableId != null && durableId.length() > 0 ? "Yes" : "No"), "N.A.", "N.A.");
}
}
}
context.getResultSender().lastResult(clientInfo);
}
}
}
}
} catch (Exception e) {
context.getResultSender().lastResult("Exception in ContunuousQueryFunction =" + e.getMessage());
}
context.getResultSender().lastResult(null);
}
Aggregations