use of com.tencent.angel.ps.server.data.request.RequestHeader in project angel by Tencent.
the class WorkerPool method parseHeader.
private RequestHeader parseHeader(ByteBuf in) {
RequestHeader header = new RequestHeader();
header.deserialize(in);
return header;
}
use of com.tencent.angel.ps.server.data.request.RequestHeader in project angel by Tencent.
the class WorkerPool method handlerRequest.
/**
* Handler RPC request
*
* @param ctx channel context
* @param msg request
*/
public void handlerRequest(ChannelHandlerContext ctx, Object msg) {
// Deserialize head
ByteBuf in = (ByteBuf) msg;
RequestHeader header = parseHeader(in);
// Get method type
TransportMethod method = TransportMethod.typeIdToTypeMap.get(header.methodId);
// Check method
if (method == null) {
throw new AngelException("Can not support method " + header.methodId);
}
// Check if data request
if (isDataRequest(method)) {
total.incrementAndGet();
runningContext.before(header.clientId, header.seqId);
runningContext.relaseToken(header.clientId, header.token);
}
try {
// Use async handler or not
boolean useAsync = needAsync(method, header);
if (useAsync) {
if (useUnlockRPC) {
handleLockFree(header, in, ctx);
} else {
getWorker(ctx).execute(new Processor(header, in, ctx));
}
} else {
handle(header, in, ctx);
}
} catch (Throwable x) {
LOG.error("handle rpc " + header + " failed ", x);
throw x;
}
}
use of com.tencent.angel.ps.server.data.request.RequestHeader in project angel by Tencent.
the class UserRequestAdapter method sendIndexGetRowsRequest.
private void sendIndexGetRowsRequest(MatrixTransportClient matrixClient, int userRequestId, int matrixId, int[] rowIds, int partId, KeyPart keyPart, InitFunc func) {
// Request header
RequestHeader header = createRequestHeader(userRequestId, TransportMethod.INDEX_GET_ROWS, matrixId, partId);
// Request body
IndexPartGetRowsRequest requestData = new IndexPartGetRowsRequest(rowIds, keyPart, func);
// Request
Request request = new Request(header, requestData);
// Send the request
matrixClient.sendGetRequest(request);
}
use of com.tencent.angel.ps.server.data.request.RequestHeader in project angel by Tencent.
the class UserRequestAdapter method createRequestHeader.
private RequestHeader createRequestHeader(int requestId, TransportMethod method, int matrixId, int partId) {
RequestHeader header = new RequestHeader();
header.setUserRequestId(requestId);
header.setMethodId(method.getMethodId());
header.setMatrixId(matrixId);
header.setPartId(partId);
return header;
}
use of com.tencent.angel.ps.server.data.request.RequestHeader in project angel by Tencent.
the class UserRequestAdapter method sendGetUDFRequest.
private void sendGetUDFRequest(MatrixTransportClient matrixClient, int userRequestId, int matrixId, int partId, GetFunc func, PartitionGetParam partGetParam) {
// Request header
RequestHeader header = createRequestHeader(userRequestId, TransportMethod.GET_PSF, matrixId, partId);
// Request body
GetUDFRequest requestData = new GetUDFRequest(func.getClass().getName(), partGetParam);
// Request
Request request = new Request(header, requestData);
// Send the request
matrixClient.sendGetRequest(request);
}
Aggregations