Search in sources :

Example 6 with ServerRegionProxy

use of org.apache.geode.cache.client.internal.ServerRegionProxy in project geode by apache.

the class DestroyEntryPropagationDUnitTest method acquireConnectionsAndDestroyEntriesK1andK2.

private void acquireConnectionsAndDestroyEntriesK1andK2() {
    try {
        Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME);
        assertNotNull(r1);
        String poolName = r1.getAttributes().getPoolName();
        assertNotNull(poolName);
        PoolImpl pool = (PoolImpl) PoolManager.find(poolName);
        assertNotNull(pool);
        Connection conn = pool.acquireConnection();
        final Connection conn1;
        if (conn.getServer().getPort() != PORT2) {
            // Ensure we have a server with the proper port
            conn1 = pool.acquireConnection();
        } else {
            conn1 = conn;
        }
        assertNotNull(conn1);
        assertEquals(PORT2, conn1.getServer().getPort());
        ServerRegionProxy srp = new ServerRegionProxy(Region.SEPARATOR + REGION_NAME, pool);
        srp.destroyOnForTestsOnly(conn1, "key1", null, Operation.DESTROY, new EventIDHolder(new EventID(new byte[] { 1 }, 100000, 1)), null);
        srp.destroyOnForTestsOnly(conn1, "key2", null, Operation.DESTROY, new EventIDHolder(new EventID(new byte[] { 1 }, 100000, 2)), null);
    } catch (Exception ex) {
        throw new AssertionError("Failed while setting acquireConnectionsAndDestroyEntry  ", ex);
    }
}
Also used : ServerRegionProxy(org.apache.geode.cache.client.internal.ServerRegionProxy) EventIDHolder(org.apache.geode.internal.cache.EventIDHolder) Connection(org.apache.geode.cache.client.internal.Connection) Region(org.apache.geode.cache.Region) EventID(org.apache.geode.internal.cache.EventID) PoolImpl(org.apache.geode.cache.client.internal.PoolImpl) CacheException(org.apache.geode.cache.CacheException) CacheWriterException(org.apache.geode.cache.CacheWriterException)

Example 7 with ServerRegionProxy

use of org.apache.geode.cache.client.internal.ServerRegionProxy in project geode by apache.

the class ClearPropagationDUnitTest method acquireConnectionsAndClear.

public static void acquireConnectionsAndClear(String host) {
    try {
        Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME);
        assertNotNull(r1);
        String poolName = r1.getAttributes().getPoolName();
        assertNotNull(poolName);
        PoolImpl pool = (PoolImpl) PoolManager.find(poolName);
        assertNotNull(pool);
        Connection conn1 = pool.acquireConnection(new ServerLocation(host, PORT2));
        assertNotNull(conn1);
        assertEquals(PORT2, conn1.getServer().getPort());
        ServerRegionProxy srp = new ServerRegionProxy(Region.SEPARATOR + REGION_NAME, pool);
        srp.clearOnForTestsOnly(conn1, new EventID(new byte[] { 1 }, 1, 1), null);
    } catch (Exception ex) {
        ex.printStackTrace();
        fail("while setting acquireConnections  " + ex);
    }
}
Also used : ServerLocation(org.apache.geode.distributed.internal.ServerLocation) ServerRegionProxy(org.apache.geode.cache.client.internal.ServerRegionProxy) Connection(org.apache.geode.cache.client.internal.Connection) Region(org.apache.geode.cache.Region) EventID(org.apache.geode.internal.cache.EventID) PoolImpl(org.apache.geode.cache.client.internal.PoolImpl) CacheException(org.apache.geode.cache.CacheException)

Example 8 with ServerRegionProxy

use of org.apache.geode.cache.client.internal.ServerRegionProxy in project geode by apache.

the class Bug36269DUnitTest method acquireConnectionsAndDestroyRegion.

public static void acquireConnectionsAndDestroyRegion(String host) {
    try {
        Connection desCon = pool.acquireConnection(new ServerLocation(host, PORT2));
        ServerRegionProxy srp = new ServerRegionProxy(Region.SEPARATOR + REGION_NAME, pool);
        srp.destroyRegionOnForTestsOnly(desCon, new EventID(new byte[] { 1 }, 1, 1), null);
    } catch (Exception ex) {
        Assert.fail("while setting acquireConnections", ex);
    }
}
Also used : ServerLocation(org.apache.geode.distributed.internal.ServerLocation) ServerRegionProxy(org.apache.geode.cache.client.internal.ServerRegionProxy) Connection(org.apache.geode.cache.client.internal.Connection) EventID(org.apache.geode.internal.cache.EventID)

Example 9 with ServerRegionProxy

use of org.apache.geode.cache.client.internal.ServerRegionProxy in project geode by apache.

the class HAInterestTestCase method stopSecondaryAndRegisterK1AndK2AndVerifyResponse.

/**
   * returns the secondary that was stopped
   */
public static VM stopSecondaryAndRegisterK1AndK2AndVerifyResponse() {
    LocalRegion r = (LocalRegion) cache.getRegion(Region.SEPARATOR + REGION_NAME);
    assertNotNull(r);
    ServerRegionProxy srp = new ServerRegionProxy(r);
    WaitCriterion wc = new WaitCriterion() {

        @Override
        public boolean done() {
            return pool.getConnectedServerCount() == 3;
        }

        @Override
        public String description() {
            return "Never got three connected servers";
        }
    };
    Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
    // close secondary EP
    VM result = getBackupVM();
    result.invoke(() -> HAInterestTestCase.stopServer());
    List list = new ArrayList();
    list.add(k1);
    list.add(k2);
    List serverKeys = srp.registerInterest(list, InterestType.KEY, InterestResultPolicy.KEYS, false, r.getAttributes().getDataPolicy().ordinal);
    assertNotNull(serverKeys);
    List resultKeys = (List) serverKeys.get(0);
    assertEquals(2, resultKeys.size());
    assertTrue(resultKeys.contains(k1));
    assertTrue(resultKeys.contains(k2));
    return result;
}
Also used : WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) ServerRegionProxy(org.apache.geode.cache.client.internal.ServerRegionProxy) VM(org.apache.geode.test.dunit.VM) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) LocalRegion(org.apache.geode.internal.cache.LocalRegion)

Example 10 with ServerRegionProxy

use of org.apache.geode.cache.client.internal.ServerRegionProxy in project geode by apache.

the class HAInterestTestCase method registerK1AndK2OnPrimaryAndSecondaryAndVerifyResponse.

public static void registerK1AndK2OnPrimaryAndSecondaryAndVerifyResponse() {
    ServerLocation primary = pool.getPrimary();
    ServerLocation secondary = (ServerLocation) pool.getRedundants().get(0);
    LocalRegion r = (LocalRegion) cache.getRegion(Region.SEPARATOR + REGION_NAME);
    assertNotNull(r);
    ServerRegionProxy srp = new ServerRegionProxy(r);
    List list = new ArrayList();
    list.add(k1);
    list.add(k2);
    // Primary server
    List serverKeys1 = srp.registerInterestOn(primary, list, InterestType.KEY, InterestResultPolicy.KEYS, false, r.getAttributes().getDataPolicy().ordinal);
    assertNotNull(serverKeys1);
    // expect serverKeys in response from primary
    List resultKeys = (List) serverKeys1.get(0);
    assertEquals(2, resultKeys.size());
    assertTrue(resultKeys.contains(k1));
    assertTrue(resultKeys.contains(k2));
    // Secondary server
    List serverKeys2 = srp.registerInterestOn(secondary, list, InterestType.KEY, InterestResultPolicy.KEYS, false, r.getAttributes().getDataPolicy().ordinal);
    // if the list is null then it is empty
    if (serverKeys2 != null) {
        // no serverKeys in response from secondary
        assertTrue(serverKeys2.isEmpty());
    }
}
Also used : ServerLocation(org.apache.geode.distributed.internal.ServerLocation) ServerRegionProxy(org.apache.geode.cache.client.internal.ServerRegionProxy) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) LocalRegion(org.apache.geode.internal.cache.LocalRegion)

Aggregations

ServerRegionProxy (org.apache.geode.cache.client.internal.ServerRegionProxy)34 Connection (org.apache.geode.cache.client.internal.Connection)10 LocalRegion (org.apache.geode.internal.cache.LocalRegion)8 ArrayList (java.util.ArrayList)7 List (java.util.List)7 EventID (org.apache.geode.internal.cache.EventID)7 FunctionException (org.apache.geode.cache.execute.FunctionException)6 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)6 PoolImpl (org.apache.geode.cache.client.internal.PoolImpl)5 StoredObject (org.apache.geode.internal.offheap.StoredObject)5 CacheClosedException (org.apache.geode.cache.CacheClosedException)4 Region (org.apache.geode.cache.Region)4 ServerLocation (org.apache.geode.distributed.internal.ServerLocation)4 CacheException (org.apache.geode.cache.CacheException)3 CacheWriterException (org.apache.geode.cache.CacheWriterException)3 Operation (org.apache.geode.cache.Operation)3 VM (org.apache.geode.test.dunit.VM)3 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)2 EventIDHolder (org.apache.geode.internal.cache.EventIDHolder)2 ConcurrentCacheModificationException (org.apache.geode.internal.cache.versions.ConcurrentCacheModificationException)2