geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject [geode] 02/03: GEODE-3774: Amended TCPServer code to store the loader and not the clientProtocolService
Date Tue, 17 Oct 2017 17:50:29 GMT
This is an automated email from the ASF dual-hosted git repository.

udo pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 184055fd327c7ab5708f86e9e8010bbd0e0ddba8
Author: kohlmu-pivotal <ukohlmeyer@pivotal.io>
AuthorDate: Thu Oct 12 16:21:56 2017 -0700

    GEODE-3774: Amended TCPServer code to store the loader and not the clientProtocolService
---
 .../distributed/internal/InternalLocator.java      |  3 ++-
 .../distributed/internal/tcpserver/TcpServer.java  | 26 ++++++++++++----------
 .../tier/sockets/ClientProtocolServiceLoader.java  |  1 -
 .../cache/tier/sockets/TcpServerFactory.java       | 12 +++-------
 4 files changed, 19 insertions(+), 23 deletions(-)

diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
index 26864d2..557610f 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java
@@ -1336,7 +1336,8 @@ public class InternalLocator extends Locator implements ConnectListener
{
       this.stats.hookupStats(sys,
           SocketCreator.getLocalHost().getCanonicalHostName() + '-' + this.server.getBindAddress());
 
-      ClientProtocolService clientProtocolService = this.server.getClientProtocolService();
+      ClientProtocolService clientProtocolService =
+          this.server.getClientProtocolServiceLoader().lookupService();
       if (clientProtocolService != null) {
         clientProtocolService.initializeStatistics("LocatorStats", sys);
       }
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/tcpserver/TcpServer.java
b/geode-core/src/main/java/org/apache/geode/distributed/internal/tcpserver/TcpServer.java
index b9d10f6..40f1f0f 100755
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/tcpserver/TcpServer.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/tcpserver/TcpServer.java
@@ -61,7 +61,9 @@ import org.apache.geode.internal.cache.InternalCache;
 import org.apache.geode.internal.cache.tier.CommunicationMode;
 import org.apache.geode.internal.cache.tier.sockets.ClientProtocolProcessor;
 import org.apache.geode.internal.cache.tier.sockets.ClientProtocolService;
+import org.apache.geode.internal.cache.tier.sockets.ClientProtocolServiceLoader;
 import org.apache.geode.internal.cache.tier.sockets.HandShake;
+import org.apache.geode.internal.cache.tier.sockets.ServiceLoadingFailureException;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.internal.net.SocketCreator;
 import org.apache.geode.internal.net.SocketCreatorFactory;
@@ -134,7 +136,7 @@ public class TcpServer {
   private final PoolStatHelper poolHelper;
   private final InternalLocator internalLocator;
   private final TcpHandler handler;
-  private final ClientProtocolService clientProtocolService;
+  private final ClientProtocolServiceLoader clientProtocolServiceLoader;
 
 
   private PooledExecutorWithDMStats executor;
@@ -159,20 +161,20 @@ public class TcpServer {
   /**
    * returns the message handler used for client/locator communications processing
    */
-  public ClientProtocolService getClientProtocolService() {
-    return clientProtocolService;
+  public ClientProtocolServiceLoader getClientProtocolServiceLoader() {
+    return clientProtocolServiceLoader;
   }
 
   public TcpServer(int port, InetAddress bind_address, Properties sslConfig,
       DistributionConfigImpl cfg, TcpHandler handler, PoolStatHelper poolHelper,
       ThreadGroup threadGroup, String threadName, InternalLocator internalLocator,
-      ClientProtocolService clientProtocolService) {
+      ClientProtocolServiceLoader clientProtocolServiceLoader) {
     this.port = port;
     this.bind_address = bind_address;
     this.handler = handler;
     this.poolHelper = poolHelper;
     this.internalLocator = internalLocator;
-    this.clientProtocolService = clientProtocolService;
+    this.clientProtocolServiceLoader = clientProtocolServiceLoader;
     // register DSFID types first; invoked explicitly so that all message type
     // initializations do not happen in first deserialization on a possibly
     // "precious" thread
@@ -382,13 +384,9 @@ public class TcpServer {
         if (gossipVersion == NON_GOSSIP_REQUEST_VERSION) {
           if (input.readUnsignedByte() == PROTOBUF_CLIENT_SERVER_PROTOCOL
               && Boolean.getBoolean("geode.feature-protobuf-protocol")) {
-            if (clientProtocolService == null) {
-              // this shouldn't happen.
-              log.error("Client protocol service not initialized but a request was received");
-              socket.close();
-              throw new IOException(
-                  "Client protocol service not initialized but a request was received");
-            } else {
+            try {
+              ClientProtocolService clientProtocolService =
+                  clientProtocolServiceLoader.lookupService();
               try (ClientProtocolProcessor pipeline =
                   clientProtocolService.createProcessorForLocator(internalLocator)) {
                 pipeline.processMessage(input, socket.getOutputStream());
@@ -396,6 +394,10 @@ public class TcpServer {
                 // should not happen on the locator as there is no handshake.
                 log.error("Unexpected exception in client message processing", e);
               }
+            } catch (ServiceLoadingFailureException e) {
+              log.error("There was an error looking up the client protocol service", e);
+              socket.close();
+              throw new IOException("There was an error looking up the client protocol service",
e);
             }
           } else {
             rejectUnknownProtocolConnection(socket, gossipVersion);
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientProtocolServiceLoader.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientProtocolServiceLoader.java
index 5051c05..8b069ad 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientProtocolServiceLoader.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/ClientProtocolServiceLoader.java
@@ -33,7 +33,6 @@ public class ClientProtocolServiceLoader {
       resultList.add(clientProtocolService);
     }
 
-
     return resultList;
   }
 
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/TcpServerFactory.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/TcpServerFactory.java
index f8e903f..47b26d8 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/TcpServerFactory.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/TcpServerFactory.java
@@ -28,17 +28,11 @@ import org.apache.geode.distributed.internal.tcpserver.TcpServer;
 import org.apache.geode.internal.logging.LogService;
 
 public class TcpServerFactory {
-  private final ClientProtocolService clientProtocolService;
+  private final ClientProtocolServiceLoader clientProtocolServiceLoader;
   static final Logger logger = LogService.getLogger();
 
   public TcpServerFactory() {
-    ClientProtocolService service = null;
-    try {
-      service = new ClientProtocolServiceLoader().lookupService();
-    } catch (ServiceLoadingFailureException ex) {
-      logger.warn("Could not load client protocol", ex);
-    }
-    clientProtocolService = service;
+    clientProtocolServiceLoader = new ClientProtocolServiceLoader();
   }
 
   public TcpServer makeTcpServer(int port, InetAddress bind_address, Properties sslConfig,
@@ -46,6 +40,6 @@ public class TcpServerFactory {
       ThreadGroup threadGroup, String threadName, InternalLocator internalLocator) {
 
     return new TcpServer(port, bind_address, sslConfig, cfg, handler, poolHelper, threadGroup,
-        threadName, internalLocator, clientProtocolService);
+        threadName, internalLocator, clientProtocolServiceLoader);
   }
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@geode.apache.org" <commits@geode.apache.org>.

Mime
View raw message