Search in sources :

Example 1 with ServerGroup

use of com.qlangtech.tis.manage.biz.dal.pojo.ServerGroup in project tis by qlangtech.

the class DownloadServlet method getDownloadResource.

protected DownloadResource getDownloadResource(Matcher matcher) {
    Integer bizid = Integer.parseInt(matcher.group(1));
    Integer appid = Integer.parseInt(matcher.group(2));
    Short groupIndex = Short.parseShort(matcher.group(3));
    // 开发环境 线上 线下。。。。
    Short runtime = Short.parseShort(matcher.group(4));
    final String resourceName = matcher.group(5);
    final ServerGroup group = getServerGroup(appid, groupIndex, runtime, this.getContext().getServerGroupDAO());
    if (group == null) {
        throw new IllegalStateException("appid:" + appid + ",groupIndex:" + groupIndex + " runtime:" + AppDomainInfo.getRunEnvir(runtime) + " can not find a group");
    }
    if (group.getPublishSnapshotId() == null) {
        throw new IllegalStateException("group id:" + group.getGid() + " group have not set publishSnapshotId");
    }
    Application app = this.getContext().getApplicationDAO().selectByPrimaryKey(appid);
    if (bizid.intValue() != app.getDptId()) {
        throw new IllegalArgumentException("bizid.intValue()" + bizid.intValue() + " != app.getBizId()" + app.getDptId());
    }
    final SnapshotDomain snapshot = this.getContext().getSnapshotViewDAO().getView(group.getPublishSnapshotId());
    // Snapshot snapshot, String resourceName
    return new DownloadResource(app, snapshot, resourceName);
}
Also used : ServerGroup(com.qlangtech.tis.manage.biz.dal.pojo.ServerGroup) SnapshotDomain(com.qlangtech.tis.manage.common.SnapshotDomain) Application(com.qlangtech.tis.manage.biz.dal.pojo.Application)

Example 2 with ServerGroup

use of com.qlangtech.tis.manage.biz.dal.pojo.ServerGroup in project tis by qlangtech.

the class DownloadServlet method getServerGroup.

public static ServerGroup getServerGroup(Integer appid, Short groupIndex, Short runtime, IServerGroupDAO serverGroupDAO) {
    ServerGroupCriteria gcriteria = new ServerGroupCriteria();
    gcriteria.createCriteria().andGroupIndexEqualTo(groupIndex).andRuntEnvironmentEqualTo(runtime).andAppIdEqualTo(appid);
    List<ServerGroup> groupList = serverGroupDAO.selectByExample(gcriteria);
    for (ServerGroup g : groupList) {
        return g;
    }
    return null;
}
Also used : ServerGroup(com.qlangtech.tis.manage.biz.dal.pojo.ServerGroup) ServerGroupCriteria(com.qlangtech.tis.manage.biz.dal.pojo.ServerGroupCriteria)

Example 3 with ServerGroup

use of com.qlangtech.tis.manage.biz.dal.pojo.ServerGroup in project tis by qlangtech.

the class BasicScreen method createServerGroupAdapterList.

public static List<ServerGroupAdapter> createServerGroupAdapterList(ServerGroupCriteriaSetter setter, final boolean publishSnapshotIdIsNotNull, RunContext daoContext) {
    ServerGroupCriteria criteria = new ServerGroupCriteria();
    ServerGroupCriteria.Criteria query = criteria.createCriteria();
    query.andNotDelete();
    setter.process(query);
    // query.andAppIdEqualTo(domain.getAppid()).andRuntEnvironmentEqualTo(
    // domain.getRunEnvironment().getId());
    // 
    // if (publishSnapshotIdIsNotNull) {
    // query.andPublishSnapshotIdIsNotNull();
    // }
    List<ServerGroup> groupList = daoContext.getServerGroupDAO().selectByExample(criteria, 1, 400);
    List<ServerGroupAdapter> groupAdapterList = new ArrayList<ServerGroupAdapter>();
    for (ServerGroup group : groupList) {
        Snapshot snapshot = new Snapshot();
        int maxSnapshotId = 0;
        if (publishSnapshotIdIsNotNull) {
            snapshot = daoContext.getSnapshotDAO().selectByPrimaryKey(group.getPublishSnapshotId());
            // SnapshotCriteria snapshotCriteria = new SnapshotCriteria();
            // snapshotCriteria.createCriteria().andAppidEqualTo(
            // group.getGid());
            // maxSnapshotId = daoContext.getSnapshotDAO().getMaxSnapshotId(
            // snapshotCriteria);
            maxSnapshotId = setter.getMaxSnapshotId(group, daoContext);
            if (snapshot == null) {
                throw new IllegalStateException("group:" + group.getGid() + " has not set PublishSnapshotId,or group.getPublishSnapshotId():" + group.getPublishSnapshotId() + " has any snapshot in db");
            }
        }
        ServerGroupAdapter adapter = new ServerGroupAdapter(group, snapshot);
        // maxSnapshotId
        adapter.setMaxSnapshotId(maxSnapshotId);
        // ServerCriteria scrit = new ServerCriteria();
        // scrit.createCriteria(false).andGidEqualTo(group.getGid());
        // ;
        // adapter.addServer(daoContext.getServerDAO().selectByExample(scrit));
        adapter.addServer(setter.getServers(daoContext, group));
        groupAdapterList.add(adapter);
    }
    return groupAdapterList;
}
Also used : Snapshot(com.qlangtech.tis.manage.biz.dal.pojo.Snapshot) ServerGroup(com.qlangtech.tis.manage.biz.dal.pojo.ServerGroup) Criteria(com.qlangtech.tis.manage.biz.dal.pojo.ServerGroupCriteria.Criteria) ServerGroupAdapter(com.qlangtech.tis.runtime.pojo.ServerGroupAdapter) ServerGroupCriteria(com.qlangtech.tis.manage.biz.dal.pojo.ServerGroupCriteria) ArrayList(java.util.ArrayList)

Example 4 with ServerGroup

use of com.qlangtech.tis.manage.biz.dal.pojo.ServerGroup in project tis by qlangtech.

the class GroupAction method createGroup.

public static Integer createGroup(RunEnvironment runtime, Integer groupIndex, Integer appid, Integer publishSnapshotId, IServerGroupDAO serverGroupDAO) {
    Assert.assertNotNull(appid);
    ServerGroupCriteria query = new ServerGroupCriteria();
    query.createCriteria().andRuntEnvironmentEqualTo(runtime.getId()).andGroupIndexEqualTo(groupIndex.shortValue()).andAppIdEqualTo(appid).andNotDelete();
    int serverGroupCount;
    if ((serverGroupCount = serverGroupDAO.countByExample(query)) > 0) {
        // basicModule.addErrorMessage(context, "gruop index重复");
        throw new IllegalStateException("appid:" + appid + ",groupIndex:" + groupIndex + " relevant group can not duplicate,current serverGroupCount:" + serverGroupCount);
    }
    ServerGroup group = new ServerGroup();
    group.setRuntEnvironment(runtime.getId());
    group.setGroupIndex(groupIndex.shortValue());
    group.setCreateTime(new Date());
    group.setAppId(appid);
    if (publishSnapshotId > 0) {
        group.setPublishSnapshotId(publishSnapshotId);
    }
    return serverGroupDAO.insertSelective(group);
}
Also used : ServerGroup(com.qlangtech.tis.manage.biz.dal.pojo.ServerGroup) ServerGroupCriteria(com.qlangtech.tis.manage.biz.dal.pojo.ServerGroupCriteria) Date(java.util.Date)

Example 5 with ServerGroup

use of com.qlangtech.tis.manage.biz.dal.pojo.ServerGroup in project tis by qlangtech.

the class GroupAction method doChangeEnvironment.

// @Func(PermissionConstant.PERMISSION_BASE_DATA_MANAGE)
public void doChangeEnvironment(Context context) throws Exception {
    Integer appid = this.getInt("appid");
    Integer runtime = this.getInt("runtime");
    ServerGroupCriteria query = new ServerGroupCriteria();
    query.createCriteria().andRuntEnvironmentEqualTo(runtime.shortValue()).andAppIdEqualTo(appid).andNotDelete();
    query.setOrderByClause("group_index desc");
    List<ServerGroup> queryResult = this.getServerGroupDAO().selectByExample(query);
    int groupIndex = 0;
    for (com.qlangtech.tis.manage.biz.dal.pojo.ServerGroup group : queryResult) {
        groupIndex = group.getGroupIndex() + 1;
        break;
    }
    getResponse().getWriter().write(String.valueOf(groupIndex));
}
Also used : ServerGroup(com.qlangtech.tis.manage.biz.dal.pojo.ServerGroup) ServerGroup(com.qlangtech.tis.manage.biz.dal.pojo.ServerGroup) ServerGroupCriteria(com.qlangtech.tis.manage.biz.dal.pojo.ServerGroupCriteria)

Aggregations

ServerGroup (com.qlangtech.tis.manage.biz.dal.pojo.ServerGroup)12 ServerGroupCriteria (com.qlangtech.tis.manage.biz.dal.pojo.ServerGroupCriteria)5 SnapshotDomain (com.qlangtech.tis.manage.common.SnapshotDomain)2 ISnapshotViewDAO (com.qlangtech.tis.manage.biz.dal.dao.ISnapshotViewDAO)1 Application (com.qlangtech.tis.manage.biz.dal.pojo.Application)1 Criteria (com.qlangtech.tis.manage.biz.dal.pojo.ServerGroupCriteria.Criteria)1 Snapshot (com.qlangtech.tis.manage.biz.dal.pojo.Snapshot)1 Func (com.qlangtech.tis.manage.spring.aop.Func)1 SnapshotNotFindException (com.qlangtech.tis.openapi.SnapshotNotFindException)1 ServerGroupAdapter (com.qlangtech.tis.runtime.pojo.ServerGroupAdapter)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1