当前位置: 首页>>代码示例>>Java>>正文


Java FormatUtil类代码示例

本文整理汇总了Java中com.alibaba.cobar.manager.util.FormatUtil的典型用法代码示例。如果您正苦于以下问题:Java FormatUtil类的具体用法?Java FormatUtil怎么用?Java FormatUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FormatUtil类属于com.alibaba.cobar.manager.util包,在下文中一共展示了FormatUtil类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: listThreadPool

import com.alibaba.cobar.manager.util.FormatUtil; //导入依赖的package包/类
/**
 * ThreadPool Tab
 * 
 * @param params
 * @return
 */
private List<Map<String, Object>> listThreadPool(AjaxParams params) {
    CobarAdapterDAO perfAccesser = cobarAccesser.getAccesser(params.getCobarNodeId());
    if (!perfAccesser.checkConnection()) {
        return null;
    }

    List<ThreadPoolStatus> pools = perfAccesser.listThreadPoolStatus();
    List<Map<String, Object>> returnList = new ArrayList<Map<String, Object>>();
    for (ThreadPoolStatus t : pools) {
        Map<String, Object> map = new HashMap<String, Object>();

        map.put("threadPoolName", t.getThreadPoolName());
        map.put("poolSize", t.getPoolSize());
        map.put("activeSize", t.getActiveSize());
        map.put("taskQueue", t.getTaskQueue());
        map.put("completedTask", FormatUtil.formatNumber(t.getCompletedTask()));
        map.put("totalTask", FormatUtil.formatNumber(t.getTotalTask()));

        returnList.add(map);
    }

    return returnList;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:30,代码来源:CobarNodeInstantPerfValueAjax.java

示例2: listConnection

import com.alibaba.cobar.manager.util.FormatUtil; //导入依赖的package包/类
/**
 * Connection Tab
 * 
 * @param params
 * @return
 */
private List<Map<String, Object>> listConnection(AjaxParams params) {
    CobarAdapterDAO perfAccesser = cobarAccesser.getAccesser(params.getCobarNodeId());
    if (!perfAccesser.checkConnection()) {
        return null;
    }
    List<ConnectionStatus> list = perfAccesser.listConnectionStatus();
    if (null != list) {
        ListSortUtil.sortConnections(list);
    }
    List<Map<String, Object>> returnList = new ArrayList<Map<String, Object>>();
    for (ConnectionStatus c : list) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("processor", c.getProcessor());
        map.put("id", c.getId());
        map.put("host", c.getHost());
        map.put("port", c.getPort());
        map.put("local_port", c.getLocal_port());
        map.put("schema", c.getSchema());
        map.put("charset", c.getCharset());
        map.put("netIn", FormatUtil.formatStore(c.getNetIn()));
        map.put("netOut", FormatUtil.formatStore(c.getNetOut()));
        map.put("aliveTime", FormatUtil.formatTime(c.getAliveTime() * 1000, 2));
        map.put("attempsCount", FormatUtil.formatNumber(c.getAttempsCount()));
        map.put("recvBuffer", FormatUtil.formatStore(c.getRecvBuffer()));
        map.put("sendQueue", c.getSendQueue());
        map.put("channel", c.getChannel());
        returnList.add(map);
    }
    return returnList;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:37,代码来源:CobarNodeInstantPerfValueAjax.java

示例3: listDatanode

import com.alibaba.cobar.manager.util.FormatUtil; //导入依赖的package包/类
@SuppressWarnings({ "unchecked" })
private List<Map<String, Object>> listDatanode(AjaxParams params) {
    CobarAdapterDAO perfAccesser = cobarAccesser.getAccesser(params.getCobarNodeId());
    if (!perfAccesser.checkConnection()) {
        return null;
    }
    PropertyUtilsBean util = new PropertyUtilsBean();
    List<DataNodesStatus> list = perfAccesser.listDataNodes();
    ;
    if (null != list) {
        ListSortUtil.sortDataNodesByPoolName(list);
    }
    List<Map<String, Object>> returnList = new ArrayList<Map<String, Object>>();
    for (DataNodesStatus c : list) {
        Map<String, Object> map = null;
        try {
            map = util.describe(c);
        } catch (Exception e1) {
            throw new RuntimeException(e1);
        }
        map.remove("class");
        map.remove("executeCount");
        map.put("executeCount", FormatUtil.formatNumber(c.getExecuteCount()));
        map.remove("recoveryTime");
        if (-1 != c.getRecoveryTime()) {
            map.put("recoveryTime", FormatUtil.formatTime(c.getRecoveryTime() * 1000, 2));
        } else {
            map.put("recoveryTime", c.getRecoveryTime());
        }
        returnList.add(map);
    }
    return returnList;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:34,代码来源:CobarNodeInstantPerfValueAjax.java

示例4: listDatanode

import com.alibaba.cobar.manager.util.FormatUtil; //导入依赖的package包/类
@SuppressWarnings({ "unchecked" })
private List<Map<String, Object>> listDatanode(AjaxParams params) {
    CobarAdapterDAO perfAccesser = cobarAccesser.getAccesser(params.getCobarNodeId());
    if (!perfAccesser.checkConnection()) {
        return null;
    }
    PropertyUtilsBean util = new PropertyUtilsBean();
    List<DataNodesStatus> list = perfAccesser.listDataNodes();;
    if (null != list) {
        ListSortUtil.sortDataNodesByPoolName(list);
    }
    List<Map<String, Object>> returnList = new ArrayList<Map<String, Object>>();
    for (DataNodesStatus c : list) {
        Map<String, Object> map = null;
        try {
            map = util.describe(c);
        } catch (Exception e1) {
            throw new RuntimeException(e1);
        }
        map.remove("class");
        map.remove("executeCount");
        map.put("executeCount", FormatUtil.formatNumber(c.getExecuteCount()));
        map.remove("recoveryTime");
        if (-1 != c.getRecoveryTime()) {
            map.put("recoveryTime", FormatUtil.formatTime(c.getRecoveryTime() * 1000, 2));
        } else {
            map.put("recoveryTime", c.getRecoveryTime());
        }
        returnList.add(map);
    }
    return returnList;
}
 
开发者ID:alibaba,项目名称:cobar,代码行数:33,代码来源:CobarNodeInstantPerfValueAjax.java

示例5: getClusterInfo

import com.alibaba.cobar.manager.util.FormatUtil; //导入依赖的package包/类
private AjaxResult getClusterInfo(AjaxParams params) {
    JSONArray array = params.getArray();
    long clusterId = params.getClusterId();

    JSONObject json = null;
    if (array.size() > 0) {
        json = array.getJSONObject(0);
    }

    AjaxResult rs = new AjaxResult();
    rs.setId(clusterId);

    List<CobarDO> nodes = xmlAccesser.getCobarDAO().getCobarList(clusterId);
    rs.setTotal(nodes.size());
    for (CobarDO cobar : nodes) {
        if (ConstantDefine.IN_ACTIVE.equals(cobar.getStatus())) {
            continue;
        }
        CobarAdapterDAO perfAccesser = cobarAccesser.getAccesser(cobar.getId());
        if (!perfAccesser.checkConnection()) {
            rs.addError(1);
            StringBuilder sb = new StringBuilder("getClusterInfo : cobar connect error for [ Name:");
            sb.append(cobar.getName()).append(" Host:").append(cobar.getHost()).append(" ]");
            logger.error(sb.toString());
            continue;
        }
        rs.addActive(1);
        rs.setSchema(perfAccesser.listDataBases().size());
        List<ProcessorStatus> list = perfAccesser.listProccessorStatus();
        rs.addNetIn(groupByPList(list, NET_IN));
        rs.addNetOut(groupByPList(list, NET_OUT));

        rs.addConnection(groupByPList(list, CONNECTION));
        rs.setTimestamp(list.get(list.size() - 1).getSampleTimeStamp());

        List<CommandStatus> commandList = perfAccesser.listCommandStatus();
        rs.addRequest(groupByCList(commandList, REQUEST_COUNT));
    }

    if (json != null && json.getLong("netIn") != -1) {
        long o_tiemstamp = json.getLong("timestamp");
        rs.setNetIn_deriv(FormatUtil.formatNetwork(Math.round(MathUtil.getDerivate(rs.getNetIn(),
            json.getLong("netIn"),
            rs.getTimestamp(),
            o_tiemstamp,
            1000.0))));
        rs.setNetOut_deriv(FormatUtil.formatNetwork(Math.round(MathUtil.getDerivate(rs.getNetOut(),
            json.getLong("netOut"),
            rs.getTimestamp(),
            o_tiemstamp,
            1000.0))));
        rs.setRequest_deriv(FormatUtil.formatNumber(Math.round(MathUtil.getDerivate(rs.getRequest(),
            json.getLong("reCount"),
            rs.getTimestamp(),
            o_tiemstamp,
            1000.0))));
    }

    return rs;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:61,代码来源:ClusterInstantPerfValueAjax.java

示例6: listProcessorStatus

import com.alibaba.cobar.manager.util.FormatUtil; //导入依赖的package包/类
/**
 * Processor Tab
 * 
 * @param params
 * @return
 */
private List<Map<String, Object>> listProcessorStatus(AjaxParams params) {
    long timestamp = 0;

    CobarAdapterDAO perfAccesser = cobarAccesser.getAccesser(params.getCobarNodeId());
    if (!perfAccesser.checkConnection()) {
        return null;
    }

    List<Map<String, Object>> returnList = new ArrayList<Map<String, Object>>();

    List<ProcessorStatus> list = perfAccesser.listProccessorStatus();
    long a[] = new long[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    for (ProcessorStatus e : list) {
        a[0] += e.getNetIn();
        a[1] += e.getNetOut();
        a[2] += e.getRequestCount();
        a[3] += e.getrQueue();
        a[4] += e.getwQueue();
        a[5] += e.getFreeBuffer();
        a[6] += e.getTotalBuffer();
        a[7] += e.getConnections();
        a[8] += e.getBc_count();
        timestamp = e.getSampleTimeStamp();

        Map<String, Object> map = new HashMap<String, Object>();
        map.put("processorId", e.getProcessorId());
        map.put("netIn", FormatUtil.formatStore(e.getNetIn()));
        map.put("netOut", FormatUtil.formatStore(e.getNetOut()));
        map.put("requestCount", FormatUtil.formatNumber(e.getRequestCount()));
        map.put("rQueue", e.getrQueue());
        map.put("wQueue", e.getwQueue());
        map.put("freeBuffer", e.getFreeBuffer());
        map.put("totalBuffer", e.getTotalBuffer());
        map.put("connections", e.getConnections());
        map.put("bc_count", e.getBc_count());
        returnList.add(map);
    }

    Map<String, Object> total = new HashMap<String, Object>();
    total.put("processorId", "TOTAL");
    total.put("netIn", FormatUtil.formatStore(a[0]));
    total.put("netOut", FormatUtil.formatStore(a[1]));
    total.put("requestCount", FormatUtil.formatNumber(a[2]));
    total.put("rQueue", a[3]);
    total.put("wQueue", a[4]);
    total.put("freeBuffer", a[5]);
    total.put("totalBuffer", a[6]);
    total.put("connections", a[7]);
    total.put("bc_count", a[8]);
    total.put("sampleTimeStamp", timestamp);
    total.put("netInC", a[0]);
    total.put("netOutC", a[1]);
    total.put("requestCountC", a[2]);
    returnList.add(total);

    return returnList;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:64,代码来源:CobarNodeInstantPerfValueAjax.java

示例7: getFormatTime

import com.alibaba.cobar.manager.util.FormatUtil; //导入依赖的package包/类
public String getFormatTime() {
    return FormatUtil.fromMilliseconds2String(this.timestamp);
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:4,代码来源:TimeStamp.java

示例8: getClusterInfo

import com.alibaba.cobar.manager.util.FormatUtil; //导入依赖的package包/类
private AjaxResult getClusterInfo(AjaxParams params) {
    JSONArray array = params.getArray();
    long clusterId = params.getClusterId();

    JSONObject json = null;
    if (array.size() > 0) {
        json = array.getJSONObject(0);
    }

    AjaxResult rs = new AjaxResult();
    rs.setId(clusterId);

    List<CobarDO> nodes = xmlAccesser.getCobarDAO().getCobarList(clusterId);
    rs.setTotal(nodes.size());
    for (CobarDO cobar : nodes) {
        if (ConstantDefine.IN_ACTIVE.equals(cobar.getStatus())) {
            continue;
        }
        CobarAdapterDAO perfAccesser = cobarAccesser.getAccesser(cobar.getId());
        if (!perfAccesser.checkConnection()) {
            rs.addError(1);
            StringBuilder sb = new StringBuilder("getClusterInfo : cobar connect error for [ Name:");
            sb.append(cobar.getName()).append(" Host:").append(cobar.getHost()).append(" ]");
            logger.error(sb.toString());
            continue;
        }
        rs.addActive(1);
        rs.setSchema(perfAccesser.listDataBases().size());
        List<ProcessorStatus> list = perfAccesser.listProccessorStatus();
        rs.addNetIn(groupByPList(list, NET_IN));
        rs.addNetOut(groupByPList(list, NET_OUT));

        rs.addConnection(groupByPList(list, CONNECTION));
        rs.setTimestamp(list.get(list.size() - 1).getSampleTimeStamp());

        List<CommandStatus> commandList = perfAccesser.listCommandStatus();
        rs.addRequest(groupByCList(commandList, REQUEST_COUNT));
    }

    if (json != null && json.getLong("netIn") != -1) {
        long o_tiemstamp = json.getLong("timestamp");
        rs.setNetIn_deriv(FormatUtil.formatNetwork(Math.round(MathUtil.getDerivate(rs.getNetIn(),
                                                                                   json.getLong("netIn"),
                                                                                   rs.getTimestamp(),
                                                                                   o_tiemstamp,
                                                                                   1000.0))));
        rs.setNetOut_deriv(FormatUtil.formatNetwork(Math.round(MathUtil.getDerivate(rs.getNetOut(),
                                                                                    json.getLong("netOut"),
                                                                                    rs.getTimestamp(),
                                                                                    o_tiemstamp,
                                                                                    1000.0))));
        rs.setRequest_deriv(FormatUtil.formatNumber(Math.round(MathUtil.getDerivate(rs.getRequest(),
                                                                                    json.getLong("reCount"),
                                                                                    rs.getTimestamp(),
                                                                                    o_tiemstamp,
                                                                                    1000.0))));
    }

    return rs;
}
 
开发者ID:alibaba,项目名称:cobar,代码行数:61,代码来源:ClusterInstantPerfValueAjax.java


注:本文中的com.alibaba.cobar.manager.util.FormatUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。