Search in sources :

Example 1 with UserRequest

use of com.tencent.angel.psagent.matrix.transport.adapter.UserRequest 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 2 with UserRequest

use of com.tencent.angel.psagent.matrix.transport.adapter.UserRequest 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 3 with UserRequest

use of com.tencent.angel.psagent.matrix.transport.adapter.UserRequest 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 4 with UserRequest

use of com.tencent.angel.psagent.matrix.transport.adapter.UserRequest 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)

Aggregations

Request (com.tencent.angel.ps.server.data.request.Request)4 Response (com.tencent.angel.ps.server.data.response.Response)4 UserRequest (com.tencent.angel.psagent.matrix.transport.adapter.UserRequest)4 Vector (com.tencent.angel.ml.math2.vector.Vector)2 PartitionGetResult (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)1 VoidResult (com.tencent.angel.ml.matrix.psf.update.base.VoidResult)1 IndexPartGetRowRequest (com.tencent.angel.ps.server.data.request.IndexPartGetRowRequest)1 IndexPartGetRowsRequest (com.tencent.angel.ps.server.data.request.IndexPartGetRowsRequest)1 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 IndexGetRowRequest (com.tencent.angel.psagent.matrix.transport.adapter.IndexGetRowRequest)1 IndexGetRowsRequest (com.tencent.angel.psagent.matrix.transport.adapter.IndexGetRowsRequest)1 ArrayList (java.util.ArrayList)1 ExecutionException (java.util.concurrent.ExecutionException)1