use of com.tencent.angel.exception.AngelException in project angel by Tencent.
the class AngelClient method runTask.
@SuppressWarnings("rawtypes")
@Override
public void runTask(Class<? extends BaseTask> taskClass) throws AngelException {
if (master == null) {
throw new AngelException("parameter servers are not started, you must execute startPSServer first!!");
}
try {
master.setParams(null, SetParamsRequest.newBuilder().addKvs(Pair.newBuilder().setKey(AngelConf.ANGEL_TASK_USER_TASKCLASS).setValue(taskClass.getName()).build()).build());
master.start(null, StartRequest.newBuilder().build());
} catch (ServiceException e) {
LOG.error("start application failed.", e);
throw new AngelException(e);
}
}
use of com.tencent.angel.exception.AngelException in project angel by Tencent.
the class AngelClient method saveMatrices.
/**
* Save matrices to files.
* @param matrixNames need save matrix name list
*/
public void saveMatrices(List<String> matrixNames) {
SaveRequest.Builder builder = SaveRequest.newBuilder();
builder.addAllMatrixNames(matrixNames);
try {
master.save(null, builder.build());
} catch (ServiceException e) {
LOG.error("save model failed.", e);
throw new AngelException(e);
}
while (!isCompleted()) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new AngelException("Interrupted as waiting app complete");
}
}
if (appFailedMessage != null) {
throw new AngelException("app run failed, " + appFailedMessage);
}
}
use of com.tencent.angel.exception.AngelException in project angel by Tencent.
the class AngelClient method runTask.
public void runTask(String taskClassName) throws AngelException {
if (master == null) {
throw new AngelException("parameter servers are not started, you must execute startPSServer first!!");
}
try {
master.setParams(null, SetParamsRequest.newBuilder().addKvs(Pair.newBuilder().setKey(AngelConf.ANGEL_TASK_USER_TASKCLASS).setValue(taskClassName).build()).build());
master.start(null, StartRequest.newBuilder().build());
} catch (ServiceException e) {
LOG.error("start application failed.", e);
throw new AngelException(e);
}
}
use of com.tencent.angel.exception.AngelException in project angel by Tencent.
the class AngelClient method addMatrix.
@Override
public void addMatrix(MatrixContext mContext) throws AngelException {
if (nameToMatrixMap.containsKey(mContext.getName())) {
throw new AngelException("Matrix \"" + mContext.getName() + "\" already exist, please check it");
}
try {
mContext.init(conf);
nameToMatrixMap.put(mContext.getName(), mContext);
} catch (Throwable x) {
throw new AngelException(x);
}
}
use of com.tencent.angel.exception.AngelException in project angel by Tencent.
the class AngelPSClient method startPS.
/**
* Start Angel ps
* @return Angel ps running context
* @throws AngelException
*/
public AngelContext startPS() throws AngelException {
int psNum = conf.getInt(AngelConf.ANGEL_PS_NUMBER, AngelConf.DEFAULT_ANGEL_PS_NUMBER);
if (psNum <= 0) {
throw new AngelException("Invalid parameter:Wrong ps number!");
}
conf.set(AngelConf.ANGEL_RUNNING_MODE, RunningMode.ANGEL_PS.toString());
client.addMatrix(new MatrixContext("init", 1, psNum, 1, 1));
client.startPSServer();
client.run();
return new AngelContext(client.getMasterLocation(), conf);
}
Aggregations