Throwing TNonblockingServer exceptions

I have a server application written in java and a client application in groovy. My server receives the request and does it. I am using Thrift with TNonBlockingServer.

    public static void nonBlockingServer(HbaseLayerService.Processor processor) {
            try {
                final Integer serverPort = ConfigurationManager.instance().getServerPort();
                TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(serverPort);
                TServer server = new TNonblockingServer(new TNonblockingServer.Args(serverTransport).processor(processor));

                server.serve();
            } catch (Exception e) {
                Throwables.propagate(e);
            }
        }

      

My client is sending data ~ 100 MB

TTransport transport = new TFramedTransport(new TSocket('localhost', 12345, 100000))
transport.open()
TProtocol protocol = new TBinaryProtocol(transport);
HbaseLayerService.Client client = new HbaseLayerService.Client(protocol);
def putList = [] //~1500000 objects (string, string, string, int, byte[])
client.putEvent(new PutEventsOperation(putsToSend));

      

during this operation I have an error:

Exception in thread "main" org.apache.thrift.transport.TTransportException
    at org.apache.thrift.transport.TIOStreamTransport.read(TIOStreamTransport.java:132)
    at org.apache.thrift.transport.TTransport.readAll(TTransport.java:86)
    at org.apache.thrift.transport.TFramedTransport.readFrame(TFramedTransport.java:129)
    at org.apache.thrift.transport.TFramedTransport.read(TFramedTransport.java:101)
    at org.apache.thrift.transport.TTransport.readAll(TTransport.java:86)
    at org.apache.thrift.protocol.TBinaryProtocol.readAll(TBinaryProtocol.java:429)
    at org.apache.thrift.protocol.TBinaryProtocol.readI32(TBinaryProtocol.java:318)
    at org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:219)
    at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:69)
    at communication_struct.thrift.HbaseLayerService$Client.recv_putEvent(HbaseLayerService.java:96)

      

This exception is of type 4: END_OF_FILE .

TSimpleServer is fine, but I want to make multiple connections and queued up operation in one thread.

+3


source to share


1 answer


Finally I found a solution. In this particular case, you must add a new dimension to TFramedTransport.Factory

as shown below:

TServer server = new TNonblockingServer(new TNonblockingServer.Args(serverTransport)
                    .processor(processor)
                    .transportFactory(new TFramedTransport.Factory(MAX_FRAMED_TRANSPORT_SIZE))
                    .protocolFactory(new TBinaryProtocol.Factory())
            );

      

The same action should be performed on the client side:



TTransport transport = new TFramedTransport(new TSocket('localhost', 12345), MAX_FRAMED_TRANSPORT_SIZE)

      

In my case MAX_FRAMED_TRANSPORT_SIZE = 256 * 1024 * 1024

.

+2


source







All Articles