Fix compilation
This commit is contained in:
parent
5a69263bd1
commit
86a984c1d6
@ -111,6 +111,7 @@ public class Main {
|
||||
|
||||
clientBuilder.setName(name);
|
||||
try (var connection = clientBuilder.build()) {
|
||||
try {
|
||||
LOG.info("Connected to {}", connection);
|
||||
|
||||
thriftServerBuilder.setClient(connection);
|
||||
@ -119,13 +120,13 @@ public class Main {
|
||||
CountDownLatch shutdownLatch = new CountDownLatch(1);
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(shutdownLatch::countDown));
|
||||
|
||||
try (var _ = thriftServerBuilder.build();
|
||||
var _ = grpcServerBuilder.build()) {
|
||||
try (var _ = thriftServerBuilder.build(); var _ = grpcServerBuilder.build()) {
|
||||
shutdownLatch.await();
|
||||
LOG.info("Shutting down...");
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException("Interrupted", e);
|
||||
} catch (Exception ex) {
|
||||
LOG.error("Unexpected error", ex);
|
||||
}
|
||||
}
|
||||
LOG.info("Shut down successfully");
|
||||
}
|
||||
|
@ -157,17 +157,23 @@ public sealed interface TransactionalDB extends Closeable {
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (db.isOwningHandle()) {
|
||||
db.flushWal(true);
|
||||
}
|
||||
} catch (RocksDBException e) {
|
||||
exceptions.add(e);
|
||||
}
|
||||
try (var options = new FlushOptions().setWaitForFlush(true).setAllowWriteStall(true)) {
|
||||
if (db.isOwningHandle()) {
|
||||
db.flush(options);
|
||||
}
|
||||
} catch (RocksDBException e) {
|
||||
exceptions.add(e);
|
||||
}
|
||||
try {
|
||||
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