Search in sources :

Example 1 with Request

use of com.tencent.angel.ps.server.data.request.Request 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 2 with Request

use of com.tencent.angel.ps.server.data.request.Request 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)

Example 3 with Request

use of com.tencent.angel.ps.server.data.request.Request in project angel by Tencent.

the class UpdateUDFHandler method handle.

@Override
public void handle(FutureResult finalResult, UserRequest userRequest, ResponseCache responseCache) {
    MapResponseCache cache = (MapResponseCache) responseCache;
    // Check update result
    Map<Request, Response> responses = cache.getResponses();
    boolean success = true;
    String detail = "";
    for (Response response : responses.values()) {
        success = success && (response.getResponseType() == ResponseType.SUCCESS);
        if (!success) {
            detail = response.getDetail();
            break;
        }
    }
    // Set the final result
    if (success) {
        finalResult.set(new VoidResult(com.tencent.angel.psagent.matrix.ResponseType.SUCCESS));
    } else {
        finalResult.set(new VoidResult(com.tencent.angel.psagent.matrix.ResponseType.FAILED, detail));
    }
}
Also used : Response(com.tencent.angel.ps.server.data.response.Response) UpdateUDFResponse(com.tencent.angel.ps.server.data.response.UpdateUDFResponse) VoidResult(com.tencent.angel.ml.matrix.psf.update.base.VoidResult) Request(com.tencent.angel.ps.server.data.request.Request) UserRequest(com.tencent.angel.psagent.matrix.transport.adapter.UserRequest)

Example 4 with Request

use of com.tencent.angel.ps.server.data.request.Request in project angel by Tencent.

the class MatrixTransportClient method addToGetQueueForServer.

private void addToGetQueueForServer(ParameterServerId serverId, Request request) {
    request.setContext(new RequestContext());
    request.getContext().setServerId(serverId);
    LinkedBlockingQueue<Request> queue = getItemQueues.get(serverId);
    if (queue == null) {
        queue = new LinkedBlockingQueue<>();
        getItemQueues.putIfAbsent(serverId, queue);
        queue = getItemQueues.get(serverId);
    }
    queue.add(request);
}
Also used : UserRequest(com.tencent.angel.psagent.matrix.transport.adapter.UserRequest) Request(com.tencent.angel.ps.server.data.request.Request) UpdateUDFRequest(com.tencent.angel.ps.server.data.request.UpdateUDFRequest) GetUDFRequest(com.tencent.angel.ps.server.data.request.GetUDFRequest) RequestContext(com.tencent.angel.ps.server.data.request.RequestContext)

Example 5 with Request

use of com.tencent.angel.ps.server.data.request.Request in project angel by Tencent.

the class MatrixTransportClient method addToPutQueueForServer.

private void addToPutQueueForServer(ParameterServerId serverId, Request request) {
    request.setContext(new RequestContext());
    request.getContext().setServerId(serverId);
    LinkedBlockingQueue<Request> queue = putItemQueues.get(serverId);
    if (queue == null) {
        queue = new LinkedBlockingQueue<>();
        putItemQueues.putIfAbsent(serverId, queue);
        queue = putItemQueues.get(serverId);
    }
    queue.add(request);
}
Also used : UserRequest(com.tencent.angel.psagent.matrix.transport.adapter.UserRequest) Request(com.tencent.angel.ps.server.data.request.Request) UpdateUDFRequest(com.tencent.angel.ps.server.data.request.UpdateUDFRequest) GetUDFRequest(com.tencent.angel.ps.server.data.request.GetUDFRequest) RequestContext(com.tencent.angel.ps.server.data.request.RequestContext)

Aggregations

Request (com.tencent.angel.ps.server.data.request.Request)18 GetUDFRequest (com.tencent.angel.ps.server.data.request.GetUDFRequest)14 UpdateUDFRequest (com.tencent.angel.ps.server.data.request.UpdateUDFRequest)14 UserRequest (com.tencent.angel.psagent.matrix.transport.adapter.UserRequest)11 RequestHeader (com.tencent.angel.ps.server.data.request.RequestHeader)9 IndexPartGetRowRequest (com.tencent.angel.ps.server.data.request.IndexPartGetRowRequest)8 IndexPartGetRowsRequest (com.tencent.angel.ps.server.data.request.IndexPartGetRowsRequest)8 GetRowSplitRequest (com.tencent.angel.ps.server.data.request.GetRowSplitRequest)7 GetRowsSplitRequest (com.tencent.angel.ps.server.data.request.GetRowsSplitRequest)7 UpdateRequest (com.tencent.angel.ps.server.data.request.UpdateRequest)7 Response (com.tencent.angel.ps.server.data.response.Response)4 Vector (com.tencent.angel.ml.math2.vector.Vector)2 PartitionGetResult (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)2 VoidResult (com.tencent.angel.ml.matrix.psf.update.base.VoidResult)2 RequestContext (com.tencent.angel.ps.server.data.request.RequestContext)2 GetUDFResponse (com.tencent.angel.ps.server.data.response.GetUDFResponse)1 IndexPartGetRowsResponse (com.tencent.angel.ps.server.data.response.IndexPartGetRowsResponse)1 StreamIndexPartGetRowResponse (com.tencent.angel.ps.server.data.response.StreamIndexPartGetRowResponse)1 UpdateUDFResponse (com.tencent.angel.ps.server.data.response.UpdateUDFResponse)1 GetPSFRequest (com.tencent.angel.psagent.matrix.transport.adapter.GetPSFRequest)1