Skip to content

Commit

Permalink
Replace AbstractVerticle -> VerticleBase
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Oct 22, 2024
1 parent 4177582 commit c6953b7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ protected static void getCassandraReleaseVersion(CassandraClient client, Handler
});
}

protected static Future<String> getCassandraReleaseVersion(CassandraClient client) {
return client.executeWithFullFetch("select release_version from system.local")
.map(result -> result.iterator().next().getString("release_version"));
}

protected static String randomClientName() {
return CassandraClient.class.getSimpleName() + "-" + UUID.randomUUID();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

import io.vertx.cassandra.CassandraClient;
import io.vertx.cassandra.CassandraClientOptions;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Promise;
import io.vertx.core.Future;
import io.vertx.core.VerticleBase;

public class VerticleWithCassandraClient extends AbstractVerticle {
public class VerticleWithCassandraClient extends VerticleBase {

private final CassandraClientOptions options;
private final String clientName;
Expand All @@ -38,27 +38,21 @@ public VerticleWithCassandraClient(CassandraClientOptions options, String client
}

@Override
public void start(Promise<Void> startFuture) {
public Future<?> start() throws Exception {
client = CassandraClient.createShared(vertx, clientName, options);
if (executeRequestOnStart) {
CassandraClientTestBase.getCassandraReleaseVersion(client, ar -> {
if (ar.succeeded()) {
startFuture.complete();
} else {
startFuture.fail(ar.cause());
}
});
return CassandraClientTestBase.getCassandraReleaseVersion(client);
} else {
startFuture.complete();
return super.start();
}
}

@Override
public void stop(Promise<Void> stopFuture) {
public Future<?> stop() throws Exception {
if (closeOnStop && client != null) {
client.close().onComplete(stopFuture);
return client.close();
} else {
stopFuture.complete();
return super.stop();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
import io.vertx.cassandra.CassandraClient;
import io.vertx.cassandra.impl.CassandraClientImpl;
import io.vertx.cassandra.impl.SessionHolder;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.DeploymentOptions;
import io.vertx.core.Vertx;
import io.vertx.core.*;
import io.vertx.core.shareddata.LocalMap;
import io.vertx.ext.unit.junit.VertxUnitRunner;
import org.junit.After;
Expand Down Expand Up @@ -61,13 +59,14 @@ public void testMapCleaned() throws Exception {
assertEquals(0, holders.size());
}

private static class SampleVerticle extends AbstractVerticle {
private static class SampleVerticle extends VerticleBase {

CassandraClient shared;

@Override
public void start() {
public Future<?> start() throws Exception {
shared = CassandraClient.createShared(vertx, CLIENT_NAME);
return super.start();
}
}
}

0 comments on commit c6953b7

Please sign in to comment.