Search in sources :

Example 1 with ISnapshotViewDAO

use of com.qlangtech.tis.manage.biz.dal.dao.ISnapshotViewDAO in project tis by qlangtech.

the class SnapshotDomainGetter method getSnapshot.

// @Override
public // request)
SnapshotDomain getSnapshot(AppKey appKey) throws SnapshotNotFindException {
    SnapshotInfoFromRequest result = new SnapshotInfoFromRequest();
    // final String resources = getResources(request);
    if (appKey.getTargetSnapshotId() != null && appKey.getTargetSnapshotId() > 0) {
        result.snapshotId = appKey.getTargetSnapshotId().intValue();
    } else {
        final ServerGroup group = runContext.getServerGroupDAO().load(appKey.appName, appKey.groupIndex, appKey.runtime.getId());
        if (group == null) {
            throw new SnapshotNotFindException("appName:" + appKey.appName + " groupIndex:" + appKey.groupIndex + " runtime:" + appKey.runtime + " has not a corresponding server group in db");
        }
        if (group.getPublishSnapshotId() == null) {
            throw new SnapshotNotFindException("groupid:" + group.getGid() + " has not set publish snapshot id");
        }
        result.snapshotId = group.getPublishSnapshotId();
    }
    // 如果在request中设置了unmergeglobalparams 这个参数
    if (!appKey.unmergeglobalparams) {
        result.runtime = appKey.runtime;
    }
    if (result.snapshotId == null) {
        throw new IllegalStateException("result.snapshotId can not be null");
    }
    ISnapshotViewDAO snapshotViewDAO = runContext.getSnapshotViewDAO();
    if (snapshotViewDAO == null) {
        throw new IllegalStateException("snapshotViewDAO can not be null");
    }
    return snapshotViewDAO.getView(result.snapshotId);
}
Also used : ServerGroup(com.qlangtech.tis.manage.biz.dal.pojo.ServerGroup) ISnapshotViewDAO(com.qlangtech.tis.manage.biz.dal.dao.ISnapshotViewDAO) SnapshotNotFindException(com.qlangtech.tis.openapi.SnapshotNotFindException)

Aggregations

ISnapshotViewDAO (com.qlangtech.tis.manage.biz.dal.dao.ISnapshotViewDAO)1 ServerGroup (com.qlangtech.tis.manage.biz.dal.pojo.ServerGroup)1 SnapshotNotFindException (com.qlangtech.tis.openapi.SnapshotNotFindException)1