Example usage for java.util.concurrent ConcurrentMap get

List of usage examples for java.util.concurrent ConcurrentMap get

Introduction

In this page you can find the example usage for java.util.concurrent ConcurrentMap get.

Prototype

V get(Object key);

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:hr.diskobolos.service.impl.DashboardServiceImpl.java

private DashboardDto.TermsOfCompetitionStatistic fetchTermsOfCompetitionStatistic() {

    DashboardDto.TermsOfCompetitionStatistic termsOfCompetitionStatisticData = new DashboardDto.TermsOfCompetitionStatistic();
    long numberOfMemberRegistersWithoutTerms = evalautionAnswerPersistence
            .fetchNumberOfMemberRegistersWithoutTerms();
    ConcurrentMap<TermsOfConditionStatus, AtomicLong> termsOfCompetitionStatistic = evalautionAnswerPersistence
            .fetchTermsOfCompetitionStatistic();

    long totalNumberOfUnfulfilledQuestionnaires = (termsOfCompetitionStatistic
            .get(TermsOfConditionStatus.NONE) != null
                    ? termsOfCompetitionStatistic.get(TermsOfConditionStatus.NONE).longValue()
                    : 0)/*from  w w w . ja  v a  2  s  . co m*/
            + numberOfMemberRegistersWithoutTerms;
    termsOfCompetitionStatisticData.setNumberOfUnfulfilledTerms(totalNumberOfUnfulfilledQuestionnaires);
    termsOfCompetitionStatisticData.setNumberOfMembersWithValidTerms(
            (termsOfCompetitionStatistic.get(TermsOfConditionStatus.VALID) != null
                    ? termsOfCompetitionStatistic.get(TermsOfConditionStatus.VALID).longValue()
                    : 0));
    termsOfCompetitionStatisticData.setNumberOfMembersWithInvalidTerms(
            (termsOfCompetitionStatistic.get(TermsOfConditionStatus.INVALID) != null
                    ? termsOfCompetitionStatistic.get(TermsOfConditionStatus.INVALID).longValue()
                    : 0));
    return termsOfCompetitionStatisticData;
}

From source file:org.opendaylight.ovsdb.plugin.internal.NodeDatabase.java

public void printTableCache() {
    for (String dbName : dbCache.keySet()) {
        System.out.println("Database " + dbName);
        ConcurrentMap<String, ConcurrentMap<String, Row>> tableDB = this.getDatabase(dbName);
        if (tableDB == null) {
            continue;
        }/*from   www .j av a2 s  .  c  o  m*/
        for (String tableName : tableDB.keySet()) {
            ConcurrentMap<String, Row> tableRows = this.getTableCache(dbName, tableName);
            System.out.println("\tTable " + tableName);
            for (String uuid : tableRows.keySet()) {
                Row row = tableRows.get(uuid);
                Collection<Column> columns = row.getColumns();
                System.out.print("\t\t" + uuid + "==");
                for (Column column : columns) {
                    if (column.getData() != null) {
                        System.out.print(column.getSchema().getName() + " : " + column.getData() + " ");
                    }
                }
                System.out.println("");
            }
            System.out.println("-----------------------------------------------------------");
        }
    }
}

From source file:org.marketcetera.photon.PhotonPositionMarketData.java

private BigDecimal getCachedValue(final ConcurrentMap<Instrument, BigDecimal> cache, final Instrument symbol) {
    BigDecimal cached = cache.get(symbol);
    return cached == NULL ? null : cached;
}

From source file:com.weibo.api.motan.util.StatsUtil.java

public static void logAccessStatistic(boolean clear) {
    DecimalFormat mbFormat = new DecimalFormat("#0.00");
    long currentTimeMillis = System.currentTimeMillis();

    ConcurrentMap<String, AccessStatisticResult> totalResults = new ConcurrentHashMap<String, AccessStatisticResult>();

    for (Map.Entry<String, AccessStatisticItem> entry : accessStatistics.entrySet()) {
        AccessStatisticItem item = entry.getValue();

        AccessStatisticResult result = item.getStatisticResult(currentTimeMillis,
                MotanConstants.STATISTIC_PEROID);

        if (clear) {
            item.clearStatistic(currentTimeMillis, MotanConstants.STATISTIC_PEROID);
        }// w w  w  .j  a va 2 s.co  m

        String key = entry.getKey();
        String[] keys = key.split(SEPARATE);
        if (keys.length != 3) {
            continue;
        }
        String application = keys[1];
        String module = keys[2];
        key = application + "|" + module;
        AccessStatisticResult appResult = totalResults.get(key);
        if (appResult == null) {
            totalResults.putIfAbsent(key, new AccessStatisticResult());
            appResult = totalResults.get(key);
        }

        appResult.totalCount += result.totalCount;
        appResult.bizExceptionCount += result.bizExceptionCount;
        appResult.slowCount += result.slowCount;
        appResult.costTime += result.costTime;
        appResult.bizTime += result.bizTime;
        appResult.otherExceptionCount += result.otherExceptionCount;

        Snapshot snapshot = InternalMetricsFactory.getRegistryInstance(entry.getKey()).histogram(HISTOGRAM_NAME)
                .getSnapshot();

        if (application.equals(APPLICATION_STATISTIC)) {
            continue;
        }
        if (result.totalCount == 0) {
            LoggerUtil.accessStatsLog("[motan-accessStatistic] app: " + application + " module: " + module
                    + " item: " + keys[0]
                    + " total_count: 0 slow_count: 0 biz_excp: 0 other_excp: 0 avg_time: 0.00ms biz_time: 0.00ms avg_tps: 0 max_tps: 0 min_tps: 0");
        } else {
            LoggerUtil.accessStatsLog(
                    "[motan-accessStatistic] app: {} module: {} item: {} total_count: {} slow_count: {} p75: {} p95: {} p98: {} p99: {} p999: {} biz_excp: {} other_excp: {} avg_time: {}ms biz_time: {}ms avg_tps: {} max_tps: {} min_tps: {} ",
                    application, module, keys[0], result.totalCount, result.slowCount,
                    mbFormat.format(snapshot.get75thPercentile()),
                    mbFormat.format(snapshot.get95thPercentile()),
                    mbFormat.format(snapshot.get98thPercentile()),
                    mbFormat.format(snapshot.get99thPercentile()),
                    mbFormat.format(snapshot.get999thPercentile()), result.bizExceptionCount,
                    result.otherExceptionCount, mbFormat.format(result.costTime / result.totalCount),
                    mbFormat.format(result.bizTime / result.totalCount),
                    (result.totalCount / MotanConstants.STATISTIC_PEROID), result.maxCount, result.minCount);
        }

    }

    if (!totalResults.isEmpty()) {
        for (Map.Entry<String, AccessStatisticResult> entry : totalResults.entrySet()) {
            String application = entry.getKey().split(SEPARATE)[0];
            String module = entry.getKey().split(SEPARATE)[1];
            AccessStatisticResult totalResult = entry.getValue();
            Snapshot snapshot = InternalMetricsFactory.getRegistryInstance(entry.getKey())
                    .histogram(HISTOGRAM_NAME).getSnapshot();
            if (totalResult.totalCount > 0) {
                LoggerUtil.accessStatsLog(
                        "[motan-totalAccessStatistic] app: {} module: {} total_count: {} slow_count: {} p75: {} p95: {} p98: {} p99: {} p999: {} biz_excp: {} other_excp: {} avg_time: {}ms biz_time: {}ms avg_tps: {}",
                        application, module, totalResult.totalCount, totalResult.slowCount,
                        mbFormat.format(snapshot.get75thPercentile()),
                        mbFormat.format(snapshot.get95thPercentile()),
                        mbFormat.format(snapshot.get98thPercentile()),
                        mbFormat.format(snapshot.get99thPercentile()),
                        mbFormat.format(snapshot.get999thPercentile()), totalResult.bizExceptionCount,
                        totalResult.otherExceptionCount,
                        mbFormat.format(totalResult.costTime / totalResult.totalCount),
                        mbFormat.format(totalResult.bizTime / totalResult.totalCount),
                        (totalResult.totalCount / MotanConstants.STATISTIC_PEROID));
            } else {
                LoggerUtil.accessStatsLog("[motan-totalAccessStatistic] app: " + application + " module: "
                        + module
                        + " total_count: 0 slow_count: 0 biz_excp: 0 other_excp: 0 avg_time: 0.00ms biz_time: 0.00ms avg_tps: 0");
            }

        }
    } else {
        LoggerUtil.accessStatsLog("[motan-totalAccessStatistic] app: " + URLParamType.application.getValue()
                + " module: " + URLParamType.module.getValue()
                + " total_count: 0 slow_count: 0 biz_excp: 0 other_excp: 0 avg_time: 0.00ms biz_time: 0.00ms avg_tps: 0");
    }

}

From source file:com.opengamma.component.ComponentConfigLoader.java

/**
 * Extracts any properties that start with "INI.".
 * <p>//from w w w.  j  ava2 s . c  om
 * These directly override any INI file settings.
 * 
 * @param properties  the properties, not null
 * @return the extracted set of INI properties, not null
 */
private Map<String, String> extractIniProperties(ConcurrentMap<String, String> properties) {
    Map<String, String> extracted = new HashMap<String, String>();
    for (String key : properties.keySet()) {
        if (key.startsWith("INI.") && key.substring(4).contains(".")) {
            extracted.put(key.substring(4), properties.get(key));
        }
    }
    return extracted;
}

From source file:org.onosproject.store.trivial.impl.SimpleFlowRuleStore.java

private List<StoredFlowEntry> getFlowEntries(DeviceId deviceId, FlowId flowId) {
    final ConcurrentMap<FlowId, List<StoredFlowEntry>> flowTable = getFlowTable(deviceId);
    List<StoredFlowEntry> r = flowTable.get(flowId);
    if (r == null) {
        final List<StoredFlowEntry> concurrentlyAdded;
        r = new CopyOnWriteArrayList<>();
        concurrentlyAdded = flowTable.putIfAbsent(flowId, r);
        if (concurrentlyAdded != null) {
            return concurrentlyAdded;
        }// w ww .ja  v  a2 s  .  co m
    }
    return r;
}

From source file:com.fhzz.dubbo.service.impl.ConsumerServiceImpl.java

public List<String> findApplicationsByServiceName(String service) {
    List<String> ret = new ArrayList<String>();
    ConcurrentMap<String, Map<Long, URL>> consumerUrls = getRegistryCache().get(Constants.CONSUMERS_CATEGORY);
    if (consumerUrls == null)
        return ret;

    Map<Long, URL> value = consumerUrls.get(service);
    if (value == null) {
        return ret;
    }//from   w  w  w .  ja  va  2s . c o  m
    for (Map.Entry<Long, URL> e2 : value.entrySet()) {
        URL u = e2.getValue();
        String app = u.getParameter(Constants.APPLICATION_KEY);
        if (app != null)
            ret.add(app);
    }

    return ret;
}

From source file:com.ejisto.event.listener.SessionRecorderManager.java

private <K, V> boolean replace(K key, ConcurrentMap<K, Set<V>> container, Set<V> newValue) {
    int counter = 10;
    while (counter-- > 0) {
        Set<V> currentValue = container.get(key);
        Set<V> copy = new HashSet<>(currentValue);
        copy.addAll(newValue);/*from   ww w  . j  a  va  2 s .co m*/
        if (container.replace(key, currentValue, copy)) {
            return true;
        }
    }
    return false;
}

From source file:com.fhzz.dubbo.service.impl.ConsumerServiceImpl.java

public List<String> findAddressesByService(String service) {
    List<String> ret = new ArrayList<String>();
    ConcurrentMap<String, Map<Long, URL>> consumerUrls = getRegistryCache().get(Constants.CONSUMERS_CATEGORY);
    if (null == consumerUrls)
        return ret;

    for (Map.Entry<Long, URL> e2 : consumerUrls.get(service).entrySet()) {
        URL u = e2.getValue();// w w  w  . j a v  a2s.c om
        String app = u.getAddress();
        if (app != null)
            ret.add(app);
    }

    return ret;
}

From source file:org.jtalks.jcommune.plugin.auth.poulpe.service.PoulpeAuthService.java

@SuppressWarnings("unchecked")
private void writeRequestInfoToLog(ClientResource clientResource) {
    ConcurrentMap<String, Object> attrs = clientResource.getRequest().getAttributes();
    Series<Header> headers = (Series<Header>) attrs.get(HeaderConstants.ATTRIBUTE_HEADERS);
    logger.info("Request to Poulpe: requested URI - {}, request headers - {}, request body - {}", new Object[] {
            clientResource.getRequest().getResourceRef(), headers, clientResource.getRequest() });
}