Skip to content

Commit

Permalink
Fix to fall back to key based config in binary mode for 1.4.5 engine
Browse files Browse the repository at this point in the history
  • Loading branch information
rajaprabhu committed May 8, 2013
1 parent 7029a1e commit 4098dbb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/main/java/net/spy/memcached/ConfigurationPoller.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/net/spy/memcached/MemcachedClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()){
Expand Down

0 comments on commit 4098dbb

Please sign in to comment.