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);
}
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;
}
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;
}
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);
}
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));
}
Aggregations