Search in sources :

Example 6 with DataVO

use of org.mx.rest.vo.DataVO in project main by JohnPeng739.

the class TopologyManageResource method submitTopology.

/**
 * 提交指定关键字ID的计算拓扑到Storm集群中
 *
 * @param userCode   操作用户代码
 * @param simulation 设置为true表示本地仿真,否则真正提交集群
 * @param id         拓扑的关键字ID
 * @return 提交成功返回提交的拓扑对象,否则返回错误信息。
 */
@Path("topology/submit/{id}")
@GET
public DataVO<TopologyVO> submitTopology(@QueryParam("userCode") String userCode, @QueryParam("simulation") boolean simulation, @PathParam("id") String id) {
    sessionDataStore.setCurrentUserCode(userCode);
    try {
        Topology topology = topologyManageService.submit(id, simulation);
        TopologyVO topologyVO = new TopologyVO();
        TopologyVO.transform(topology, topologyVO);
        return new DataVO<>(topologyVO);
    } catch (UserInterfaceErrorException ex) {
        return new DataVO<>(ex);
    }
}
Also used : PaginationDataVO(org.mx.rest.vo.PaginationDataVO) DataVO(org.mx.rest.vo.DataVO) UserInterfaceErrorException(com.ds.retl.exception.UserInterfaceErrorException) Topology(com.ds.retl.dal.entity.Topology) TopologyVO(com.ds.retl.rest.vo.topology.TopologyVO)

Example 7 with DataVO

use of org.mx.rest.vo.DataVO in project main by JohnPeng739.

the class TopologyManageResource method getTopologyRealStatus.

@Path("topologies/realStatus")
@GET
public DataVO<List<TopologyRealStatusVO>> getTopologyRealStatus(@QueryParam("topologyIds") String topologyIds) {
    if (StringUtils.isBlank(topologyIds)) {
        return new DataVO<>(new UserInterfaceErrorException(UserInterfaceErrors.SYSTEM_ILLEGAL_PARAM));
    }
    try {
        String[] ids = topologyIds.split(",");
        JSONArray topologies = stormClient.getToptologies();
        List<TopologyRealStatusVO> list = new ArrayList<>();
        if (topologies != null && topologies.size() > 0) {
            for (String id : ids) {
                for (int index = 0; index < topologies.size(); index++) {
                    JSONObject item = topologies.getJSONObject(index);
                    if (item == null) {
                        continue;
                    }
                    if (id.equals(item.getString("id"))) {
                        list.add(new TopologyRealStatusVO(item));
                    }
                }
            }
        }
        return new DataVO<>(list);
    } catch (UserInterfaceErrorException ex) {
        return new DataVO<>(ex);
    }
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) PaginationDataVO(org.mx.rest.vo.PaginationDataVO) DataVO(org.mx.rest.vo.DataVO) UserInterfaceErrorException(com.ds.retl.exception.UserInterfaceErrorException) JSONArray(com.alibaba.fastjson.JSONArray) ArrayList(java.util.ArrayList) TopologyRealStatusVO(com.ds.retl.rest.vo.topology.TopologyRealStatusVO)

Example 8 with DataVO

use of org.mx.rest.vo.DataVO in project main by JohnPeng739.

the class TopologyManageResource method saveTopology.

/**
 * 保存输入的拓扑配置信息
 *
 * @param userCode              操作用户代码
 * @param topologyId            拓扑关键字ID,如果是新增,则为null
 * @param topologyConfigJsonStr 计算拓扑配置信息
 * @return 保存成功返回提交的拓扑对象,否则返回错误信息。
 */
@Path("topology/save")
@POST
public DataVO<TopologyVO> saveTopology(@QueryParam("userCode") String userCode, @QueryParam("topologyId") String topologyId, String topologyConfigJsonStr) {
    sessionDataStore.setCurrentUserCode(userCode);
    try {
        Topology topology = topologyManageService.save(topologyId, topologyConfigJsonStr);
        TopologyVO topologyVO = new TopologyVO();
        TopologyVO.transform(topology, topologyVO);
        sessionDataStore.removeCurrentUserCode();
        return new DataVO<>(topologyVO);
    } catch (UserInterfaceErrorException ex) {
        return new DataVO<>(ex);
    }
}
Also used : PaginationDataVO(org.mx.rest.vo.PaginationDataVO) DataVO(org.mx.rest.vo.DataVO) UserInterfaceErrorException(com.ds.retl.exception.UserInterfaceErrorException) Topology(com.ds.retl.dal.entity.Topology) TopologyVO(com.ds.retl.rest.vo.topology.TopologyVO)

Example 9 with DataVO

use of org.mx.rest.vo.DataVO in project main by JohnPeng739.

the class UserManageResource method initUser.

/**
 * 初始化用户
 *
 * @return 初始化的管理员用户
 */
@Path("init")
@GET
public DataVO<UserVO> initUser() {
    try {
        sessionDataStore.setCurrentUserCode("SYSTEM");
        User user = userManageService.initUser();
        UserVO userVO = new UserVO();
        UserVO.transform(user, userVO);
        sessionDataStore.removeCurrentUserCode();
        return new DataVO<>(userVO);
    } catch (UserInterfaceErrorException ex) {
        return new DataVO<>(ex);
    }
}
Also used : User(com.ds.retl.dal.entity.User) UserVO(com.ds.retl.rest.vo.user.UserVO) PaginationDataVO(org.mx.rest.vo.PaginationDataVO) DataVO(org.mx.rest.vo.DataVO) UserInterfaceErrorException(com.ds.retl.exception.UserInterfaceErrorException)

Example 10 with DataVO

use of org.mx.rest.vo.DataVO in project main by JohnPeng739.

the class ServerManageResource method saveServerInfo.

@Path("server")
@POST
public DataVO<ServerInfoVO> saveServerInfo(@QueryParam("userCode") String userCode, String info) {
    sessionDataStore.setCurrentUserCode(userCode);
    try {
        JSONObject json = serverManageService.saveServerInfo(info);
        sessionDataStore.removeCurrentUserCode();
        return new DataVO<>(new ServerInfoVO(json));
    } catch (UserInterfaceErrorException ex) {
        return new DataVO<>(ex);
    }
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) PaginationDataVO(org.mx.rest.vo.PaginationDataVO) DataVO(org.mx.rest.vo.DataVO) ServerInfoVO(com.ds.retl.rest.vo.server.ServerInfoVO) UserInterfaceErrorException(com.ds.retl.exception.UserInterfaceErrorException)

Aggregations

DataVO (org.mx.rest.vo.DataVO)14 PaginationDataVO (org.mx.rest.vo.PaginationDataVO)13 UserInterfaceErrorException (com.ds.retl.exception.UserInterfaceErrorException)12 Topology (com.ds.retl.dal.entity.Topology)5 TopologyVO (com.ds.retl.rest.vo.topology.TopologyVO)5 JSONObject (com.alibaba.fastjson.JSONObject)3 User (com.ds.retl.dal.entity.User)3 UserVO (com.ds.retl.rest.vo.user.UserVO)3 ServerInfoVO (com.ds.retl.rest.vo.server.ServerInfoVO)2 ArrayList (java.util.ArrayList)2 EntityAccessException (org.mx.dal.exception.EntityAccessException)2 JSONArray (com.alibaba.fastjson.JSONArray)1 JmsManager (com.ds.retl.jms.JmsManager)1 LabelValueVO (com.ds.retl.rest.vo.LabelValueVO)1 ServicesStatusVO (com.ds.retl.rest.vo.server.ServicesStatusVO)1 RetlStatisticVO (com.ds.retl.rest.vo.statistic.RetlStatisticVO)1 SupportedVO (com.ds.retl.rest.vo.topology.SupportedVO)1 TopologyRealStatusVO (com.ds.retl.rest.vo.topology.TopologyRealStatusVO)1 ServerManageService (com.ds.retl.service.ServerManageService)1 TypeValidateFunc (com.ds.retl.validate.TypeValidateFunc)1