Package io.dropwizard.util

Examples of io.dropwizard.util.Duration


     *
     * @param registry the SchemeRegistry
     * @return a InstrumentedClientConnManger instance
     */
    protected NHttpClientConnectionManager createConnectionManager(SchemeRegistry registry, String name) {
        final Duration ttl = configuration.getTimeToLive();
        ConnectingIOReactor ioReactor = createDefaultIOReactor(IOReactorConfig.custom()
                .setSoTimeout((int) configuration.getTimeout().toMilliseconds())
                .setConnectTimeout((int) configuration.getConnectionTimeout().toMilliseconds())
                .setTcpNoDelay(true).build());

        PoolingNHttpClientConnectionManager manager
                = new InstrumentedNClientConnManager(
                        ioReactor, null, null, //TODO: add this parameters values
                        metricRegistry,
                        convertRegistry(this.registry),
                        ttl.getQuantity(),
                        ttl.getUnit(),
                        resolver,
                        name);
        manager.setDefaultMaxPerRoute(configuration.getMaxConnectionsPerRoute());
        manager.setMaxTotal(configuration.getMaxConnections());
        return manager;
View Full Code Here


        if (!_expire.isPresent() && !_maximumSize.isPresent()) {
            cacheBuilder.maximumSize(0);
        } else {
            if (_expire.isPresent()) {
                Duration expire = _expire.get();
                cacheBuilder.expireAfterWrite(expire.getQuantity(), expire.getUnit());
            }

            if (_maximumSize.isPresent()) {
                cacheBuilder
                        .weigher(CachedResponseWeigher.INSTANCE)
View Full Code Here

     * @param name
     * @return a InstrumentedHttpClientConnectionManger instance
     */
    protected InstrumentedHttpClientConnectionManager createConnectionManager(Registry<ConnectionSocketFactory> registry,
                                                                              String name) {
        final Duration ttl = configuration.getTimeToLive();
        final InstrumentedHttpClientConnectionManager manager = new InstrumentedHttpClientConnectionManager(
                metricRegistry,
                registry,
                null, null,
                resolver,
                ttl.getQuantity(),
                ttl.getUnit(),
                name);
        return configureConnectionManager(manager);
    }
View Full Code Here

        }).when(executor).execute(Mockito.any(Runnable.class));
        //Mock the StreamProcessor - Throws Unrecoverable IllegalStateException
        StreamProcessor processor = Mockito.mock(StreamProcessor.class);
        final boolean shutDownServerOnUnrecoverableError = true;
        final int maxRetries = 3;
        final Duration durationForResettingErrorHandlingState = Duration.milliseconds(50);
        Mockito.doThrow(new RuntimeException()).
                doThrow(new RuntimeException()).
                doThrow(new RuntimeException()).
                doThrow(new RuntimeException()).
                doThrow(new RuntimeException()).
View Full Code Here

        }).when(executor).execute(Mockito.any(Runnable.class));
        //Mock the StreamProcessor - Throws Unrecoverable IllegalStateException
        StreamProcessor processor = Mockito.mock(StreamProcessor.class);
        final boolean shutDownServerOnUnrecoverableError = true;
        final int maxRetries = 3;
        final Duration durationForResettingErrorHandlingState = Duration.milliseconds(50);
        Mockito.doThrow(new RuntimeException()).
                doThrow(new RuntimeException()).
                doThrow(new RuntimeException()).
                doThrow(new RuntimeException()).
                doThrow(new RuntimeException()).
View Full Code Here

            }
            if (fieldValue.isTextual()) {
                try {
                    Time time = prop.getAnnotation(Time.class);
                    if (time != null) {
                        Duration dropWizardDuration = Duration.parse(fieldValue.asText());
                        long asLong = time.value().convert(dropWizardDuration.getQuantity(), dropWizardDuration.getUnit());
                        fieldValues.put(propertyName, asLong);
                    } else if (prop.getAnnotation(Bytes.class) != null) {
                        Size dropWizardSize = Size.parse(fieldValue.asText());
                        long asLong = dropWizardSize.toBytes();
                        fieldValues.put(propertyName, asLong);
View Full Code Here

            }
            if (fieldValue.isTextual()) {
                try {
                    Time time = prop.getAnnotation(Time.class);
                    if (time != null) {
                        Duration dropWizardDuration = Duration.parse(fieldValue.asText());
                        long asLong = time.value().convert(dropWizardDuration.getQuantity(), dropWizardDuration.getUnit());
                        fieldValues.put(propertyName, asLong);
                    } else if (prop.getAnnotation(Bytes.class) != null) {
                        Size dropWizardSize = Size.parse(fieldValue.asText());
                        long asLong = dropWizardSize.toBytes();
                        fieldValues.put(propertyName, asLong);
View Full Code Here

                    // sometimes we erroneously get strings that would parse into valid numbers and maybe other edge
                    // cases (eg. when using system property overrides in typesafe-config). So we'll go ahead and guard
                    // with this regex to make sure we only get reasonable candidates.
                    Time time = prop.getAnnotation(Time.class);
                    if ((time != null) && NUMBER_UNIT.matcher(fieldValue.textValue()).matches()) {
                        Duration dropWizardDuration = Duration.parse(fieldValue.asText());
                        long asLong = time.value().convert(dropWizardDuration.getQuantity(), dropWizardDuration.getUnit());
                        fieldValues.put(propertyName, asLong);
                    } else if ((prop.getAnnotation(Bytes.class) != null) &&
                               NUMBER_UNIT.matcher(fieldValue.textValue()).matches()) {
                        Size dropWizardSize = Size.parse(fieldValue.asText());
                        long asLong = dropWizardSize.toBytes();
View Full Code Here

TOP

Related Classes of io.dropwizard.util.Duration

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.