Search in sources :

Example 11 with UserInterfaceErrorException

use of com.ds.retl.exception.UserInterfaceErrorException in project main by JohnPeng739.

the class ServerManageResource method getServicesStatus.

@Path("server/status")
@GET
public DataVO<ServicesStatusVO> getServicesStatus(@QueryParam("machineIp") String machineIp) {
    try {
        Map<String, ServerManageService.ServiceStatus> status = serverManageService.serviceStatusRest(machineIp);
        ServerManageService.ServiceStatus zkStatus = status.get("zookeeper");
        ServerManageService.ServiceStatus stormStatus = status.get("storm");
        return new DataVO<>(new ServicesStatusVO(zkStatus, stormStatus));
    } catch (UserInterfaceErrorException ex) {
        return new DataVO<>(ex);
    }
}
Also used : ServerManageService(com.ds.retl.service.ServerManageService) PaginationDataVO(org.mx.rest.vo.PaginationDataVO) DataVO(org.mx.rest.vo.DataVO) UserInterfaceErrorException(com.ds.retl.exception.UserInterfaceErrorException) ServicesStatusVO(com.ds.retl.rest.vo.server.ServicesStatusVO)

Example 12 with UserInterfaceErrorException

use of com.ds.retl.exception.UserInterfaceErrorException in project main by JohnPeng739.

the class ServerManageResource method deleteServerInfo.

@Path("server/{machineName}")
@DELETE
public DataVO<ServerInfoVO> deleteServerInfo(@QueryParam("userCode") String userCode, @PathParam("machineName") String machineName) {
    sessionDataStore.setCurrentUserCode(userCode);
    try {
        JSONObject json = serverManageService.deleteServerInfo(machineName);
        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)

Example 13 with UserInterfaceErrorException

use of com.ds.retl.exception.UserInterfaceErrorException in project main by JohnPeng739.

the class TopologyManageResource method submitTopology.

/**
 * 提交输入的拓扑配置信息到Storm集群中
 *
 * @param userCode              操作用户代码
 * @param topologyId            拓扑关键字ID,如果是新增,则为null
 * @param topologyConfigJsonStr 计算拓扑配置信息
 * @return 提交成功返回提交的拓扑对象,否则返回错误信息。
 */
@Path("topology/submit")
@POST
public DataVO<TopologyVO> submitTopology(@QueryParam("userCode") String userCode, @QueryParam("topologyId") String topologyId, String topologyConfigJsonStr) {
    sessionDataStore.setCurrentUserCode(userCode);
    try {
        Topology topology = topologyManageService.submit(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 14 with UserInterfaceErrorException

use of com.ds.retl.exception.UserInterfaceErrorException 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 15 with UserInterfaceErrorException

use of com.ds.retl.exception.UserInterfaceErrorException 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)

Aggregations

UserInterfaceErrorException (com.ds.retl.exception.UserInterfaceErrorException)35 JSONObject (com.alibaba.fastjson.JSONObject)17 EntityAccessException (org.mx.dal.exception.EntityAccessException)15 PaginationDataVO (org.mx.rest.vo.PaginationDataVO)13 DataVO (org.mx.rest.vo.DataVO)12 Topology (com.ds.retl.dal.entity.Topology)8 User (com.ds.retl.dal.entity.User)7 Transactional (org.springframework.transaction.annotation.Transactional)6 TopologyVO (com.ds.retl.rest.vo.topology.TopologyVO)5 ServerInfoVO (com.ds.retl.rest.vo.server.ServerInfoVO)3 UserVO (com.ds.retl.rest.vo.user.UserVO)3 IOException (java.io.IOException)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 EntityInstantiationException (org.mx.dal.exception.EntityInstantiationException)3 RestInvokeException (org.mx.rest.client.RestInvokeException)3 JSONArray (com.alibaba.fastjson.JSONArray)2 ConfigJson (com.ds.retl.dal.entity.ConfigJson)2 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 PrintStream (java.io.PrintStream)2