Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,41 @@ public Promise<ResultSet> execute(Statement statement) {
});
}

public Promise<Void> closeSession() {
return Promise.async(downstream -> {
CloseFuture closeFuture = session.closeAsync();
downstream.accept(closeFuture);
});
}

public Promise<Void> closeCluster() {
return Promise.async(downstream -> {
CloseFuture closeFuture = cluster.closeAsync();
downstream.accept(closeFuture);
});
}

@Override
public void onStart(StartEvent event) throws Exception {
connect();
}

@Override
public void onStop(StopEvent event) throws Exception {
session.closeAsync();
closeSession()
.mapError(error -> {
logger.error("CassandraService error closing session", error);
return null;
})
.flatMap(ignore -> {
logger.info("CassandraService session closed");
return closeCluster();
})
.mapError(error -> {
logger.error("CassandraService error closing cluster", error);
return null;
})
.then(ignore -> logger.info("CassandraService cluster closed"));
}

public Session getSession() {
Expand Down