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