Package com.volantis.shared.time

Examples of com.volantis.shared.time.Period


        CacheBuilder builder = new CacheBuilderImpl();
        builder.setMaxCount(10);

        Cache cache = builder.buildCache();
        Period period = Period.inMilliSeconds(5000);

        Runnable runnable = new FinalizeRunnable(cache, period);

        Thread[] threads = new Thread[2];
        for (int i = 0; i < threads.length; i++) {
View Full Code Here


     */
    public synchronized StatisticsSnapshot getStatisticsSnapshot(
            Object source) {

        Time timestamp = clock.getCurrentTime();
        Period period = timestamp.getPeriodSince(creationTime);

        return new StatisticsSnapshotImpl(source, period, timestamp, hitCount,
                missAddedCount, removedCount);
    }
View Full Code Here

                iter.remove();
                headers.remove(oldHeader);
            }
        }
        // compute the current age
        final Period currentAge = state.getCurrentAge(clock.getCurrentTime());
        final long currentAgeLong = currentAge.inMillis() / 1000;
        final int currentAgeInt;
        if (currentAgeLong > Integer.MAX_VALUE) {
            currentAgeInt = Integer.MAX_VALUE;
        } else {
            currentAgeInt = (int) currentAgeLong;
View Full Code Here

        if (snapshot.source != source) {
            throw new IllegalArgumentException(
                    "Statistics not gathered from same source");
        }

        Period period = gatherTime.getPeriodSince(snapshot.gatherTime);
        if (period.inMillis() < 0) {
            throw new IllegalArgumentException("Other snapshot must have been " +
                    "gathered before this snapshot");
        }

        int deltaHitCount = getHitCount() - snapshot.getHitCount();
View Full Code Here

            cacheBuilder.setExpirationChecker(EXPIRATION_CHECKER);
            cache = cacheBuilder.buildCache();
            caches.put(name, cache);
        }

        final Period ttl;
        if ("unlimited".equals(maxAge)) {
            ttl = Period.INDEFINITELY;
        } else {
            int defaultMaxAge = 0;
            try {
View Full Code Here

    public void testReadFromFileNoTimeout() throws Exception {

        String expected = toString(URLContentManagerTestCase.class.
                                   getResourceAsStream("content.xml"));
        Period timeout = null;
        URLContent readContent = readFromFile("content.xml", timeout);
        String readContentAsString = toString(readContent.getInputStream());
        assertEquals(expected, readContentAsString);
    }
View Full Code Here

        final Timer timer = new Timer(true);
        timer.schedule(new RunnableTimerTask(
                new ThreadInterruptingTimingOutTask()), 500);

        Period timeout = null;
        try {

            // Reading the contents of a large file so that we can
            // test interrupting this thread before
            // read has completed.
View Full Code Here

    }

    public void testReadingFromStreamThatHasBeenTimedOut() throws Exception {

        // set a 1 second timeout.
        Period timeout = Period.inMilliSeconds(500);

        try {
            // Reading the contents of a large file so that we can
            // test the time out before the read has completed.
            URLContent readContent = readFromFile("content.xml", timeout);
View Full Code Here

    }

    public void testReadingFromStreamWithLongTimeOutPeriod() throws Exception {

        // set a 500 second timeout.
        Period timeout = Period.inSeconds(500);

        try {
            // Reading the contents of a large file so that we can
            // test the time out before the read has completed.
            URLContent readContent = readFromFile("content.xml", timeout);
View Full Code Here

        // Made this method static since it doesn't use an instance variables.
        // Made this method have default visibility to allow for testing.

        // @todo potentially this should be moved onto the CacheControl class.
        Period result;

        if (timeToLive == null ||
                CacheControl.LIVE_FOREVER.equals(timeToLive)) {
            result = Period.INDEFINITELY;
        } else {
View Full Code Here

TOP

Related Classes of com.volantis.shared.time.Period

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.