Package gov.nasa.arc.mct.buffer.util

Examples of gov.nasa.arc.mct.buffer.util.ElapsedTimer


    }

    @Override
    public Map<String, SortedMap<Long, Map<String, String>>> getData(Set<String> feedIDs, TimeUnit timeUnit, long startTime,
            long endTime) {
        final ElapsedTimer timer = new ElapsedTimer();
        timer.startInterval();
       
        Map<String, TreeMap<Long, Map<String, String>>> cachedData = getCachedData();
       
        Map<String, SortedMap<Long, Map<String, String>>> returnedData = new HashMap<String, SortedMap<Long, Map<String, String>>>();

        startTime = TimeUnit.NANOSECONDS.convert(startTime, timeUnit);
        endTime = TimeUnit.NANOSECONDS.convert(endTime, timeUnit);

        for (String feedID : feedIDs) {
            synchronized (this) {
                TreeMap<Long, Map<String, String>> feedCachedData = cachedData.get(feedID);
                if (feedCachedData == null) {
                    continue;
                }

                Map<Long, Map<String, String>> feedSearchedData = feedCachedData.subMap(startTime, true, endTime, true);
                if (feedSearchedData != null && !feedSearchedData.isEmpty()) {
                    SortedMap<Long, Map<String, String>> feedData = new TreeMap<Long, Map<String, String>>();
                    feedData.putAll(feedSearchedData);
                    returnedData.put(feedID, feedData);
                }
            }
        }
       
        timer.stopInterval();
        READ_PERF_LOGGER.debug("Time to get {} feeds from memory: {} from partition " + this.env.getCurrentBufferPartition(), feedIDs.size(), timer.getIntervalInMillis());

        return returnedData;
    }
View Full Code Here


        return cachedData == null;
    }

    @Override
    public Map<String, PartitionTimestamps> putData(Map<String, Map<Long, Map<String, String>>> value, TimeUnit timeUnit) {
        final ElapsedTimer timer = new ElapsedTimer();
        timer.startInterval();
       
        Map<String, PartitionTimestamps> timestamps = new HashMap<String, PartitionTimestamps>();
        Map<String, TreeMap<Long, Map<String, String>>> cachedData = getCachedData();

        for (Entry<String, Map<Long, Map<String, String>>> entry : value.entrySet()) {
            String feedID = entry.getKey();
            long largestTime = 0;
            long smallestTime = 0;
            synchronized (this) {
                TreeMap<Long, Map<String, String>> cachedFeedData = cachedData.get(feedID);
                if (cachedFeedData == null) {
                    cachedFeedData = new TreeMap<Long, Map<String, String>>(TIMESTAMP_COMPARATOR);
                    cachedData.put(feedID, cachedFeedData);
                }
                for (Entry<Long, Map<String, String>> feedData : entry.getValue().entrySet()) {
                    Long time = feedData.getKey();
                    time = TimeUnit.NANOSECONDS.convert(time, timeUnit);
                    LOGGER.debug("Putting data for feed {} with time {}", feedID, time);
                    if (time.longValue() > largestTime) {
                        largestTime = time.longValue();
                    }
                    if (smallestTime == 0) {
                        smallestTime = time.longValue();
                    } else if (time.longValue() < smallestTime) {
                        smallestTime = time.longValue();
                    }
                    Map<String, String> clonedFeedData = new HashMap<String, String>(feedData.getValue());
                    cachedFeedData.put(time, clonedFeedData);
                }
            }
            timestamps.put(feedID, new PartitionTimestamps(smallestTime, largestTime));
        }
       
       
        timer.stopInterval();
        WRITE_PERF_LOGGER.debug("Time to write {} feeds: {} from partition " + this.env.getCurrentBufferPartition(), value.size(), timer.getIntervalInMillis());

        return timestamps;
    }
View Full Code Here

        return timestamps;
    }
   
    @Override
    public void putData(Map<String, Map<Long, Map<String, String>>> value, TimeUnit timeUnit, MetaDataBuffer metadata, int metadataIndex) {
        final ElapsedTimer timer = new ElapsedTimer();
        timer.startInterval();
       
        Map<String, TreeMap<Long, Map<String, String>>> cachedData = getCachedData();

        for (Entry<String, Map<Long, Map<String, String>>> entry : value.entrySet()) {
            String feedID = entry.getKey();
            long largestTime = 0;
            long smallestTime = 0;
            synchronized (this) {
                TreeMap<Long, Map<String, String>> cachedFeedData = cachedData.get(feedID);
                if (cachedFeedData == null) {
                    cachedFeedData = new TreeMap<Long, Map<String, String>>(TIMESTAMP_COMPARATOR);
                    cachedData.put(feedID, cachedFeedData);
                }
                for (Entry<Long, Map<String, String>> feedData : entry.getValue().entrySet()) {
                    Long time = feedData.getKey();
                    time = TimeUnit.NANOSECONDS.convert(time, timeUnit);
                    LOGGER.debug("Putting data for feed {} with time {}", feedID, time);
                    if (time.longValue() > largestTime) {
                        largestTime = time.longValue();
                    }
                    if (smallestTime == 0) {
                        smallestTime = time.longValue();
                    } else if (time.longValue() < smallestTime) {
                        smallestTime = time.longValue();
                    }
                    Map<String, String> clonedFeedData = new HashMap<String, String>(feedData.getValue());
                    cachedFeedData.put(time, clonedFeedData);
                }
            }
            metadata.updatePartitionMetaData(metadataIndex, feedID, smallestTime, largestTime);
        }
       
       
        timer.stopInterval();
        if (WRITE_PERF_LOGGER.isDebugEnabled()) {
            WRITE_PERF_LOGGER.debug("Time to write {} feeds: {} from partition " + this.env.getCurrentBufferPartition(), value.size(), timer.getIntervalInMillis());
   
        }
    }
View Full Code Here

    }

    @Override
    public Map<String, List<Map<String, String>>> getData(Set<String> feedIDs, TimeUnit timeUnit, long startTime,
            long endTime) {
        final ElapsedTimer timer = new ElapsedTimer();
       
        feedIDs = new HashSet<String>(feedIDs);
        int feedSize = feedIDs.size();
        Map<String, List<Map<String, String>>> returnedData = new HashMap<String, List<Map<String,String>>>();
        for (DataProvider dataRetrieval : dataProviders) {
            timer.startInterval();

            Map<String, SortedMap<Long, Map<String, String>>> obtainedValues = dataRetrieval
                    .getData(feedIDs, startTime, endTime, timeUnit);
           
            for (Entry<String, SortedMap<Long, Map<String, String>>> entry: obtainedValues.entrySet()) {
                returnedData.put(entry.getKey(), new LinkedList<Map<String,String>>(entry.getValue().values()));
            }
            filterObtainedFeeds(dataRetrieval, feedIDs, obtainedValues, timeUnit, startTime);
           
            timer.stopInterval();
            READ_PERF_LOGGER.debug("Time to get {} feeds: {} ms from provider " + dataRetrieval.getLOS(), feedSize, timer.getIntervalInMillis());

            if (feedIDs.isEmpty()) { break; }
        }
        return returnedData;
    }
View Full Code Here

TOP

Related Classes of gov.nasa.arc.mct.buffer.util.ElapsedTimer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.