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 io.netty.util.concurrent.EventExecutor;
13 import io.netty.util.concurrent.EventExecutorGroup;
14 import io.netty.util.concurrent.Future;
15 import io.netty.util.concurrent.ProgressivePromise;
16 import io.netty.util.concurrent.Promise;
17 import io.netty.util.concurrent.ScheduledFuture;
18 import java.util.Collection;
19 import java.util.Iterator;
20 import java.util.List;
21 import java.util.concurrent.Callable;
22 import java.util.concurrent.ExecutionException;
23 import java.util.concurrent.TimeUnit;
24 import java.util.concurrent.TimeoutException;
25 import org.osgi.service.component.annotations.Activate;
26 import org.osgi.service.component.annotations.Component;
27 import org.osgi.service.component.annotations.Deactivate;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
31 @Component(immediate = true, property = "type=global-event-executor")
32 public final class OSGiGlobalEventExecutor implements EventExecutor {
33 private static final Logger LOG = LoggerFactory.getLogger(OSGiGlobalEventExecutor.class);
36 public boolean isShuttingDown() {
37 return INSTANCE.isShuttingDown();
41 public Future<?> shutdownGracefully() {
42 return INSTANCE.shutdownGracefully();
46 public Future<?> shutdownGracefully(final long quietPeriod, final long timeout, final TimeUnit unit) {
47 return INSTANCE.shutdownGracefully(quietPeriod, timeout, unit);
51 public Future<?> terminationFuture() {
52 return INSTANCE.terminationFuture();
57 public void shutdown() {
62 public List<Runnable> shutdownNow() {
63 return INSTANCE.shutdownNow();
67 public Iterator<EventExecutor> iterator() {
68 return INSTANCE.iterator();
72 public Future<?> submit(final Runnable task) {
73 return INSTANCE.submit(task);
77 public <T> Future<T> submit(final Runnable task, final T result) {
78 return INSTANCE.submit(task, result);
82 public <T> Future<T> submit(final Callable<T> task) {
83 return INSTANCE.submit(task);
87 public ScheduledFuture<?> schedule(final Runnable command, final long delay, final TimeUnit unit) {
88 return INSTANCE.schedule(command, delay, unit);
92 public <V> ScheduledFuture<V> schedule(final Callable<V> callable, final long delay, final TimeUnit unit) {
93 return INSTANCE.schedule(callable, delay, unit);
97 public ScheduledFuture<?> scheduleAtFixedRate(final Runnable command, final long initialDelay, final long period,
98 final TimeUnit unit) {
99 return INSTANCE.scheduleAtFixedRate(command, initialDelay, period, unit);
103 public ScheduledFuture<?> scheduleWithFixedDelay(final Runnable command, final long initialDelay, final long delay,
104 final TimeUnit unit) {
105 return INSTANCE.scheduleWithFixedDelay(command, initialDelay, delay, unit);
109 public boolean isShutdown() {
110 return INSTANCE.isShutdown();
114 public boolean isTerminated() {
115 return INSTANCE.isTerminated();
119 public boolean awaitTermination(final long timeout, final TimeUnit unit) throws InterruptedException {
120 return INSTANCE.awaitTermination(timeout, unit);
124 public <T> List<java.util.concurrent.Future<T>> invokeAll(final Collection<? extends Callable<T>> tasks)
125 throws InterruptedException {
126 return INSTANCE.invokeAll(tasks);
130 public <T> List<java.util.concurrent.Future<T>> invokeAll(final Collection<? extends Callable<T>> tasks,
131 final long timeout, final TimeUnit unit) throws InterruptedException {
132 return INSTANCE.invokeAll(tasks, timeout, unit);
136 public <T> T invokeAny(final Collection<? extends Callable<T>> tasks)
137 throws InterruptedException, ExecutionException {
138 return INSTANCE.invokeAny(tasks);
142 public <T> T invokeAny(final Collection<? extends Callable<T>> tasks, final long timeout, final TimeUnit unit)
143 throws InterruptedException, ExecutionException, TimeoutException {
144 return INSTANCE.invokeAny(tasks, timeout, unit);
148 public void execute(final Runnable command) {
149 INSTANCE.execute(command);
153 public EventExecutor next() {
154 return INSTANCE.next();
158 public EventExecutorGroup parent() {
159 return INSTANCE.parent();
163 public boolean inEventLoop() {
164 return INSTANCE.inEventLoop();
168 public boolean inEventLoop(final Thread thread) {
169 return INSTANCE.inEventLoop(thread);
173 public <V> Promise<V> newPromise() {
174 return INSTANCE.newPromise();
178 public <V> ProgressivePromise<V> newProgressivePromise() {
179 return INSTANCE.newProgressivePromise();
183 public <V> Future<V> newSucceededFuture(final V result) {
184 return INSTANCE.newSucceededFuture(result);
188 public <V> Future<V> newFailedFuture(final Throwable cause) {
189 return INSTANCE.newFailedFuture(cause);
194 LOG.info("Global Event executor enabled");
199 LOG.info("Global Event executor disabled");