Search in sources :

Example 1 with RequestHeader

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;
}
Also used : RequestHeader(com.tencent.angel.ps.server.data.request.RequestHeader)

Example 2 with RequestHeader

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;
    }
}
Also used : AngelException(com.tencent.angel.exception.AngelException) RequestHeader(com.tencent.angel.ps.server.data.request.RequestHeader) ByteBuf(io.netty.buffer.ByteBuf)

Example 3 with RequestHeader

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);
}
Also used : IndexPartGetRowsRequest(com.tencent.angel.ps.server.data.request.IndexPartGetRowsRequest) GetRowSplitRequest(com.tencent.angel.ps.server.data.request.GetRowSplitRequest) UpdateRequest(com.tencent.angel.ps.server.data.request.UpdateRequest) Request(com.tencent.angel.ps.server.data.request.Request) UpdateUDFRequest(com.tencent.angel.ps.server.data.request.UpdateUDFRequest) GetRowsSplitRequest(com.tencent.angel.ps.server.data.request.GetRowsSplitRequest) IndexPartGetRowRequest(com.tencent.angel.ps.server.data.request.IndexPartGetRowRequest) GetUDFRequest(com.tencent.angel.ps.server.data.request.GetUDFRequest) IndexPartGetRowsRequest(com.tencent.angel.ps.server.data.request.IndexPartGetRowsRequest) RequestHeader(com.tencent.angel.ps.server.data.request.RequestHeader)

Example 4 with RequestHeader

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;
}
Also used : RequestHeader(com.tencent.angel.ps.server.data.request.RequestHeader)

Example 5 with RequestHeader

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);
}
Also used : GetRowSplitRequest(com.tencent.angel.ps.server.data.request.GetRowSplitRequest) UpdateRequest(com.tencent.angel.ps.server.data.request.UpdateRequest) Request(com.tencent.angel.ps.server.data.request.Request) UpdateUDFRequest(com.tencent.angel.ps.server.data.request.UpdateUDFRequest) GetRowsSplitRequest(com.tencent.angel.ps.server.data.request.GetRowsSplitRequest) IndexPartGetRowRequest(com.tencent.angel.ps.server.data.request.IndexPartGetRowRequest) GetUDFRequest(com.tencent.angel.ps.server.data.request.GetUDFRequest) IndexPartGetRowsRequest(com.tencent.angel.ps.server.data.request.IndexPartGetRowsRequest) RequestHeader(com.tencent.angel.ps.server.data.request.RequestHeader) GetUDFRequest(com.tencent.angel.ps.server.data.request.GetUDFRequest)

Aggregations

RequestHeader (com.tencent.angel.ps.server.data.request.RequestHeader)13 GetUDFRequest (com.tencent.angel.ps.server.data.request.GetUDFRequest)9 Request (com.tencent.angel.ps.server.data.request.Request)9 UpdateUDFRequest (com.tencent.angel.ps.server.data.request.UpdateUDFRequest)9 GetRowSplitRequest (com.tencent.angel.ps.server.data.request.GetRowSplitRequest)7 GetRowsSplitRequest (com.tencent.angel.ps.server.data.request.GetRowsSplitRequest)7 IndexPartGetRowRequest (com.tencent.angel.ps.server.data.request.IndexPartGetRowRequest)7 IndexPartGetRowsRequest (com.tencent.angel.ps.server.data.request.IndexPartGetRowsRequest)7 UpdateRequest (com.tencent.angel.ps.server.data.request.UpdateRequest)7 UserRequest (com.tencent.angel.psagent.matrix.transport.adapter.UserRequest)2 AngelException (com.tencent.angel.exception.AngelException)1 PartitionGetResult (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)1 VoidResult (com.tencent.angel.ml.matrix.psf.update.base.VoidResult)1 ByteBuf (io.netty.buffer.ByteBuf)1