Java源码示例:io.fabric8.kubernetes.client.informers.ResourceEventHandler

示例1
public ProcessorListener(ResourceEventHandler<T> handler, long resyncPeriodInMillis) {
  this.resyncPeriodInMillis = resyncPeriodInMillis;
  this.handler = handler;
  this.queue = new LinkedBlockingQueue<>();

  determineNextResync(ZonedDateTime.now());
}
 
示例2
@Override
public void handle(ResourceEventHandler<T> resourceEventHandler) {
  if (getOldObject() instanceof  DeltaFIFO.DeletedFinalStateUnknown) {
    resourceEventHandler.onDelete(((DeltaFIFO.DeletedFinalStateUnknown<T>) getOldObject()).getObj(), true);
  } else {
    resourceEventHandler.onDelete(getOldObject(), false);
  }
}
 
示例3
@Override
public void addEventHandlerWithResyncPeriod(ResourceEventHandler<T> handler, long resyncPeriodMillis) {
  if (stopped) {
    log.info("DefaultSharedIndexInformer#Handler was not added to shared informer because it has stopped already");
    return;
  }

  if (resyncPeriodMillis > 0) {
    if (resyncPeriodMillis < MINIMUM_RESYNC_PERIOD_MILLIS) {
      log.warn("DefaultSharedIndexInformer#resyncPeriod {} is too small. Chanding it to minimul allowed rule of {}", resyncPeriodMillis, MINIMUM_RESYNC_PERIOD_MILLIS);
      resyncPeriodMillis = MINIMUM_RESYNC_PERIOD_MILLIS;
    }

    if (resyncPeriodMillis < this.resyncCheckPeriodMillis) {
      if (started) {
        log.warn("DefaultSharedIndexInformer#resyncPeriod {} is smaller than resyncCheckPeriod {} and the informer has already started. Changing it to {}", resyncPeriodMillis, resyncCheckPeriodMillis);
        resyncPeriodMillis = resyncCheckPeriodMillis;
      } else {
        // if the event handler's resyncPeriod is smaller than the current resyncCheckPeriod
        // update resyncCheckPeriod to match resyncPeriod and adjust the resync periods of all
        // the listeners accordingly.
        this.resyncCheckPeriodMillis = resyncPeriodMillis;
      }
    }
  }

  ProcessorListener<T> listener = new ProcessorListener(handler, determineResyncPeriod(resyncCheckPeriodMillis, this.resyncCheckPeriodMillis));
  if (!started) {
    this.processor.addListener(listener);
    return;
  }

  this.processor.addAndStartListener(listener);
  List<T> objectList = this.indexer.list();
  for (Object item : objectList) {
    listener.add(new ProcessorListener.AddNotification(item));
  }
}
 
示例4
@Override
public void handle(ResourceEventHandler<T> resourceEventHandler) {
  resourceEventHandler.onUpdate(getOldObject(), getNewObject());
}
 
示例5
@Override
public void handle(ResourceEventHandler<T> resourceEventHandler) {
  resourceEventHandler.onAdd(getNewObject());
}
 
示例6
ExpectingNotificationHandler(ResourceEventHandler<T> handler, long resyncPeriod) {
  super(handler, resyncPeriod);
}
 
示例7
/**
 * add event callback
 *
 * @param handler event handler
 */
@Override
public void addEventHandler(ResourceEventHandler<T> handler) {
  addEventHandlerWithResyncPeriod(handler, defaultEventHandlerResyncPeriod);
}
 
示例8
public abstract void handle(ResourceEventHandler<T> resourceEventHandler);