use of com.tencent.angel.worker.Worker in project angel by Tencent.
the class IndexGetRowsHashTest method testSparseIntUDF.
public void testSparseIntUDF() throws Exception {
Worker worker = LocalClusterContext.get().getWorker(workerAttempt0Id).getWorker();
MatrixClient client1 = worker.getPSAgent().getMatrixClient(SPARSE_INT_MAT, 0);
int matrixW1Id = client1.getMatrixId();
int[] index = genIndexs(feaNum, nnz);
IntIntVector deltaVec = null;
for (int rowId = 0; rowId < rowNum; rowId++) {
deltaVec = new IntIntVector(feaNum, new IntIntSparseVectorStorage(feaNum));
for (int i = 0; i < index.length; i++) {
deltaVec.set(index[i], index[i]);
}
client1.increment(rowId, deltaVec, true);
}
int[] rowIds = new int[rowNum];
for (int i = 0; i < rowNum; i++) {
rowIds[i] = i;
}
Vector[] rows = client1.get(rowIds, index);
for (int i = 0; i < rowNum; i++) {
for (int id : index) {
Assert.assertEquals(((IntIntVector) rows[i]).get(id), deltaVec.get(id), zero);
}
Assert.assertTrue(index.length == ((IntIntVector) rows[i]).size());
}
}
use of com.tencent.angel.worker.Worker in project angel by Tencent.
the class IndexGetRowsHashTest method testDenseIntUDF.
public void testDenseIntUDF() throws Exception {
Worker worker = LocalClusterContext.get().getWorker(workerAttempt0Id).getWorker();
MatrixClient client1 = worker.getPSAgent().getMatrixClient(DENSE_INT_MAT, 0);
int matrixW1Id = client1.getMatrixId();
int[] index = genIndexs(feaNum, nnz);
IntIntVector deltaVec = null;
for (int rowId = 0; rowId < rowNum; rowId++) {
deltaVec = new IntIntVector(feaNum, new IntIntDenseVectorStorage(feaNum));
for (int i = 0; i < feaNum; i++) deltaVec.set(i, i);
client1.increment(rowId, deltaVec, true);
}
int[] rowIds = new int[rowNum];
for (int i = 0; i < rowNum; i++) {
rowIds[i] = i;
}
Vector[] rows = client1.get(rowIds, index);
for (int i = 0; i < rowNum; i++) {
for (int id : index) {
Assert.assertEquals(((IntIntVector) rows[i]).get(id), deltaVec.get(id), zero);
}
}
}
use of com.tencent.angel.worker.Worker in project angel by Tencent.
the class PSAgentTest method testTaskContext.
@Test
public void testTaskContext() throws Exception {
try {
AngelApplicationMaster angelAppMaster = LocalClusterContext.get().getMaster().getAppMaster();
assertTrue(angelAppMaster != null);
AMTaskManager taskManager = angelAppMaster.getAppContext().getTaskManager();
assertTrue(taskManager != null);
WorkerManager workerManager = angelAppMaster.getAppContext().getWorkerManager();
assertTrue(workerManager != null);
Worker worker = LocalClusterContext.get().getWorker(worker0Attempt0Id).getWorker();
assertTrue(worker != null);
PSAgent psAgent = worker.getPSAgent();
assertTrue(psAgent != null);
PSAgentContext psAgentContext = PSAgentContext.get();
assertTrue(psAgentContext.getPsAgent() != null);
TaskContext taskContext1 = psAgentContext.getTaskContext(1);
TaskContext taskContext2 = psAgentContext.getTaskContext(2);
assertTrue(taskContext1 != null);
assertTrue(taskContext2 != null);
assertEquals(taskContext1.getIndex(), 1);
assertEquals(taskContext2.getIndex(), 2);
assertEquals(taskContext1.getEpoch(), 0);
assertEquals(taskContext2.getEpoch(), 0);
assertEquals(taskContext1.getProgress(), 0.0, 1e-5);
assertEquals(taskContext2.getProgress(), 0.0, 1e-5);
} catch (Exception x) {
LOG.error("run testTaskContext failed ", x);
throw x;
}
}
use of com.tencent.angel.worker.Worker in project angel by Tencent.
the class PSAgentTest method testPSAgentContext.
@Test
public void testPSAgentContext() throws Exception {
try {
AngelApplicationMaster angelAppMaster = LocalClusterContext.get().getMaster().getAppMaster();
assertTrue(angelAppMaster != null);
AMTaskManager taskManager = angelAppMaster.getAppContext().getTaskManager();
assertTrue(taskManager != null);
WorkerManager workerManager = angelAppMaster.getAppContext().getWorkerManager();
assertTrue(workerManager != null);
Worker worker = LocalClusterContext.get().getWorker(worker0Attempt0Id).getWorker();
assertTrue(worker != null);
PSAgent psAgent = worker.getPSAgent();
assertTrue(psAgent != null);
PSAgentContext psAgentContext = PSAgentContext.get();
assertTrue(psAgentContext.getPsAgent() != null);
assertTrue(psAgentContext.getConf() != null);
assertTrue(psAgentContext.getMetrics() != null);
assertTrue(psAgentContext.getMasterClient() != null);
// assertTrue(psAgentContext.getOpLogCache() != null);
assertTrue(psAgentContext.getMatrixTransportClient() != null);
assertTrue(psAgentContext.getMatrixMetaManager() != null);
assertTrue(psAgentContext.getMatrixMetaManager() != null);
assertTrue(psAgentContext.getLocationManager() != null);
assertEquals(psAgentContext.getRunningMode(), psAgent.getRunningMode());
assertEquals(psAgentContext.getIp(), psAgent.getIp());
assertEquals(psAgentContext.getStaleness(), psAgent.getConf().getInt(AngelConf.ANGEL_STALENESS, AngelConf.DEFAULT_ANGEL_STALENESS));
assertEquals(psAgentContext.getMatrixStorageManager(), psAgent.getMatrixStorageManager());
assertEquals(psAgentContext.getUserRequestAdapter(), psAgent.getUserRequestAdapter());
assertEquals(psAgentContext.getExecutor(), psAgent.getExecutor());
assertTrue(psAgentContext.getTaskContext(1) != null);
assertTrue(psAgentContext.getTaskContext(2) != null);
int taskNum = psAgentContext.getTotalTaskNum();
assertEquals(taskNum, 2);
int localTaskNum = psAgentContext.getLocalTaskNum();
assertEquals(localTaskNum, 2);
} catch (Exception x) {
LOG.error("run testPSAgentContext failed ", x);
throw x;
}
}
use of com.tencent.angel.worker.Worker in project angel by Tencent.
the class PSAgentTest method testClockCache.
@Test
public void testClockCache() throws Exception {
try {
AngelApplicationMaster angelAppMaster = LocalClusterContext.get().getMaster().getAppMaster();
assertTrue(angelAppMaster != null);
AMTaskManager taskManager = angelAppMaster.getAppContext().getTaskManager();
assertTrue(taskManager != null);
WorkerManager workerManager = angelAppMaster.getAppContext().getWorkerManager();
assertTrue(workerManager != null);
Worker worker = LocalClusterContext.get().getWorker(worker0Attempt0Id).getWorker();
assertTrue(worker != null);
PSAgent psAgent = worker.getPSAgent();
assertTrue(psAgent != null);
} catch (Exception x) {
LOG.error("run testClockCache failed ", x);
throw x;
}
}
Aggregations