Search in sources :

Example 1 with DistributedRegionFunctionResultSender

use of org.apache.geode.internal.cache.execute.DistributedRegionFunctionResultSender in project geode by apache.

the class DistributedRegion method executeOnReplicate.

private ResultCollector executeOnReplicate(final DistributedRegionFunctionExecutor execution, final Function function, final Object args, ResultCollector rc, final Set filter, final DistributedMember target) {
    final Set singleMember = Collections.singleton(target);
    execution.validateExecution(function, singleMember);
    execution.setExecutionNodes(singleMember);
    HashMap<InternalDistributedMember, Object> memberArgs = new HashMap<InternalDistributedMember, Object>();
    memberArgs.put((InternalDistributedMember) target, execution.getArgumentsForMember(target.getId()));
    ResultSender resultSender = new DistributedRegionFunctionResultSender(null, rc, function, execution.getServerResultSender());
    DistributedRegionFunctionResultWaiter waiter = new DistributedRegionFunctionResultWaiter(this.getSystem(), this.getFullPath(), rc, function, filter, Collections.singleton(target), memberArgs, resultSender);
    rc = waiter.getFunctionResultFrom(Collections.singleton(target), function, execution);
    return rc;
}
Also used : DistributedRegionFunctionResultSender(org.apache.geode.internal.cache.execute.DistributedRegionFunctionResultSender) Set(java.util.Set) CopyOnWriteArraySet(java.util.concurrent.CopyOnWriteArraySet) HashSet(java.util.HashSet) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) DistributedRegionFunctionResultWaiter(org.apache.geode.internal.cache.execute.DistributedRegionFunctionResultWaiter) HashMap(java.util.HashMap) ServerToClientFunctionResultSender(org.apache.geode.internal.cache.execute.ServerToClientFunctionResultSender) ResultSender(org.apache.geode.cache.execute.ResultSender) DistributedRegionFunctionResultSender(org.apache.geode.internal.cache.execute.DistributedRegionFunctionResultSender)

Example 2 with DistributedRegionFunctionResultSender

use of org.apache.geode.internal.cache.execute.DistributedRegionFunctionResultSender in project geode by apache.

the class DistributedRegion method executeOnRegion.

void executeOnRegion(DistributedRegionFunctionStreamingMessage msg, final Function function, final Object args, int prid, final Set filter, boolean isReExecute) throws IOException {
    final DM dm = getDistributionManager();
    ResultSender resultSender = new DistributedRegionFunctionResultSender(dm, msg, function);
    final RegionFunctionContextImpl context = new RegionFunctionContextImpl(function.getId(), this, args, filter, null, null, resultSender, isReExecute);
    FunctionStats stats = FunctionStats.getFunctionStats(function.getId(), dm.getSystem());
    try {
        long start = stats.startTime();
        stats.startFunctionExecution(function.hasResult());
        function.execute(context);
        stats.endFunctionExecution(start, function.hasResult());
    } catch (FunctionException functionException) {
        if (logger.isDebugEnabled()) {
            logger.debug("FunctionException occurred on remote node  while executing Function: {}", function.getId(), functionException);
        }
        stats.endFunctionExecutionWithException(function.hasResult());
        throw functionException;
    } catch (CacheClosedException cacheClosedexception) {
        if (logger.isDebugEnabled()) {
            logger.debug("CacheClosedException occurred on remote node  while executing Function: {}", function.getId(), cacheClosedexception);
        }
        throw cacheClosedexception;
    } catch (Exception exception) {
        if (logger.isDebugEnabled()) {
            logger.debug("Exception occurred on remote node  while executing Function: {}", function.getId(), exception);
        }
        stats.endFunctionExecutionWithException(function.hasResult());
        throw new FunctionException(exception);
    }
}
Also used : DistributedRegionFunctionResultSender(org.apache.geode.internal.cache.execute.DistributedRegionFunctionResultSender) RegionFunctionContextImpl(org.apache.geode.internal.cache.execute.RegionFunctionContextImpl) FunctionException(org.apache.geode.cache.execute.FunctionException) DM(org.apache.geode.distributed.internal.DM) FunctionStats(org.apache.geode.internal.cache.execute.FunctionStats) CacheClosedException(org.apache.geode.cache.CacheClosedException) ServerToClientFunctionResultSender(org.apache.geode.internal.cache.execute.ServerToClientFunctionResultSender) ResultSender(org.apache.geode.cache.execute.ResultSender) DistributedRegionFunctionResultSender(org.apache.geode.internal.cache.execute.DistributedRegionFunctionResultSender) TimeoutException(org.apache.geode.cache.TimeoutException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) InvalidDeltaException(org.apache.geode.InvalidDeltaException) AsyncEventQueueConfigurationException(org.apache.geode.internal.cache.wan.AsyncEventQueueConfigurationException) RegionDistributionException(org.apache.geode.cache.RegionDistributionException) LockServiceDestroyedException(org.apache.geode.distributed.LockServiceDestroyedException) IOException(java.io.IOException) RoleException(org.apache.geode.cache.RoleException) GatewaySenderConfigurationException(org.apache.geode.internal.cache.wan.GatewaySenderConfigurationException) CancelException(org.apache.geode.CancelException) DiskAccessException(org.apache.geode.cache.DiskAccessException) CacheWriterException(org.apache.geode.cache.CacheWriterException) RegionAccessException(org.apache.geode.cache.RegionAccessException) FunctionException(org.apache.geode.cache.execute.FunctionException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) CacheLoaderException(org.apache.geode.cache.CacheLoaderException) CacheClosedException(org.apache.geode.cache.CacheClosedException) ConcurrentCacheModificationException(org.apache.geode.internal.cache.versions.ConcurrentCacheModificationException) PersistentReplicatesOfflineException(org.apache.geode.cache.persistence.PersistentReplicatesOfflineException)

Example 3 with DistributedRegionFunctionResultSender

use of org.apache.geode.internal.cache.execute.DistributedRegionFunctionResultSender in project geode by apache.

the class DistributedRegion method executeLocally.

ResultCollector executeLocally(final DistributedRegionFunctionExecutor execution, final Function function, final Object args, int prid, final ResultCollector rc, final Set filter, final ServerToClientFunctionResultSender sender) {
    final LocalResultCollector<?, ?> localRC = execution.getLocalResultCollector(function, rc);
    final DM dm = getDistributionManager();
    final DistributedRegionFunctionResultSender resultSender = new DistributedRegionFunctionResultSender(dm, localRC, function, sender);
    final RegionFunctionContextImpl context = new RegionFunctionContextImpl(function.getId(), DistributedRegion.this, args, filter, null, null, resultSender, execution.isReExecute());
    execution.executeFunctionOnLocalNode(function, context, resultSender, dm, isTX());
    return localRC;
}
Also used : DistributedRegionFunctionResultSender(org.apache.geode.internal.cache.execute.DistributedRegionFunctionResultSender) RegionFunctionContextImpl(org.apache.geode.internal.cache.execute.RegionFunctionContextImpl) DM(org.apache.geode.distributed.internal.DM)

Example 4 with DistributedRegionFunctionResultSender

use of org.apache.geode.internal.cache.execute.DistributedRegionFunctionResultSender in project geode by apache.

the class LocalRegion method executeFunction.

/**
   * Execute the provided named function in all locations that contain the given keys. So function
   * can be executed on just one fabric node, executed in parallel on a subset of nodes in parallel
   * across all the nodes.
   * 
   * @since GemFire 5.8Beta
   */
public ResultCollector executeFunction(final DistributedRegionFunctionExecutor execution, final Function function, final Object args, final ResultCollector rc, final Set filter, final ServerToClientFunctionResultSender sender) {
    if (function.optimizeForWrite() && this.memoryThresholdReached.get() && !MemoryThresholds.isLowMemoryExceptionDisabled()) {
        Set<DistributedMember> members = getMemoryThresholdReachedMembers();
        throw new LowMemoryException(LocalizedStrings.ResourceManager_LOW_MEMORY_FOR_0_FUNCEXEC_MEMBERS_1.toLocalizedString(function.getId(), members), members);
    }
    final LocalResultCollector<?, ?> resultCollector = execution.getLocalResultCollector(function, rc);
    final DM dm = getDistributionManager();
    execution.setExecutionNodes(Collections.singleton(getMyId()));
    final DistributedRegionFunctionResultSender resultSender = new DistributedRegionFunctionResultSender(dm, resultCollector, function, sender);
    final RegionFunctionContextImpl context = new RegionFunctionContextImpl(function.getId(), LocalRegion.this, args, filter, null, null, resultSender, execution.isReExecute());
    execution.executeFunctionOnLocalNode(function, context, resultSender, dm, isTX());
    return resultCollector;
}
Also used : DistributedRegionFunctionResultSender(org.apache.geode.internal.cache.execute.DistributedRegionFunctionResultSender) RegionFunctionContextImpl(org.apache.geode.internal.cache.execute.RegionFunctionContextImpl) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) DistributedMember(org.apache.geode.distributed.DistributedMember) DM(org.apache.geode.distributed.internal.DM) LowMemoryException(org.apache.geode.cache.LowMemoryException)

Aggregations

DistributedRegionFunctionResultSender (org.apache.geode.internal.cache.execute.DistributedRegionFunctionResultSender)4 DM (org.apache.geode.distributed.internal.DM)3 RegionFunctionContextImpl (org.apache.geode.internal.cache.execute.RegionFunctionContextImpl)3 ResultSender (org.apache.geode.cache.execute.ResultSender)2 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)2 ServerToClientFunctionResultSender (org.apache.geode.internal.cache.execute.ServerToClientFunctionResultSender)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 CopyOnWriteArraySet (java.util.concurrent.CopyOnWriteArraySet)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 CancelException (org.apache.geode.CancelException)1 InvalidDeltaException (org.apache.geode.InvalidDeltaException)1 CacheClosedException (org.apache.geode.cache.CacheClosedException)1 CacheLoaderException (org.apache.geode.cache.CacheLoaderException)1 CacheWriterException (org.apache.geode.cache.CacheWriterException)1 DiskAccessException (org.apache.geode.cache.DiskAccessException)1 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)1 LowMemoryException (org.apache.geode.cache.LowMemoryException)1