Skip to content

Commit

Permalink
Remove redundant ExecutorService
Browse files Browse the repository at this point in the history
This service is no longer required as a part of this rework:
opendaylight/controller@9917911

JIRA: LIGHTY-298
Signed-off-by: tobias.pobocik <[email protected]>
  • Loading branch information
Tobianas committed May 14, 2024
1 parent 91c849d commit 0574650
Show file tree
Hide file tree
Showing 17 changed files with 5 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private LightyController initController(final ControllerConfiguration config) th

private CommunityRestConf initRestconf(final RestConfConfiguration config, final LightyServices services) {
final RestConfConfiguration conf = RestConfConfigUtils.getRestConfConfiguration(config, services);
return CommunityRestConfBuilder.from(conf).withScheduledThreadPool(services.getScheduledThreadPool()).build();
return CommunityRestConfBuilder.from(conf).build();
}

private GnmiSouthboundModule initGnmiModule(final LightyServices services,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ private CommunityRestConf initRestconf(final RestConfConfiguration rcConfig, fin

return CommunityRestConfBuilder.from(restConfConfiguration)
.withLightyServer(jettyServerBuilder)
.withScheduledThreadPool(services.getScheduledThreadPool())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
import io.netty.channel.EventLoopGroup;
import io.netty.util.Timer;
import io.netty.util.concurrent.EventExecutor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledExecutorService;
import org.opendaylight.controller.cluster.ActorSystemProvider;
import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface;
import org.opendaylight.controller.cluster.datastore.admin.ClusterAdminRpcService;
Expand Down Expand Up @@ -95,10 +93,6 @@ protected void configure() {
bind(EventLoopGroup.class)
.annotatedWith(Names.named("WorkerGroup"))
.toInstance(lightyServices.getWorkerGroup());
bind(ExecutorService.class)
.toInstance(lightyServices.getThreadPool());
bind(ScheduledExecutorService.class)
.toInstance(lightyServices.getScheduledThreadPool());
bind(Timer.class)
.toInstance(lightyServices.getTimer());
bind(DOMMountPointService.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,6 @@ public void testDIEventLoopGroupWorker() {
assertNotNull(testService.getEventLoopGroupWorker());
}

@Test
public void testDIThreadPool() {
assertNotNull(testService.getThreadPool());
}

@Test
public void testDIScheduledThreadPool() {
assertNotNull(testService.getScheduledThreadPool());
}

@Test
public void testDITimer() {
assertNotNull(testService.getTimer());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
import io.netty.util.concurrent.EventExecutor;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledExecutorService;
import org.opendaylight.controller.cluster.ActorSystemProvider;
import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface;
import org.opendaylight.controller.cluster.datastore.admin.ClusterAdminRpcService;
Expand Down Expand Up @@ -94,12 +92,6 @@ public class TestService {
@Named("WorkerGroup")
private EventLoopGroup eventLoopGroupWorker;

@Inject
private ExecutorService threadPool;

@Inject
private ScheduledExecutorService scheduledThreadPool;

@Inject
private Timer timer;

Expand Down Expand Up @@ -212,14 +204,6 @@ public EventLoopGroup getEventLoopGroupWorker() {
return eventLoopGroupWorker;
}

public ExecutorService getThreadPool() {
return threadPool;
}

public ScheduledExecutorService getScheduledThreadPool() {
return scheduledThreadPool;
}

public Timer getTimer() {
return timer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
import io.netty.util.concurrent.EventExecutor;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledExecutorService;
import org.opendaylight.controller.cluster.ActorSystemProvider;
import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface;
import org.opendaylight.controller.cluster.datastore.admin.ClusterAdminRpcService;
Expand Down Expand Up @@ -265,17 +263,6 @@ public EventLoopGroup workerGroup() {
return this.lightyController.getServices().getWorkerGroup();
}

@Bean(destroyMethod = "")
@Primary
public ExecutorService threadPool() {
return this.lightyController.getServices().getThreadPool();
}

@Bean(destroyMethod = "")
public ScheduledExecutorService scheduledThreadPool() {
return this.lightyController.getServices().getScheduledThreadPool();
}

@Bean(destroyMethod = "")
public Timer timer() {
return this.lightyController.getServices().getTimer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import io.netty.util.concurrent.EventExecutor;
import java.util.Collections;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledExecutorService;
import org.junit.jupiter.api.Test;
import org.opendaylight.controller.cluster.ActorSystemProvider;
import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface;
Expand Down Expand Up @@ -157,13 +155,6 @@ public class LightyCoreSpringConfigurationTest extends AbstractJUnit4SpringConte
@Qualifier("WorkerGroup")
EventLoopGroup workerGroupTestProperty;

@Autowired
ExecutorService threadPoolTestProperty;

@Autowired
@Qualifier("scheduledThreadPool")
ScheduledExecutorService scheduledThreadPoolTestProperty;

@Autowired
Timer timerTestProperty;

Expand Down Expand Up @@ -198,8 +189,6 @@ public void testLightyBeansExists() {
assertNotNull(eventExecutorTestProperty);
assertNotNull(bossGroupTestProperty);
assertNotNull(workerGroupTestProperty);
assertNotNull(threadPoolTestProperty);
assertNotNull(scheduledThreadPoolTestProperty);
assertNotNull(timerTestProperty);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import io.netty.channel.EventLoopGroup;
import io.netty.util.Timer;
import io.netty.util.concurrent.EventExecutor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledExecutorService;
import org.opendaylight.controller.cluster.ActorSystemProvider;
import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface;
import org.opendaylight.controller.cluster.datastore.admin.ClusterAdminRpcService;
Expand Down Expand Up @@ -90,10 +88,6 @@ public interface LightyServices extends LightyModuleRegistryService {

EventLoopGroup getWorkerGroup();

ExecutorService getThreadPool();

ScheduledExecutorService getScheduledThreadPool();

Timer getTimer();

DOMMountPointService getDOMMountPointService();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import io.netty.util.HashedWheelTimer;
import io.netty.util.Timer;
import io.netty.util.concurrent.DefaultEventExecutor;
import io.netty.util.concurrent.DefaultThreadFactory;
import io.netty.util.concurrent.EventExecutor;
import java.io.IOException;
import java.io.InputStream;
Expand All @@ -44,9 +43,6 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.eclipse.jdt.annotation.Nullable;
Expand Down Expand Up @@ -174,8 +170,6 @@ public class LightyControllerImpl extends AbstractLightyModule implements Lighty
private EventExecutor eventExecutor;
private EventLoopGroup bossGroup;
private EventLoopGroup workerGroup;
private ExecutorService threadPool;
private ScheduledExecutorService scheduledThreadPool;
private Timer timer;
private ModuleInfoSnapshot moduleInfoSnapshot;
private ModuleInfoSnapshotResolver snapshotResolver;
Expand Down Expand Up @@ -351,10 +345,6 @@ protected boolean initProcedure() {
this.workerGroup = new NioEventLoopGroup();
this.eventExecutor = new DefaultEventExecutor();
this.timer = new HashedWheelTimer();
this.threadPool =
Executors.newFixedThreadPool(2, new DefaultThreadFactory("default-pool"));
this.scheduledThreadPool =
new ScheduledThreadPoolExecutor(2, new DefaultThreadFactory("default-scheduled-pool"));
this.yangLibraryWriter = new YangLibraryWriterSingleton(clusterSingletonServiceProvider, schemaService,
dataBroker, true);
yangLibraryWriter.instantiateServiceInstance();
Expand Down Expand Up @@ -398,12 +388,6 @@ protected boolean stopProcedure() throws InterruptedException, ExecutionExceptio
if (this.timer != null) {
this.timer.stop();
}
if (this.threadPool != null) {
this.threadPool.shutdown();
}
if (this.scheduledThreadPool != null) {
this.scheduledThreadPool.shutdown();
}
if (this.clusterSingletonServiceProvider != null) {
this.clusterSingletonServiceProvider.close();
}
Expand Down Expand Up @@ -583,16 +567,6 @@ public EventLoopGroup getWorkerGroup() {
return this.workerGroup;
}

@Override
public ExecutorService getThreadPool() {
return this.threadPool;
}

@Override
public ScheduledExecutorService getScheduledThreadPool() {
return this.scheduledThreadPool;
}

@Override
public Timer getTimer() {
return this.timer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ public void controllerSimpleTest() {
Assert.assertNotNull(lightyController.getServices().getEventExecutor());
Assert.assertNotNull(lightyController.getServices().getBossGroup());
Assert.assertNotNull(lightyController.getServices().getWorkerGroup());
Assert.assertNotNull(lightyController.getServices().getThreadPool());
Assert.assertNotNull(lightyController.getServices().getScheduledThreadPool());
Assert.assertNotNull(lightyController.getServices().getTimer());
Assert.assertNotNull(lightyController.getServices().getDOMMountPointService());
Assert.assertNotNull(lightyController.getServices().getDOMNotificationPublishService());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ public synchronized void start(String[] args) throws InterruptedException, Execu

restconf = CommunityRestConfBuilder
.from(RestConfConfigUtils.getRestConfConfiguration(restConfConfiguration, controller.getServices()))
.withScheduledThreadPool(controller.getServices().getScheduledThreadPool())
.build();
Preconditions.checkState(startLightyModule(restconf, modulesConfig.getModuleTimeoutSeconds()),
"Unable to start restconf module");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ private void startLighty(final ControllerConfiguration controllerConfiguration,
.from(RestConfConfigUtils.getRestConfConfiguration(restconfConfiguration,
this.lightyController.getServices()))
.withLightyServer(jettyServerBuilder)
.withScheduledThreadPool(this.lightyController.getServices().getScheduledThreadPool())
.build();
final boolean restconfStartOk = this.restconf.start()
.get(modulesConfig.getModuleTimeoutSeconds(), TimeUnit.SECONDS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ private void startLighty(final ControllerConfiguration controllerConfiguration,
.from(RestConfConfigUtils.getRestConfConfiguration(restconfConfiguration,
this.lightyController.getServices()))
.withLightyServer(jettyServerBuilder)
.withScheduledThreadPool(lightyController.getServices().getScheduledThreadPool())
.build();

//3. start openApi and RestConf server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ private void startLighty(final ControllerConfiguration controllerConfiguration,
.from(RestConfConfigUtils.getRestConfConfiguration(restconfConfiguration,
this.lightyController.getServices()))
.withLightyServer(jettyServerBuilder)
.withScheduledThreadPool(lightyController.getServices().getScheduledThreadPool())
.build();

//3. start openApi and RestConf server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public static CommunityRestConf startRestconf(RestConfConfiguration restConfConf
final CommunityRestConf communityRestConf = CommunityRestConfBuilder
.from(RestConfConfigUtils.getRestConfConfiguration(restConfConfiguration,
services))
.withScheduledThreadPool(services.getScheduledThreadPool())
.build();

LOG.info("Starting CommunityRestConf");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.Set;
import java.util.concurrent.ScheduledExecutorService;
import javax.ws.rs.core.Application;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
Expand Down Expand Up @@ -57,14 +56,13 @@ public class CommunityRestConf extends AbstractLightyModule {
private final String restconfServletContextPath;
private Server jettyServer;
private LightyServerBuilder lightyServerBuilder;
private final ScheduledExecutorService scheduledThreadPool;

public CommunityRestConf(final DOMDataBroker domDataBroker, final DOMRpcService domRpcService,
final DOMActionService domActionService, final DOMNotificationService domNotificationService,
final DOMMountPointService domMountPointService,
final DOMSchemaService domSchemaService, final InetAddress inetAddress,
final int httpPort, final String restconfServletContextPath,
final LightyServerBuilder serverBuilder, final ScheduledExecutorService threadPool) {
final LightyServerBuilder serverBuilder) {
this.domDataBroker = domDataBroker;
this.domRpcService = domRpcService;
this.domActionService = domActionService;
Expand All @@ -75,17 +73,16 @@ public CommunityRestConf(final DOMDataBroker domDataBroker, final DOMRpcService
this.httpPort = httpPort;
this.inetAddress = inetAddress;
this.restconfServletContextPath = restconfServletContextPath;
this.scheduledThreadPool = threadPool;
}

public CommunityRestConf(final DOMDataBroker domDataBroker,
final DOMRpcService domRpcService, final DOMActionService domActionService,
final DOMNotificationService domNotificationService, final DOMMountPointService domMountPointService,
final DOMSchemaService domSchemaService, final InetAddress inetAddress, final int httpPort,
final String restconfServletContextPath, final ScheduledExecutorService threadPool) {
final String restconfServletContextPath) {
this(domDataBroker, domRpcService, domActionService, domNotificationService,
domMountPointService, domSchemaService, inetAddress, httpPort,
restconfServletContextPath, null, threadPool);
restconfServletContextPath, null);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import io.lighty.modules.northbound.restconf.community.impl.config.RestConfConfiguration;
import io.lighty.server.LightyServerBuilder;
import java.util.concurrent.ScheduledExecutorService;

/**
* Builder for {@link CommunityRestConf}.
Expand All @@ -18,7 +17,6 @@ public final class CommunityRestConfBuilder {

private RestConfConfiguration restconfConfiguration = null;
private LightyServerBuilder lightyServerBuilder = null;
private ScheduledExecutorService threadPool = null;


private CommunityRestConfBuilder(final RestConfConfiguration configuration) {
Expand Down Expand Up @@ -52,10 +50,6 @@ public CommunityRestConfBuilder withLightyServer(final LightyServerBuilder serve
* @param pool input scheduledThreadPool.
* @return instance of {@link CommunityRestConfBuilder}.
*/
public CommunityRestConfBuilder withScheduledThreadPool(final ScheduledExecutorService pool) {
this.threadPool = pool;
return this;
}

/**
* Build new {@link CommunityRestConf} instance from {@link CommunityRestConfBuilder}.
Expand All @@ -68,6 +62,6 @@ public CommunityRestConf build() {
this.restconfConfiguration.getDomMountPointService(),
this.restconfConfiguration.getDomSchemaService(),
this.restconfConfiguration.getInetAddress(), this.restconfConfiguration.getHttpPort(),
this.restconfConfiguration.getRestconfServletContextPath(), this.lightyServerBuilder, this.threadPool);
this.restconfConfiguration.getRestconfServletContextPath(), this.lightyServerBuilder);
}
}

0 comments on commit 0574650

Please sign in to comment.