diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-09-18 10:47:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-18 10:47:22 +0200 |
commit | 250f7e16efa36fe2b5e24bf75fe3f0af5cb4fed8 (patch) | |
tree | 38476c06ef0d5c99535d181c4e6a2cbede1ad552 /container-search/src/main/java/com/yahoo/prelude/fastsearch/FS4ResourcePool.java | |
parent | 58d1a577ed35a5415ea94b037de60e4211322245 (diff) |
Revert "Revert "Revert "Revert "Balder/no more fs4 dispatching from fastsearcher""""
Diffstat (limited to 'container-search/src/main/java/com/yahoo/prelude/fastsearch/FS4ResourcePool.java')
-rw-r--r-- | container-search/src/main/java/com/yahoo/prelude/fastsearch/FS4ResourcePool.java | 38 |
1 files changed, 4 insertions, 34 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/fastsearch/FS4ResourcePool.java b/container-search/src/main/java/com/yahoo/prelude/fastsearch/FS4ResourcePool.java index f85a4019b78..ed9eb72d7dd 100644 --- a/container-search/src/main/java/com/yahoo/prelude/fastsearch/FS4ResourcePool.java +++ b/container-search/src/main/java/com/yahoo/prelude/fastsearch/FS4ResourcePool.java @@ -5,14 +5,6 @@ import com.google.inject.Inject; import com.yahoo.component.AbstractComponent; import com.yahoo.concurrent.ThreadFactoryFactory; import com.yahoo.container.QrConfig; -import com.yahoo.container.search.Fs4Config; -import com.yahoo.fs4.mplex.Backend; -import com.yahoo.fs4.mplex.ConnectionPool; -import com.yahoo.fs4.mplex.ListenerPool; - -import java.util.HashMap; -import java.util.Map; -import java.util.Timer; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -22,7 +14,7 @@ import java.util.logging.Level; import java.util.logging.Logger; /** - * Provider for {@link com.yahoo.fs4.mplex.ListenerPool}. All users will get the same pool instance. + * All users will get the same pool instance. * * @author baldersheim */ @@ -32,22 +24,18 @@ public class FS4ResourcePool extends AbstractComponent { private static final AtomicInteger instanceCounter = new AtomicInteger(0); private final String serverId; private final int instanceId; - private final ListenerPool listeners; - private final Timer timer = new Timer(); // This is a timer for cleaning the closed connections - private final Map<String, Backend> connectionPoolMap = new HashMap<>(); private final ExecutorService executor; private final ScheduledExecutorService scheduledExecutor; @Inject - public FS4ResourcePool(Fs4Config fs4Config, QrConfig config) { - this(config.discriminator(), fs4Config.numlistenerthreads()); + public FS4ResourcePool(QrConfig config) { + this(config.discriminator()); } - public FS4ResourcePool(String serverId, int listenerThreads) { + public FS4ResourcePool(String serverId) { this.serverId = serverId; instanceId = instanceCounter.getAndIncrement(); String name = "FS4-" + instanceId; - listeners = new ListenerPool(name, listenerThreads); executor = Executors.newCachedThreadPool(ThreadFactoryFactory.getDaemonThreadFactory(name)); scheduledExecutor = Executors.newScheduledThreadPool(1, ThreadFactoryFactory.getDaemonThreadFactory(name + ".scheduled")); } @@ -57,28 +45,10 @@ public class FS4ResourcePool extends AbstractComponent { public ExecutorService getExecutor() { return executor; } public ScheduledExecutorService getScheduledExecutor() { return scheduledExecutor; } - public Backend getBackend(String host, int port) { - String key = host + ":" + port; - synchronized (connectionPoolMap) { - Backend pool = connectionPoolMap.get(key); - if (pool == null) { - pool = new Backend(host, port, serverId, listeners, new ConnectionPool(timer)); - connectionPoolMap.put(key, pool); - } - return pool; - } - } - @Override public void deconstruct() { logger.log(Level.INFO, "Deconstructing FS4ResourcePool with id '" + instanceId + "'."); super.deconstruct(); - listeners.close(); - timer.cancel(); - for (Backend backend : connectionPoolMap.values()) { - backend.shutdown(); - backend.close(); - } executor.shutdown(); scheduledExecutor.shutdown(); try { |