Search in sources :

Example 6 with Topology

use of com.ds.retl.dal.entity.Topology 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 7 with Topology

use of com.ds.retl.dal.entity.Topology in project main by JohnPeng739.

the class TopologyManageResource method killTopology.

/**
 * 杀死集群中的计算拓扑
 *
 * @param userCode   操作用户代码
 * @param topologyId 拓扑关键字ID
 * @return 操作成功后的拓扑对象
 */
@Path("topology/kill")
@GET
public DataVO<TopologyVO> killTopology(@QueryParam("userCode") String userCode, @QueryParam("topologyId") String topologyId) {
    sessionDataStore.setCurrentUserCode(userCode);
    try {
        Topology topology = topologyManageService.kill(topologyId);
        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 8 with Topology

use of com.ds.retl.dal.entity.Topology in project main by JohnPeng739.

the class TopologyManageResource method getTopology.

/**
 * 根据拓扑数据库ID获取拓扑信息
 *
 * @param topologyId 关键字ID,不是集群中的ID
 * @return 拓扑值对象
 */
@Path("topology")
@GET
public DataVO<TopologyVO> getTopology(@QueryParam("topologyId") String topologyId) {
    try {
        Topology topology = accessor.getById(topologyId, Topology.class);
        TopologyVO vo = new TopologyVO();
        TopologyVO.transform(topology, vo);
        return new DataVO<>(vo);
    } catch (EntityAccessException ex) {
        if (logger.isErrorEnabled()) {
            logger.error(ex);
        }
        return new DataVO<>(new UserInterfaceErrorException(UserInterfaceErrors.DB_OPERATE_FAIL));
    }
}
Also used : PaginationDataVO(org.mx.rest.vo.PaginationDataVO) DataVO(org.mx.rest.vo.DataVO) UserInterfaceErrorException(com.ds.retl.exception.UserInterfaceErrorException) EntityAccessException(org.mx.dal.exception.EntityAccessException) Topology(com.ds.retl.dal.entity.Topology) TopologyVO(com.ds.retl.rest.vo.topology.TopologyVO)

Aggregations

Topology (com.ds.retl.dal.entity.Topology)8 UserInterfaceErrorException (com.ds.retl.exception.UserInterfaceErrorException)8 TopologyVO (com.ds.retl.rest.vo.topology.TopologyVO)5 DataVO (org.mx.rest.vo.DataVO)5 PaginationDataVO (org.mx.rest.vo.PaginationDataVO)5 EntityAccessException (org.mx.dal.exception.EntityAccessException)4 JSONObject (com.alibaba.fastjson.JSONObject)2 EntityInstantiationException (org.mx.dal.exception.EntityInstantiationException)1 Transactional (org.springframework.transaction.annotation.Transactional)1