Esempio n. 1
0
 @Override
 public void event(MapEvent<String, byte[]> event) {
   if (event.key().equals(name)) {
     final MeteringAgent.Context newTimer = monitor.startTimer(NOTIFY_LISTENER);
     byte[] rawNewValue = Versioned.valueOrNull(event.newValue());
     byte[] rawOldValue = Versioned.valueOrNull(event.oldValue());
     try {
       listener.event(
           new AtomicValueEvent<>(
               name,
               rawNewValue == null ? null : serializer.decode(rawNewValue),
               rawOldValue == null ? null : serializer.decode(rawOldValue)));
       newTimer.stop(null);
     } catch (Exception e) {
       newTimer.stop(e);
       Throwables.propagate(e);
     }
   }
 }
Esempio n. 2
0
 @Override
 public void event(MapEvent<RegionId, Region> event) {
   Region region = null;
   RegionEvent.Type type = null;
   switch (event.type()) {
     case INSERT:
       type = RegionEvent.Type.REGION_ADDED;
       region = checkNotNull(event.newValue().value());
       break;
     case UPDATE:
       type = RegionEvent.Type.REGION_UPDATED;
       region = checkNotNull(event.newValue().value());
       break;
     case REMOVE:
       type = RegionEvent.Type.REGION_REMOVED;
       region = checkNotNull(event.oldValue().value());
       break;
     default:
       log.error("Unsupported event type: " + event.type());
   }
   notifyDelegate(new RegionEvent(type, region));
 }