Search in sources :

Example 6 with Paginator

use of com.alibaba.citrus.util.Paginator in project otter by alibaba.

the class LogRecordTab method execute.

public void execute(@Param("pageIndex") int pageIndex, @Param("searchKey") String searchKey, @Param("pipelineId") Long pipelineId, Context context) throws Exception {
    @SuppressWarnings("unchecked") Map<String, Object> condition = new HashMap<String, Object>();
    if ("请输入关键字(目前支持log内容关键字搜索)".equals(searchKey)) {
        searchKey = "";
    }
    condition.put("pipelineId", pipelineId);
    condition.put("searchKey", searchKey);
    int count = logRecordService.getCount(condition);
    Paginator paginator = new Paginator();
    paginator.setItems(count);
    paginator.setPage(pageIndex);
    condition.put("offset", paginator.getOffset());
    condition.put("length", paginator.getLength());
    List<LogRecord> logRecords = logRecordService.listByCondition(condition);
    for (LogRecord logRecord : logRecords) {
        if (!StringUtils.isEmpty(logRecord.getMessage())) {
            logRecord.setMessage(logRecord.getMessage().replaceAll("\n\t", "<br/>"));
        }
    }
    context.put("logRecords", logRecords);
    context.put("paginator", paginator);
    context.put("searchKey", searchKey);
    context.put("pipelineId", pipelineId);
    Channel channel = channelService.findByPipelineId(pipelineId);
    context.put("channel", channel);
}
Also used : HashMap(java.util.HashMap) LogRecord(com.alibaba.otter.shared.common.model.config.record.LogRecord) Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) Paginator(com.alibaba.citrus.util.Paginator)

Example 7 with Paginator

use of com.alibaba.citrus.util.Paginator in project otter by alibaba.

the class SelectDataSource method execute.

public void execute(@Param("pageIndex") int pageIndex, @Param("searchKey") String searchKey, Context context) throws Exception {
    @SuppressWarnings("unchecked") Map<String, Object> condition = new HashMap<String, Object>();
    if ("请输入关键字(目前支持DataSource的ID、名字搜索)".equals(searchKey)) {
        searchKey = "";
    }
    condition.put("searchKey", searchKey);
    int count = dataMediaSourceService.getCount(condition);
    Paginator paginator = new Paginator();
    paginator.setItems(count);
    paginator.setPage(pageIndex);
    condition.put("offset", paginator.getOffset());
    condition.put("length", paginator.getLength());
    List<DataMediaSource> dataMediaSources = dataMediaSourceService.listByCondition(condition);
    context.put("sources", dataMediaSources);
    context.put("paginator", paginator);
    context.put("searchKey", searchKey);
}
Also used : HashMap(java.util.HashMap) DataMediaSource(com.alibaba.otter.shared.common.model.config.data.DataMediaSource) Paginator(com.alibaba.citrus.util.Paginator)

Example 8 with Paginator

use of com.alibaba.citrus.util.Paginator in project otter by alibaba.

the class AutoKeeperClustersList method execute.

public void execute(@Param("pageIndex") int pageIndex, @Param("searchKey") String searchKey, Context context) throws Exception {
    @SuppressWarnings("unchecked") Map<String, Object> condition = new HashMap<String, Object>();
    if ("请输入关键字(目前支持Zookeeper的地址搜索)".equals(searchKey)) {
        searchKey = "";
    }
    condition.put("searchKey", searchKey);
    int count = autoKeeperClusterService.getCount();
    Paginator paginator = new Paginator();
    paginator.setItems(count);
    paginator.setPage(pageIndex);
    condition.put("offset", paginator.getOffset());
    condition.put("length", paginator.getLength());
    List<AutoKeeperCluster> autoKeeperClusters = autoKeeperClusterService.listAutoKeeperClusters();
    context.put("paginator", paginator);
    context.put("autoKeeperClusters", autoKeeperClusters);
}
Also used : HashMap(java.util.HashMap) AutoKeeperCluster(com.alibaba.otter.shared.common.model.autokeeper.AutoKeeperCluster) Paginator(com.alibaba.citrus.util.Paginator)

Example 9 with Paginator

use of com.alibaba.citrus.util.Paginator in project otter by alibaba.

the class ChannelList method execute.

public void execute(@Param("pageIndex") int pageIndex, @Param("searchKey") String searchKey, @Param("channelStatus") String status, @Param("channelId") Long channelId, @Param("errorType") String errorType, Context context) throws Exception {
    @SuppressWarnings("unchecked") Map<String, Object> condition = new HashMap<String, Object>();
    if ("请输入关键字(目前支持Channel的ID、名字搜索)".equals(searchKey)) {
        searchKey = "";
    }
    condition.put("searchKey", searchKey);
    List<Long> theStatusPks = new ArrayList<Long>();
    if (null != status) {
        List<Long> allChannelPks = channelService.listAllChannelId();
        for (Long channelPk : allChannelPks) {
            ChannelStatus channelStatus = arbitrateManageService.channelEvent().status(channelPk);
            if (channelStatus.equals(ChannelStatus.valueOf(status))) {
                theStatusPks.add(channelPk);
            }
        }
    }
    int count = channelService.getCount(condition);
    Paginator paginator = new Paginator();
    paginator.setItems(count);
    paginator.setPage(pageIndex);
    condition.put("offset", paginator.getOffset());
    condition.put("length", paginator.getLength());
    List<Channel> channels = new ArrayList<Channel>();
    if ((null != channelId) && (channelId != 0l)) {
        channels.add(channelService.findById(channelId));
        paginator.setItems(1);
        paginator.setPage(0);
        // 定义为新的searchKey
        searchKey = String.valueOf(channelId);
    } else {
        channels = channelService.listByConditionWithoutColumn(condition);
    }
    List<SeniorChannel> seniorChannels = new ArrayList<SeniorChannel>();
    for (Channel channel : channels) {
        boolean processEmpty = false;
        List<Pipeline> pipelines = channel.getPipelines();
        for (Pipeline pipeline : pipelines) {
            if (processStatService.listRealtimeProcessStat(channel.getId(), pipeline.getId()).isEmpty()) {
                processEmpty = true;
            }
        }
        SeniorChannel seniorChannel = new SeniorChannel();
        seniorChannel.setId(channel.getId());
        seniorChannel.setName(channel.getName());
        seniorChannel.setParameters(channel.getParameters());
        seniorChannel.setPipelines(channel.getPipelines());
        seniorChannel.setStatus(channel.getStatus());
        seniorChannel.setDescription(channel.getDescription());
        seniorChannel.setGmtCreate(channel.getGmtCreate());
        seniorChannel.setGmtModified(channel.getGmtModified());
        seniorChannel.setProcessEmpty(processEmpty);
        seniorChannels.add(seniorChannel);
    }
    context.put("channels", seniorChannels);
    context.put("paginator", paginator);
    context.put("searchKey", searchKey);
    context.put("errorType", errorType);
}
Also used : HashMap(java.util.HashMap) SeniorChannel(com.alibaba.otter.manager.web.common.model.SeniorChannel) Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) ArrayList(java.util.ArrayList) ChannelStatus(com.alibaba.otter.shared.common.model.config.channel.ChannelStatus) Paginator(com.alibaba.citrus.util.Paginator) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline) SeniorChannel(com.alibaba.otter.manager.web.common.model.SeniorChannel)

Example 10 with Paginator

use of com.alibaba.citrus.util.Paginator in project otter by alibaba.

the class DataMatrixList method execute.

public void execute(@Param("pageIndex") int pageIndex, @Param("matrixId") Long matrixId, @Param("groupKey") String groupKey, @Param("searchKey") String searchKey, Context context) throws Exception {
    Map<String, Object> condition = new HashMap<String, Object>();
    if ("请输入关键字(目前支持Node的ID、名字搜索)".equals(searchKey)) {
        searchKey = "";
    }
    condition.put("searchKey", searchKey);
    int count = dataMatrixService.getCount(condition);
    Paginator paginator = new Paginator();
    paginator.setItems(count);
    paginator.setPage(pageIndex);
    condition.put("offset", paginator.getOffset());
    condition.put("length", paginator.getLength());
    List<DataMatrix> matrixs = new ArrayList<DataMatrix>();
    if ((null != matrixId) && (matrixId != 0l)) {
        DataMatrix matrix = dataMatrixService.findById(matrixId);
        matrixs.add(matrix);
        paginator.setItems(1);
        paginator.setPage(0);
        // 定义为新的searchKey
        searchKey = String.valueOf(matrixId);
    } else if (StringUtils.isNotEmpty(groupKey)) {
        DataMatrix matrix = dataMatrixService.findByGroupKey(groupKey);
        matrixs.add(matrix);
        paginator.setItems(1);
        paginator.setPage(0);
        // 定义为新的searchKey
        searchKey = String.valueOf(groupKey);
    } else {
        matrixs = dataMatrixService.listByCondition(condition);
    }
    List<SeniorDataMatrix> seniorMatrixs = new ArrayList<SeniorDataMatrix>();
    for (DataMatrix matrix : matrixs) {
        SeniorDataMatrix seniorMatrix = new SeniorDataMatrix();
        seniorMatrix.setId(matrix.getId());
        seniorMatrix.setGroupKey(matrix.getGroupKey());
        seniorMatrix.setMaster(matrix.getMaster());
        seniorMatrix.setSlave(matrix.getSlave());
        seniorMatrix.setGmtCreate(matrix.getGmtCreate());
        seniorMatrix.setGmtModified(matrix.getGmtModified());
        Map dataSourceCondition = new HashMap();
        condition.put("searchKey", "jdbc:mysql://groupKey=" + matrix.getGroupKey());
        List<DataMediaSource> dataSources = dataMediaSourceService.listByCondition(dataSourceCondition);
        seniorMatrix.setUsed(!CollectionUtils.isEmpty(dataSources));
        seniorMatrixs.add(seniorMatrix);
    }
    context.put("dataMatrixs", seniorMatrixs);
    context.put("paginator", paginator);
    context.put("searchKey", searchKey);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) DataMatrix(com.alibaba.otter.shared.common.model.config.data.DataMatrix) SeniorDataMatrix(com.alibaba.otter.manager.web.common.model.SeniorDataMatrix) Paginator(com.alibaba.citrus.util.Paginator) SeniorDataMatrix(com.alibaba.otter.manager.web.common.model.SeniorDataMatrix) DataMediaSource(com.alibaba.otter.shared.common.model.config.data.DataMediaSource) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

Paginator (com.alibaba.citrus.util.Paginator)14 HashMap (java.util.HashMap)14 ArrayList (java.util.ArrayList)7 DataMedia (com.alibaba.otter.shared.common.model.config.data.DataMedia)3 DataMediaSource (com.alibaba.otter.shared.common.model.config.data.DataMediaSource)3 Canal (com.alibaba.otter.canal.instance.manager.model.Canal)2 SeniorCanal (com.alibaba.otter.manager.web.common.model.SeniorCanal)2 Channel (com.alibaba.otter.shared.common.model.config.channel.Channel)2 Pipeline (com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)2 LogRecord (com.alibaba.otter.shared.common.model.config.record.LogRecord)2 SeniorChannel (com.alibaba.otter.manager.web.common.model.SeniorChannel)1 SeniorDataMatrix (com.alibaba.otter.manager.web.common.model.SeniorDataMatrix)1 SeniorDataMedia (com.alibaba.otter.manager.web.common.model.SeniorDataMedia)1 SeniorDataMediaSource (com.alibaba.otter.manager.web.common.model.SeniorDataMediaSource)1 SeniorNode (com.alibaba.otter.manager.web.common.model.SeniorNode)1 AutoKeeperCluster (com.alibaba.otter.shared.common.model.autokeeper.AutoKeeperCluster)1 AlarmRule (com.alibaba.otter.shared.common.model.config.alarm.AlarmRule)1 ChannelStatus (com.alibaba.otter.shared.common.model.config.channel.ChannelStatus)1 DataMatrix (com.alibaba.otter.shared.common.model.config.data.DataMatrix)1 DataMediaPair (com.alibaba.otter.shared.common.model.config.data.DataMediaPair)1