Search in sources :

Example 21 with ServerRegionProxy

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

the class EventIdOptimizationDUnitTest method generateEventsByClearRegionOperation.

/**
   * Generates events having specific values of threadId and sequenceId, via clearRegionOperation
   * through connection object
   * 
   * @throws Exception - thrown if any problem occurs in clearRegionOperation
   */
public static void generateEventsByClearRegionOperation() throws Exception {
    Connection connection = pool.acquireConnection();
    String regionName = Region.SEPARATOR + REGION_NAME;
    ServerRegionProxy srp = new ServerRegionProxy(regionName, pool);
    for (int i = 0; i < eventIds.length; i++) {
        srp.clearOnForTestsOnly(connection, eventIds[i], null);
    }
    srp.clearOnForTestsOnly(connection, eventIdForLastKey, null);
}
Also used : ServerRegionProxy(org.apache.geode.cache.client.internal.ServerRegionProxy) Connection(org.apache.geode.cache.client.internal.Connection)

Example 22 with ServerRegionProxy

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

the class EventIdOptimizationDUnitTest method generateEventsByDestroyRegionOperation.

/**
   * Generates events having specific values of threadId and sequenceId, via destroyRegionOperation
   * through connection object
   * 
   * @throws Exception - thrown if any problem occurs in destroyRegionOperation
   */
public static void generateEventsByDestroyRegionOperation() throws Exception {
    Connection connection = pool.acquireConnection();
    String regionName = Region.SEPARATOR + REGION_NAME;
    for (int i = 0; i < 1; i++) {
        ServerRegionProxy srp = new ServerRegionProxy(regionName + i, pool);
        srp.destroyRegionOnForTestsOnly(connection, eventIds[i], null);
    }
    {
        ServerRegionProxy srp = new ServerRegionProxy(regionName, pool);
        srp.destroyRegionOnForTestsOnly(connection, eventIdForLastKey, null);
    }
}
Also used : ServerRegionProxy(org.apache.geode.cache.client.internal.ServerRegionProxy) Connection(org.apache.geode.cache.client.internal.Connection)

Example 23 with ServerRegionProxy

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

the class HAInterestTestCase method stopPrimaryAndRegisterK1AndK2AndVerifyResponse.

public static void stopPrimaryAndRegisterK1AndK2AndVerifyResponse() {
    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 "connected server count never became 3";
        }
    };
    Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
    // close primaryEP
    getPrimaryVM().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));
}
Also used : WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) 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)

Example 24 with ServerRegionProxy

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

the class HAInterestTestCase method stopBothPrimaryAndSecondaryAndRegisterK1AndK2AndVerifyResponse.

public static void stopBothPrimaryAndSecondaryAndRegisterK1AndK2AndVerifyResponse() {
    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 "connected server count never became 3";
        }
    };
    Wait.waitForCriterion(wc, TIMEOUT_MILLIS, INTERVAL_MILLIS, true);
    // close primaryEP
    VM backup = getBackupVM();
    getPrimaryVM().invoke(() -> HAInterestTestCase.stopServer());
    // close secondary
    backup.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));
}
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 25 with ServerRegionProxy

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

the class ServerRegionFunctionExecutor method executeOnServer.

private ResultCollector executeOnServer(String functionId, ResultCollector collector, byte hasResult, boolean isHA, boolean optimizeForWrite) throws FunctionException {
    ServerRegionProxy srp = getServerRegionProxy();
    FunctionStats stats = FunctionStats.getFunctionStats(functionId, this.region.getSystem());
    try {
        validateExecution(null, null);
        long start = stats.startTime();
        stats.startFunctionExecution(true);
        srp.executeFunction(this.region.getFullPath(), functionId, this, collector, hasResult, isHA, optimizeForWrite, false);
        stats.endFunctionExecution(start, true);
        return collector;
    } catch (FunctionException functionException) {
        stats.endFunctionExecutionWithException(true);
        throw functionException;
    } catch (Exception exception) {
        stats.endFunctionExecutionWithException(true);
        throw new FunctionException(exception);
    }
}
Also used : ServerRegionProxy(org.apache.geode.cache.client.internal.ServerRegionProxy) FunctionException(org.apache.geode.cache.execute.FunctionException) FunctionException(org.apache.geode.cache.execute.FunctionException) CacheClosedException(org.apache.geode.cache.CacheClosedException)

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