2 * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.config.yang.netty.eventexecutor;
10 import static io.netty.util.concurrent.GlobalEventExecutor.INSTANCE;
12 import com.google.common.annotations.Beta;
13 import io.netty.util.concurrent.EventExecutor;
14 import io.netty.util.concurrent.EventExecutorGroup;
15 import io.netty.util.concurrent.Future;
16 import io.netty.util.concurrent.ProgressivePromise;
17 import io.netty.util.concurrent.Promise;
18 import io.netty.util.concurrent.ScheduledFuture;
19 import java.util.Collection;
20 import java.util.Iterator;
21 import java.util.List;
22 import java.util.concurrent.Callable;
23 import java.util.concurrent.ExecutionException;
24 import java.util.concurrent.TimeUnit;
25 import java.util.concurrent.TimeoutException;
26 import org.osgi.service.component.annotations.Activate;
27 import org.osgi.service.component.annotations.Component;
28 import org.osgi.service.component.annotations.Deactivate;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
33 @Component(immediate = true, property = "type=global-event-executor")
34 public final class OSGiGlobalEventExecutor implements EventExecutor {
35 private static final Logger LOG = LoggerFactory.getLogger(OSGiGlobalEventExecutor.class);
38 public boolean isShuttingDown() {
39 return INSTANCE.isShuttingDown();
43 public Future<?> shutdownGracefully() {
44 return INSTANCE.shutdownGracefully();
48 public Future<?> shutdownGracefully(final long quietPeriod, final long timeout, final TimeUnit unit) {
49 return INSTANCE.shutdownGracefully(quietPeriod, timeout, unit);
53 public Future<?> terminationFuture() {
54 return INSTANCE.terminationFuture();
59 public void shutdown() {
64 public List<Runnable> shutdownNow() {
65 return INSTANCE.shutdownNow();
69 public Iterator<EventExecutor> iterator() {
70 return INSTANCE.iterator();
74 public Future<?> submit(final Runnable task) {
75 return INSTANCE.submit(task);
79 public <T> Future<T> submit(final Runnable task, final T result) {
80 return INSTANCE.submit(task, result);
84 public <T> Future<T> submit(final Callable<T> task) {
85 return INSTANCE.submit(task);
89 public ScheduledFuture<?> schedule(final Runnable command, final long delay, final TimeUnit unit) {
90 return INSTANCE.schedule(command, delay, unit);
94 public <V> ScheduledFuture<V> schedule(final Callable<V> callable, final long delay, final TimeUnit unit) {
95 return INSTANCE.schedule(callable, delay, unit);
99 public ScheduledFuture<?> scheduleAtFixedRate(final Runnable command, final long initialDelay, final long period,
100 final TimeUnit unit) {
101 return INSTANCE.scheduleAtFixedRate(command, initialDelay, period, unit);
105 public ScheduledFuture<?> scheduleWithFixedDelay(final Runnable command, final long initialDelay, final long delay,
106 final TimeUnit unit) {
107 return INSTANCE.scheduleWithFixedDelay(command, initialDelay, delay, unit);
111 public boolean isShutdown() {
112 return INSTANCE.isShutdown();
116 public boolean isTerminated() {
117 return INSTANCE.isTerminated();
121 public boolean awaitTermination(final long timeout, final TimeUnit unit) throws InterruptedException {
122 return INSTANCE.awaitTermination(timeout, unit);
126 public <T> List<java.util.concurrent.Future<T>> invokeAll(final Collection<? extends Callable<T>> tasks)
127 throws InterruptedException {
128 return INSTANCE.invokeAll(tasks);
132 public <T> List<java.util.concurrent.Future<T>> invokeAll(final Collection<? extends Callable<T>> tasks,
133 final long timeout, final TimeUnit unit) throws InterruptedException {
134 return INSTANCE.invokeAll(tasks, timeout, unit);
138 public <T> T invokeAny(final Collection<? extends Callable<T>> tasks)
139 throws InterruptedException, ExecutionException {
140 return INSTANCE.invokeAny(tasks);
144 public <T> T invokeAny(final Collection<? extends Callable<T>> tasks, final long timeout, final TimeUnit unit)
145 throws InterruptedException, ExecutionException, TimeoutException {
146 return INSTANCE.invokeAny(tasks, timeout, unit);
150 public void execute(final Runnable command) {
151 INSTANCE.execute(command);
155 public EventExecutor next() {
156 return INSTANCE.next();
160 public EventExecutorGroup parent() {
161 return INSTANCE.parent();
165 public boolean inEventLoop() {
166 return INSTANCE.inEventLoop();
170 public boolean inEventLoop(final Thread thread) {
171 return INSTANCE.inEventLoop(thread);
175 public <V> Promise<V> newPromise() {
176 return INSTANCE.newPromise();
180 public <V> ProgressivePromise<V> newProgressivePromise() {
181 return INSTANCE.newProgressivePromise();
185 public <V> Future<V> newSucceededFuture(final V result) {
186 return INSTANCE.newSucceededFuture(result);
190 public <V> Future<V> newFailedFuture(final Throwable cause) {
191 return INSTANCE.newFailedFuture(cause);
196 LOG.info("Global Event executor enabled");
201 LOG.info("Global Event executor disabled");