From 4098dbba486654b74e09df7cc64cef4324543457 Mon Sep 17 00:00:00 2001 From: Rajaprabhu Loganathan Date: Wed, 8 May 2013 14:09:32 -0700 Subject: [PATCH] Fix to fall back to key based config in binary mode for 1.4.5 engine --- .../java/net/spy/memcached/ConfigurationPoller.java | 7 +++++++ .../java/net/spy/memcached/MemcachedClient.java | 13 +++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/spy/memcached/ConfigurationPoller.java b/src/main/java/net/spy/memcached/ConfigurationPoller.java index fa8493094..47acfdd29 100644 --- a/src/main/java/net/spy/memcached/ConfigurationPoller.java +++ b/src/main/java/net/spy/memcached/ConfigurationPoller.java @@ -115,6 +115,13 @@ public void run(){ newConfigResponse = (String)client.getConfig(socketAddressToGetConfig, ConfigurationType.CLUSTER, configTranscoder); + if(newConfigResponse == null || newConfigResponse.trim().isEmpty()){ + newConfigResponse = (String)client.get(socketAddressToGetConfig, ConfigurationType.CLUSTER.getValueWithNameSpace(), configTranscoder); + if(newConfigResponse != null && ! newConfigResponse.trim().isEmpty()){ + client.setIsConfigurationProtocolSupported(false); + } + } + }catch(OperationNotSupportedException e){ //Fallback to key based config access. client.setIsConfigurationProtocolSupported(false); diff --git a/src/main/java/net/spy/memcached/MemcachedClient.java b/src/main/java/net/spy/memcached/MemcachedClient.java index 4306b79b4..0d179c269 100644 --- a/src/main/java/net/spy/memcached/MemcachedClient.java +++ b/src/main/java/net/spy/memcached/MemcachedClient.java @@ -298,16 +298,21 @@ private void initializeClientUsingConfigEndPoint(ConnectionFactory cf, InetSocke throws IOException{ configurationNode = new NodeEndPoint(configurationEndPoint.getHostName(), configurationEndPoint.getPort()); setupConnection(cf, Collections.singletonList(configurationEndPoint)); - - String configResult; + boolean checkKey = false; + String configResult = null; try{ try{ //GetConfig configResult = (String)this.getConfig(configurationEndPoint, ConfigurationType.CLUSTER, configTranscoder); }catch(OperationNotSupportedException e){ - + checkKey = true; + } + + if(checkKey || configResult == null || configResult.trim().isEmpty()){ configResult = (String)this.get(configurationEndPoint, ConfigurationType.CLUSTER.getValueWithNameSpace(), configTranscoder); - isConfigurationProtocolSupported = false; + if(configResult != null && ! configResult.trim().isEmpty()){ + isConfigurationProtocolSupported = false; + } } if(configResult != null && ! configResult.trim().isEmpty()){