Skip to content
This repository has been archived by the owner on Dec 10, 2019. It is now read-only.

Commit

Permalink
[CROSSDATA-125] [CONNECTION] Bug with blank spaces in hosts solved
Browse files Browse the repository at this point in the history
  • Loading branch information
mafernandez-stratio committed Nov 13, 2015
1 parent e557f5f commit 62055e6
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,24 @@ public void connect(ICredentials credentials, ConnectorClusterConfig config)

//Check if the cluster is attached with other connector
if (sessions.containsKey(clusterName.getName())) {
throw new ConnectionException("The connection to " + clusterName.getName() + " already exists.");
LOG.warn("The connection to " + clusterName.getName() + " already exists.");
return;
}

Map<String, String> clusterOptions = config.getClusterOptions();
Map<String, String> connectorOptions = config.getConnectorOptions();

EngineConfig engineConfig = new EngineConfig();
//the hosts must be received as [host1:port,host2:port,host3:port...]
engineConfig.setCassandraHosts(
clusterOptions.get("Hosts").substring(1, clusterOptions.get("Hosts").length() - 1)
.split(","));

String[] hosts = clusterOptions.get("Hosts").substring(1, clusterOptions.get("Hosts").length() - 1).split(",");

String[] trimmedHosts = new String[hosts.length];

for(int i=0; i < hosts.length; i++){
trimmedHosts[i] = hosts[i].trim();
}

engineConfig.setCassandraHosts(trimmedHosts);
engineConfig.setCassandraPort(Integer.parseInt(clusterOptions.get("Port")));
engineConfig.setCredentials(credentials);

Expand Down

0 comments on commit 62055e6

Please sign in to comment.