use of org.apache.geode.cache.execute.Execution in project geode by apache.
the class ClientServerSessionCache method bootstrapServers.
////////////////////////////////////////////////////////////////////////
// Private methods
private void bootstrapServers() {
Execution execution = FunctionService.onServers(this.cache);
ResultCollector collector = execution.execute(new BootstrappingFunction());
// Get the result. Nothing is being done with it.
try {
collector.getResult();
} catch (Exception e) {
// If an exception occurs in the function, log it.
LOG.warn("Caught unexpected exception:", e);
}
}
use of org.apache.geode.cache.execute.Execution in project geode by apache.
the class ClientServerSessionCache method bootstrapServers.
private void bootstrapServers() {
Execution execution = FunctionService.onServers(this.cache);
ResultCollector collector = execution.execute(new BootstrappingFunction());
// Get the result. Nothing is being done with it.
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 GemFireDeadlockDetector method find.
/**
* Find any deadlocks the exist in this distributed system.
*
* The deadlocks are returned as a list of dependencies. See {@link DeadlockDetector}
*/
public DependencyGraph find() {
final DeadlockDetector detector = new DeadlockDetector();
ResultCollector<HashSet<Dependency>, Serializable> collector = new ResultCollector<HashSet<Dependency>, Serializable>() {
public synchronized Serializable getResult() throws FunctionException {
return null;
}
public synchronized Serializable getResult(long timeout, TimeUnit unit) throws FunctionException, InterruptedException {
return null;
}
public synchronized void addResult(DistributedMember memberID, HashSet<Dependency> resultOfSingleExecution) {
detector.addDependencies(resultOfSingleExecution);
}
public void endResults() {
}
public void clearResults() {
}
};
Execution execution;
if (targetMembers != null) {
execution = FunctionService.onMembers(targetMembers).withCollector(collector);
} else {
execution = FunctionService.onMembers().withCollector(collector);
}
((AbstractExecution) execution).setIgnoreDepartedMembers(true);
collector = execution.execute(new CollectDependencyFunction());
// Wait for results
collector.getResult();
return detector.getDependencyGraph();
}
use of org.apache.geode.cache.execute.Execution in project geode by apache.
the class ClientExporter method export.
@Override
public long export(Region<K, V> region, ExportSink sink, SnapshotOptions<K, V> options) throws IOException {
try {
ClientArgs<K, V> args = new ClientArgs<K, V>(region.getFullPath(), pool.getPRSingleHopEnabled(), options);
ClientExportCollector results = new ClientExportCollector(sink);
// For single hop we rely on tcp queuing to throttle the export; otherwise
// we allow the WindowedExporter to provide back pressure.
Execution exec = pool.getPRSingleHopEnabled() ? FunctionService.onRegion(region) : FunctionService.onServer(pool);
ResultCollector<?, ?> rc = exec.setArguments(args).withCollector(results).execute(new ProxyExportFunction<K, V>());
// check for errors.
return (Long) rc.getResult();
} catch (FunctionException e) {
throw new IOException(e);
}
}
use of org.apache.geode.cache.execute.Execution in project geode by apache.
the class MemberRegionFunction method execute.
@Override
public void execute(FunctionContext context) {
Object[] args = (Object[]) context.getArguments();
String region = (String) args[0];
String functionId = (String) args[1];
Cache cache = CacheFactory.getAnyInstance();
try {
Function function = FunctionService.getFunction(functionId);
if (function == null) {
context.getResultSender().lastResult("For region on a member did not get function " + functionId);
}
Execution execution = FunctionService.onRegion(cache.getRegion(region));
if (execution == null) {
context.getResultSender().lastResult("For region on a member could not execute");
} else {
execution.execute(function);
context.getResultSender().lastResult("succeeded in executing on region " + region);
}
} catch (FunctionException e) {
context.getResultSender().lastResult("FunctionException in MemberRegionFunction =" + e.getMessage());
} catch (Exception e) {
context.getResultSender().lastResult("Exception in MemberRegionFunction =" + e.getMessage());
}
}
Aggregations