use of com.tencent.angel.common.location.Location in project angel by Tencent.
the class InitNeighborTest2 method testCSR.
@Test
public void testCSR() throws Exception {
Worker worker = LocalClusterContext.get().getWorker(workerAttempt0Id).getWorker();
MatrixClient client = worker.getPSAgent().getMatrixClient(SPARSE_INT_MAT, 0);
int matrixId = client.getMatrixId();
ParameterServer ps = LocalClusterContext.get().getPS(psAttempt0Id).getPS();
Location masterLoc = LocalClusterContext.get().getMaster().getAppMaster().getAppContext().getMasterService().getLocation();
TConnection connection = TConnectionManager.getConnection(ps.getConf());
MasterProtocol master = connection.getMasterService(masterLoc.getIp(), masterLoc.getPort());
// Init node neighbors
Long2ObjectOpenHashMap<long[]> nodeIdToNeighbors = new Long2ObjectOpenHashMap<>();
nodeIdToNeighbors.put(1, new long[] { 2, 3, 4, 5, 6 });
nodeIdToNeighbors.put(2, new long[] { 4, 5 });
nodeIdToNeighbors.put(3, new long[] { 4, 5, 6 });
nodeIdToNeighbors.put(4, new long[] { 5, 6 });
nodeIdToNeighbors.put(5, new long[] { 6 });
nodeIdToNeighbors.put(8, new long[] { 3, 4 });
InitNeighbor func = new InitNeighbor(new InitNeighborParam(matrixId, nodeIdToNeighbors));
client.asyncUpdate(func).get();
nodeIdToNeighbors.clear();
/*nodeIdToNeighbors.put(1, new long[]{4, 5, 6});
nodeIdToNeighbors.put(2, new long[]{5});
nodeIdToNeighbors.put(4, new long[]{5, 6});
func = new InitNeighbor(new InitNeighborParam(matrixId, nodeIdToNeighbors));
client.asyncUpdate(func).get();
nodeIdToNeighbors.clear();
nodeIdToNeighbors.put(3, new long[]{4, 5, 6});
nodeIdToNeighbors.put(5, new long[]{6});
nodeIdToNeighbors.put(8, new long[]{3, 4});
func = new InitNeighbor(new InitNeighborParam(matrixId, nodeIdToNeighbors));
client.asyncUpdate(func).get();
nodeIdToNeighbors.clear();
*/
// client.asyncUpdate(new InitNeighborOver(new InitNeighborOverParam(matrixId))).get();
// Sample the neighbors
long[] nodeIds = new long[] { 1, 2, 3, 4, 5, 6, 7, 8 };
SampleNeighborParam param = new SampleNeighborParam(matrixId, nodeIds, 2);
Long2ObjectOpenHashMap<long[]> result = ((SampleNeighborResult) (client.get(new SampleNeighbor(param)))).getNodeIdToNeighbors();
ObjectIterator<Long2ObjectMap.Entry<long[]>> iter = result.long2ObjectEntrySet().fastIterator();
LOG.info("==============================sample neighbors result============================");
Long2ObjectMap.Entry<long[]> entry;
while (iter.hasNext()) {
entry = iter.next();
LOG.info("node id = " + entry.getLongKey() + ", neighbors = " + Arrays.toString(entry.getValue()));
}
client.checkpoint(0).get();
ps.stop(-1);
PSErrorRequest request = PSErrorRequest.newBuilder().setPsAttemptId(ProtobufUtil.convertToIdProto(psAttempt0Id)).setMsg("out of memory").build();
master.psError(null, request);
Thread.sleep(10000);
param = new SampleNeighborParam(matrixId, nodeIds, -1);
result = ((SampleNeighborResult) (client.get(new SampleNeighbor(param)))).getNodeIdToNeighbors();
iter = result.long2ObjectEntrySet().fastIterator();
LOG.info("==============================sample neighbors result============================");
while (iter.hasNext()) {
entry = iter.next();
LOG.info("node id = " + entry.getLongKey() + ", neighbors = " + Arrays.toString(entry.getValue()));
}
}
use of com.tencent.angel.common.location.Location in project angel by Tencent.
the class WorkerTest method testWorker.
@Test
public void testWorker() throws Exception {
try {
localWorker = LocalClusterContext.get().getWorker(worker0Attempt0Id);
worker = localWorker.getWorker();
assertTrue(worker != null);
// test workerId
assertEquals(worker0Id, worker.getWorkerId());
WorkerId wid = new WorkerId("Worker_0_0");
assertEquals(wid, worker0Id);
assertTrue(worker0Id.equals(wid));
// test workerAttemptId
assertEquals(worker0Attempt0Id, worker.getWorkerAttemptId());
WorkerAttemptId waId = new WorkerAttemptId("WorkerAttempt_0_0_0");
assertEquals(worker0Attempt0Id, waId);
assertTrue(worker0Attempt0Id.equals(waId));
assertEquals(ProtobufUtil.convertToIdProto(worker0Attempt0Id), worker.getWorkerAttemptIdProto());
// tet worker initFinished
assertTrue(worker.isWorkerInitFinished());
// test worker getInitMinclock
assertEquals(0, worker.getInitMinClock());
// test worker loacation
Location location = worker.getWorkerService().getLocation();
String localIp = NetUtils.getRealLocalIP();
assertEquals(localIp, location.getIp());
int port = location.getPort();
assertTrue(port > 0 && port < 655355);
} catch (Exception x) {
LOG.error("run testWorker failed ", x);
throw x;
}
}
use of com.tencent.angel.common.location.Location in project angel by Tencent.
the class MatrixTransportClient method closeChannelForServer.
private void closeChannelForServer(ParameterServerId serverId) {
Location loc = PSAgentContext.get().getLocationManager().getPsLocation(serverId);
if (loc == null) {
return;
}
channelManager.removeChannelPool(loc);
}
Aggregations