use of org.apache.servicecomb.transport.highway.message.RequestHeader in project incubator-servicecomb-java-chassis by apache.
the class HighwayClientConnection method createLogin.
@Override
protected TcpOutputStream createLogin() {
try {
RequestHeader header = new RequestHeader();
header.setMsgType(MsgType.LOGIN);
LoginRequest login = new LoginRequest();
login.setProtocol(HighwayTransport.NAME);
login.setUseProtobufMapCodec(true);
HighwayOutputStream os = new HighwayOutputStream(AbstractTcpClientPackage.getAndIncRequestId(), null);
os.write(header, LoginRequest.getLoginRequestSchema(), login);
return os;
} catch (Throwable e) {
throw new Error("impossible.", e);
}
}
use of org.apache.servicecomb.transport.highway.message.RequestHeader in project incubator-servicecomb-java-chassis by apache.
the class TestHighwayServerConnection method testRequestError.
@Test
public void testRequestError() throws Exception {
header.setMsgType(MsgType.REQUEST);
Buffer headerBuffer = createBuffer(requestHeaderSchema, header);
Buffer bodyBuffer = Buffer.buffer();
Holder<Boolean> holder = new Holder<>(false);
new MockUp<HighwayServerInvoke>() {
@Mock
public boolean init(NetSocket netSocket, long msgId, RequestHeader header, Buffer bodyBuffer) {
return false;
}
};
connection.handle(0, headerBuffer, bodyBuffer);
Assert.assertEquals(null, connection.getProtocol());
Assert.assertEquals(null, connection.getZipName());
Assert.assertEquals(false, holder.value);
}
use of org.apache.servicecomb.transport.highway.message.RequestHeader in project incubator-servicecomb-java-chassis by apache.
the class TestHighwayServerConnection method init.
@Before
public void init() {
new Expectations(CseContext.getInstance()) {
{
netSocket.remoteAddress();
result = new SocketAddressImpl(new InetSocketAddress("127.0.0.1", 80));
}
};
connection = new HighwayServerConnection(endpoint);
connection.init(netSocket);
header = new RequestHeader();
}
use of org.apache.servicecomb.transport.highway.message.RequestHeader in project java-chassis by ServiceComb.
the class HighwayCodec method encodeRequest.
public static TcpOutputStream encodeRequest(long msgId, Invocation invocation, OperationProtobuf operationProtobuf) throws Exception {
// 写header
RequestHeader header = new RequestHeader();
header.setMsgType(MsgType.REQUEST);
header.setFlags(0);
header.setDestMicroservice(invocation.getMicroserviceName());
header.setSchemaId(invocation.getSchemaId());
header.setOperationName(invocation.getOperationName());
header.setContext(invocation.getContext());
HighwayOutputStream os = new HighwayOutputStream(msgId);
os.write(header, operationProtobuf.getRequestRootSerializer(), invocation.getSwaggerArguments());
return os;
}
use of org.apache.servicecomb.transport.highway.message.RequestHeader in project java-chassis by ServiceComb.
the class HighwayClientConnection method createLogin.
@Override
protected TcpOutputStream createLogin() {
try {
RequestHeader header = new RequestHeader();
header.setMsgType(MsgType.LOGIN);
LoginRequest login = new LoginRequest();
login.setProtocol(Const.HIGHWAY);
HighwayOutputStream os = new HighwayOutputStream(AbstractTcpClientPackage.getAndIncRequestId());
os.write(header, LoginRequest.getRootSerializer(), login);
return os;
} catch (Throwable e) {
throw new Error("impossible.", e);
}
}
Aggregations