Search in sources :

Example 1 with DataVO

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

the class RetlStatisticResource method getRetlStatistic.

@Path("retl-statistic")
@GET
public DataVO<RetlStatisticVO> getRetlStatistic() {
    // 尚未真正实现,这里模拟山东省的数据
    String[] cities = { "济南市", "青岛市", "烟台市", "德州市", "泰安市", "临沂市", "威海市", "东营市", "济宁市", "日照市", "淄博市", "枣庄市", "潍坊市", "滨州市", "菏泽市", "莱芜市", "聊城市" };
    RetlStatisticVO vo = new RetlStatisticVO();
    Random random = new Random();
    for (String city : cities) {
        int total = random.nextInt(5000);
        int error = random.nextInt(total);
        vo.add(city, total, error);
    }
    return new DataVO<>(vo);
}
Also used : RetlStatisticVO(com.ds.retl.rest.vo.statistic.RetlStatisticVO) Random(java.util.Random) DataVO(org.mx.rest.vo.DataVO) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 2 with DataVO

use of org.mx.rest.vo.DataVO 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 3 with DataVO

use of org.mx.rest.vo.DataVO 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 4 with DataVO

use of org.mx.rest.vo.DataVO 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 5 with DataVO

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

the class TopologyManageResource method getSupported.

/**
 * 获取系统中相关的各种支持列表信息
 *
 * @return 支持信息列表
 */
@Path("topology/supported")
@GET
public DataVO<SupportedVO> getSupported() {
    SupportedVO supportedVO = new SupportedVO();
    // get JMS supported
    List<LabelValueVO> supportedJms = new ArrayList<>();
    for (JmsManager.Supported s : JmsManager.Supported.values()) {
        supportedJms.add(new LabelValueVO(s.name(), s.name()));
    }
    Collections.sort(supportedJms);
    supportedVO.setJmsTypes(supportedJms);
    // get validate types
    List<String> validateClasses = ClassUtils.scanPackage("com.ds.retl.validate");
    List<LabelValueVO> validateTypes = this.transform(validateClasses);
    Collections.sort(validateTypes);
    supportedVO.setValidateTypes(validateTypes);
    // get validate rule types
    TypeValidateFunc.ValueType[] types = TypeValidateFunc.ValueType.values();
    List<LabelValueVO> supportedValidateRules = new ArrayList<>();
    for (TypeValidateFunc.ValueType type : types) {
        switch(type) {
            case STRING:
                supportedValidateRules.add(new LabelValueVO("1. 字符串类型", type.name()));
                break;
            case DATE:
                supportedValidateRules.add(new LabelValueVO("2. 时间类型", type.name()));
                break;
            case INT:
                supportedValidateRules.add(new LabelValueVO("3. 整数", type.name()));
                break;
            case DECIMAL:
                supportedValidateRules.add(new LabelValueVO("4. 小数类型", type.name()));
                break;
            case BOOL:
                supportedValidateRules.add(new LabelValueVO("5. 布尔类型", type.name()));
                break;
            default:
                if (logger.isWarnEnabled()) {
                    logger.warn(String.format("Unsupported type: %s.", type));
                }
        }
    }
    Collections.sort(supportedValidateRules);
    supportedVO.setValidateRuleTypes(supportedValidateRules);
    // get transform types
    List<String> transformClasses = ClassUtils.scanPackage("com.ds.retl.transform");
    List<LabelValueVO> transformTypes = this.transform(transformClasses);
    Collections.sort(transformTypes);
    supportedVO.setTransformTypes(transformTypes);
    return new DataVO<>(supportedVO);
}
Also used : ArrayList(java.util.ArrayList) LabelValueVO(com.ds.retl.rest.vo.LabelValueVO) PaginationDataVO(org.mx.rest.vo.PaginationDataVO) DataVO(org.mx.rest.vo.DataVO) TypeValidateFunc(com.ds.retl.validate.TypeValidateFunc) JmsManager(com.ds.retl.jms.JmsManager) SupportedVO(com.ds.retl.rest.vo.topology.SupportedVO)

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