ClientServerSessionCache extends AbstractSessionCache { @Override public void touchSessions(Set<String> sessionIds) { String regionAttributesID = getSessionManager().getRegionAttributesId().toLowerCase(); if (regionAttributesID.startsWith("partition")) { Execution execution = getExecutionForFunctionOnRegionWithFilter(sessionIds); try { ResultCollector collector = execution.execute(TouchPartitionedRegionEntriesFunction.ID); collector.getResult(); } catch (Exception e) { getSessionManager().getLogger().warn("Caught unexpected exception:", e); } } else { Object[] arguments = new Object[] {this.sessionRegion.getFullPath(), sessionIds}; Execution execution = getExecutionForFunctionOnServersWithArguments(arguments); try { ResultCollector collector = execution.execute(TouchReplicatedRegionEntriesFunction.ID); collector.getResult(); } catch (Exception e) { getSessionManager().getLogger().warn("Caught unexpected exception:", e); } } } ClientServerSessionCache(SessionManager sessionManager, ClientCache cache); @Override void initialize(); @Override String getDefaultRegionAttributesId(); @Override boolean getDefaultEnableLocalCache(); @Override void touchSessions(Set<String> sessionIds); @Override boolean isPeerToPeer(); @Override boolean isClientServer(); @Override Set<String> keySet(); @Override int size(); @Override boolean isBackingCacheAvailable(); @Override GemFireCache getCache();  }
@Test public void touchSessionsInvokesPRFunctionForPRAndDoesNotThrowExceptionWhenFunctionDoesNotThrowException() { final Set<String> sessionIds = new HashSet<>(); when(sessionManager.getRegionAttributesId()).thenReturn(RegionShortcut.PARTITION.toString()); sessionCache.touchSessions(sessionIds); verify(emptyExecution).execute(TouchPartitionedRegionEntriesFunction.ID); }
@Test public void touchSessionsInvokesPRFunctionForPRAndThrowsExceptionWhenFunctionThrowsException() { final Set<String> sessionIds = new HashSet<>(); final FunctionException exception = new FunctionException(); final ResultCollector<Object, List<Object>> exceptionCollector = uncheckedCast(mock(ResultCollector.class)); when(sessionManager.getRegionAttributesId()).thenReturn(RegionShortcut.PARTITION.toString()); when(emptyExecution.execute(TouchPartitionedRegionEntriesFunction.ID)) .thenReturn(exceptionCollector); when(exceptionCollector.getResult()).thenThrow(exception); sessionCache.touchSessions(sessionIds); verify(logger).warn("Caught unexpected exception:", exception); }