use of org.apache.sling.discovery.oak.pinger.OakViewChecker in project sling by apache.
the class OakVirtualInstanceBuilder method createViewChecker.
@Override
protected ViewChecker createViewChecker() throws Exception {
getOakViewChecker();
return new ViewChecker() {
private final Logger logger = LoggerFactory.getLogger(getClass());
private SimulatedLease lease = new SimulatedLease(getResourceResolverFactory(), leaseCollection, getSlingId());
protected void activate(ComponentContext c) throws Throwable {
OakViewChecker pinger = getOakViewChecker();
PrivateAccessor.invoke(pinger, "activate", new Class[] { ComponentContext.class }, new Object[] { c });
}
@Override
public void checkView() {
try {
lease.updateDescriptor(getConfig());
} catch (Exception e) {
logger.error("run: could not update lease: " + e);
}
}
public void run() {
heartbeatAndCheckView();
}
@Override
public void heartbeatAndCheckView() {
// as soon as I see others the descriptor is updated
try {
lease.updateLeaseAndDescriptor(getConfig());
} catch (Exception e) {
logger.error("run: could not update lease: " + e, e);
}
try {
getOakViewChecker().run();
} catch (Exception e) {
logger.error("run: could not ping: " + e, e);
}
if (!getIdMapService().isInitialized()) {
if (!getIdMapService().waitForInit(1500)) {
fail("init didnt work");
}
}
}
};
}
Aggregations