Java Code Examples for java.util.concurrent.ConcurrentHashMap.values()

The following are Jave code examples for showing how to use values() of the java.util.concurrent.ConcurrentHashMap class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: cljbuck   File: Main.java   View Source Code Vote up 6 votes
/**
 * Prints the applications help for available commands.
 *  @param out
 * @param commandList
 */
private void printUsage(final PrintStream out, final ConcurrentHashMap<String, Command> commandList) {
    out.println("Description:");
    out.println("  cljbuild is a clojure/jvm build too.");
    out.println("");
    out.println("Usage:");
    out.println("  cljbuild <command> [<command-options>]");
    out.println("");
    out.println("Available commands:");

    for (final Command c : commandList.values()) {
        final String target = c.getTarget();
        final int padLen = 14 - target.length();
        final char[] padding = new char[padLen];
        Arrays.fill(padding, ' ');

        out.print("  ");
        out.print(target);
        out.print(padding);
        out.print(" ");
        out.println(c.getDescription());
    }

    out.println("");
}
 
Example 2
Project: odoxSync   File: DirectorySynchronizer.java   View Source Code Vote up 6 votes
public void addBlankFile(BlankFileMessage blankFileMessage) {
    int clientId = blankFileMessage.getClientId();
    int fileId = blankFileMessage.getFileId();

    Client client = clients.get(clientId);
    File clientFile = getOrCreateClientFile(fileId, client);

    ConcurrentHashMap<Long, Region> clientRegions = clientFile.getRegions();
    ConcurrentHashMap<Long, Region> serverRegions = files.get(fileId).getRegions();

    byte[] emptyByteArrayRegionSize = new byte[(int) REGION_SIZE];
    byte[] slowDigestForWholeEmptyRegion = Base64.getEncoder().encode(emptyByteArrayRegionSize);

    for (Region serverRegion : serverRegions.values()) {
        long offset = serverRegion.getOffset();
        long size = serverRegion.getSize();

        Region region = clientRegions.computeIfAbsent(offset, (aLong) ->
                new Region(offset, size));
        region.setQuickDigest(0);
        if(region.getSize() == REGION_SIZE) {
            region.setSlowDigest(slowDigestForWholeEmptyRegion);
        } else {
            byte[] emptyArraySmallerSize = new byte[(int) region.getSize()];
            region.setSlowDigest(
                    Base64.getEncoder()
                            .encode(emptyArraySmallerSize));
        }
    }
}
 
Example 3
Project: odoxSync   File: Progress.java   View Source Code Vote up 6 votes
/**
 * Method handling HTTP GET requests. The returned object will be sent
 * to the client as "text/plain" media type.
 *
 * @return String that will be returned as a text/plain response.
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
public Map<Integer, List<FileProgress>> getIt() {
    ConcurrentHashMap<Integer, Client> clients = DirectorySynchronizer.INSTANCE.clients;
    ConcurrentHashMap<Integer, File> serverFiles = DirectorySynchronizer.INSTANCE.files;

    Map<Integer, List<FileProgress>> result = new HashMap<>();

    for (Client client : clients.values()) {

        List<FileProgress> fileProgresses = getFileProgresses(serverFiles, client);
        result.put(client.getId(), fileProgresses);
    }
    return result;
}
 
Example 4
Project: weex-uikit   File: WXSliderNeighbor.java   View Source Code Vote up 6 votes
/**
 * we do it in a hack way.
 * travel the dom tree, to get how many children does this slider-neighbor have.
 *
 * @return
 */
private int getNeighborChildrenCount() {

    try {
        WXDomManager domManager = WXSDKManager.getInstance().getWXDomManager();
        Field domRegistriesField = domManager.getClass().getDeclaredField("mDomRegistries");
        domRegistriesField.setAccessible(true);
        ConcurrentHashMap<String, Object> domRegistriesMap = (ConcurrentHashMap<String, Object>) domRegistriesField.get(domManager);
        Object domStatement = domRegistriesMap.get(getInstanceId()); // WXDomStatement
        Field mRegistryField = domStatement.getClass().getDeclaredField("mRegistry");
        mRegistryField.setAccessible(true);
        ConcurrentHashMap<String, WXDomObject> mRegistryMap = (ConcurrentHashMap<String, WXDomObject>) mRegistryField.get(domStatement);
        for(WXDomObject domObject : mRegistryMap.values()) {
            if(domObject.getType().equalsIgnoreCase(WXBasicComponentType.SLIDER_NEIGHBOR)) {
                int sum = 0;
                for (int i = 0,count = domObject.getChildCount(); i < count; i++) {
                    if(domObject.getChild(i) instanceof WXIndicator.IndicatorDomNode) {
                        continue;
                    }
                    sum++;
                }
                return sum;
            }
        }
    } catch (Exception e) {
        // ignore
    }

    return -1;

}
 
Example 5
Project: reading-and-annotate-rocketmq-3.4.6   File: DefaultMessageStore.java   View Source Code Vote up 6 votes
@Override
public int cleanUnusedTopic(Set<String> topics) {
    Iterator<Entry<String, ConcurrentHashMap<Integer, ConsumeQueue>>> it = this.consumeQueueTable.entrySet().iterator();
    while (it.hasNext()) {
        Entry<String, ConcurrentHashMap<Integer, ConsumeQueue>> next = it.next();
        String topic = next.getKey();
        if (!topics.contains(topic) && !topic.equals(ScheduleMessageService.SCHEDULE_TOPIC)) {
            ConcurrentHashMap<Integer, ConsumeQueue> queueTable = next.getValue();
            for (ConsumeQueue cq : queueTable.values()) {
                cq.destroy();
                log.info("cleanUnusedTopic: {} {} ConsumeQueue cleaned",//
                    cq.getTopic(), //
                    cq.getQueueId() //
                );

                this.commitLog.removeQueurFromTopicQueueTable(cq.getTopic(), cq.getQueueId());
            }
            it.remove();

            log.info("cleanUnusedTopic: {},topic destroyed", topic);
        }
    }

    return 0;
}
 
Example 6
Project: apache-tomcat-7.0.73-with-comment   File: SlowQueryReport.java   View Source Code Vote up 6 votes
/**
 * Sort QueryStats by last invocation time
 * @param queries
 */
protected void removeOldest(ConcurrentHashMap<String,QueryStats> queries) {
    ArrayList<QueryStats> list = new ArrayList<QueryStats>(queries.values());
    Collections.sort(list, queryStatsComparator);
    int removeIndex = 0;
    while (queries.size() > maxQueries) {
        String sql = list.get(removeIndex).getQuery();
        queries.remove(sql);
        if (log.isDebugEnabled()) log.debug("Removing slow query, capacity reached:"+sql);
        removeIndex++;
    }
}
 
Example 7
Project: rmq4note   File: DefaultMessageStore.java   View Source Code Vote up 6 votes
@Override
public int cleanUnusedTopic(Set<String> topics) {
    Iterator<Entry<String, ConcurrentHashMap<Integer, ConsumeQueue>>> it = this.consumeQueueTable.entrySet().iterator();
    while (it.hasNext()) {
        Entry<String, ConcurrentHashMap<Integer, ConsumeQueue>> next = it.next();
        String topic = next.getKey();

        if (!topics.contains(topic) && !topic.equals(ScheduleMessageService.SCHEDULE_TOPIC)) {
            ConcurrentHashMap<Integer, ConsumeQueue> queueTable = next.getValue();
            for (ConsumeQueue cq : queueTable.values()) {
                cq.destroy();
                log.info("cleanUnusedTopic: {} {} ConsumeQueue cleaned", //
                    cq.getTopic(), //
                    cq.getQueueId() //
                );

                this.commitLog.removeQueueFromTopicQueueTable(cq.getTopic(), cq.getQueueId());
            }
            it.remove();

            log.info("cleanUnusedTopic: {},topic destroyed", topic);
        }
    }

    return 0;
}
 
Example 8
Project: rmq4note   File: DefaultMessageStore.java   View Source Code Vote up 5 votes
private void recoverConsumeQueue() {
    for (ConcurrentHashMap<Integer, ConsumeQueue> maps : this.consumeQueueTable.values()) {
        for (ConsumeQueue logic : maps.values()) {
            logic.recover();
        }
    }
}
 
Example 9
Project: LiQ   File: MessageQueueHolder.java   View Source Code Vote up 5 votes
/**
 * recover topic message queue
 */
public void recoverMessageQueue() {
    for (ConcurrentHashMap<Integer, MessageQueueValue> mqs : mqMap.values()) {
        for (MessageQueueValue v : mqs.values()) {
            if (v.getMessageQueue() != null) {
                v.getMessageQueue().recover();
            }
        }
    }
}
 
Example 10
Project: rmq4note   File: DefaultMessageStore.java   View Source Code Vote up 5 votes
private void doFlush(int retryTimes) {
    //获取默认刷屏缓存页大小   2
    int flushConsumeQueueLeastPages = DefaultMessageStore.this.getMessageStoreConfig().getFlushConsumeQueueLeastPages();

    if (retryTimes == RETRY_TIMES_OVER) {
        flushConsumeQueueLeastPages = 0;
    }

    long logicsMsgTimestamp = 0;

    //彻底刷屏间隔  1000 * 60
    int flushConsumeQueueThoroughInterval = DefaultMessageStore.this.getMessageStoreConfig().getFlushConsumeQueueThoroughInterval();
    long currentTimeMillis = System.currentTimeMillis();
    if (currentTimeMillis >= (this.lastFlushTimestamp + flushConsumeQueueThoroughInterval)) {
        this.lastFlushTimestamp = currentTimeMillis;
        flushConsumeQueueLeastPages = 0;
        //获取存储检查点的物理消息时间戳
        logicsMsgTimestamp = DefaultMessageStore.this.getStoreCheckpoint().getLogicsMsgTimestamp();
    }

    ConcurrentHashMap<String, ConcurrentHashMap<Integer, ConsumeQueue>> tables = DefaultMessageStore.this.consumeQueueTable;

    for (ConcurrentHashMap<Integer, ConsumeQueue> maps : tables.values()) {
        //ConsumeQueue 自己维护物理存储抽象类
        for (ConsumeQueue cq : maps.values()) {
            boolean result = false;
            for (int i = 0; i < retryTimes && !result; i++) {
                result = cq.flush(flushConsumeQueueLeastPages);
            }
        }
    }

    if (0 == flushConsumeQueueLeastPages) {
        if (logicsMsgTimestamp > 0) {
            DefaultMessageStore.this.getStoreCheckpoint().setLogicsMsgTimestamp(logicsMsgTimestamp);
        }
        DefaultMessageStore.this.getStoreCheckpoint().flush();
    }
}
 
Example 11
Project: mycat-src-1.6.1-RELEASE   File: ShowSqlResultSet.java   View Source Code Vote up 5 votes
public static void execute(ManagerConnection c) {
    ByteBuffer buffer = c.allocate();

    // write header
    buffer = header.write(buffer, c,true);

    // write fields
    for (FieldPacket field : fields) {
        buffer = field.write(buffer, c,true);
    }

    // write eof
    buffer = eof.write(buffer, c,true);

    // write rows
    byte packetId = eof.packetId;     
    int i=0;
    Map<String, UserStat> statMap = UserStatAnalyzer.getInstance().getUserStatMap();
	for (UserStat userStat : statMap.values()) {
    	String user = userStat.getUser();        
    	ConcurrentHashMap<String, SqlResultSet> map=userStat.getSqlResultSizeRecorder().getSqlResultSet();
         if ( map != null ) { 
 	        for (SqlResultSet sqlResultSet:map.values()) {
 	        	RowDataPacket row = getRow(++i, user,sqlResultSet.getSql(), sqlResultSet.getCount(), sqlResultSet.getResultSetSize(),c.getCharset());
 	            row.packetId = ++packetId;
 	            buffer = row.write(buffer, c,true);
 	        }
         }
	}    
    // write last eof
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c,true);

    // write buffer
    c.write(buffer);
}
 
Example 12
Project: cljbuck   File: Rules.java   View Source Code Vote up 5 votes
private void addEdges(final Tracer tracer, final MutableGraph<BuildRule> graph, final ConcurrentHashMap<String, BuildRule> nodeMap) {
    tracer.info(started(hashCode).toString());
    for (final BuildRule buildRuleV : nodeMap.values()) {
        for (final String predecessor : buildRuleV.getDeps()) {
            final BuildRule buildRuleU = nodeMap.get(predecessor);
            if (null == buildRuleU) {
                System.err.println("Unable to find " + predecessor);
                continue;
            }
            graph.putEdge(buildRuleU, buildRuleV);
        }
    }
    tracer.info(finished(hashCode).toString());
}
 
Example 13
Project: rmq4note   File: DefaultMessageStore.java   View Source Code Vote up 5 votes
public void truncateDirtyLogicFiles(long phyOffset) {
    ConcurrentHashMap<String, ConcurrentHashMap<Integer, ConsumeQueue>> tables = DefaultMessageStore.this.consumeQueueTable;

    for (ConcurrentHashMap<Integer, ConsumeQueue> maps : tables.values()) {
        for (ConsumeQueue logic : maps.values()) {
            logic.truncateDirtyLogicFiles(phyOffset);
        }
    }
}
 
Example 14
Project: reading-and-annotate-rocketmq-3.4.6   File: DefaultMessageStore.java   View Source Code Vote up 5 votes
public void destroyLogics() {
    for (ConcurrentHashMap<Integer, ConsumeQueue> maps : this.consumeQueueTable.values()) {
        for (ConsumeQueue logic : maps.values()) {
            logic.destroy();
        }
    }
}
 
Example 15
Project: reading-and-annotate-rocketmq-3.4.6   File: DefaultMessageStore.java   View Source Code Vote up 5 votes
private void recoverTopicQueueTable() {
    HashMap<String/* topic-queueid */, Long/* offset */> table = new HashMap<String, Long>(1024);
    long minPhyOffset = this.commitLog.getMinOffset();
    for (ConcurrentHashMap<Integer, ConsumeQueue> maps : this.consumeQueueTable.values()) {
        for (ConsumeQueue logic : maps.values()) {
            String key = logic.getTopic() + "-" + logic.getQueueId();
            table.put(key, logic.getMaxOffsetInQuque());
            logic.correctMinOffset(minPhyOffset);
        }
    }

    this.commitLog.setTopicQueueTable(table);
}
 
Example 16
Project: reading-and-annotate-rocketmq-3.4.6   File: DefaultMessageStore.java   View Source Code Vote up 5 votes
private void recoverConsumeQueue() {
    for (ConcurrentHashMap<Integer, ConsumeQueue> maps : this.consumeQueueTable.values()) {
        for (ConsumeQueue logic : maps.values()) {
            logic.recover();
        }
    }
}
 
Example 17
Project: rmq4note   File: DefaultMessageStore.java   View Source Code Vote up 5 votes
private void recoverTopicQueueTable() {
    HashMap<String/* topic-queueid */, Long/* offset */> table = new HashMap<String, Long>(1024);
    //获取未删除,有效并且最旧的消息的开始位置
    long minPhyOffset = this.commitLog.getMinOffset();
    for (ConcurrentHashMap<Integer, ConsumeQueue> maps : this.consumeQueueTable.values()) {
        for (ConsumeQueue logic : maps.values()) {
            String key = logic.getTopic() + "-" + logic.getQueueId();
            //logic.getMaxOffsetInQueue():这里获取当前队列最大的逻辑位移(即已经持久化的最大的位置索引消息)
            table.put(key, logic.getMaxOffsetInQueue());
            logic.correctMinOffset(minPhyOffset);
        }
    }

    this.commitLog.setTopicQueueTable(table);
}
 
Example 18
Project: reading-and-annotate-rocketmq-3.4.6   File: DefaultMessageStore.java   View Source Code Vote up 5 votes
private void doFlush(int retryTimes) {

            int flushConsumeQueueLeastPages = DefaultMessageStore.this.getMessageStoreConfig().getFlushConsumeQueueLeastPages();

            if (retryTimes == RetryTimesOver) {
                flushConsumeQueueLeastPages = 0;
            }

            long logicsMsgTimestamp = 0;

            int flushConsumeQueueThoroughInterval = DefaultMessageStore.this.getMessageStoreConfig().getFlushConsumeQueueThoroughInterval();
            long currentTimeMillis = System.currentTimeMillis();
            if (currentTimeMillis >= (this.lastFlushTimestamp + flushConsumeQueueThoroughInterval)) {
                this.lastFlushTimestamp = currentTimeMillis;
                flushConsumeQueueLeastPages = 0;
                logicsMsgTimestamp = DefaultMessageStore.this.getStoreCheckpoint().getLogicsMsgTimestamp();
            }

            ConcurrentHashMap<String, ConcurrentHashMap<Integer, ConsumeQueue>> tables = DefaultMessageStore.this.consumeQueueTable;

            for (ConcurrentHashMap<Integer, ConsumeQueue> maps : tables.values()) {
                for (ConsumeQueue cq : maps.values()) {
                    boolean result = false;
                    for (int i = 0; i < retryTimes && !result; i++) {
                        result = cq.commit(flushConsumeQueueLeastPages);
                    }
                }
            }

            if (0 == flushConsumeQueueLeastPages) {
                if (logicsMsgTimestamp > 0) {
                    DefaultMessageStore.this.getStoreCheckpoint().setLogicsMsgTimestamp(logicsMsgTimestamp);
                }
                DefaultMessageStore.this.getStoreCheckpoint().flush();
            }
        }
 
Example 19
Project: MaxSim   File: MaxSimMaxineInfoBuilder.java   View Source Code Vote up 5 votes
private void buildMaxineDataTransInfo(MaxSimInterface.MaxineInfoDB.Builder maxineInfoDB) {
    ConcurrentHashMap<TypeDescriptor, MaxSimInterface.DataTransInfo.Builder> typeDescriptorToDataTransInfoMap =
        MaxSimDataTransformationScheme.getTypeDescriptorToDataTransInfoMap();
    for (MaxSimInterface.DataTransInfo.Builder dataTransInfoBuilder : typeDescriptorToDataTransInfoMap.values()) {
        if (dataTransInfoBuilder.hasTransTag()) {
            maxineInfoDB.addDataTransInfo(dataTransInfoBuilder);
        }
    }
}
 
Example 20
Project: rmq4note   File: DefaultMessageStore.java   View Source Code Vote up 5 votes
public void destroyLogics() {
    for (ConcurrentHashMap<Integer, ConsumeQueue> maps : this.consumeQueueTable.values()) {
        for (ConsumeQueue logic : maps.values()) {
            logic.destroy();
        }
    }
}