xvrl commented on code in PR #14827:
URL: https://github.com/apache/druid/pull/14827#discussion_r1317620143


##########
server/src/main/java/org/apache/druid/client/cache/MemcachedCache.java:
##########
@@ -355,9 +358,28 @@ public void updateHistogram(String name, int amount)
           .setReadBufferSize(config.getReadBufferSize())
           .setOpQueueFactory(opQueueFactory)
           .setMetricCollector(metricCollector)
-          .setEnableMetrics(MetricType.DEBUG) // Not as scary as it sounds
-          .build();
-
+          .setEnableMetrics(MetricType.DEBUG); // Not as scary as it sounds
+      if (config.enableTls()) {
+        // Build SSLContext
+        TrustManagerFactory tmf = 
TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+        tmf.init((KeyStore) null);
+        SSLContext sslContext = SSLContext.getInstance("TLS");
+        sslContext.init(null, tmf.getTrustManagers(), null);
+        // Create the client in TLS mode
+        connectionFactoryBuilder.setSSLContext(sslContext);
+      }
+      if ("dynamic".equals(config.getClientMode())) {
+        connectionFactoryBuilder.setClientMode(ClientMode.Dynamic);
+        
connectionFactoryBuilder.setHostnameForTlsVerification(config.getHosts().split(",")[0]);
+      } else if ("static".equals(config.getClientMode())) {
+        connectionFactoryBuilder.setClientMode(ClientMode.Static);
+      } else {
+        throw new RuntimeException("Invalid value provided for 
`druid.cache.clientMode`. Value must be 'static' or 'dynamic'.");

Review Comment:
   cache configurations can be nested as l1/l2 so it's not always the case that 
the prefix for this configuration is `druid.cache.`, so I would remove the 
prefix. We should also add the value to make it clear what the issue was.
   
   ```suggestion
           throw new RE("Invalid value provided for memcached client 
configuration `clientMode` [{}]. Value must be 'static' or 'dynamic'.", 
config.getClientMode());
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to