/**
   * Called immediately after an element has been put into the cache and the element already existed
   * in the cache. This is thus an update.
   *
   * <p>The {@link net.sf.ehcache.Cache#put(net.sf.ehcache.Element)} method will block until this
   * method returns.
   *
   * <p>Implementers may wish to have access to the Element's fields, including value, so the
   * element is provided. Implementers should be careful not to modify the element. The effect of
   * any modifications is undefined.
   *
   * @param cache the cache emitting the notification
   * @param element the element which was just put into the cache.
   */
  public final void notifyElementUpdated(final Ehcache cache, final Element element)
      throws CacheException {
    if (notAlive()) {
      return;
    }
    if (!replicateUpdates) {
      return;
    }

    if (replicateUpdatesViaCopy) {
      if (!element.isSerializable()) {
        if (LOG.isWarnEnabled()) {
          LOG.warn(
              "Object with key "
                  + element.getObjectKey()
                  + " is not Serializable and cannot be updated via copy.");
        }
        return;
      }
      addToReplicationQueue(new CacheEventMessage(EventMessage.PUT, cache, element, null));
    } else {
      if (!element.isKeySerializable()) {
        if (LOG.isWarnEnabled()) {
          LOG.warn(
              "Object with key "
                  + element.getObjectKey()
                  + " does not have a Serializable key and cannot be replicated via invalidate.");
        }
        return;
      }
      addToReplicationQueue(
          new CacheEventMessage(EventMessage.REMOVE, cache, null, element.getKey()));
    }
  }
  /**
   * Called immediately after an element has been removed. The remove method will block until this
   * method returns.
   *
   * <p>This implementation queues the removal notification for in order replication to peers.
   *
   * @param cache the cache emitting the notification
   * @param element just deleted
   */
  public final void notifyElementRemoved(final Ehcache cache, final Element element)
      throws CacheException {
    if (!replicateRemovals) {
      return;
    }

    if (!element.isKeySerializable()) {
      if (LOG.isWarnEnabled()) {
        LOG.warn(
            "Key " + element.getObjectKey() + " is not Serializable and cannot be replicated.");
      }
      return;
    }
    addToReplicationQueue(
        new CacheEventMessage(EventMessage.REMOVE, cache, null, element.getKey()));
  }