Search in sources :

Example 21 with AngelException

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);
    }
}
Also used : AngelException(com.tencent.angel.exception.AngelException) ServiceException(com.google.protobuf.ServiceException)

Example 22 with AngelException

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);
    }
}
Also used : AngelException(com.tencent.angel.exception.AngelException) ServiceException(com.google.protobuf.ServiceException)

Example 23 with AngelException

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);
    }
}
Also used : AngelException(com.tencent.angel.exception.AngelException) ServiceException(com.google.protobuf.ServiceException)

Example 24 with AngelException

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);
    }
}
Also used : AngelException(com.tencent.angel.exception.AngelException)

Example 25 with AngelException

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);
}
Also used : AngelException(com.tencent.angel.exception.AngelException) MatrixContext(com.tencent.angel.ml.matrix.MatrixContext)

Aggregations

AngelException (com.tencent.angel.exception.AngelException)27 ServiceException (com.google.protobuf.ServiceException)8 IOException (java.io.IOException)6 MatrixClient (com.tencent.angel.psagent.matrix.MatrixClient)5 InvalidParameterException (com.tencent.angel.exception.InvalidParameterException)3 TVector (com.tencent.angel.ml.math.TVector)3 DenseDoubleVector (com.tencent.angel.ml.math.vector.DenseDoubleVector)3 SparseDoubleVector (com.tencent.angel.ml.math.vector.SparseDoubleVector)3 ArrayList (java.util.ArrayList)3 MatrixContext (com.tencent.angel.ml.matrix.MatrixContext)2 IndexGetFunc (com.tencent.angel.ml.matrix.psf.get.enhance.indexed.IndexGetFunc)2 IndexGetParam (com.tencent.angel.ml.matrix.psf.get.enhance.indexed.IndexGetParam)2 ModelLineConvert (com.tencent.angel.tools.ModelLineConvert)2 TextModelLineConvert (com.tencent.angel.tools.TextModelLineConvert)2 Random (java.util.Random)2 FileStatus (org.apache.hadoop.fs.FileStatus)2 FileSystem (org.apache.hadoop.fs.FileSystem)2 Path (org.apache.hadoop.fs.Path)2 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)2 Output (com.esotericsoftware.kryo.io.Output)1