com.clickzetta.platform.test.BaseIgsRouter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of clickzetta-java Show documentation
Show all versions of clickzetta-java Show documentation
The java SDK for clickzetta's Lakehouse
package com.clickzetta.platform.test;
import com.clickzetta.platform.client.proxy.RequestConstructor;
import com.google.common.annotations.VisibleForTesting;
import com.google.protobuf.AbstractMessage;
import cz.proto.ingestion.Ingestion;
import cz.proto.ingestion.v2.IGSRouterServiceGrpc;
import cz.proto.ingestion.v2.IngestionV2;
import io.grpc.stub.StreamObserver;
import java.io.IOException;
@VisibleForTesting
public class BaseIgsRouter extends IGSRouterServiceGrpc.IGSRouterServiceImplBase {
private Ingestion.HostPortTuple controllerTuple;
public BaseIgsRouter(Ingestion.HostPortTuple controllerTuple) {
this.controllerTuple = controllerTuple;
}
@Override
public void getControllerAddress(IngestionV2.GetControllerAddressRequest request,
StreamObserver responseObserver) {
try {
responseObserver.onNext(buildRouterRpcCallResponse(
Ingestion.MethodEnum.GET_ROUTER_CONTROLLER_ADDRESS, RequestConstructor.toReqString(request)));
} catch (IOException e) {
throw new RuntimeException(e);
}
responseObserver.onCompleted();
}
public T buildRouterRpcCallResponse(Ingestion.MethodEnum method, String message) {
switch (method) {
case GET_ROUTER_CONTROLLER_ADDRESS: {
String serverAddress = String.format("%s:%s", controllerTuple.getHost(), controllerTuple.getPort());
return (T) IngestionV2.GetControllerAddressResponse.newBuilder()
.setStatus(IngestionV2.ResponseStatus.newBuilder().setCode(IngestionV2.Code.SUCCESS).build())
.setServiceAddress(serverAddress).build();
}
case GATEWAY_RPC_CALL:
default:
throw new UnsupportedOperationException("not support method " + method);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy