/* * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.controller.config.yang.netty.eventexecutor; import static io.netty.util.concurrent.GlobalEventExecutor.INSTANCE; import com.google.common.annotations.Beta; import io.netty.util.concurrent.EventExecutor; import io.netty.util.concurrent.EventExecutorGroup; import io.netty.util.concurrent.Future; import io.netty.util.concurrent.ProgressivePromise; import io.netty.util.concurrent.Promise; import io.netty.util.concurrent.ScheduledFuture; import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Deactivate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @Beta @Component(immediate = true, property = "type=global-event-executor") public final class OSGiGlobalEventExecutor implements EventExecutor { private static final Logger LOG = LoggerFactory.getLogger(OSGiGlobalEventExecutor.class); @Override public boolean isShuttingDown() { return INSTANCE.isShuttingDown(); } @Override public Future shutdownGracefully() { return INSTANCE.shutdownGracefully(); } @Override public Future shutdownGracefully(final long quietPeriod, final long timeout, final TimeUnit unit) { return INSTANCE.shutdownGracefully(quietPeriod, timeout, unit); } @Override public Future terminationFuture() { return INSTANCE.terminationFuture(); } @Override @Deprecated public void shutdown() { INSTANCE.shutdown(); } @Override public List shutdownNow() { return INSTANCE.shutdownNow(); } @Override public Iterator iterator() { return INSTANCE.iterator(); } @Override public Future submit(final Runnable task) { return INSTANCE.submit(task); } @Override public Future submit(final Runnable task, final T result) { return INSTANCE.submit(task, result); } @Override public Future submit(final Callable task) { return INSTANCE.submit(task); } @Override public ScheduledFuture schedule(final Runnable command, final long delay, final TimeUnit unit) { return INSTANCE.schedule(command, delay, unit); } @Override public ScheduledFuture schedule(final Callable callable, final long delay, final TimeUnit unit) { return INSTANCE.schedule(callable, delay, unit); } @Override public ScheduledFuture scheduleAtFixedRate(final Runnable command, final long initialDelay, final long period, final TimeUnit unit) { return INSTANCE.scheduleAtFixedRate(command, initialDelay, period, unit); } @Override public ScheduledFuture scheduleWithFixedDelay(final Runnable command, final long initialDelay, final long delay, final TimeUnit unit) { return INSTANCE.scheduleWithFixedDelay(command, initialDelay, delay, unit); } @Override public boolean isShutdown() { return INSTANCE.isShutdown(); } @Override public boolean isTerminated() { return INSTANCE.isTerminated(); } @Override public boolean awaitTermination(final long timeout, final TimeUnit unit) throws InterruptedException { return INSTANCE.awaitTermination(timeout, unit); } @Override public List> invokeAll(final Collection> tasks) throws InterruptedException { return INSTANCE.invokeAll(tasks); } @Override public List> invokeAll(final Collection> tasks, final long timeout, final TimeUnit unit) throws InterruptedException { return INSTANCE.invokeAll(tasks, timeout, unit); } @Override public T invokeAny(final Collection> tasks) throws InterruptedException, ExecutionException { return INSTANCE.invokeAny(tasks); } @Override public T invokeAny(final Collection> tasks, final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return INSTANCE.invokeAny(tasks, timeout, unit); } @Override public void execute(final Runnable command) { INSTANCE.execute(command); } @Override public EventExecutor next() { return INSTANCE.next(); } @Override public EventExecutorGroup parent() { return INSTANCE.parent(); } @Override public boolean inEventLoop() { return INSTANCE.inEventLoop(); } @Override public boolean inEventLoop(final Thread thread) { return INSTANCE.inEventLoop(thread); } @Override public Promise newPromise() { return INSTANCE.newPromise(); } @Override public ProgressivePromise newProgressivePromise() { return INSTANCE.newProgressivePromise(); } @Override public Future newSucceededFuture(final V result) { return INSTANCE.newSucceededFuture(result); } @Override public Future newFailedFuture(final Throwable cause) { return INSTANCE.newFailedFuture(cause); } @Activate void activate() { LOG.info("Global Event executor enabled"); } @Deactivate void deactivate() { LOG.info("Global Event executor disabled"); } }