Remove most of io.atomix.utils.concurrent 84/104684/1
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 2 Mar 2023 01:00:14 +0000 (02:00 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 2 Mar 2023 01:05:22 +0000 (02:05 +0100)
Most of the stuff in the concurrent package is not used, remove it.

JIRA: CONTROLLER-2071
Change-Id: Ife0ea74b9327075dac9dfb605364bf2a9301362f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
13 files changed:
third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/AtomixThread.java [deleted file]
third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/AtomixThreadFactory.java [deleted file]
third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/ComposableFuture.java [deleted file]
third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/NullThreadContext.java [deleted file]
third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/OrderedExecutor.java [deleted file]
third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/Retries.java [deleted file]
third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/RetryingFunction.java [deleted file]
third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/Scheduled.java [deleted file]
third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/Scheduler.java [deleted file]
third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/ThreadContext.java [deleted file]
third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/ThreadContextFactory.java [deleted file]
third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/Threads.java [deleted file]
third-party/atomix/utils/src/test/java/io/atomix/utils/concurrent/RetryingFunctionTest.java [deleted file]

diff --git a/third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/AtomixThread.java b/third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/AtomixThread.java
deleted file mode 100644 (file)
index 21f47f2..0000000
+++ /dev/null
@@ -1,56 +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.concurrent;
-
-import java.lang.ref.WeakReference;
-
-/**
- * Atomix thread.
- * <p>
- * The Atomix thread primarily serves to store a {@link ThreadContext} for the current thread.
- * The context is stored in a {@link WeakReference} in order to allow the thread to be garbage collected.
- * <p>
- * There is no {@link ThreadContext} associated with the thread when it is first created.
- * It is the responsibility of thread creators to {@link #setContext(ThreadContext) set} the thread context when appropriate.
- *
- * @author <a href="http://github.com/kuujo">Jordan Halterman</a>
- */
-public class AtomixThread extends Thread {
-  private WeakReference<ThreadContext> context;
-
-  public AtomixThread(Runnable target) {
-    super(target);
-  }
-
-  /**
-   * Sets the thread context.
-   *
-   * @param context The thread context.
-   */
-  public void setContext(ThreadContext context) {
-    this.context = new WeakReference<>(context);
-  }
-
-  /**
-   * Returns the thread context.
-   *
-   * @return The thread {@link ThreadContext} or {@code null} if no context has been configured.
-   */
-  public ThreadContext getContext() {
-    return context != null ? context.get() : null;
-  }
-
-}
diff --git a/third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/AtomixThreadFactory.java b/third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/AtomixThreadFactory.java
deleted file mode 100644 (file)
index eda5a21..0000000
+++ /dev/null
@@ -1,30 +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.concurrent;
-
-import java.util.concurrent.ThreadFactory;
-
-/**
- * Named thread factory.
- *
- * @author <a href="http://github.com/kuujo">Jordan Halterman</a>
- */
-public class AtomixThreadFactory implements ThreadFactory {
-  @Override
-  public Thread newThread(Runnable r) {
-    return new AtomixThread(r);
-  }
-}
diff --git a/third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/ComposableFuture.java b/third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/ComposableFuture.java
deleted file mode 100644 (file)
index f789018..0000000
+++ /dev/null
@@ -1,82 +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.concurrent;
-
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.Executor;
-import java.util.function.BiConsumer;
-import java.util.function.Consumer;
-
-/**
- * Special implementation of {@link CompletableFuture} with missing utility methods.
- *
- * @author <a href="http://github.com/kuujo">Jordan Halterman</a>
- */
-public class ComposableFuture<T> extends CompletableFuture<T> implements BiConsumer<T, Throwable> {
-
-  @Override
-  public void accept(T result, Throwable error) {
-    if (error == null) {
-      complete(result);
-    } else {
-      completeExceptionally(error);
-    }
-  }
-
-  /**
-   * Sets a consumer to be called when the future is failed.
-   *
-   * @param consumer The consumer to call.
-   * @return A new future.
-   */
-  public CompletableFuture<T> except(Consumer<Throwable> consumer) {
-    return whenComplete((result, error) -> {
-      if (error != null) {
-        consumer.accept(error);
-      }
-    });
-  }
-
-  /**
-   * Sets a consumer to be called asynchronously when the future is failed.
-   *
-   * @param consumer The consumer to call.
-   * @return A new future.
-   */
-  public CompletableFuture<T> exceptAsync(Consumer<Throwable> consumer) {
-    return whenCompleteAsync((result, error) -> {
-      if (error != null) {
-        consumer.accept(error);
-      }
-    });
-  }
-
-  /**
-   * Sets a consumer to be called asynchronously when the future is failed.
-   *
-   * @param consumer The consumer to call.
-   * @param executor The executor with which to call the consumer.
-   * @return A new future.
-   */
-  public CompletableFuture<T> exceptAsync(Consumer<Throwable> consumer, Executor executor) {
-    return whenCompleteAsync((result, error) -> {
-      if (error != null) {
-        consumer.accept(error);
-      }
-    }, executor);
-  }
-
-}
diff --git a/third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/NullThreadContext.java b/third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/NullThreadContext.java
deleted file mode 100644 (file)
index 9ee1d75..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2018-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.concurrent;
-
-import java.time.Duration;
-
-/**
- * Null thread context.
- */
-public class NullThreadContext implements ThreadContext {
-  @Override
-  public Scheduled schedule(Duration delay, Runnable callback) {
-    return null;
-  }
-
-  @Override
-  public Scheduled schedule(Duration initialDelay, Duration interval, Runnable callback) {
-    return null;
-  }
-
-  @Override
-  public boolean isBlocked() {
-    return false;
-  }
-
-  @Override
-  public void block() {
-
-  }
-
-  @Override
-  public void unblock() {
-
-  }
-
-  @Override
-  public void close() {
-
-  }
-
-  @Override
-  public void execute(Runnable command) {
-
-  }
-}
diff --git a/third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/OrderedExecutor.java b/third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/OrderedExecutor.java
deleted file mode 100644 (file)
index c3cee5a..0000000
+++ /dev/null
@@ -1,60 +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.
- */
-package io.atomix.utils.concurrent;
-
-import java.util.LinkedList;
-import java.util.concurrent.Executor;
-
-/**
- * Executor that executes tasks in order on a shared thread pool.
- * <p>
- * The ordered executor behaves semantically like a single-threaded executor, but multiplexes tasks on a shared thread
- * pool, ensuring blocked threads in the shared thread pool don't block individual ordered executors.
- */
-public class OrderedExecutor implements Executor {
-  private final Executor parent;
-  private final LinkedList<Runnable> tasks = new LinkedList<>();
-  private boolean running;
-
-  public OrderedExecutor(Executor parent) {
-    this.parent = parent;
-  }
-
-  private void run() {
-    for (;;) {
-      final Runnable task;
-      synchronized (tasks) {
-        task = tasks.poll();
-        if (task == null) {
-          running = false;
-          return;
-        }
-      }
-      task.run();
-    }
-  }
-
-  @Override
-  public void execute(Runnable command) {
-    synchronized (tasks) {
-      tasks.add(command);
-      if (!running) {
-        running = true;
-        parent.execute(this::run);
-      }
-    }
-  }
-}
diff --git a/third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/Retries.java b/third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/Retries.java
deleted file mode 100644 (file)
index bd42a2b..0000000
+++ /dev/null
@@ -1,96 +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.
- */
-package io.atomix.utils.concurrent;
-
-import java.util.concurrent.ThreadLocalRandom;
-import java.util.function.Function;
-import java.util.function.Supplier;
-
-/**
- * Retry utilities.
- */
-public final class Retries {
-
-  /**
-   * Returns a function that retries execution on failure.
-   * @param base base function
-   * @param exceptionClass type of exception for which to retry
-   * @param maxRetries max number of retries before giving up
-   * @param maxDelayBetweenRetries max delay between successive retries. The actual delay is randomly picked from
-   * the interval (0, maxDelayBetweenRetries]
-   * @return function
-   * @param <U> type of function input
-   * @param <V> type of function output
-   */
-  public static <U, V> Function<U, V> retryable(Function<U, V> base,
-                                                Class<? extends Throwable> exceptionClass,
-                                                int maxRetries,
-                                                int maxDelayBetweenRetries) {
-    return new RetryingFunction<>(base, exceptionClass, maxRetries, maxDelayBetweenRetries);
-  }
-
-  /**
-   * Returns a Supplier that retries execution on failure.
-   * @param base base supplier
-   * @param exceptionClass type of exception for which to retry
-   * @param maxRetries max number of retries before giving up
-   * @param maxDelayBetweenRetries max delay between successive retries. The actual delay is randomly picked from
-   * the interval (0, maxDelayBetweenRetries]
-   * @return supplier
-   * @param <V> type of supplied result
-   */
-  public static <V> Supplier<V> retryable(Supplier<V> base,
-                                          Class<? extends Throwable> exceptionClass,
-                                          int maxRetries,
-                                          int maxDelayBetweenRetries) {
-    return () -> new RetryingFunction<>(v -> base.get(),
-        exceptionClass,
-        maxRetries,
-        maxDelayBetweenRetries).apply(null);
-  }
-
-  /**
-   * Suspends the current thread for a random number of millis between 0 and
-   * the indicated limit.
-   *
-   * @param ms max number of millis
-   */
-  public static void randomDelay(int ms) {
-    try {
-      Thread.sleep(ThreadLocalRandom.current().nextInt(ms));
-    } catch (InterruptedException e) {
-      throw new RuntimeException("Interrupted", e);
-    }
-  }
-
-  /**
-   * Suspends the current thread for a specified number of millis and nanos.
-   *
-   * @param ms    number of millis
-   * @param nanos number of nanos
-   */
-  public static void delay(int ms, int nanos) {
-    try {
-      Thread.sleep(ms, nanos);
-    } catch (InterruptedException e) {
-      throw new RuntimeException("Interrupted", e);
-    }
-  }
-
-  private Retries() {
-  }
-
-}
diff --git a/third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/RetryingFunction.java b/third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/RetryingFunction.java
deleted file mode 100644 (file)
index 9ef40f4..0000000
+++ /dev/null
@@ -1,62 +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.concurrent;
-
-import java.util.function.Function;
-
-import static com.google.common.base.Throwables.throwIfUnchecked;
-
-/**
- * Function that retries execution on failure.
- *
- * @param <U> input type
- * @param <V> output type
- */
-public class RetryingFunction<U, V> implements Function<U, V> {
-  private final Function<U, V> baseFunction;
-  private final Class<? extends Throwable> exceptionClass;
-  private final int maxRetries;
-  private final int maxDelayBetweenRetries;
-
-  public RetryingFunction(Function<U, V> baseFunction,
-      Class<? extends Throwable> exceptionClass,
-      int maxRetries,
-      int maxDelayBetweenRetries) {
-    this.baseFunction = baseFunction;
-    this.exceptionClass = exceptionClass;
-    this.maxRetries = maxRetries;
-    this.maxDelayBetweenRetries = maxDelayBetweenRetries;
-  }
-
-  @SuppressWarnings("squid:S1181")
-  // Yes we really do want to catch Throwable
-  @Override
-  public V apply(U input) {
-    int retryAttempts = 0;
-    while (true) {
-      try {
-        return baseFunction.apply(input);
-      } catch (Throwable t) {
-        if (!exceptionClass.isAssignableFrom(t.getClass()) || retryAttempts == maxRetries) {
-          throwIfUnchecked(t);
-          throw new RuntimeException(t);
-        }
-        Retries.randomDelay(maxDelayBetweenRetries);
-        retryAttempts++;
-      }
-    }
-  }
-}
diff --git a/third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/Scheduled.java b/third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/Scheduled.java
deleted file mode 100644 (file)
index 02bfd29..0000000
+++ /dev/null
@@ -1,31 +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.concurrent;
-
-/**
- * Scheduled task.
- *
- * @author <a href="http://github.com/kuujo">Jordan Halterman</a>
- */
-public interface Scheduled {
-
-  /**
-   * Cancels the scheduled task.
-   */
-  void cancel();
-
-}
diff --git a/third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/Scheduler.java b/third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/Scheduler.java
deleted file mode 100644 (file)
index f581f35..0000000
+++ /dev/null
@@ -1,70 +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.
- */
-package io.atomix.utils.concurrent;
-
-import java.time.Duration;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Scheduler.
- */
-public interface Scheduler {
-
-  /**
-   * Schedules a runnable after a delay.
-   *
-   * @param delay the delay after which to run the callback
-   * @param timeUnit the time unit
-   * @param callback the callback to run
-   * @return the scheduled callback
-   */
-  default Scheduled schedule(long delay, TimeUnit timeUnit, Runnable callback) {
-    return schedule(Duration.ofMillis(timeUnit.toMillis(delay)), callback);
-  }
-
-  /**
-   * Schedules a runnable after a delay.
-   *
-   * @param delay the delay after which to run the callback
-   * @param callback the callback to run
-   * @return the scheduled callback
-   */
-  Scheduled schedule(Duration delay, Runnable callback);
-
-  /**
-   * Schedules a runnable at a fixed rate.
-   *
-   * @param initialDelay the initial delay
-   * @param interval the interval at which to run the callback
-   * @param timeUnit the time unit
-   * @param callback the callback to run
-   * @return the scheduled callback
-   */
-  default Scheduled schedule(long initialDelay, long interval, TimeUnit timeUnit, Runnable callback) {
-    return schedule(Duration.ofMillis(timeUnit.toMillis(initialDelay)), Duration.ofMillis(timeUnit.toMillis(interval)), callback);
-  }
-
-  /**
-   * Schedules a runnable at a fixed rate.
-   *
-   * @param initialDelay the initial delay
-   * @param interval the interval at which to run the callback
-   * @param callback the callback to run
-   * @return the scheduled callback
-   */
-  Scheduled schedule(Duration initialDelay, Duration interval, Runnable callback);
-
-}
diff --git a/third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/ThreadContext.java b/third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/ThreadContext.java
deleted file mode 100644 (file)
index 2cb4189..0000000
+++ /dev/null
@@ -1,97 +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.concurrent;
-
-import java.util.concurrent.Executor;
-
-import static com.google.common.base.Preconditions.checkState;
-
-/**
- * Thread context.
- * <p>
- * The thread context is used by Catalyst to determine the correct thread on which to execute asynchronous callbacks.
- * All threads created within Catalyst must be instances of {@link AtomixThread}. Once
- * a thread has been created, the context is stored in the thread object via
- * {@link AtomixThread#setContext(ThreadContext)}. This means there is a one-to-one relationship
- * between a context and a thread. That is, a context is representative of a thread and provides an interface for firing
- * events on that thread.
- * <p>
- * Components of the framework that provide custom threads should use {@link AtomixThreadFactory}
- * to allocate new threads and provide a custom {@link ThreadContext} implementation.
- *
- * @author <a href="http://github.com/kuujo">Jordan Halterman</a>
- */
-public interface ThreadContext extends AutoCloseable, Executor, Scheduler {
-
-  /**
-   * Returns the current thread context.
-   *
-   * @return The current thread context or {@code null} if no context exists.
-   */
-  static ThreadContext currentContext() {
-    Thread thread = Thread.currentThread();
-    return thread instanceof AtomixThread ? ((AtomixThread) thread).getContext() : null;
-  }
-
-  /**
-   * @throws IllegalStateException if the current thread is not a catalyst thread
-   */
-  static ThreadContext currentContextOrThrow() {
-    ThreadContext context = currentContext();
-    checkState(context != null, "not on a Catalyst thread");
-    return context;
-  }
-
-  /**
-   * Returns a boolean indicating whether the current thread is in this context.
-   *
-   * @return Indicates whether the current thread is in this context.
-   */
-  default boolean isCurrentContext() {
-    return currentContext() == this;
-  }
-
-  /**
-   * Checks that the current thread is the correct context thread.
-   */
-  default void checkThread() {
-    checkState(currentContext() == this, "not on a Catalyst thread");
-  }
-
-  /**
-   * Returns whether the thread context is currently marked blocked.
-   *
-   * @return whether the thread context is currently marked blocked
-   */
-  boolean isBlocked();
-
-  /**
-   * Marks the thread context as blocked.
-   */
-  void block();
-
-  /**
-   * Marks the thread context as unblocked.
-   */
-  void unblock();
-
-  /**
-   * Closes the context.
-   */
-  @Override
-  void close();
-
-}
diff --git a/third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/ThreadContextFactory.java b/third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/ThreadContextFactory.java
deleted file mode 100644 (file)
index 09b6256..0000000
+++ /dev/null
@@ -1,36 +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.
- */
-package io.atomix.utils.concurrent;
-
-/**
- * Thread context factory.
- */
-public interface ThreadContextFactory {
-
-  /**
-   * Creates a new thread context.
-   *
-   * @return a new thread context
-   */
-  ThreadContext createContext();
-
-  /**
-   * Closes the factory.
-   */
-  default void close() {
-  }
-
-}
diff --git a/third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/Threads.java b/third-party/atomix/utils/src/main/java/io/atomix/utils/concurrent/Threads.java
deleted file mode 100644 (file)
index 360ceea..0000000
+++ /dev/null
@@ -1,42 +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.
- */
-package io.atomix.utils.concurrent;
-
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-import org.slf4j.Logger;
-
-import java.util.concurrent.ThreadFactory;
-
-/**
- * Thread utilities.
- */
-public final class Threads {
-
-  /**
-   * Returns a thread factory that produces threads named according to the
-   * supplied name pattern.
-   *
-   * @param pattern name pattern
-   * @return thread factory
-   */
-  public static ThreadFactory namedThreads(String pattern, Logger log) {
-    return new ThreadFactoryBuilder()
-        .setNameFormat(pattern)
-        .setThreadFactory(new AtomixThreadFactory())
-        .setUncaughtExceptionHandler((t, e) -> log.error("Uncaught exception on " + t.getName(), e))
-        .build();
-  }
-}
diff --git a/third-party/atomix/utils/src/test/java/io/atomix/utils/concurrent/RetryingFunctionTest.java b/third-party/atomix/utils/src/test/java/io/atomix/utils/concurrent/RetryingFunctionTest.java
deleted file mode 100644 (file)
index 8d70ccc..0000000
+++ /dev/null
@@ -1,92 +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.
- */
-package io.atomix.utils.concurrent;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Retrying function test.
- */
-public class RetryingFunctionTest {
-  private int round;
-
-  @Before
-  public void setUp() {
-    round = 1;
-  }
-
-  @After
-  public void tearDown() {
-    round = 0;
-  }
-
-  @Test(expected = RetryableException.class)
-  public void testNoRetries() {
-    new RetryingFunction<>(this::succeedAfterOneFailure, RetryableException.class, 0, 10).apply(null);
-  }
-
-  @Test
-  public void testSuccessAfterOneRetry() {
-    new RetryingFunction<>(this::succeedAfterOneFailure, RetryableException.class, 1, 10).apply(null);
-  }
-
-  @Test(expected = RetryableException.class)
-  public void testFailureAfterOneRetry() {
-    new RetryingFunction<>(this::succeedAfterTwoFailures, RetryableException.class, 1, 10).apply(null);
-  }
-
-  @Test
-  public void testFailureAfterTwoRetries() {
-    new RetryingFunction<>(this::succeedAfterTwoFailures, RetryableException.class, 2, 10).apply(null);
-  }
-
-  @Test(expected = NonRetryableException.class)
-  public void testFailureWithNonRetryableFailure() {
-    new RetryingFunction<>(this::failCompletely, RetryableException.class, 2, 10).apply(null);
-  }
-
-  private String succeedAfterOneFailure(String input) {
-    if (round++ <= 1) {
-      throw new RetryableException();
-    } else {
-      return "pass";
-    }
-  }
-
-  private String succeedAfterTwoFailures(String input) {
-    if (round++ <= 2) {
-      throw new RetryableException();
-    } else {
-      return "pass";
-    }
-  }
-
-  private String failCompletely(String input) {
-    if (round++ <= 1) {
-      throw new NonRetryableException();
-    } else {
-      return "pass";
-    }
-  }
-
-  private static class RetryableException extends RuntimeException {
-  }
-
-  private static class NonRetryableException extends RuntimeException {
-  }
-}