use of org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID 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);
}
use of org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID in project geode by apache.
the class CqServiceImpl method getAllClientCqs.
@Override
public List<ServerCQ> getAllClientCqs(ClientProxyMembershipID clientProxyId) {
Collection<? extends InternalCqQuery> cqs = getAllCqs();
ArrayList<ServerCQ> clientCqs = new ArrayList<>();
for (InternalCqQuery cq : cqs) {
ServerCQImpl cQuery = (ServerCQImpl) cq;
ClientProxyMembershipID id = cQuery.getClientProxyId();
if (id != null && id.equals(clientProxyId)) {
clientCqs.add(cQuery);
}
}
return clientCqs;
}
use of org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID in project geode by apache.
the class CqServiceUnitTest method constructCqServerNameShouldReturnSameResultRegardlessOfOptimizedCacheNames.
@Test
public void constructCqServerNameShouldReturnSameResultRegardlessOfOptimizedCacheNames() {
CqServiceImpl cqService = new CqServiceImpl(Fakes.cache());
ClientProxyMembershipID proxyMembershipID = new ClientProxyMembershipID(Fakes.cache().getDistributedSystem().getDistributedMember());
String name1 = cqService.constructServerCqName("myCq", proxyMembershipID);
String name2 = cqService.constructServerCqName("myCq", proxyMembershipID);
assertEquals(name1, name2);
}
use of org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID in project geode by apache.
the class HARegionQueue method addClientCQsAndInterestList.
public static void addClientCQsAndInterestList(ClientUpdateMessageImpl msg, HAEventWrapper haEventWrapper, Map haContainer, String regionName) {
ClientProxyMembershipID proxyID = ((HAContainerWrapper) haContainer).getProxyID(regionName);
if (haEventWrapper.getClientCqs() != null) {
CqNameToOp clientCQ = haEventWrapper.getClientCqs().get(proxyID);
if (clientCQ != null) {
msg.addClientCqs(proxyID, clientCQ);
}
}
// if (haEventWrapper.getPutInProgress()) {
// ((HAEventWrapper)entry.getKey()).setPutInProgress(true);
// }
// This is a remote HAEventWrapper.
// Add new Interested client lists.
ClientUpdateMessageImpl clientMsg = (ClientUpdateMessageImpl) haEventWrapper.getClientUpdateMessage();
if (clientMsg.isClientInterestedInUpdates(proxyID)) {
msg.addClientInterestList(proxyID, true);
} else if (clientMsg.isClientInterestedInInvalidates(proxyID)) {
msg.addClientInterestList(proxyID, false);
}
}
use of org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID in project geode by apache.
the class DistributedAckRegionCCEDUnitTest method testEntryVersionRollover.
@Test
public void testEntryVersionRollover() throws Exception {
assumeTrue(getClass() == DistributedAckRegionCCEDUnitTest.class);
final String name = this.getUniqueName() + "-CC";
final int numEntries = 1;
SerializableRunnable createRegion = new SerializableRunnable("Create Region") {
public void run() {
try {
RegionFactory f = getCache().createRegionFactory(getRegionAttributes());
CCRegion = (LocalRegion) f.create(name);
for (int i = 0; i < numEntries; i++) {
CCRegion.put("cckey" + i, "ccvalue");
}
assertEquals("expected no conflated events", 0, CCRegion.getCachePerfStats().getConflatedEventsCount());
} catch (CacheException ex) {
org.apache.geode.test.dunit.Assert.fail("While creating region", ex);
}
}
};
VM vm0 = Host.getHost(0).getVM(0);
vm0.invoke(createRegion);
try {
createRegion.run();
VersionTag tag = new VMVersionTag();
// set the version to the max - it should make the system think there's a rollover and reject
// the change. Then apply it to the cache as if it is a replayed client operation. That should
// cause the cache to apply the op locally
tag.setEntryVersion(0xFFFFFF);
tag.setDistributedSystemId(1);
tag.setRegionVersion(CCRegion.getVersionVector().getNextVersion());
VersionTagHolder holder = new VersionTagHolder(tag);
ClientProxyMembershipID id = ClientProxyMembershipID.getNewProxyMembership(CCRegion.getDistributionManager().getSystem());
CCRegion.basicBridgePut("cckey0", "newvalue", null, true, null, id, true, holder);
vm0.invoke(new SerializableRunnable("check conflation count") {
public void run() {
assertEquals("expected one conflated event", 1, CCRegion.getCachePerfStats().getConflatedEventsCount());
}
});
} finally {
disconnectAllFromDS();
}
}
Aggregations