]>
git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/thrift/lib/java/src/org/apache/thrift/TServiceClient.java
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
20 package org
.apache
.thrift
;
22 import org
.apache
.thrift
.protocol
.TMessage
;
23 import org
.apache
.thrift
.protocol
.TMessageType
;
24 import org
.apache
.thrift
.protocol
.TProtocol
;
27 * A TServiceClient is used to communicate with a TService implementation
28 * across protocols and transports.
30 public abstract class TServiceClient
{
31 public TServiceClient(TProtocol prot
) {
35 public TServiceClient(TProtocol iprot
, TProtocol oprot
) {
40 protected TProtocol iprot_
;
41 protected TProtocol oprot_
;
46 * Get the TProtocol being used as the input (read) protocol.
47 * @return the TProtocol being used as the input (read) protocol.
49 public TProtocol
getInputProtocol() {
54 * Get the TProtocol being used as the output (write) protocol.
55 * @return the TProtocol being used as the output (write) protocol.
57 public TProtocol
getOutputProtocol() {
61 protected void sendBase(String methodName
, TBase
<?
,?
> args
) throws TException
{
62 sendBase(methodName
, args
, TMessageType
.CALL
);
65 protected void sendBaseOneway(String methodName
, TBase
<?
,?
> args
) throws TException
{
66 sendBase(methodName
, args
, TMessageType
.ONEWAY
);
69 private void sendBase(String methodName
, TBase
<?
,?
> args
, byte type
) throws TException
{
70 oprot_
.writeMessageBegin(new TMessage(methodName
, type
, ++seqid_
));
72 oprot_
.writeMessageEnd();
73 oprot_
.getTransport().flush();
76 protected void receiveBase(TBase
<?
,?
> result
, String methodName
) throws TException
{
77 TMessage msg
= iprot_
.readMessageBegin();
78 if (msg
.type
== TMessageType
.EXCEPTION
) {
79 TApplicationException x
= new TApplicationException();
81 iprot_
.readMessageEnd();
84 if (msg
.seqid
!= seqid_
) {
85 throw new TApplicationException(TApplicationException
.BAD_SEQUENCE_ID
,
86 String
.format("%s failed: out of sequence response: expected %d but got %d", methodName
, seqid_
, msg
.seqid
));
89 iprot_
.readMessageEnd();