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);
}
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;
}
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));
}
}
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);
}
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);
}
Aggregations