public static void putOperation() { Region region = cache.getRegion(PartitionedRegionName); assertNotNull(region); final HashSet testKeysSet = new HashSet(); for (int i = (totalNumBuckets.intValue() * 10); i > 0; i--) { testKeysSet.add("execKey-" + i); } int j = 0; HashSet origVals = new HashSet(); for (Iterator i = testKeysSet.iterator(); i.hasNext();) { Integer val = new Integer(j++); origVals.add(val); region.put(i.next(), val); } }
private void createScenario() { ArrayList commonAttributes = createCommonServerAttributes( "TestPartitionedRegion", null, 0, 13, null); createClientServerScenarioNoSingleHop(commonAttributes, 20, 20, 20); }
public void testserverMultiKeyExecutionNoResult_byName() { createScenario(); Function function = new TestFunction(false, TEST_FUNCTION7); registerFunctionAtServer(function); isByName = new Boolean(true); client.invoke( PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.class, "serverMultiKeyExecutionNoResult", new Object[] { isByName }); }
public static void serverSingleKeyExecutionSocketTimeOut(Boolean isByName) { Region region = cache.getRegion(PartitionedRegionName); assertNotNull(region); final String testKey = "execKey"; final Set testKeysSet = new HashSet(); testKeysSet.add(testKey); DistributedSystem.setThreadsSocketPolicy(false); Function function = new TestFunction(true, TestFunction.TEST_FUNCTION_SOCKET_TIMEOUT); FunctionService.registerFunction(function); Execution dataSet = FunctionService.onRegion(region); region.put(testKey, new Integer(1)); try { ResultCollector rs = execute(dataSet, testKeysSet, Boolean.TRUE, function, isByName); assertEquals(Boolean.TRUE, ((List)rs.getResult()).get(0)); ResultCollector rs2 = execute(dataSet, testKeysSet, testKey, function, isByName); assertEquals(testKey, ((List)rs2.getResult()).get(0)); } catch (Exception ex) { ex.printStackTrace(); getLogWriter().info("Exception : ", ex); fail("Test failed after the put operation", ex); } }
public void testServerFailoverWithTwoServerAliveHA() throws InterruptedException { ArrayList commonAttributes = createCommonServerAttributes( "TestPartitionedRegion", null, 1, 13, null); createClientServerScenarion(commonAttributes, 20, 20, 20); Function function = new TestFunction(true, TestFunction.TEST_FUNCTION_HA); registerFunctionAtServer(function); server2.invoke( PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.class, "verifyDeadAndLiveServers", new Object[] { new Integer(1), new Integer(2) }); DistributedTestCase.join(async[0], 6 * 60 * 1000, getLogWriter()); if (async[0].getException() != null) { fail("UnExpected Exception Occured : ", async[0].getException()); assertEquals(2, l.size());
public static void getAll() { Region region = cache.getRegion(PartitionedRegionName); assertNotNull(region); final List testKeysList = new ArrayList(); for (int i = (totalNumBuckets.intValue() * 3); i > 0; i--) { testKeysList.add("execKey-" + i); } DistributedSystem.setThreadsSocketPolicy(false); try { int j = 0; Map origVals = new HashMap(); for (Iterator i = testKeysList.iterator(); i.hasNext();) { Integer val = new Integer(j++); Object key = i.next(); origVals.put(key, val); region.put(key, val); } Map resultMap = region.getAll(testKeysList); assertTrue(resultMap.equals(origVals)); pause(2000); Map secondResultMap = region.getAll(testKeysList); assertTrue(secondResultMap.equals(origVals)); } catch (Exception e) { fail("Test failed after the put operation", e); } }
public static void serverMultiKeyExecution_FunctionInvocationTargetException() { Region region = cache.getRegion(PartitionedRegionName); assertNotNull(region); final HashSet testKeysSet = new HashSet(); for (int i = (totalNumBuckets.intValue() * 2); i > 0; i--) { assertEquals(list.get(0), 0); fail("This is not expected Exception", e);
public void testServerGetAllFunction() { createScenario(); client.invoke( PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.class, "getAll"); }
public static void checkBucketsOnServer() { PartitionedRegion region = (PartitionedRegion)cache .getRegion(PartitionedRegionName); HashMap localBucket2RegionMap = (HashMap)region.getDataStore() .getSizeLocally(); getLogWriter().info( "Size of the " + PartitionedRegionName + " in this VM :- " + localBucket2RegionMap.size()); Set entrySet = localBucket2RegionMap.entrySet(); assertNotNull(entrySet); }
public static void FunctionExecution_Inline_Bug40714() { Region region = cache.getRegion(PartitionedRegionName); assertNotNull(region); final HashSet testKeysSet = new HashSet(); for (int i = (totalNumBuckets.intValue() * 10); i > 0; i--) { assertEquals(3, resultMap.size()); assertEquals(Boolean.TRUE, result);
public static void serverMultiKeyExecution(Boolean isByName) { Region region = cache.getRegion(PartitionedRegionName); assertNotNull(region); final HashSet testKeysSet = new HashSet(); for (int i = (totalNumBuckets.intValue() * 2); i > 0; i--) { ResultCollector rc1 = execute(dataSet, testKeysSet, Boolean.TRUE, function, isByName); l = ((List)rc1.getResult()); getLogWriter().info("Result size : " + l.size()); assertEquals(3, l.size()); for (Iterator i = l.iterator(); i.hasNext();) { assertEquals(Boolean.TRUE, i.next()); ResultCollector rc2 = execute(dataSet, testKeysSet, testKeysSet, function, isByName); l2 = ((List)rc2.getResult()); assertEquals(3, l2.size()); HashSet foundVals = new HashSet(); for (Iterator i = l2.iterator(); i.hasNext();) { ArrayList subL = (ArrayList)i.next(); assertTrue(subL.size() > 0); for (Iterator subI = subL.iterator(); subI.hasNext();) { assertTrue(foundVals.add(subI.next())); assertEquals(origVals, foundVals); fail("Test failed after the put operation", e);
public void testServerCacheClosedFailoverWithTwoServerAliveHA() throws InterruptedException { ArrayList commonAttributes = createCommonServerAttributes( "TestPartitionedRegion", null, 1, 13, null); createClientServerScenarion(commonAttributes, 20, 20, 20); Function function = new TestFunction(true, TestFunction.TEST_FUNCTION_HA); registerFunctionAtServer(function); server2.invoke( PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.class, "verifyDeadAndLiveServers", new Object[] { new Integer(1), new Integer(2) }); DistributedTestCase.join(async[0], 5 * 60 * 1000, getLogWriter()); if (async[0].getException() != null) { fail("UnExpected Exception Occured : ", async[0].getException()); assertEquals(2, l.size());
public static void putAll() { Region region = cache.getRegion(PartitionedRegionName); assertNotNull(region); final List testKeysList = new ArrayList(); for (int i = (totalNumBuckets.intValue() * 3); i > 0; i--) { testKeysList.add("execKey-" + i); } DistributedSystem.setThreadsSocketPolicy(false); try { int j = 0; Map origVals = new HashMap(); for (Iterator i = testKeysList.iterator(); i.hasNext();) { Integer val = new Integer(j++); Object key = i.next(); origVals.put(key, val); region.put(key, val); } Map resultMap = region.getAll(testKeysList); assertTrue(resultMap.equals(origVals)); pause(2000); Map secondResultMap = region.getAll(testKeysList); assertTrue(secondResultMap.equals(origVals)); } catch (Exception e) { fail("Test failed after the put operation", e); } }
public void testServerPutAllFunction() { createScenario(); client.invoke( PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.class, "putAll"); }
public static void serverSingleKeyExecution(Boolean isByName) { Region region = cache.getRegion(PartitionedRegionName); assertNotNull(region); final String testKey = "execKey"; final Set testKeysSet = new HashSet(); Execution dataSet = FunctionService.onRegion(region); try { execute(dataSet, testKeysSet, Boolean.TRUE, function, isByName); assertTrue(expected.getMessage().contains( "No target node found for KEY = " + testKey) || expected.getMessage() ResultCollector rs = execute(dataSet, testKeysSet, Boolean.TRUE, function, isByName); assertEquals(Boolean.TRUE, ((List)rs.getResult()).get(0)); ResultCollector rs2 = execute(dataSet, testKeysSet, testKey, function, isByName); assertEquals(new Integer(1), ((List)rs2.getResult()).get(0)); ResultCollector rs1 = execute(dataSet, testKeysSet, putData, function, isByName); assertEquals(Boolean.TRUE, ((List)rs1.getResult()).get(0)); assertEquals(new Integer(2), region.get(testKey + "1")); assertEquals(new Integer(3), region.get(testKey + "2")); getLogWriter().info("Exception : ", ex);
public void testServerAllKeyExecution_byInstance() { createScenario(); Function function = new TestFunction(true, TEST_FUNCTION2); registerFunctionAtServer(function); isByName = new Boolean(false); client.invoke( PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.class, "serverAllKeyExecution", new Object[] { isByName }); }
public void testserverMultiKeyExecution_FunctionInvocationTargetException() { createScenario(); client.invoke( PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.class, "serverMultiKeyExecution_FunctionInvocationTargetException"); }
public static void serverSingleKeyExecution_FunctionInvocationTargetException() { Region region = cache.getRegion(PartitionedRegionName); assertNotNull(region); final String testKey = "execKey"; final Set testKeysSet = new HashSet(); testKeysSet.add(testKey); DistributedSystem.setThreadsSocketPolicy(false); Function function = new TestFunction(true, TestFunction.TEST_FUNCTION_REEXECUTE_EXCEPTION); FunctionService.registerFunction(function); Execution dataSet = FunctionService.onRegion(region); region.put(testKey, new Integer(1)); try { ResultCollector rs = execute(dataSet, testKeysSet, Boolean.TRUE, function, false); ArrayList list = (ArrayList)rs.getResult(); assertTrue(((Integer)list.get(0)) >= 5); } catch (Exception ex) { ex.printStackTrace(); fail("This is not expected Exception", ex); } }
public void testServerSingleKeyExecution_SocketTimeOut() { createScenario(); Function function = new TestFunction(true, TestFunction.TEST_FUNCTION_SOCKET_TIMEOUT); registerFunctionAtServer(function); isByName = new Boolean(true); client.invoke( PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.class, "serverSingleKeyExecutionSocketTimeOut", new Object[] { isByName }); }
public void testServerSingleKeyExecution_byInlineFunction() { createScenario(); client.invoke( PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.class, "serverSingleKeyExecution_Inline"); }