in brooklyn-server/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/RebindIteration.java [526:629]
protected void reconstructEverything() {
checkEnteringPhase(6);
// Reconstruct locations
logRebindingDebug("RebindManager reconstructing locations");
for (LocationMemento locMemento : sortParentFirst(memento.getLocationMementos()).values()) {
Location location = rebindContext.getLocation(locMemento.getId());
logRebindingDebug("RebindManager reconstructing location {}", locMemento);
if (location == null) {
// usually because of creation-failure, when not using fail-fast
exceptionHandler.onNotFound(BrooklynObjectType.LOCATION, locMemento.getId());
} else {
try {
((LocationInternal)location).getRebindSupport().reconstruct(rebindContext, locMemento);
} catch (Exception e) {
exceptionHandler.onRebindFailed(BrooklynObjectType.LOCATION, location, e);
}
}
}
// Reconstruct policies
if (rebindManager.persistPoliciesEnabled) {
logRebindingDebug("RebindManager reconstructing policies");
for (PolicyMemento policyMemento : memento.getPolicyMementos().values()) {
Policy policy = rebindContext.getPolicy(policyMemento.getId());
logRebindingDebug("RebindManager reconstructing policy {}", policyMemento);
if (policy == null) {
// usually because of creation-failure, when not using fail-fast
exceptionHandler.onNotFound(BrooklynObjectType.POLICY, policyMemento.getId());
} else {
try {
policy.getRebindSupport().reconstruct(rebindContext, policyMemento);
} catch (Exception e) {
exceptionHandler.onRebindFailed(BrooklynObjectType.POLICY, policy, e);
rebindContext.unregisterPolicy(policy);
}
}
}
}
// Reconstruct enrichers
if (rebindManager.persistEnrichersEnabled) {
logRebindingDebug("RebindManager reconstructing enrichers");
for (EnricherMemento enricherMemento : memento.getEnricherMementos().values()) {
Enricher enricher = rebindContext.getEnricher(enricherMemento.getId());
logRebindingDebug("RebindManager reconstructing enricher {}", enricherMemento);
if (enricher == null) {
// usually because of creation-failure, when not using fail-fast
exceptionHandler.onNotFound(BrooklynObjectType.ENRICHER, enricherMemento.getId());
} else {
try {
enricher.getRebindSupport().reconstruct(rebindContext, enricherMemento);
} catch (Exception e) {
exceptionHandler.onRebindFailed(BrooklynObjectType.ENRICHER, enricher, e);
rebindContext.unregisterEnricher(enricher);
}
}
}
}
// Reconstruct feeds
if (rebindManager.persistFeedsEnabled) {
logRebindingDebug("RebindManager reconstructing feeds");
for (FeedMemento feedMemento : memento.getFeedMementos().values()) {
Feed feed = rebindContext.getFeed(feedMemento.getId());
logRebindingDebug("RebindManager reconstructing feed {}", feedMemento);
if (feed == null) {
// usually because of creation-failure, when not using fail-fast
exceptionHandler.onNotFound(BrooklynObjectType.FEED, feedMemento.getId());
} else {
try {
feed.getRebindSupport().reconstruct(rebindContext, feedMemento);
} catch (Exception e) {
exceptionHandler.onRebindFailed(BrooklynObjectType.FEED, feed, e);
rebindContext.unregisterFeed(feed);
}
}
}
}
// Reconstruct entities
logRebindingDebug("RebindManager reconstructing entities");
for (EntityMemento entityMemento : sortParentFirst(memento.getEntityMementos()).values()) {
Entity entity = rebindContext.lookup().lookupEntity(entityMemento.getId());
logRebindingDebug("RebindManager reconstructing entity {}", entityMemento);
if (entity == null) {
// usually because of creation-failure, when not using fail-fast
exceptionHandler.onNotFound(BrooklynObjectType.ENTITY, entityMemento.getId());
} else {
try {
entityMemento.injectTypeClass(entity.getClass());
((EntityInternal)entity).getRebindSupport().reconstruct(rebindContext, entityMemento);
} catch (Exception e) {
exceptionHandler.onRebindFailed(BrooklynObjectType.ENTITY, entity, e);
}
}
}
}