Skip to content
Snippets Groups Projects
Commit d5e9f5a8 authored by Sören Henning's avatar Sören Henning
Browse files

instantiate CassandraService even if no server is available

parent ef22e3a8
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@ import org.springframework.stereotype.Service;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Session;
import com.datastax.driver.core.exceptions.NoHostAvailableException;
@Service
public class CassandraService {
......@@ -12,11 +13,15 @@ public class CassandraService {
private static final int PORT = 32770;
private static final String KEYSPACE = "demo3";
private final Session session;
private Session session; // TODO final
public CassandraService() {
final Cluster cluster = Cluster.builder().addContactPoint(IP_ADDRESS).withPort(PORT).build();
this.session = cluster.connect(KEYSPACE);
try {
final Cluster cluster = Cluster.builder().addContactPoint(IP_ADDRESS).withPort(PORT).build();
this.session = cluster.connect(KEYSPACE);
} catch (NoHostAvailableException exception) {
this.session = null;
}
}
public Session getSession() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment