use of org.apache.geode.cache.execute.Execution in project geode by apache.
the class PeerToPeerSessionCache method touchSessions.
@Override
public void touchSessions(Set<String> sessionIds) {
// Get the region attributes id to determine the region type. This is
// problematic since the region attributes id doesn't really define the
// region type. This should look at the actual session region.
String regionAttributesID = getSessionManager().getRegionAttributesId().toLowerCase();
// Invoke the appropriate function depending on the type of region
ResultCollector collector = null;
if (regionAttributesID.startsWith("partition")) {
// Execute the partitioned touch function on the primary server(s)
Execution execution = FunctionService.onRegion(getSessionRegion()).withFilter(sessionIds);
collector = execution.execute(TouchPartitionedRegionEntriesFunction.ID, true, false, true);
} else {
// Execute the member touch function on all the server(s)
Execution execution = FunctionService.onMembers().setArguments(new Object[] { this.sessionRegion.getFullPath(), sessionIds });
collector = execution.execute(TouchReplicatedRegionEntriesFunction.ID, true, false, false);
}
// Get the result
try {
collector.getResult();
} catch (Exception e) {
// If an exception occurs in the function, log it.
getSessionManager().getLogger().warn("Caught unexpected exception:", e);
}
}
use of org.apache.geode.cache.execute.Execution in project geode by apache.
the class ClientServerSessionCache method touchSessions.
@Override
public void touchSessions(Set<String> sessionIds) {
// Get the region attributes id to determine the region type. This is
// problematic since the region attributes id doesn't really define the
// region type. Currently there is no way to know the type of region created
// on the server. Maybe the CreateRegionFunction should return it.
String regionAttributesID = getSessionManager().getRegionAttributesId().toLowerCase();
// Invoke the appropriate function depending on the type of region
if (regionAttributesID.startsWith("partition")) {
// Execute the partitioned touch function on the primary server(s)
Execution execution = FunctionService.onRegion(getSessionRegion()).withFilter(sessionIds);
try {
ResultCollector collector = execution.execute(TouchPartitionedRegionEntriesFunction.ID, true, false, true);
collector.getResult();
} catch (Exception e) {
// If an exception occurs in the function, log it.
getSessionManager().getLogger().warn("Caught unexpected exception:", e);
}
} else {
// Execute the member touch function on all the server(s)
Execution execution = FunctionService.onServers(getCache()).setArguments(new Object[] { this.sessionRegion.getFullPath(), sessionIds });
try {
ResultCollector collector = execution.execute(TouchReplicatedRegionEntriesFunction.ID, true, false, false);
collector.getResult();
} catch (Exception e) {
// If an exception occurs in the function, log it.
getSessionManager().getLogger().warn("Caught unexpected exception:", e);
}
}
}
use of org.apache.geode.cache.execute.Execution in project geode by apache.
the class ClientServerSessionCache method createSessionRegionOnServers.
private void createSessionRegionOnServers() {
// Create the RegionConfiguration
RegionConfiguration configuration = createRegionConfiguration();
// Send it to the server tier
Execution execution = FunctionService.onServer(this.cache).setArguments(configuration);
ResultCollector collector = execution.execute(CreateRegionFunction.ID);
// Verify the region was successfully created on the servers
List<RegionStatus> results = (List<RegionStatus>) collector.getResult();
for (RegionStatus status : results) {
if (status == RegionStatus.INVALID) {
StringBuilder builder = new StringBuilder();
builder.append("An exception occurred on the server while attempting to create or validate region named ").append(getSessionManager().getRegionName()).append(". See the server log for additional details.");
throw new IllegalStateException(builder.toString());
}
}
}
use of org.apache.geode.cache.execute.Execution in project geode by apache.
the class ClientServerSessionCache method size.
@Override
public int size() {
// Add a single dummy key to force the function to go to one server
Set<String> filters = new HashSet<String>();
filters.add("test-key");
// Execute the function on the session region
Execution execution = FunctionService.onRegion(getSessionRegion()).withFilter(filters);
ResultCollector collector = execution.execute(RegionSizeFunction.ID, true, true, true);
List<Integer> result = (List<Integer>) collector.getResult();
// Return the first (and only) element
return result.get(0);
}
use of org.apache.geode.cache.execute.Execution in project geode by apache.
the class BootstrappingFunction method bootstrapMember.
private void bootstrapMember(InternalDistributedMember member) {
// Create and execute the function
Cache cache = CacheFactory.getAnyInstance();
Execution execution = FunctionService.onMember(member);
ResultCollector collector = execution.execute(this);
// Get the result. Nothing is being done with it.
try {
collector.getResult();
} catch (Exception e) {
// If an exception occurs in the function, log it.
cache.getLogger().warning("Caught unexpected exception:", e);
}
}
Aggregations