Before a GPSS client can load data into Greenplum Database, the client must first establish a connection to the Greenplum Streaming Server.
When you start a GPSS server instance, you provide a JSON-format configuration file. You identify the hostname and port on which the GPSS server instance listens for connection requests in this configuration file. For more information about the GPSS server, refer to the gpss reference page.
The GPSS client application must create a gRPC managed channel to this GPSS instance. Because GPSS supports the simple RPC service, the client creates a blocking stub on the channel.
This sample Java client code connects to and disconnects from a GPSS service instance listening for connections on port number 5019 on the local host:
java.util.concurrent.TimeUnit;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
String gpssHost = "localhost";
Integer gpssPort = 5019;
ManagedChannel channel = null;
GpssGrpc.GpssBlockingStub bStub = null;
try {
// connect to GPSS gRPC service instance; create a channel and a blocking stub
channel = ManagedChannelBuilder.forAddress(gpssHost, gpssPort)
.usePlaintext(true)
.build();
bStub = GpssGrpc.newBlockingStub(channel);
// (placeholder) do stuff here
// shutdown the channel
channel.shutdown().awaitTermination(7, TimeUnit.SECONDS);
} catch (Exception e) {
...
}
After the GPSS client instantiates a stub, the client can use the stub to invoke the GPSS service methods.