use of org.apache.sling.discovery.commons.providers.spi.base.DiscoveryLiteDescriptor in project sling by apache.
the class TopologyWebConsolePlugin method updateDiscoveryLiteHistory.
/**
* if there's any change add a discoveryLite descriptor entry to the history, truncating if necessary
*/
private synchronized void updateDiscoveryLiteHistory() {
ResourceResolver resourceResolver = null;
try {
resourceResolver = getResourceResolver();
DiscoveryLiteDescriptor descriptor = DiscoveryLiteDescriptor.getDescriptorFrom(resourceResolver);
if (lastDiscoveryLiteDescriptor != null && descriptor.getDescriptorStr().equals(lastDiscoveryLiteDescriptor.getDescriptorStr())) {
// de-duplication - then there's nothing to update
return;
}
final String logEntry = getCurrentDateFormatted() + ": " + descriptor.getDescriptorStr();
lastDiscoveryLiteDescriptor = descriptor;
discoveryLiteHistory.add(logEntry);
while (discoveryLiteHistory.size() > 12) {
discoveryLiteHistory.remove(0);
}
} catch (Exception e) {
logger.error("addDiscoveryLiteHistoryEntry: Exception: " + e, e);
} finally {
if (resourceResolver != null) {
resourceResolver.close();
}
}
}
use of org.apache.sling.discovery.commons.providers.spi.base.DiscoveryLiteDescriptor in project sling by apache.
the class OakClusterViewService method getLocalClusterView.
@Override
public LocalClusterView getLocalClusterView() throws UndefinedClusterViewException {
logger.trace("getLocalClusterView: start");
ResourceResolver resourceResolver = null;
try {
resourceResolver = getResourceResolver();
DiscoveryLiteDescriptor descriptor = DiscoveryLiteDescriptor.getDescriptorFrom(resourceResolver);
if (lastSeqNum != descriptor.getSeqNum()) {
logger.info("getLocalClusterView: sequence number change detected - clearing idmap cache");
idMapService.clearCache();
lastSeqNum = descriptor.getSeqNum();
}
return asClusterView(descriptor, resourceResolver);
} catch (UndefinedClusterViewException e) {
logger.info("getLocalClusterView: undefined clusterView: " + e.getReason() + " - " + e.getMessage());
throw e;
} catch (Exception e) {
if (e.getMessage() != null && e.getMessage().contains("No Descriptor value available")) {
logger.warn("getLocalClusterView: repository exception: " + e);
} else {
logger.error("getLocalClusterView: repository exception: " + e, e);
}
throw new UndefinedClusterViewException(Reason.REPOSITORY_EXCEPTION, "Exception while processing descriptor: " + e);
} finally {
logger.trace("getLocalClusterView: end");
if (resourceResolver != null) {
resourceResolver.close();
}
}
}
Aggregations