Fix thrift server not starting, more logs
This commit is contained in:
parent
bee5f5f189
commit
11b1d800dc
@ -120,7 +120,9 @@ public class Main {
|
||||
CountDownLatch shutdownLatch = new CountDownLatch(1);
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(shutdownLatch::countDown));
|
||||
|
||||
try (var _ = thriftServerBuilder.build(); var _ = grpcServerBuilder.build()) {
|
||||
try (var thrift = thriftServerBuilder.build(); var grpc = grpcServerBuilder.build()) {
|
||||
thrift.start();
|
||||
grpc.start();
|
||||
shutdownLatch.await();
|
||||
LOG.info("Shutting down...");
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ public class TestGrpcLoop {
|
||||
public static void main(String[] args) throws IOException, InterruptedException {
|
||||
var embeddedDB = new EmbeddedConnection(null, "main", null);
|
||||
var server = new GrpcServer(embeddedDB, new InetSocketAddress("localhost", 12345));
|
||||
server.start();
|
||||
var clientB = new ClientBuilder();
|
||||
clientB.setHttpAddress(new Utils.HostAndPort("localhost", 12345));
|
||||
clientB.setName("local");
|
||||
|
@ -56,6 +56,7 @@ public class LoggingClient implements RocksDBConnection {
|
||||
|
||||
@Override
|
||||
public <R> R requestSync(RocksDBAPICommand<R> req) {
|
||||
logger.trace("Request input (sync): {}", req);
|
||||
R result;
|
||||
try {
|
||||
result = syncApi.requestSync(req);
|
||||
@ -78,6 +79,7 @@ public class LoggingClient implements RocksDBConnection {
|
||||
|
||||
@Override
|
||||
public <R> CompletableFuture<R> requestAsync(RocksDBAPICommand<R> req) {
|
||||
logger.trace("Request input (async): {}", req);
|
||||
return asyncApi.requestAsync(req).whenComplete((result, e) -> {
|
||||
if (e != null) {
|
||||
logger.trace("Request failed: {} Error: {}", req, e.getMessage());
|
||||
|
@ -94,10 +94,14 @@ public class GrpcServer extends Server {
|
||||
.maxInboundMessageSize(512 * 1024 * 1024)
|
||||
.addService(grpc)
|
||||
.build();
|
||||
server.start();
|
||||
LOG.info("GRPC RocksDB server is listening at " + socketAddress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws IOException {
|
||||
server.start();
|
||||
}
|
||||
|
||||
private final class GrpcServerImpl extends RocksDBServiceImplBase {
|
||||
|
||||
private final RocksDBAsyncAPI asyncApi;
|
||||
|
@ -5,7 +5,7 @@ import it.cavallium.rockserver.core.client.RocksDBConnection;
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Server implements Closeable {
|
||||
public abstract class Server implements Closeable {
|
||||
|
||||
private final RocksDBConnection client;
|
||||
|
||||
@ -17,6 +17,8 @@ public class Server implements Closeable {
|
||||
return client;
|
||||
}
|
||||
|
||||
public abstract void start() throws IOException;
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
client.close();
|
||||
|
@ -57,6 +57,10 @@ public class ThriftServer extends Server {
|
||||
}
|
||||
}
|
||||
|
||||
public void start() {
|
||||
thriftThread.start();
|
||||
}
|
||||
|
||||
private static @NotNull List<@NotNull Keys> keysToRecords(Arena arena, @NotNull List<@NotNull List< @NotNull ByteBuffer>> keysMulti) {
|
||||
return keysMulti.stream().map(keys -> keysToRecord(arena, keys)).toList();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user