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
}
}
Aggregations