use of com.tencent.angel.worker.WorkerAttemptId in project angel by Tencent.
the class ComplexMatrixTest method setup.
@Before
public void setup() throws Exception {
try {
// set basic configuration keys
Configuration conf = new Configuration();
conf.setBoolean("mapred.mapper.new-api", true);
conf.setBoolean(AngelConf.ANGEL_JOB_OUTPUT_PATH_DELETEONEXIST, true);
conf.set(AngelConf.ANGEL_TASK_USER_TASKCLASS, DummyTask.class.getName());
// use local deploy mode and dummy dataspliter
conf.set(AngelConf.ANGEL_DEPLOY_MODE, "LOCAL");
conf.setBoolean(AngelConf.ANGEL_AM_USE_DUMMY_DATASPLITER, true);
conf.set(AngelConf.ANGEL_INPUTFORMAT_CLASS, CombineTextInputFormat.class.getName());
conf.set(AngelConf.ANGEL_SAVE_MODEL_PATH, LOCAL_FS + TMP_PATH + "/out");
conf.set(AngelConf.ANGEL_TRAIN_DATA_PATH, LOCAL_FS + TMP_PATH + "/in");
conf.set(AngelConf.ANGEL_LOG_PATH, LOCAL_FS + TMP_PATH + "/log");
conf.setInt(AngelConf.ANGEL_WORKERGROUP_NUMBER, 1);
conf.setInt(AngelConf.ANGEL_PS_NUMBER, 1);
conf.setInt(AngelConf.ANGEL_WORKER_TASK_NUMBER, 2);
conf.setInt(AngelConf.ANGEL_WORKER_HEARTBEAT_INTERVAL_MS, 1000);
conf.setInt(AngelConf.ANGEL_PS_HEARTBEAT_INTERVAL_MS, 1000);
// get a angel client
angelClient = AngelClientFactory.get(conf);
// add matrix
MatrixContext mMatrix = new MatrixContext();
mMatrix.setName("w1");
mMatrix.setRowNum(1);
mMatrix.setColNum(nodeNum);
mMatrix.setMaxRowNumInBlock(1);
mMatrix.setMaxColNumInBlock(nodeNum / 10);
mMatrix.setRowType(RowType.T_ANY_INTKEY_DENSE);
mMatrix.setValueType(IntArrayElement.class);
angelClient.addMatrix(mMatrix);
MatrixContext mMatrix2 = new MatrixContext();
mMatrix2.setName("w2");
mMatrix2.setRowNum(1);
mMatrix2.setColNum(nodeNum);
mMatrix2.setMaxRowNumInBlock(1);
mMatrix2.setMaxColNumInBlock(nodeNum / 10);
mMatrix2.setRowType(RowType.T_ANY_INTKEY_SPARSE);
mMatrix2.setValueType(IntArrayElement.class);
angelClient.addMatrix(mMatrix2);
angelClient.startPSServer();
angelClient.run();
Thread.sleep(10000);
group0Id = new WorkerGroupId(0);
worker0Id = new WorkerId(group0Id, 0);
worker0Attempt0Id = new WorkerAttemptId(worker0Id, 0);
task0Id = new TaskId(0);
task1Id = new TaskId(1);
psId = new ParameterServerId(0);
psAttempt0Id = new PSAttemptId(psId, 0);
} catch (Exception x) {
LOG.error("setup failed ", x);
throw x;
}
}
use of com.tencent.angel.worker.WorkerAttemptId in project angel by Tencent.
the class MasterServiceTest method setup.
@Before
public void setup() throws Exception {
try {
// set basic configuration keys
Configuration conf = new Configuration();
conf.setBoolean("mapred.mapper.new-api", true);
conf.setBoolean(AngelConf.ANGEL_JOB_OUTPUT_PATH_DELETEONEXIST, true);
conf.set(AngelConf.ANGEL_TASK_USER_TASKCLASS, DummyTask.class.getName());
// use local deploy mode and dummy dataspliter
conf.set(AngelConf.ANGEL_DEPLOY_MODE, "LOCAL");
conf.setBoolean(AngelConf.ANGEL_AM_USE_DUMMY_DATASPLITER, true);
conf.set(AngelConf.ANGEL_INPUTFORMAT_CLASS, CombineTextInputFormat.class.getName());
conf.set(AngelConf.ANGEL_SAVE_MODEL_PATH, LOCAL_FS + TMP_PATH + "/out");
conf.set(AngelConf.ANGEL_TRAIN_DATA_PATH, LOCAL_FS + TMP_PATH + "/in");
conf.set(AngelConf.ANGEL_LOG_PATH, LOCAL_FS + TMP_PATH + "/log");
conf.setInt(AngelConf.ANGEL_WORKERGROUP_NUMBER, 1);
conf.setInt(AngelConf.ANGEL_PS_NUMBER, 1);
conf.setInt(AngelConf.ANGEL_WORKER_TASK_NUMBER, 2);
conf.setInt(AngelConf.ANGEL_WORKER_HEARTBEAT_INTERVAL_MS, 1000);
conf.setInt(AngelConf.ANGEL_PS_HEARTBEAT_INTERVAL_MS, 1000);
// get a angel client
angelClient = AngelClientFactory.get(conf);
// add matrix
MatrixContext mMatrix = new MatrixContext();
mMatrix.setName("w1");
mMatrix.setRowNum(1);
mMatrix.setColNum(100000);
mMatrix.setMaxRowNumInBlock(1);
mMatrix.setMaxColNumInBlock(50000);
mMatrix.setRowType(RowType.T_INT_DENSE);
mMatrix.set(MatrixConf.MATRIX_OPLOG_ENABLEFILTER, "false");
mMatrix.set(MatrixConf.MATRIX_HOGWILD, "true");
mMatrix.set(MatrixConf.MATRIX_AVERAGE, "false");
mMatrix.set(MatrixConf.MATRIX_OPLOG_TYPE, "DENSE_INT");
angelClient.addMatrix(mMatrix);
MatrixContext mMatrix2 = new MatrixContext();
mMatrix2.setName("w2");
mMatrix2.setRowNum(1);
mMatrix2.setColNum(100000);
mMatrix2.setMaxRowNumInBlock(1);
mMatrix2.setMaxColNumInBlock(50000);
mMatrix2.setRowType(RowType.T_DOUBLE_DENSE);
mMatrix2.set(MatrixConf.MATRIX_OPLOG_ENABLEFILTER, "false");
mMatrix2.set(MatrixConf.MATRIX_HOGWILD, "false");
mMatrix2.set(MatrixConf.MATRIX_AVERAGE, "false");
mMatrix2.set(MatrixConf.MATRIX_OPLOG_TYPE, "DENSE_DOUBLE");
angelClient.addMatrix(mMatrix2);
angelClient.startPSServer();
angelClient.run();
Thread.sleep(5000);
group0Id = new WorkerGroupId(0);
worker0Id = new WorkerId(group0Id, 0);
worker0Attempt0Id = new WorkerAttemptId(worker0Id, 0);
task0Id = new TaskId(0);
task1Id = new TaskId(1);
psId = new ParameterServerId(0);
psAttempt0Id = new PSAttemptId(psId, 0);
} catch (Exception x) {
LOG.error("setup failed ", x);
throw x;
}
}
use of com.tencent.angel.worker.WorkerAttemptId in project angel by Tencent.
the class MasterServiceTest method testMasterService.
@Test
public void testMasterService() throws Exception {
try {
LOG.info("===========================testMasterService===============================");
Worker worker = LocalClusterContext.get().getWorker(worker0Attempt0Id).getWorker();
Location masterLoc = LocalClusterContext.get().getMaster().getAppMaster().getAppContext().getMasterService().getLocation();
TConnection connection = TConnectionManager.getConnection(worker.getConf());
MasterProtocol master = connection.getMasterService(masterLoc.getIp(), masterLoc.getPort());
int psAgentId = master.getPSAgentId(null, PSAgentMasterServiceProtos.GetPSAgentIdRequest.getDefaultInstance()).getPsAgentId();
// worker register
WorkerAttemptId worker1Attempt0Id = new WorkerAttemptId(new WorkerId(new WorkerGroupId(1), 0), 0);
WorkerRegisterRequest registeRequest = WorkerRegisterRequest.newBuilder().setPsAgentId(psAgentId).setWorkerAttemptId(ProtobufUtil.convertToIdProto(worker1Attempt0Id)).setLocation(LocationProto.newBuilder().setIp("0.0.0.0").setPort(10000).build()).build();
WorkerRegisterResponse registerResponse = master.workerRegister(null, registeRequest);
assertTrue(registerResponse.getCommand() == WorkerCommandProto.W_SHUTDOWN);
WorkerReportRequest.Builder reportBuilder = WorkerReportRequest.newBuilder();
Pair.Builder kvBuilder = Pair.newBuilder();
TaskStateProto.Builder taskBuilder = TaskStateProto.newBuilder();
reportBuilder.setWorkerAttemptId(ProtobufUtil.convertToIdProto(worker0Attempt0Id));
taskBuilder.setProgress(0.20f);
taskBuilder.setState("RUNNING");
taskBuilder.setTaskId(ProtobufUtil.convertToIdProto(task0Id));
kvBuilder.setKey("task_key1");
kvBuilder.setValue("100");
taskBuilder.addCounters(kvBuilder.build());
kvBuilder.setKey("task_key2");
kvBuilder.setValue("200");
taskBuilder.addCounters(kvBuilder.build());
reportBuilder.addTaskReports(taskBuilder.build());
taskBuilder.setProgress(0.30f);
taskBuilder.setState("RUNNING");
taskBuilder.setTaskId(ProtobufUtil.convertToIdProto(task1Id));
kvBuilder.setKey("task_key1");
kvBuilder.setValue("1000");
taskBuilder.addCounters(kvBuilder.build());
kvBuilder.setKey("task_key2");
kvBuilder.setValue("2000");
taskBuilder.addCounters(kvBuilder.build());
reportBuilder.addTaskReports(taskBuilder.build());
kvBuilder.setKey("worker_key1");
kvBuilder.setValue("100");
reportBuilder.addPairs(kvBuilder.build());
kvBuilder.setKey("worker_key2");
kvBuilder.setValue("200");
reportBuilder.addPairs(kvBuilder.build());
WorkerReportResponse reportResponse = master.workerReport(null, reportBuilder.build());
assertTrue(reportResponse.getCommand() == WorkerCommandProto.W_SUCCESS);
assertEquals(reportResponse.getActiveTaskNum(), 2);
AngelApplicationMaster angelAppMaster = LocalClusterContext.get().getMaster().getAppMaster();
WorkerAttempt worker0Attempt = angelAppMaster.getAppContext().getWorkerManager().getWorker(worker0Attempt0Id.getWorkerId()).getWorkerAttempt(worker0Attempt0Id);
assertTrue(worker0Attempt != null);
Map<String, String> workerMetrics = worker0Attempt.getMetrics();
String valueForWorkerKey1 = workerMetrics.get("worker_key1");
String valueForWorkerKey2 = workerMetrics.get("worker_key2");
assertNotNull(valueForWorkerKey1);
assertNotNull(valueForWorkerKey2);
assertEquals(valueForWorkerKey1, "100");
assertEquals(valueForWorkerKey2, "200");
AMTaskManager amTaskManager = angelAppMaster.getAppContext().getTaskManager();
AMTask task0 = amTaskManager.getTask(task0Id);
AMTask task1 = amTaskManager.getTask(task1Id);
assertTrue(task0 != null);
assertTrue(task1 != null);
Map<String, String> task0Metrics = task0.getMetrics();
Map<String, String> task1Metrics = task1.getMetrics();
String valueForTask0Key1 = task0Metrics.get("task_key1");
String valueForTask0Key2 = task0Metrics.get("task_key2");
String valueForTask1Key1 = task1Metrics.get("task_key1");
String valueForTask1Key2 = task1Metrics.get("task_key2");
assertTrue(valueForTask0Key1 != null);
assertTrue(valueForTask0Key2 != null);
assertTrue(valueForTask1Key1 != null);
assertTrue(valueForTask1Key2 != null);
assertEquals(valueForTask0Key1, "100");
assertEquals(valueForTask0Key2, "200");
assertEquals(valueForTask1Key1, "1000");
assertEquals(valueForTask1Key2, "2000");
assertEquals(task0.getProgress(), 0.20f, 0.000001);
assertEquals(task1.getProgress(), 0.30f, 0.000001);
} catch (Exception x) {
LOG.error("run testMasterService failed ", x);
throw x;
}
}
use of com.tencent.angel.worker.WorkerAttemptId in project angel by Tencent.
the class PSManagerTest method setup.
@Before
public void setup() throws Exception {
try {
// set basic configuration keys
Configuration conf = new Configuration();
conf.setBoolean("mapred.mapper.new-api", true);
conf.setBoolean(AngelConf.ANGEL_JOB_OUTPUT_PATH_DELETEONEXIST, true);
conf.set(AngelConf.ANGEL_TASK_USER_TASKCLASS, DummyTask.class.getName());
// use local deploy mode and dummy dataspliter
conf.set(AngelConf.ANGEL_DEPLOY_MODE, "LOCAL");
conf.setBoolean(AngelConf.ANGEL_AM_USE_DUMMY_DATASPLITER, true);
conf.set(AngelConf.ANGEL_INPUTFORMAT_CLASS, CombineTextInputFormat.class.getName());
conf.set(AngelConf.ANGEL_SAVE_MODEL_PATH, LOCAL_FS + TMP_PATH + "/out");
conf.set(AngelConf.ANGEL_TRAIN_DATA_PATH, LOCAL_FS + TMP_PATH + "/in");
conf.set(AngelConf.ANGEL_LOG_PATH, LOCAL_FS + TMP_PATH + "/log");
conf.setInt(AngelConf.ANGEL_WORKERGROUP_NUMBER, 1);
conf.setInt(AngelConf.ANGEL_PS_NUMBER, 1);
conf.setInt(AngelConf.ANGEL_WORKER_TASK_NUMBER, 2);
conf.setInt(AngelConf.ANGEL_PS_BACKUP_INTERVAL_MS, 1000);
conf.setInt(AngelConf.ANGEL_WORKER_HEARTBEAT_INTERVAL_MS, 1000);
conf.setInt(AngelConf.ANGEL_PS_HEARTBEAT_INTERVAL_MS, 1000);
// get a angel client
angelClient = AngelClientFactory.get(conf);
// add matrix
MatrixContext mMatrix = new MatrixContext();
mMatrix.setName("w1");
mMatrix.setRowNum(1);
mMatrix.setColNum(100000);
mMatrix.setMaxRowNumInBlock(1);
mMatrix.setMaxColNumInBlock(50000);
mMatrix.setRowType(RowType.T_INT_DENSE);
mMatrix.set(MatrixConf.MATRIX_OPLOG_ENABLEFILTER, "false");
mMatrix.set(MatrixConf.MATRIX_HOGWILD, "true");
mMatrix.set(MatrixConf.MATRIX_AVERAGE, "false");
angelClient.addMatrix(mMatrix);
MatrixContext mMatrix2 = new MatrixContext();
mMatrix2.setName("w2");
mMatrix2.setRowNum(1);
mMatrix2.setColNum(100000);
mMatrix2.setMaxRowNumInBlock(1);
mMatrix2.setMaxColNumInBlock(50000);
mMatrix2.setRowType(RowType.T_DOUBLE_DENSE);
mMatrix2.set(MatrixConf.MATRIX_OPLOG_ENABLEFILTER, "false");
mMatrix2.set(MatrixConf.MATRIX_HOGWILD, "false");
mMatrix2.set(MatrixConf.MATRIX_AVERAGE, "false");
angelClient.addMatrix(mMatrix2);
angelClient.startPSServer();
angelClient.run();
Thread.sleep(5000);
group0Id = new WorkerGroupId(0);
worker0Id = new WorkerId(group0Id, 0);
worker0Attempt0Id = new WorkerAttemptId(worker0Id, 0);
task0Id = new TaskId(0);
task1Id = new TaskId(1);
psId = new ParameterServerId(0);
psAttempt0Id = new PSAttemptId(psId, 0);
} catch (Exception x) {
LOG.error("setup failed ", x);
throw x;
}
}
use of com.tencent.angel.worker.WorkerAttemptId in project angel by Tencent.
the class IncrementRowTest method setup.
@Before
public void setup() throws Exception {
// set basic configuration keys
Configuration conf = new Configuration();
conf.setBoolean("mapred.mapper.new-api", true);
conf.setBoolean(AngelConf.ANGEL_JOB_OUTPUT_PATH_DELETEONEXIST, true);
conf.set(AngelConf.ANGEL_TASK_USER_TASKCLASS, DummyTask.class.getName());
// use local deploy mode and dummy dataspliter
conf.set(AngelConf.ANGEL_DEPLOY_MODE, "LOCAL");
conf.setBoolean(AngelConf.ANGEL_AM_USE_DUMMY_DATASPLITER, true);
conf.set(AngelConf.ANGEL_INPUTFORMAT_CLASS, CombineTextInputFormat.class.getName());
conf.set(AngelConf.ANGEL_SAVE_MODEL_PATH, LOCAL_FS + TMP_PATH + "/out");
conf.set(AngelConf.ANGEL_TRAIN_DATA_PATH, LOCAL_FS + TMP_PATH + "/in");
conf.set(AngelConf.ANGEL_LOG_PATH, LOCAL_FS + TMP_PATH + "/log");
conf.setInt(AngelConf.ANGEL_WORKERGROUP_NUMBER, 1);
conf.setInt(AngelConf.ANGEL_PS_NUMBER, 1);
conf.setInt(AngelConf.ANGEL_WORKER_TASK_NUMBER, 1);
conf.setInt(AngelConf.ANGEL_MODEL_PARTITIONER_PARTITION_SIZE, 1000);
conf.setInt(AngelConf.ANGEL_PSAGENT_CACHE_SYNC_TIMEINTERVAL_MS, 10);
conf.setInt(AngelConf.ANGEL_WORKER_HEARTBEAT_INTERVAL_MS, 1000);
conf.setInt(AngelConf.ANGEL_PS_HEARTBEAT_INTERVAL_MS, 1000);
conf.setBoolean("use.new.split", true);
conf.setInt(AngelConf.ANGEL_WORKER_MAX_ATTEMPTS, 1);
conf.setInt(AngelConf.ANGEL_PS_MAX_ATTEMPTS, 1);
// get a angel client
angelClient = AngelClientFactory.get(conf);
// add dense double matrix
MatrixContext dMat = new MatrixContext();
dMat.setName(DENSE_DOUBLE_MAT);
dMat.setRowNum(1);
dMat.setColNum(feaNum);
dMat.setMaxColNumInBlock(feaNum / 100);
dMat.setRowType(RowType.T_DOUBLE_DENSE);
dMat.setPartitionerClass(ColumnRangePartitioner.class);
angelClient.addMatrix(dMat);
// add sparse double matrix
MatrixContext sMat = new MatrixContext();
sMat.setName(SPARSE_DOUBLE_MAT);
sMat.setRowNum(1);
sMat.setColNum(feaNum);
sMat.setMaxColNumInBlock(feaNum / 100);
sMat.setRowType(RowType.T_DOUBLE_SPARSE);
angelClient.addMatrix(sMat);
// add dense float matrix
MatrixContext dfMat = new MatrixContext();
dfMat.setName(DENSE_FLOAT_MAT);
dfMat.setRowNum(1);
dfMat.setColNum(feaNum);
dfMat.setMaxColNumInBlock(feaNum / 3);
dfMat.setRowType(RowType.T_FLOAT_DENSE);
dfMat.setPartitionerClass(ColumnRangePartitioner.class);
angelClient.addMatrix(dfMat);
// add sparse float matrix
MatrixContext sfMat = new MatrixContext();
sfMat.setName(SPARSE_FLOAT_MAT);
sfMat.setRowNum(1);
sfMat.setColNum(feaNum);
sfMat.setMaxColNumInBlock(feaNum / 3);
sfMat.setRowType(RowType.T_FLOAT_SPARSE);
angelClient.addMatrix(sfMat);
// add dense float matrix
MatrixContext diMat = new MatrixContext();
diMat.setName(DENSE_INT_MAT);
diMat.setRowNum(1);
diMat.setColNum(feaNum);
diMat.setMaxColNumInBlock(feaNum / 3);
diMat.setRowType(RowType.T_INT_DENSE);
diMat.setPartitionerClass(ColumnRangePartitioner.class);
angelClient.addMatrix(diMat);
// add sparse float matrix
MatrixContext siMat = new MatrixContext();
siMat.setName(SPARSE_INT_MAT);
siMat.setRowNum(1);
siMat.setColNum(feaNum);
siMat.setMaxColNumInBlock(feaNum / 3);
siMat.setRowType(RowType.T_INT_SPARSE);
angelClient.addMatrix(siMat);
// add dense long matrix
MatrixContext dlMat = new MatrixContext();
dlMat.setName(DENSE_LONG_MAT);
dlMat.setRowNum(1);
dlMat.setColNum(feaNum);
dlMat.setMaxColNumInBlock(feaNum / 3);
dlMat.setRowType(RowType.T_LONG_DENSE);
dlMat.setPartitionerClass(ColumnRangePartitioner.class);
angelClient.addMatrix(dlMat);
// add sparse long matrix
MatrixContext slMat = new MatrixContext();
slMat.setName(SPARSE_LONG_MAT);
slMat.setRowNum(1);
slMat.setColNum(feaNum);
slMat.setMaxColNumInBlock(feaNum / 3);
slMat.setRowType(RowType.T_LONG_SPARSE);
angelClient.addMatrix(slMat);
// add sparse long-key double matrix
MatrixContext dLongKeysMatrix = new MatrixContext();
dLongKeysMatrix.setName(SPARSE_DOUBLE_LONG_MAT);
dLongKeysMatrix.setRowNum(1);
dLongKeysMatrix.setColNum(feaNum);
dLongKeysMatrix.setMaxColNumInBlock(feaNum / 3);
dLongKeysMatrix.setRowType(RowType.T_DOUBLE_SPARSE_LONGKEY);
angelClient.addMatrix(dLongKeysMatrix);
// add sparse long-key float matrix
MatrixContext slfMatrix = new MatrixContext();
slfMatrix.setName(SPARSE_FLOAT_LONG_MAT);
slfMatrix.setRowNum(1);
slfMatrix.setColNum(feaNum);
slfMatrix.setMaxColNumInBlock(feaNum / 3);
slfMatrix.setRowType(RowType.T_FLOAT_SPARSE_LONGKEY);
angelClient.addMatrix(slfMatrix);
// add sparse long-key int matrix
MatrixContext sliMatrix = new MatrixContext();
sliMatrix.setName(SPARSE_INT_LONG_MAT);
sliMatrix.setRowNum(1);
sliMatrix.setColNum(feaNum);
sliMatrix.setMaxColNumInBlock(feaNum / 3);
sliMatrix.setRowType(RowType.T_INT_SPARSE_LONGKEY);
angelClient.addMatrix(sliMatrix);
// add sparse long-key long matrix
MatrixContext sllMatrix = new MatrixContext();
sllMatrix.setName(SPARSE_LONG_LONG_MAT);
sllMatrix.setRowNum(1);
sllMatrix.setColNum(feaNum);
sllMatrix.setMaxColNumInBlock(feaNum / 3);
sllMatrix.setRowType(RowType.T_LONG_SPARSE_LONGKEY);
angelClient.addMatrix(sllMatrix);
// Start PS
angelClient.startPSServer();
// Start to run application
angelClient.run();
Thread.sleep(5000);
psId = new ParameterServerId(0);
psAttempt0Id = new PSAttemptId(psId, 0);
WorkerGroupId workerGroupId = new WorkerGroupId(0);
workerId = new WorkerId(workerGroupId, 0);
workerAttempt0Id = new WorkerAttemptId(workerId, 0);
}
Aggregations