Search in sources :

Example 11 with Request

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

the class IndexGetRowsHandler method handle.

@Override
public void handle(FutureResult finalResult, UserRequest userRequest, ResponseCache responseCache) {
    IndexGetRowsRequest indexGetRowsRequest = (IndexGetRowsRequest) userRequest;
    MapResponseCache cache = (MapResponseCache) responseCache;
    ConcurrentHashMap<Request, Response> responses = cache.getResponses();
    // Merge
    Vector[] result = merge(indexGetRowsRequest, responses);
    // Set final result
    finalResult.set(result);
}
Also used : Response(com.tencent.angel.ps.server.data.response.Response) IndexPartGetRowsResponse(com.tencent.angel.ps.server.data.response.IndexPartGetRowsResponse) IndexGetRowsRequest(com.tencent.angel.psagent.matrix.transport.adapter.IndexGetRowsRequest) Request(com.tencent.angel.ps.server.data.request.Request) IndexPartGetRowsRequest(com.tencent.angel.ps.server.data.request.IndexPartGetRowsRequest) IndexGetRowsRequest(com.tencent.angel.psagent.matrix.transport.adapter.IndexGetRowsRequest) UserRequest(com.tencent.angel.psagent.matrix.transport.adapter.UserRequest) Vector(com.tencent.angel.ml.math2.vector.Vector)

Example 12 with Request

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

the class MatrixTransportClient method update.

@Override
public FutureResult<VoidResult> update(UpdateFunc func, PartitionUpdateParam param) {
    // Request header
    RequestHeader header = createRequestHeader(-1, TransportMethod.UPDATE_PSF, param.getMatrixId(), param.getPartKey().getPartitionId());
    // Request body
    UpdateUDFRequest requestData = new UpdateUDFRequest(func.getClass().getName(), param);
    // Request
    Request request = new Request(header, requestData);
    FutureResult<VoidResult> resultFuture = new FutureResult<>();
    requestToResultMap.put(request, resultFuture);
    // Send the request
    sendUpdateRequest(request);
    return resultFuture;
}
Also used : VoidResult(com.tencent.angel.ml.matrix.psf.update.base.VoidResult) 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) RequestHeader(com.tencent.angel.ps.server.data.request.RequestHeader) UpdateUDFRequest(com.tencent.angel.ps.server.data.request.UpdateUDFRequest)

Example 13 with Request

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

the class GetUDFHandler method handle.

@Override
public void handle(FutureResult finalResult, UserRequest userRequest, ResponseCache responseCache) {
    GetPSFRequest getPSFRequest = (GetPSFRequest) userRequest;
    MapResponseCache cache = (MapResponseCache) responseCache;
    // Adaptor to Get PSF merge
    ConcurrentHashMap<Request, Response> responses = cache.getResponses();
    int responseNum = responses.size();
    List<PartitionGetResult> partGetResults = new ArrayList<>(responseNum);
    for (Response response : responses.values()) {
        partGetResults.add(((GetUDFResponse) response.getData()).getPartResult());
    }
    // Merge the sub-results
    try {
        finalResult.set(getPSFRequest.getGetFunc().merge(partGetResults));
    } catch (Exception x) {
        LOG.error("merge row failed ", x);
        finalResult.setExecuteException(new ExecutionException(x));
    }
}
Also used : Response(com.tencent.angel.ps.server.data.response.Response) GetUDFResponse(com.tencent.angel.ps.server.data.response.GetUDFResponse) Request(com.tencent.angel.ps.server.data.request.Request) GetPSFRequest(com.tencent.angel.psagent.matrix.transport.adapter.GetPSFRequest) UserRequest(com.tencent.angel.psagent.matrix.transport.adapter.UserRequest) ArrayList(java.util.ArrayList) GetPSFRequest(com.tencent.angel.psagent.matrix.transport.adapter.GetPSFRequest) ExecutionException(java.util.concurrent.ExecutionException) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult) ExecutionException(java.util.concurrent.ExecutionException)

Example 14 with Request

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

the class IndexGetRowHandler method handle.

@Override
public void handle(FutureResult finalResult, UserRequest userRequest, ResponseCache responseCache) {
    IndexGetRowRequest indexGetRowRequest = (IndexGetRowRequest) userRequest;
    MapResponseCache cache = (MapResponseCache) responseCache;
    ConcurrentHashMap<Request, Response> responses = cache.getResponses();
    // Merge
    Vector result = merge(indexGetRowRequest, responses);
    // Set matrix/row meta
    result.setMatrixId(indexGetRowRequest.getMatrixId());
    result.setRowId(indexGetRowRequest.getRowId());
    // Set final result
    finalResult.set(result);
}
Also used : Response(com.tencent.angel.ps.server.data.response.Response) StreamIndexPartGetRowResponse(com.tencent.angel.ps.server.data.response.StreamIndexPartGetRowResponse) IndexGetRowRequest(com.tencent.angel.psagent.matrix.transport.adapter.IndexGetRowRequest) Request(com.tencent.angel.ps.server.data.request.Request) IndexGetRowRequest(com.tencent.angel.psagent.matrix.transport.adapter.IndexGetRowRequest) IndexPartGetRowRequest(com.tencent.angel.ps.server.data.request.IndexPartGetRowRequest) UserRequest(com.tencent.angel.psagent.matrix.transport.adapter.UserRequest) Vector(com.tencent.angel.ml.math2.vector.Vector)

Example 15 with Request

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

the class UserRequestAdapter method sendUpdateRequest.

private void sendUpdateRequest(MatrixTransportClient matrixClient, int userRequestId, int matrixId, int partId, CompStreamKeyValuePart split, UpdateOp op) {
    // Request header
    RequestHeader header = createRequestHeader(userRequestId, TransportMethod.UPDATE, matrixId, partId);
    // Request body
    UpdateRequest requestData = new UpdateRequest(split, op);
    // Request
    Request request = new Request(header, requestData);
    // Send the request
    matrixClient.sendUpdateRequest(request);
}
Also used : UpdateRequest(com.tencent.angel.ps.server.data.request.UpdateRequest) 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)

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