Search in sources :

Example 1 with FunctionService

use of org.apache.geode.cache.execute.FunctionService in project geode by apache.

the class DeployedJar method cleanUp.

/**
   * Unregisters all functions from this jar if it was undeployed (i.e. newVersion == null), or all
   * functions not present in the new version if it was redeployed.
   *
   * @param newVersion The new version of this jar that was deployed, or null if this jar was
   *        undeployed.
   */
protected synchronized void cleanUp(DeployedJar newVersion) {
    Stream<String> oldFunctions = this.registeredFunctions.stream().map(Function::getId);
    Stream<String> removedFunctions;
    if (newVersion == null) {
        removedFunctions = oldFunctions;
    } else {
        Predicate<String> isRemoved = (String oldFunctionId) -> !newVersion.hasFunctionWithId(oldFunctionId);
        removedFunctions = oldFunctions.filter(isRemoved);
    }
    removedFunctions.forEach(FunctionService::unregisterFunction);
    this.registeredFunctions.clear();
    try {
        TypeRegistry typeRegistry = ((InternalCache) CacheFactory.getAnyInstance()).getPdxRegistry();
        if (typeRegistry != null) {
            typeRegistry.flushCache();
        }
    } catch (CacheClosedException ignored) {
    // That's okay, it just means there was nothing to flush to begin with
    }
}
Also used : Function(org.apache.geode.cache.execute.Function) InternalCache(org.apache.geode.internal.cache.InternalCache) FunctionService(org.apache.geode.cache.execute.FunctionService) CacheClosedException(org.apache.geode.cache.CacheClosedException) TypeRegistry(org.apache.geode.pdx.internal.TypeRegistry)

Aggregations

CacheClosedException (org.apache.geode.cache.CacheClosedException)1 Function (org.apache.geode.cache.execute.Function)1 FunctionService (org.apache.geode.cache.execute.FunctionService)1 InternalCache (org.apache.geode.internal.cache.InternalCache)1 TypeRegistry (org.apache.geode.pdx.internal.TypeRegistry)1