use of oracle.kubernetes.operator.TuningParameters.MainTuning in project weblogic-kubernetes-operator by oracle.
the class Main method scheduleDomainStatusUpdating.
private static void scheduleDomainStatusUpdating(DomainPresenceInfo info) {
AtomicInteger unchangedCount = new AtomicInteger(0);
AtomicReference<ScheduledFuture<?>> statusUpdater = info.getStatusUpdater();
Runnable command = new Runnable() {
public void run() {
// resolve visibility
Runnable r = this;
Packet packet = new Packet();
packet.getComponents().put(ProcessingConstants.DOMAIN_COMPONENT_NAME, Component.createFor(info, version));
MainTuning main = tuningAndConfig.getMainTuning();
Step strategy = DomainStatusUpdater.createStatusStep(main.statusUpdateTimeoutSeconds, null);
engine.createFiber().start(strategy, packet, new CompletionCallback() {
@Override
public void onCompletion(Packet packet) {
Boolean isStatusUnchanged = (Boolean) packet.get(ProcessingConstants.STATUS_UNCHANGED);
ScheduledFuture<?> existing = null;
if (Boolean.TRUE.equals(isStatusUnchanged)) {
if (unchangedCount.incrementAndGet() == main.unchangedCountToDelayStatusRecheck) {
// slow down retries because of sufficient unchanged statuses
existing = statusUpdater.getAndSet(engine.getExecutor().scheduleWithFixedDelay(r, main.eventualLongDelay, main.eventualLongDelay, TimeUnit.SECONDS));
}
} else {
// reset to trying after shorter delay because of changed status
unchangedCount.set(0);
existing = statusUpdater.getAndSet(engine.getExecutor().scheduleWithFixedDelay(r, main.initialShortDelay, main.initialShortDelay, TimeUnit.SECONDS));
if (existing != null) {
existing.cancel(false);
}
}
if (existing != null) {
existing.cancel(false);
}
}
@Override
public void onThrowable(Packet packet, Throwable throwable) {
LOGGER.severe(MessageKeys.EXCEPTION, throwable);
// retry to trying after shorter delay because of exception
unchangedCount.set(0);
ScheduledFuture<?> existing = statusUpdater.getAndSet(engine.getExecutor().scheduleWithFixedDelay(r, main.initialShortDelay, main.initialShortDelay, TimeUnit.SECONDS));
if (existing != null) {
existing.cancel(false);
}
}
});
}
};
MainTuning main = tuningAndConfig.getMainTuning();
ScheduledFuture<?> existing = statusUpdater.getAndSet(engine.getExecutor().scheduleWithFixedDelay(command, main.initialShortDelay, main.initialShortDelay, TimeUnit.SECONDS));
if (existing != null) {
existing.cancel(false);
}
}
Aggregations