Search in sources :

Example 61 with Map

use of java.util.Map in project cachecloud by sohutv.

the class ClientDataCollectReportExecutor method collectReportAllData.

/**
     * 收集上报数据
     * @param currentMinuteStamp
     */
private void collectReportAllData(String currentMinuteStamp) {
    //1. 获取上一分钟的所有数据
    String lastMinute = getLastMinute(currentMinuteStamp);
    if (lastMinute == null || "".equals(lastMinute.trim())) {
        return;
    }
    List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
    list.addAll(collectReportCostTimeData(lastMinute));
    list.addAll(collectReportValueDistriData(lastMinute));
    list.addAll(collectReportExceptionData(lastMinute));
    //上报统计数据,观察是否存在内存泄露的情况
    Map<String, Object> otherInfo = new HashMap<String, Object>(4, 1);
    otherInfo.put(ClientReportConstant.COST_MAP_SIZE, UsefulDataCollector.getDataCostTimeMapAll().size());
    otherInfo.put(ClientReportConstant.VALUE_MAP_SIZE, UsefulDataCollector.getDataValueLengthDistributeMapAll().size());
    otherInfo.put(ClientReportConstant.EXCEPTION_MAP_SIZE, UsefulDataCollector.getDataExceptionMapAll().size());
    otherInfo.put(ClientReportConstant.COLLECTION_MAP_SIZE, UsefulDataCollector.getCollectionCostTimeMapAll().size());
    //2. 上报数据
    if (!list.isEmpty()) {
        ClientReportBean ccReportBean = new ClientReportBean(clientIp, NumberUtil.toLong(lastMinute), System.currentTimeMillis(), list, otherInfo);
        ClientReportDataCenter.reportData(ccReportBean);
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ClientReportBean(com.sohu.tv.jedis.stat.model.ClientReportBean) HashMap(java.util.HashMap) Map(java.util.Map) AtomicLongMap(com.sohu.tv.jedis.stat.utils.AtomicLongMap)

Example 62 with Map

use of java.util.Map in project cachecloud by sohutv.

the class ClientDataCollectReportExecutor method collectReportValueDistriData.

/**
     * 收集值分布
     * 
     * @param lastMinute
     */
private List<Map<String, Object>> collectReportValueDistriData(String lastMinute) {
    try {
        // 1. 只取当前时间前一分钟的的数据
        Map<ValueLengthModel, Long> jedisValueLengthMap = UsefulDataCollector.getValueLengthLastMinute(lastMinute);
        if (jedisValueLengthMap == null || jedisValueLengthMap.isEmpty()) {
            return Collections.emptyList();
        }
        // 2.解析拼接数据
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
        for (Entry<ValueLengthModel, Long> entry : jedisValueLengthMap.entrySet()) {
            ValueLengthModel model = entry.getKey();
            Long count = entry.getValue();
            Map<String, Object> tempMap = new HashMap<String, Object>();
            tempMap.put(ClientReportConstant.VALUE_DISTRI, model.getRedisValueSizeEnum().getValue());
            tempMap.put(ClientReportConstant.VALUE_COUNT, count);
            tempMap.put(ClientReportConstant.VALUE_COMMAND, model.getCommand());
            tempMap.put(ClientReportConstant.VALUE_HOST_PORT, model.getHostPort());
            tempMap.put(ClientReportConstant.CLIENT_DATA_TYPE, ClientCollectDataTypeEnum.VALUE_LENGTH_DISTRI_TYPE.getValue());
            list.add(tempMap);
        }
        return list;
    } catch (Exception e) {
        UsefulDataCollector.collectException(e, "", System.currentTimeMillis(), ClientExceptionType.CLIENT_EXCEPTION_TYPE);
        logger.error("collectReportValueDistriData:" + e.getMessage(), e);
        return Collections.emptyList();
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ValueLengthModel(com.sohu.tv.jedis.stat.model.ValueLengthModel) HashMap(java.util.HashMap) Map(java.util.Map) AtomicLongMap(com.sohu.tv.jedis.stat.utils.AtomicLongMap) ParseException(java.text.ParseException)

Example 63 with Map

use of java.util.Map in project cachecloud by sohutv.

the class HashesCommandsTest method hgetAllPipeline.

@Test
public void hgetAllPipeline() {
    Map<byte[], byte[]> bh = new HashMap<byte[], byte[]>();
    bh.put(bbar, bcar);
    bh.put(bcar, bbar);
    jedis.hmset(bfoo, bh);
    Pipeline pipeline = jedis.pipelined();
    Response<Map<byte[], byte[]>> bhashResponse = pipeline.hgetAll(bfoo);
    pipeline.sync();
    Map<byte[], byte[]> bhash = bhashResponse.get();
    assertEquals(2, bhash.size());
    assertArrayEquals(bcar, bhash.get(bbar));
    assertArrayEquals(bbar, bhash.get(bcar));
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Pipeline(redis.clients.jedis.Pipeline) Test(org.junit.Test)

Example 64 with Map

use of java.util.Map in project sonatype-aether by sonatype.

the class DependencyGraphParser method addNode.

private void addNode(DependencyNode root, int level, List<NodeEntry> entries) {
    NodeEntry entry = new NodeEntry();
    Dependency dependency = root.getDependency();
    StringBuilder defBuilder = new StringBuilder();
    if (dependency == null) {
        defBuilder.append("(null)");
    } else {
        Artifact artifact = dependency.getArtifact();
        defBuilder.append(artifact.getGroupId()).append(":").append(artifact.getArtifactId()).append(":").append(artifact.getExtension()).append(":").append(artifact.getVersion());
        if (dependency.getScope() != null && (!"".equals(dependency.getScope()))) {
            defBuilder.append(":").append(dependency.getScope());
        }
        Map<String, String> properties = artifact.getProperties();
        if (!(properties == null || properties.isEmpty())) {
            for (Map.Entry<String, String> prop : properties.entrySet()) {
                defBuilder.append(";").append(prop.getKey()).append("=").append(prop.getValue());
            }
        }
    }
    entry.setDefinition(defBuilder.toString());
    entry.setLevel(level++);
    entries.add(entry);
    for (DependencyNode node : root.getChildren()) {
        addNode(node, level, entries);
    }
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) Dependency(org.sonatype.aether.graph.Dependency) HashMap(java.util.HashMap) Map(java.util.Map) Artifact(org.sonatype.aether.artifact.Artifact)

Example 65 with Map

use of java.util.Map in project elasticsearch-jetty by sonian.

the class JettyHttpServerTransport method doStart.

@Override
protected void doStart() throws ElasticsearchException {
    PortsRange portsRange = new PortsRange(port);
    final AtomicReference<Exception> lastException = new AtomicReference<Exception>();
    Log.setLog(loggerWrapper);
    portsRange.iterate(new PortsRange.PortCallback() {

        @Override
        public boolean onPortNumber(int portNumber) {
            try {
                Server server = null;
                XmlConfiguration lastXmlConfiguration = null;
                Object[] objs = new Object[jettyConfig.length];
                Map<String, String> esProperties = jettySettings(bindHost, portNumber);
                for (int i = 0; i < jettyConfig.length; i++) {
                    String configFile = jettyConfig[i];
                    URL config = environment.resolveConfig(configFile);
                    XmlConfiguration xmlConfiguration = new XmlConfiguration(config);
                    // in the later configurations
                    if (lastXmlConfiguration != null) {
                        xmlConfiguration.getIdMap().putAll(lastXmlConfiguration.getIdMap());
                    } else {
                        xmlConfiguration.getIdMap().put("ESServerTransport", JettyHttpServerTransport.this);
                        xmlConfiguration.getIdMap().put("ESClient", client);
                    }
                    // Inject elasticsearch properties
                    xmlConfiguration.getProperties().putAll(esProperties);
                    objs[i] = xmlConfiguration.configure();
                    lastXmlConfiguration = xmlConfiguration;
                }
                // Find jetty Server with id  jettyConfigServerId
                Object serverObject = lastXmlConfiguration.getIdMap().get(jettyConfigServerId);
                if (serverObject != null) {
                    if (serverObject instanceof Server) {
                        server = (Server) serverObject;
                    }
                } else {
                    // For compatibility - if it's not available, find first available jetty Server
                    for (Object obj : objs) {
                        if (obj instanceof Server) {
                            server = (Server) obj;
                            break;
                        }
                    }
                }
                if (server == null) {
                    logger.error("Cannot find server with id [{}] in configuration files [{}]", jettyConfigServerId, jettyConfig);
                    lastException.set(new ElasticsearchException("Cannot find server with id " + jettyConfigServerId));
                    return true;
                }
                // Keep it for now for backward compatibility with previous versions of jetty.xml
                server.setAttribute(TRANSPORT_ATTRIBUTE, JettyHttpServerTransport.this);
                // Start all lifecycle objects configured by xml configurations
                for (Object obj : objs) {
                    if (obj instanceof LifeCycle) {
                        LifeCycle lifeCycle = (LifeCycle) obj;
                        if (!lifeCycle.isRunning()) {
                            lifeCycle.start();
                        }
                    }
                }
                jettyServer = server;
                lastException.set(null);
            } catch (BindException e) {
                lastException.set(e);
                return false;
            } catch (Exception e) {
                logger.error("Jetty Startup Failed ", e);
                lastException.set(e);
                return true;
            }
            return true;
        }
    });
    if (lastException.get() != null) {
        throw new BindHttpException("Failed to bind to [" + port + "]", lastException.get());
    }
    InetSocketAddress jettyBoundAddress = findFirstInetConnector(jettyServer);
    if (jettyBoundAddress != null) {
        InetSocketAddress publishAddress;
        try {
            publishAddress = new InetSocketAddress(networkService.resolvePublishHostAddress(publishHost), jettyBoundAddress.getPort());
        } catch (Exception e) {
            throw new BindTransportException("Failed to resolve publish address", e);
        }
        this.boundAddress = new BoundTransportAddress(new InetSocketTransportAddress(jettyBoundAddress), new InetSocketTransportAddress(publishAddress));
    } else {
        throw new BindHttpException("Failed to find a jetty connector with Inet transport");
    }
}
Also used : LifeCycle(org.eclipse.jetty.util.component.LifeCycle) Server(org.eclipse.jetty.server.Server) AtomicReference(java.util.concurrent.atomic.AtomicReference) XmlConfiguration(org.eclipse.jetty.xml.XmlConfiguration) ElasticsearchException(org.elasticsearch.ElasticsearchException) PortsRange(org.elasticsearch.common.transport.PortsRange) InetSocketTransportAddress(org.elasticsearch.common.transport.InetSocketTransportAddress) ElasticsearchException(org.elasticsearch.ElasticsearchException) BindTransportException(org.elasticsearch.transport.BindTransportException) BoundTransportAddress(org.elasticsearch.common.transport.BoundTransportAddress) BindTransportException(org.elasticsearch.transport.BindTransportException) Map(java.util.Map)

Aggregations

Map (java.util.Map)18519 HashMap (java.util.HashMap)11152 ArrayList (java.util.ArrayList)4318 List (java.util.List)3718 Test (org.junit.Test)3076 Set (java.util.Set)2132 HashSet (java.util.HashSet)1884 IOException (java.io.IOException)1729 LinkedHashMap (java.util.LinkedHashMap)1605 Iterator (java.util.Iterator)1517 TreeMap (java.util.TreeMap)1160 ImmutableMap (com.google.common.collect.ImmutableMap)1043 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)869 File (java.io.File)788 Collection (java.util.Collection)765 Collectors (java.util.stream.Collectors)652 ConcurrentMap (java.util.concurrent.ConcurrentMap)412 LinkedList (java.util.LinkedList)409 Collections (java.util.Collections)388 InputStream (java.io.InputStream)362