Fix compilation
This commit is contained in:
parent
5a69263bd1
commit
86a984c1d6
@ -111,21 +111,22 @@ public class Main {
|
||||
|
||||
clientBuilder.setName(name);
|
||||
try (var connection = clientBuilder.build()) {
|
||||
LOG.info("Connected to {}", connection);
|
||||
try {
|
||||
LOG.info("Connected to {}", connection);
|
||||
|
||||
thriftServerBuilder.setClient(connection);
|
||||
grpcServerBuilder.setClient(connection);
|
||||
thriftServerBuilder.setClient(connection);
|
||||
grpcServerBuilder.setClient(connection);
|
||||
|
||||
CountDownLatch shutdownLatch = new CountDownLatch(1);
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(shutdownLatch::countDown));
|
||||
CountDownLatch shutdownLatch = new CountDownLatch(1);
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(shutdownLatch::countDown));
|
||||
|
||||
try (var _ = thriftServerBuilder.build();
|
||||
var _ = grpcServerBuilder.build()) {
|
||||
shutdownLatch.await();
|
||||
LOG.info("Shutting down...");
|
||||
try (var _ = thriftServerBuilder.build(); var _ = grpcServerBuilder.build()) {
|
||||
shutdownLatch.await();
|
||||
LOG.info("Shutting down...");
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LOG.error("Unexpected error", ex);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException("Interrupted", e);
|
||||
}
|
||||
LOG.info("Shut down successfully");
|
||||
}
|
||||
|
@ -157,17 +157,23 @@ public sealed interface TransactionalDB extends Closeable {
|
||||
}
|
||||
}
|
||||
try {
|
||||
db.flushWal(true);
|
||||
if (db.isOwningHandle()) {
|
||||
db.flushWal(true);
|
||||
}
|
||||
} catch (RocksDBException e) {
|
||||
exceptions.add(e);
|
||||
}
|
||||
try (var options = new FlushOptions().setWaitForFlush(true).setAllowWriteStall(true)) {
|
||||
db.flush(options);
|
||||
if (db.isOwningHandle()) {
|
||||
db.flush(options);
|
||||
}
|
||||
} catch (RocksDBException e) {
|
||||
exceptions.add(e);
|
||||
}
|
||||
try {
|
||||
db.closeE();
|
||||
if (db.isOwningHandle()) {
|
||||
db.closeE();
|
||||
}
|
||||
} catch (RocksDBException e) {
|
||||
exceptions.add(e);
|
||||
}
|
||||
|
@ -4,11 +4,8 @@ import static it.cavallium.rockserver.core.common.Utils.toMemorySegment;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.google.protobuf.Empty;
|
||||
import com.google.rpc.DebugInfo;
|
||||
import io.grpc.Metadata;
|
||||
import io.grpc.Status;
|
||||
import io.grpc.netty.NettyServerBuilder;
|
||||
import io.grpc.protobuf.ProtoUtils;
|
||||
import io.grpc.stub.StreamObserver;
|
||||
import it.cavallium.rockserver.core.client.RocksDBConnection;
|
||||
import it.cavallium.rockserver.core.common.ColumnHashType;
|
||||
@ -506,17 +503,10 @@ public class GrpcServer extends Server {
|
||||
};
|
||||
}
|
||||
|
||||
private static final Metadata.Key<DebugInfo> DEBUG_INFO_TRAILER_KEY =
|
||||
ProtoUtils.keyForProto(DebugInfo.getDefaultInstance());
|
||||
|
||||
private static <PREV, T> BiConsumer<? super PREV, Throwable> handleResponseObserver(Function<PREV, T> resultMapper,
|
||||
StreamObserver<T> responseObserver) {
|
||||
return (value, ex) -> {
|
||||
if (ex != null) {
|
||||
Metadata trailers = new Metadata();
|
||||
trailers.put(DEBUG_INFO_TRAILER_KEY, DebugInfo.newBuilder()
|
||||
.setDetail("rockserver grpc execution failed")
|
||||
.build());
|
||||
var cause = ex;
|
||||
if (cause instanceof CompletionException completionException) {
|
||||
cause = completionException;
|
||||
@ -526,7 +516,7 @@ public class GrpcServer extends Server {
|
||||
}
|
||||
var error = Status.INTERNAL.withCause(cause)
|
||||
.withDescription(cause.toString())
|
||||
.asException(trailers);
|
||||
.asException();
|
||||
responseObserver.onError(error);
|
||||
} else {
|
||||
T mapped;
|
||||
|
Loading…
Reference in New Issue
Block a user