Package com.volantis.shared.time

Examples of com.volantis.shared.time.Time


            }
        };

        builder.setMethodAccessor(accessor);

        Time t = Time.inMilliSeconds(System.currentTimeMillis());
        builder.setRequestTime(t);
        builder.setResponseTime(t);
        final CachedHttpContentState state = builder.build();

        // A mock Representation that adds a "default" timeout to local and
View Full Code Here


        try {
            SelectionKey key = channel.register(selector,
                    SelectionKey.OP_CONNECT);

            Period timeRemaining = connectionTimeout;
            Time startTime = clock.getCurrentTime();

            boolean connected = false;
            while (!connected) {
                long timeout = timeRemaining.inMillisTreatIndefinitelyAsZero();
                int keys = selector.select(timeout);
                if (keys == 0) {
                    // Selector woken up, check to see whether it has timed out.
                    Time now = clock.getCurrentTime();
                    Period elapsed = now.getPeriodSince(startTime);
                    if (Comparator.GE.compare(
                            elapsed, timeRemaining)) {
                        // Timed out so fail.
                        throw new ConnectException("Timed out");
                    } else {
View Full Code Here

                    (CachedHttpContentState) entry.getExtensionObject();
                if (existingState != null) {
                    // this is a validation
                    // set the If-Modified-Since header using the stored
                    // last modified value (if there is any)
                    final Time lastModified = existingState.getLastModified();
                    if (lastModified != null) {
                        final String lastModifiedAsString;
                        // SimpleDateFormat is not thread safe
                        synchronized (RFC1123) {
                            lastModifiedAsString = RFC1123.format(
                                new Date(lastModified.inMillis()));
                        }
                        final Header header =
                            new HeaderImpl(HeaderNames.IF_MODIFIED_SINCE_HEADER);
                        header.setValue(lastModifiedAsString);
                        executor.addRequestHeader(header);
View Full Code Here

                    (CachedHttpContentState) entry.getExtensionObject();
                if (existingState != null) {
                    // this is a validation
                    // set the If-Modified-Since header using the stored
                    // last modified value (if there is any)
                    final Time lastModified = existingState.getLastModified();
                    if (lastModified != null) {
                        final String lastModifiedAsString;
                        // SimpleDateFormat is not thread safe so create a
                        // new instance
                        DateFormat RFC1123 = DateFormats.RFC_1123_GMT.create();

                        lastModifiedAsString = RFC1123.format(
                            new Date(lastModified.inMillis()));

                        method.setRequestHeader(HEADER_IF_MODIFIED_SINCE,
                            lastModifiedAsString);
                    }
View Full Code Here

     * @param headerName the name of the header
     * @return the time or null
     */
    private Time getHeaderAsTime(final String headerName) {
        final Header header = getHeader(headerName);
        Time result = null;
        if (header != null) {
            try {
                result = Time.inMilliSeconds(
                    DateParser.parseDate(header.getValue()).getTime());
            } catch (DateParseException e) {
View Full Code Here

     *         groups.
     */
    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

                            this.state =
                                CacheBodyOperationProcessState.PLAYBACK_AND_SUPPRESS;

                            final SystemClock clock =
                                SystemClock.getDefaultInstance();
                            final Time currentTime = clock.getCurrentTime();
                            final PipelineCacheState pcs =
                                new PipelineCacheState(currentTime.addPeriod(
                                    dependency.getTimeToLive()));
                            dependencyContext.addDependency(dependency);

                            // update the cache with the old value so other
                            // threads don't need to wait the timeout period
View Full Code Here

            (HttpServletResponse) requestContext.getResponse();
        if (cachingDirectives != null && cachingDirectives.isEnabled() &&
            cachingDirectives.getExpires() != null) {
            // if enabled, set Expires, Cache-Control/max-age and Vary response
            // headers
            final Time expires = cachingDirectives.getExpires();
            if (expires != Time.NEVER) {
                response.addDateHeader("Expires", expires.inMillis());
                // compute max-age value
                final Period timeToLive = cachingDirectives.getTimeToLive();
                long maxAgeInSeconds = 0;
                if (timeToLive != null) {
                    maxAgeInSeconds =
View Full Code Here

     * @param priority the priority
     * @return true if the call changed the time of expiry
     */
    public boolean setMaxAge(final Period period, final Priority priority) {
        checkClosed();
        final Time time = clock.getCurrentTime().addPeriod(period);
        return setExpires(time, priority);
    }
View Full Code Here

    // Javadoc inherited.
    public HttpStatusCode execute() throws IOException {

        // Log the time it took to retrieve the object and if the object
        // retrieval was successful if debug logging is enabled.
        Time startTime = clock.getCurrentTime();

        HttpStatusCode code = null;
        try {
            code = executer.execute(method);
        } catch (InterruptedIOException e) {
            // Connection timed out.
                code = HttpStatusCode.RESPONSE_TIMED_OUT;
                if (logger.isErrorEnabled()) {
                    logger.error("Received exception but assumed timed out", e);
                }

        }

        if (logger.isDebugEnabled()) {
            if (code == HttpStatusCode.RESPONSE_TIMED_OUT) {
                String message = "Remote request to '" + url +
                        "' timed-out " +
                        "at " + connectionTimeout + "milliseconds.";
                logger.debug(message);
            } else {
                Time now = clock.getCurrentTime();
                Period retrievalDuration = now.getPeriodSince(startTime);
                String message = "Remote request to '" + url +
                        "' retrieval time was " +
                        retrievalDuration + ".";
                logger.debug(message);
            }
View Full Code Here

TOP

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

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.