use of com.tencent.angel.PartitionKey in project angel by Tencent.
the class ServerPartition method deserialize.
@Override
public void deserialize(ByteBuf buf) {
partitionKey = new PartitionKey();
partitionKey.deserialize(buf);
rowType = RowType.valueOf(buf.readInt());
int rowNum = buf.readInt();
RowType rowType;
for (int i = 0; i < rowNum; i++) {
rowType = RowType.valueOf(buf.readInt());
ServerRow row = initRow(rowType);
row.deserialize(buf);
rows.put(row.getRowId(), row);
}
}
use of com.tencent.angel.PartitionKey in project angel by Tencent.
the class WorkerPool method putPart.
private ByteBuf putPart(int seqId, int methodId, ByteBuf in) {
PartitionKey partKey = new PartitionKey();
partKey.deserialize(in);
ByteBuf buf = ByteBufUtils.newByteBuf(8 + 4);
buf.writeInt(seqId);
buf.writeInt(methodId);
try {
// context.getMatrixStorageManager().update(partKey, in);
Response resposne = new Response(ResponseType.SUCCESS);
// resposne.encode(buf);
// TODO:
} catch (Exception x) {
x.printStackTrace();
Response resposne = new Response(ResponseType.SERVER_HANDLE_FATAL, x.getMessage());
// resposne.encode(buf);
// TODO:
}
return buf;
}
use of com.tencent.angel.PartitionKey in project angel by Tencent.
the class WorkerPool method getRowsSplit.
/**
* Get a batch of row splits
* @param seqId rpc request id
* @param request rpc request
* @return serialized rpc response contains row splits
*/
private ByteBuf getRowsSplit(int seqId, GetRowsSplitRequest request) {
if (LOG.isDebugEnabled()) {
LOG.debug("get row request=" + request);
}
PartitionKey partKey = request.getPartKey();
int clock = request.getClock();
GetRowsSplitResponse response = new GetRowsSplitResponse();
if (!isClockReady(partKey, clock)) {
response.setResponseType(ResponseType.CLOCK_NOTREADY);
} else {
List<ServerRow> rows = new ArrayList<ServerRow>();
List<Integer> rowIndexes = request.getRowIndexes();
if (rowIndexes != null) {
int size = rowIndexes.size();
for (int i = 0; i < size; i++) {
ServerRow row = context.getMatrixStorageManager().getRow(partKey.getMatrixId(), rowIndexes.get(i), partKey.getPartitionId());
if (row != null) {
rows.add(row);
}
}
}
response.setResponseType(ResponseType.SUCCESS);
response.setRowsSplit(rows);
}
ByteBuf buf = ByteBufUtils.newByteBuf(4 + response.bufferLen(), useDirectorBuffer);
buf.writeInt(seqId);
response.serialize(buf);
return buf;
}
use of com.tencent.angel.PartitionKey in project angel by Tencent.
the class WorkerPool method getClocks.
/**
* Get clocks for all matrices partition
* @param seqId rpc request id
* @param request rpc request
* @return serialized rpc response contains clocks
*/
private ByteBuf getClocks(int seqId, GetClocksRequest request) {
Map<PartitionKey, Integer> clocks = context.getClockVectorManager().getPartClocksFromCache();
GetClocksResponse response = new GetClocksResponse(ResponseType.SUCCESS, null, clocks);
ByteBuf buf = ByteBufUtils.newByteBuf(4 + response.bufferLen(), useDirectorBuffer);
buf.writeInt(seqId);
response.serialize(buf);
return buf;
}
use of com.tencent.angel.PartitionKey in project angel by Tencent.
the class WorkerPool method getPartition.
/**
* Get matrix partition
* @param seqId rpc request id
* @param request rpc request
* @return serialized rpc response contains whole partition
*/
private ByteBuf getPartition(int seqId, GetPartitionRequest request) {
if (LOG.isDebugEnabled()) {
LOG.debug("get partition request=" + request);
}
PartitionKey partKey = request.getPartKey();
int clock = request.getClock();
long startTs = System.currentTimeMillis();
GetPartitionResponse response = new GetPartitionResponse();
if (!isClockReady(partKey, clock)) {
response.setResponseType(ResponseType.CLOCK_NOTREADY);
} else {
ServerPartition partition = context.getMatrixStorageManager().getPart(partKey.getMatrixId(), partKey.getPartitionId());
response.setResponseType(ResponseType.SUCCESS);
response.setPartition(partition);
}
ByteBuf buf = ByteBufUtils.newByteBuf(4 + response.bufferLen(), useDirectorBuffer);
buf.writeInt(seqId);
response.serialize(buf);
return buf;
}
Aggregations