Promote OSGiGlobalEventExecutor
[controller.git] / opendaylight / config / netty-event-executor-config / src / main / java / org / opendaylight / controller / config / yang / netty / eventexecutor / OSGiGlobalEventExecutor.java
1 /*
2  * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.config.yang.netty.eventexecutor;
9
10 import static io.netty.util.concurrent.GlobalEventExecutor.INSTANCE;
11
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;
30
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);
34
35     @Override
36     public boolean isShuttingDown() {
37         return INSTANCE.isShuttingDown();
38     }
39
40     @Override
41     public Future<?> shutdownGracefully() {
42         return INSTANCE.shutdownGracefully();
43     }
44
45     @Override
46     public Future<?> shutdownGracefully(final long quietPeriod, final long timeout, final TimeUnit unit) {
47         return INSTANCE.shutdownGracefully(quietPeriod, timeout, unit);
48     }
49
50     @Override
51     public Future<?> terminationFuture() {
52         return INSTANCE.terminationFuture();
53     }
54
55     @Override
56     @Deprecated
57     public void shutdown() {
58         INSTANCE.shutdown();
59     }
60
61     @Override
62     public List<Runnable> shutdownNow() {
63         return INSTANCE.shutdownNow();
64     }
65
66     @Override
67     public Iterator<EventExecutor> iterator() {
68         return INSTANCE.iterator();
69     }
70
71     @Override
72     public Future<?> submit(final Runnable task) {
73         return INSTANCE.submit(task);
74     }
75
76     @Override
77     public <T> Future<T> submit(final Runnable task, final T result) {
78         return INSTANCE.submit(task, result);
79     }
80
81     @Override
82     public <T> Future<T> submit(final Callable<T> task) {
83         return INSTANCE.submit(task);
84     }
85
86     @Override
87     public ScheduledFuture<?> schedule(final Runnable command, final long delay, final TimeUnit unit) {
88         return INSTANCE.schedule(command, delay, unit);
89     }
90
91     @Override
92     public <V> ScheduledFuture<V> schedule(final Callable<V> callable, final long delay, final TimeUnit unit) {
93         return INSTANCE.schedule(callable, delay, unit);
94     }
95
96     @Override
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);
100     }
101
102     @Override
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);
106     }
107
108     @Override
109     public boolean isShutdown() {
110         return INSTANCE.isShutdown();
111     }
112
113     @Override
114     public boolean isTerminated() {
115         return INSTANCE.isTerminated();
116     }
117
118     @Override
119     public boolean awaitTermination(final long timeout, final TimeUnit unit) throws InterruptedException {
120         return INSTANCE.awaitTermination(timeout, unit);
121     }
122
123     @Override
124     public <T> List<java.util.concurrent.Future<T>> invokeAll(final Collection<? extends Callable<T>> tasks)
125             throws InterruptedException {
126         return INSTANCE.invokeAll(tasks);
127     }
128
129     @Override
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);
133     }
134
135     @Override
136     public <T> T invokeAny(final Collection<? extends Callable<T>> tasks)
137             throws InterruptedException, ExecutionException {
138         return INSTANCE.invokeAny(tasks);
139     }
140
141     @Override
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);
145     }
146
147     @Override
148     public void execute(final Runnable command) {
149         INSTANCE.execute(command);
150     }
151
152     @Override
153     public EventExecutor next() {
154         return INSTANCE.next();
155     }
156
157     @Override
158     public EventExecutorGroup parent() {
159         return INSTANCE.parent();
160     }
161
162     @Override
163     public boolean inEventLoop() {
164         return INSTANCE.inEventLoop();
165     }
166
167     @Override
168     public boolean inEventLoop(final Thread thread) {
169         return INSTANCE.inEventLoop(thread);
170     }
171
172     @Override
173     public <V> Promise<V> newPromise() {
174         return INSTANCE.newPromise();
175     }
176
177     @Override
178     public <V> ProgressivePromise<V> newProgressivePromise() {
179         return INSTANCE.newProgressivePromise();
180     }
181
182     @Override
183     public <V> Future<V> newSucceededFuture(final V result) {
184         return INSTANCE.newSucceededFuture(result);
185     }
186
187     @Override
188     public <V> Future<V> newFailedFuture(final Throwable cause) {
189         return INSTANCE.newFailedFuture(cause);
190     }
191
192     @Activate
193     void activate() {
194         LOG.info("Global Event executor enabled");
195     }
196
197     @Deactivate
198     void deactivate() {
199         LOG.info("Global Event executor disabled");
200     }
201
202 }