Remove io.atomix.utils.event 77/104677/1
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 2 Mar 2023 00:19:32 +0000 (01:19 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 2 Mar 2023 00:20:23 +0000 (01:20 +0100)
Nothing in this package is needed here, remove it.

JIRA: CONTROLLER-2071
Change-Id: Ib3d75d07b4e9c7b902471c31863bd6fe2b558e19
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
third-party/atomix/utils/src/main/java/io/atomix/utils/event/AbstractEvent.java [deleted file]
third-party/atomix/utils/src/main/java/io/atomix/utils/event/AbstractListenerManager.java [deleted file]
third-party/atomix/utils/src/main/java/io/atomix/utils/event/Event.java [deleted file]
third-party/atomix/utils/src/main/java/io/atomix/utils/event/EventFilter.java [deleted file]
third-party/atomix/utils/src/main/java/io/atomix/utils/event/EventListener.java [deleted file]
third-party/atomix/utils/src/main/java/io/atomix/utils/event/EventSink.java [deleted file]
third-party/atomix/utils/src/main/java/io/atomix/utils/event/ListenerRegistry.java [deleted file]
third-party/atomix/utils/src/main/java/io/atomix/utils/event/ListenerService.java [deleted file]
third-party/atomix/utils/src/main/java/io/atomix/utils/event/package-info.java [deleted file]

diff --git a/third-party/atomix/utils/src/main/java/io/atomix/utils/event/AbstractEvent.java b/third-party/atomix/utils/src/main/java/io/atomix/utils/event/AbstractEvent.java
deleted file mode 100644 (file)
index cd34430..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2014-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.atomix.utils.event;
-
-import io.atomix.utils.misc.TimestampPrinter;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * Base event implementation.
- */
-public class AbstractEvent<T extends Enum, S> implements Event<T, S> {
-  private final long time;
-  private final T type;
-  private final S subject;
-
-  /**
-   * Creates an event of a given type and for the specified subject and the
-   * current time.
-   *
-   * @param type    event type
-   * @param subject event subject
-   */
-  protected AbstractEvent(T type, S subject) {
-    this(type, subject, System.currentTimeMillis());
-  }
-
-  /**
-   * Creates an event of a given type and for the specified subject and time.
-   *
-   * @param type    event type
-   * @param subject event subject
-   * @param time    occurrence time
-   */
-  protected AbstractEvent(T type, S subject, long time) {
-    this.type = type;
-    this.subject = subject;
-    this.time = time;
-  }
-
-  @Override
-  public long time() {
-    return time;
-  }
-
-  @Override
-  public T type() {
-    return type;
-  }
-
-  @Override
-  public S subject() {
-    return subject;
-  }
-
-  @Override
-  public String toString() {
-    return toStringHelper(this)
-        .add("time", new TimestampPrinter(time))
-        .add("type", type())
-        .add("subject", subject())
-        .toString();
-  }
-}
diff --git a/third-party/atomix/utils/src/main/java/io/atomix/utils/event/AbstractListenerManager.java b/third-party/atomix/utils/src/main/java/io/atomix/utils/event/AbstractListenerManager.java
deleted file mode 100644 (file)
index 55d9626..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.atomix.utils.event;
-
-/**
- * Basis for components which need to export listener mechanism.
- */
-public abstract class AbstractListenerManager<E extends Event, L extends EventListener<E>> implements ListenerService<E, L> {
-
-  protected final ListenerRegistry<E, L> listenerRegistry = new ListenerRegistry<>();
-
-  @Override
-  public void addListener(L listener) {
-    listenerRegistry.addListener(listener);
-  }
-
-  @Override
-  public void removeListener(L listener) {
-    listenerRegistry.removeListener(listener);
-  }
-
-  /**
-   * Posts the specified event to the local event dispatcher.
-   *
-   * @param event event to be posted; may be null
-   */
-  protected void post(E event) {
-    listenerRegistry.process(event);
-  }
-
-}
diff --git a/third-party/atomix/utils/src/main/java/io/atomix/utils/event/Event.java b/third-party/atomix/utils/src/main/java/io/atomix/utils/event/Event.java
deleted file mode 100644 (file)
index 2484900..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2014-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.atomix.utils.event;
-
-/**
- * Abstraction of an of a time-stamped event pertaining to an arbitrary subject.
- */
-public interface Event<T, S> {
-
-  /**
-   * Returns the timestamp of when the event occurred, given in milliseconds
-   * since the start of epoch.
-   *
-   * @return timestamp in milliseconds
-   */
-  long time();
-
-  /**
-   * Returns the type of the event.
-   *
-   * @return event type
-   */
-  T type();
-
-  /**
-   * Returns the subject of the event.
-   *
-   * @return subject to which this event pertains
-   */
-  S subject();
-
-}
diff --git a/third-party/atomix/utils/src/main/java/io/atomix/utils/event/EventFilter.java b/third-party/atomix/utils/src/main/java/io/atomix/utils/event/EventFilter.java
deleted file mode 100644 (file)
index fa38b72..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.atomix.utils.event;
-
-/**
- * Entity capable of filtering events.
- */
-public interface EventFilter<E extends Event> {
-
-  /**
-   * Indicates whether the specified event is of interest or not.
-   * Default implementation always returns true.
-   *
-   * @param event event to be inspected
-   * @return true if event is relevant; false otherwise
-   */
-  default boolean isRelevant(E event) {
-    return true;
-  }
-
-}
diff --git a/third-party/atomix/utils/src/main/java/io/atomix/utils/event/EventListener.java b/third-party/atomix/utils/src/main/java/io/atomix/utils/event/EventListener.java
deleted file mode 100644 (file)
index 6e0e1c7..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2014-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.atomix.utils.event;
-
-/**
- * Entity capable of receiving events.
- */
-@FunctionalInterface
-public interface EventListener<E extends Event> extends EventFilter<E> {
-
-  /**
-   * Reacts to the specified event.
-   *
-   * @param event event to be processed
-   */
-  void event(E event);
-
-}
diff --git a/third-party/atomix/utils/src/main/java/io/atomix/utils/event/EventSink.java b/third-party/atomix/utils/src/main/java/io/atomix/utils/event/EventSink.java
deleted file mode 100644 (file)
index cbffc9c..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2014-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.atomix.utils.event;
-
-/**
- * Abstraction of an event sink capable of processing the specified event types.
- */
-public interface EventSink<E extends Event> {
-
-  /**
-   * Processes the specified event.
-   *
-   * @param event event to be processed
-   */
-  void process(E event);
-
-  /**
-   * Handles notification that event processing time limit has been exceeded.
-   */
-  default void onProcessLimit() {
-  }
-
-}
diff --git a/third-party/atomix/utils/src/main/java/io/atomix/utils/event/ListenerRegistry.java b/third-party/atomix/utils/src/main/java/io/atomix/utils/event/ListenerRegistry.java
deleted file mode 100644 (file)
index 757288c..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.atomix.utils.event;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArraySet;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Base implementation of an event sink and a registry capable of tracking
- * listeners and dispatching events to them as part of event sink processing.
- */
-public class ListenerRegistry<E extends Event, L extends EventListener<E>>
-    implements ListenerService<E, L>, EventSink<E> {
-
-  private static final long LIMIT = 1_800; // ms
-
-  private final Logger log = LoggerFactory.getLogger(getClass());
-
-  private long lastStart;
-  private L lastListener;
-
-  /**
-   * Set of listeners that have registered.
-   */
-  protected final Set<L> listeners = new CopyOnWriteArraySet<>();
-
-  @Override
-  public void addListener(L listener) {
-    checkNotNull(listener, "Listener cannot be null");
-    listeners.add(listener);
-  }
-
-  @Override
-  public void removeListener(L listener) {
-    checkNotNull(listener, "Listener cannot be null");
-    if (!listeners.remove(listener)) {
-      log.warn("Listener {} not registered", listener);
-    }
-  }
-
-  @Override
-  public void process(E event) {
-    for (L listener : listeners) {
-      try {
-        lastListener = listener;
-        lastStart = System.currentTimeMillis();
-        if (listener.isRelevant(event)) {
-          listener.event(event);
-        }
-        lastStart = 0;
-      } catch (Exception error) {
-        reportProblem(event, error);
-      }
-    }
-  }
-
-  @Override
-  public void onProcessLimit() {
-    if (lastStart > 0) {
-      long duration = System.currentTimeMillis() - lastStart;
-      if (duration > LIMIT) {
-        log.error("Listener {} exceeded execution time limit: {} ms; ejected",
-            lastListener.getClass().getName(),
-            duration);
-        removeListener(lastListener);
-      }
-      lastStart = 0;
-    }
-  }
-
-  /**
-   * Reports a problem encountered while processing an event.
-   *
-   * @param event event being processed
-   * @param error error encountered while processing
-   */
-  protected void reportProblem(E event, Throwable error) {
-    log.warn("Exception encountered while processing event " + event, error);
-  }
-
-}
diff --git a/third-party/atomix/utils/src/main/java/io/atomix/utils/event/ListenerService.java b/third-party/atomix/utils/src/main/java/io/atomix/utils/event/ListenerService.java
deleted file mode 100644 (file)
index 45db98a..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2015-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.atomix.utils.event;
-
-/**
- * Abstraction of a service capable of asynchronously notifying listeners.
- */
-public interface ListenerService<E extends Event, L extends EventListener<E>> {
-
-  /**
-   * Adds the specified listener.
-   *
-   * @param listener listener to be added
-   */
-  void addListener(L listener);
-
-  /**
-   * Removes the specified listener.
-   *
-   * @param listener listener to be removed
-   */
-  void removeListener(L listener);
-
-}
diff --git a/third-party/atomix/utils/src/main/java/io/atomix/utils/event/package-info.java b/third-party/atomix/utils/src/main/java/io/atomix/utils/event/package-info.java
deleted file mode 100644 (file)
index 41952bb..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Provides classes and interfaces for creating and handling generic events.
- */
-package io.atomix.utils.event;