Search in sources :

Example 16 with CacheClientProxy

use of org.apache.geode.internal.cache.tier.sockets.CacheClientProxy in project geode by apache.

the class CacheServerBridge method getUniqueClientIds.

private Map<String, ClientConnInfo> getUniqueClientIds() {
    Map<String, ClientConnInfo> uniqueIds = null;
    ServerConnection[] serverConnections = acceptor.getAllServerConnectionList();
    Collection<CacheClientProxy> clientProxies = acceptor.getCacheClientNotifier().getClientProxies();
    if (clientProxies.size() > 0) {
        uniqueIds = new HashMap<String, ClientConnInfo>();
        for (CacheClientProxy p : clientProxies) {
            ClientConnInfo clientConInfo = new ClientConnInfo(p.getProxyID(), p.getSocketHost(), p.getRemotePort(), p.isPrimary());
            uniqueIds.put(p.getProxyID().getDSMembership(), clientConInfo);
        }
    }
    if (serverConnections != null && serverConnections.length > 0) {
        if (uniqueIds == null) {
            uniqueIds = new HashMap<String, ClientConnInfo>();
        }
        for (ServerConnection conn : serverConnections) {
            ClientProxyMembershipID clientId = conn.getProxyID();
            if (clientId != null) {
                // Check added to fix bug 51987
                if (uniqueIds.get(clientId.getDSMembership()) == null) {
                    ClientConnInfo clientConInfo = new ClientConnInfo(conn.getProxyID(), conn.getSocketHost(), conn.getSocketPort(), false);
                    uniqueIds.put(clientId.getDSMembership(), clientConInfo);
                }
            }
        }
    }
    if (uniqueIds == null) {
        return Collections.emptyMap();
    }
    return uniqueIds;
}
Also used : CacheClientProxy(org.apache.geode.internal.cache.tier.sockets.CacheClientProxy) ClientProxyMembershipID(org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID) ServerConnection(org.apache.geode.internal.cache.tier.sockets.ServerConnection)

Example 17 with CacheClientProxy

use of org.apache.geode.internal.cache.tier.sockets.CacheClientProxy in project geode by apache.

the class Bug48571DUnitTest method verifyStats.

public static void verifyStats() throws Exception {
    CacheClientNotifier ccn = CacheClientNotifier.getInstance();
    CacheClientProxy ccp = ccn.getClientProxies().iterator().next();
    cache.getLoggerI18n().info(LocalizedStrings.DEBUG, "getQueueSize() " + ccp.getQueueSize());
    cache.getLoggerI18n().info(LocalizedStrings.DEBUG, "getQueueSizeStat() " + ccp.getQueueSizeStat());
    cache.getLoggerI18n().info(LocalizedStrings.DEBUG, "getEventsEnqued() " + ccp.getHARegionQueue().getStatistics().getEventsEnqued());
    cache.getLoggerI18n().info(LocalizedStrings.DEBUG, "getEventsDispatched() " + ccp.getHARegionQueue().getStatistics().getEventsDispatched());
    cache.getLoggerI18n().info(LocalizedStrings.DEBUG, "getEventsRemoved() " + ccp.getHARegionQueue().getStatistics().getEventsRemoved());
    cache.getLoggerI18n().info(LocalizedStrings.DEBUG, "getNumVoidRemovals() " + ccp.getHARegionQueue().getStatistics().getNumVoidRemovals());
    assertEquals(ccp.getQueueSize(), ccp.getQueueSizeStat());
}
Also used : CacheClientProxy(org.apache.geode.internal.cache.tier.sockets.CacheClientProxy) CacheClientNotifier(org.apache.geode.internal.cache.tier.sockets.CacheClientNotifier)

Example 18 with CacheClientProxy

use of org.apache.geode.internal.cache.tier.sockets.CacheClientProxy in project geode by apache.

the class ClientHealthStatsDUnitTest method verifyStats.

/**
   * Invoked in serverVM
   */
private void verifyStats(final int serverPort) throws Exception {
    ManagementService service = this.managementTestRule.getManagementService();
    CacheServerMXBean serverBean = service.getLocalCacheServerMXBean(serverPort);
    CacheClientNotifier clientNotifier = CacheClientNotifier.getInstance();
    CacheClientProxy clientProxy = clientNotifier.getClientProxies().iterator().next();
    assertThat(clientProxy.getQueueSizeStat()).isEqualTo(clientProxy.getQueueSize());
    ClientQueueDetail queueDetails = serverBean.showClientQueueDetails()[0];
    assertThat(clientProxy.getQueueSizeStat()).isEqualTo((int) queueDetails.getQueueSize());
}
Also used : CacheClientProxy(org.apache.geode.internal.cache.tier.sockets.CacheClientProxy) SystemManagementService(org.apache.geode.management.internal.SystemManagementService) CacheClientNotifier(org.apache.geode.internal.cache.tier.sockets.CacheClientNotifier)

Example 19 with CacheClientProxy

use of org.apache.geode.internal.cache.tier.sockets.CacheClientProxy in project geode by apache.

the class ClientHealthStatsDUnitTest method cacheClientProxyHasBeenPause.

/**
   * Invoked in serverVM
   */
private boolean cacheClientProxyHasBeenPause() {
    CacheClientNotifier clientNotifier = CacheClientNotifier.getInstance();
    Collection<CacheClientProxy> clientProxies = clientNotifier.getClientProxies();
    for (CacheClientProxy clientProxy : clientProxies) {
        if (clientProxy.isPaused()) {
            return true;
        }
    }
    return false;
}
Also used : CacheClientProxy(org.apache.geode.internal.cache.tier.sockets.CacheClientProxy) CacheClientNotifier(org.apache.geode.internal.cache.tier.sockets.CacheClientNotifier)

Example 20 with CacheClientProxy

use of org.apache.geode.internal.cache.tier.sockets.CacheClientProxy in project geode by apache.

the class CqQueryUsingPoolDUnitTest method testFilterRegistrationDuringGII.

/**
   * Test Filter registration during GII. Bug fix 39014
   */
@Test
public void testFilterRegistrationDuringGII() throws Exception {
    final Host host = Host.getHost(0);
    VM server1 = host.getVM(0);
    VM server2 = host.getVM(1);
    VM client1 = host.getVM(2);
    VM client2 = host.getVM(3);
    Wait.pause(3 * 1000);
    createServer(server1);
    final int port1 = server1.invoke(() -> CqQueryUsingPoolDUnitTest.getCacheServerPort());
    final String host0 = NetworkUtils.getServerHostName(server1.getHost());
    final int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(1);
    String poolName = "testFilterRegistrationDuringGII";
    createPool(client1, poolName, new String[] { host0, host0 }, new int[] { port1, ports[0] }, "-1");
    createPool(client2, poolName, new String[] { host0, host0 }, new int[] { port1, ports[0] }, "-1");
    createClient(client1, new int[] { port1, ports[0] }, host0, "-1", poolName);
    createClient(client2, new int[] { port1, ports[0] }, host0, "-1", poolName);
    // Create CQs.
    final int numCQs = 2;
    for (int i = 0; i < numCQs; i++) {
        // Create CQs.
        createCQ(client1, poolName, "client1_" + i, cqs[i]);
        executeCQ(client1, "client1_" + i, false, null);
        createCQ(client2, poolName, "client2_" + i, cqs[i]);
        executeCQ(client2, "client2_" + i, false, null);
    }
    final int interestSize = 20;
    registerInterestListCQ(client1, regions[0], interestSize, false);
    registerInterestListCQ(client2, regions[0], 0, true);
    Wait.pause(1 * 1000);
    // CREATE.
    createValues(server1, regions[0], 100);
    createValues(server1, regions[1], 10);
    waitForCreated(client1, "client1_0", KEY + 10);
    // Create server2.
    server2.invoke(new CacheSerializableRunnable("Create Cache Server") {

        @Override
        public void run2() throws CacheException {
            LogWriterUtils.getLogWriter().info("### Create Cache Server. ###");
            AttributesFactory factory = new AttributesFactory();
            factory.setScope(Scope.DISTRIBUTED_ACK);
            factory.setMirrorType(MirrorType.KEYS_VALUES);
            for (int i = 0; i < regions.length; i++) {
                createRegion(regions[i], factory.createRegionAttributes());
            }
            InitialImageOperation.slowImageProcessing = 100;
            try {
                try {
                    startBridgeServer(ports[0], true);
                } catch (Exception ex) {
                    Assert.fail("While starting CacheServer", ex);
                }
                while (true) {
                    if (InitialImageOperation.slowImageSleeps > 0) {
                        // Create events while GII for HARegion is in progress.
                        LocalRegion region1 = (LocalRegion) getRootRegion().getSubregion(regions[0]);
                        for (int i = 90; i <= 120; i++) {
                            region1.put(KEY + i, new Portfolio(i, i));
                        }
                        break;
                    }
                    Wait.pause(20);
                }
            } finally {
                InitialImageOperation.slowImageProcessing = 0;
            }
        }
    });
    Wait.pause(3 * 1000);
    // Check if CQs are registered as part of GII.
    server2.invoke(new CacheSerializableRunnable("Create values") {

        @Override
        public void run2() throws CacheException {
            DefaultQueryService qs = (DefaultQueryService) getCache().getQueryService();
            Collection<CacheClientProxy> proxies = CacheClientNotifier.getInstance().getClientProxies();
            Iterator iter = proxies.iterator();
            try {
                for (CacheClientProxy p : proxies) {
                    ClientProxyMembershipID clientId = p.getProxyID();
                    List cqs = qs.getCqService().getAllClientCqs(clientId);
                    getCache().getLogger().fine("Number of CQs found for client :" + clientId + " are :" + cqs.size());
                    if (cqs.size() != numCQs) {
                        fail("Number of CQs registerted by the client is :" + cqs.size() + " less than expected : " + numCQs);
                    }
                    CqQuery cq = (CqQuery) cqs.get(0);
                    LocalRegion region1 = (LocalRegion) getRootRegion().getSubregion(regions[0]);
                    if (cq.getName().startsWith("client1_")) {
                        if (region1.getFilterProfile().getKeysOfInterest(clientId) == null || region1.getFilterProfile().getKeysOfInterest(clientId).size() != interestSize) {
                            fail("Interest registartion during Secondary HARegion creation has failed.");
                        }
                    } else {
                        if (!region1.getFilterProfile().isInterestedInAllKeys(clientId)) {
                            fail("Interest registartion during Secondary HARegion creation has failed.");
                        }
                    }
                }
            } catch (Exception ex) {
                fail("Exception while validating filter count. ", ex);
            }
        }
    });
    // Close.
    closeClient(client1);
    closeClient(client2);
    closeServer(server1);
    closeServer(server2);
}
Also used : CacheClientProxy(org.apache.geode.internal.cache.tier.sockets.CacheClientProxy) CacheException(org.apache.geode.cache.CacheException) Portfolio(org.apache.geode.cache.query.data.Portfolio) Host(org.apache.geode.test.dunit.Host) LocalRegion(org.apache.geode.internal.cache.LocalRegion) CqExistsException(org.apache.geode.cache.query.CqExistsException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) RMIException(org.apache.geode.test.dunit.RMIException) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException) ClientProxyMembershipID(org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID) AttributesFactory(org.apache.geode.cache.AttributesFactory) CqAttributesFactory(org.apache.geode.cache.query.CqAttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) VM(org.apache.geode.test.dunit.VM) Iterator(java.util.Iterator) Collection(java.util.Collection) List(java.util.List) ArrayList(java.util.ArrayList) CqQuery(org.apache.geode.cache.query.CqQuery) DefaultQueryService(org.apache.geode.cache.query.internal.DefaultQueryService) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) Test(org.junit.Test)

Aggregations

CacheClientProxy (org.apache.geode.internal.cache.tier.sockets.CacheClientProxy)24 CacheClientNotifier (org.apache.geode.internal.cache.tier.sockets.CacheClientNotifier)11 ClientProxyMembershipID (org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID)7 IOException (java.io.IOException)6 CqException (org.apache.geode.cache.query.CqException)5 LocalRegion (org.apache.geode.internal.cache.LocalRegion)5 Cache (org.apache.geode.cache.Cache)4 CqClosedException (org.apache.geode.cache.query.CqClosedException)4 CqExistsException (org.apache.geode.cache.query.CqExistsException)4 StringId (org.apache.geode.i18n.StringId)4 QueryException (org.apache.geode.cache.query.QueryException)3 RegionNotFoundException (org.apache.geode.cache.query.RegionNotFoundException)3 CqService (org.apache.geode.cache.query.internal.cq.CqService)3 CacheServerImpl (org.apache.geode.internal.cache.CacheServerImpl)3 AcceptorImpl (org.apache.geode.internal.cache.tier.sockets.AcceptorImpl)3 Part (org.apache.geode.internal.cache.tier.sockets.Part)3 AuthorizeRequest (org.apache.geode.internal.security.AuthorizeRequest)3 Collection (java.util.Collection)2 Iterator (java.util.Iterator)2 AttributesFactory (org.apache.geode.cache.AttributesFactory)2