Example usage for java.lang Integer getInteger

List of usage examples for java.lang Integer getInteger

Introduction

In this page you can find the example usage for java.lang Integer getInteger.

Prototype

public static Integer getInteger(String nm, Integer val) 

Source Link

Document

Returns the integer value of the system property with the specified name.

Usage

From source file:org.apache.pdfbox.pdfparser.BaseParser.java

/**
 * Constructor./*from w w  w.j a  va 2 s  .  c o  m*/
 *
 * @since Apache PDFBox 1.3.0
 * @param input The input stream to read the data from.
 * @param forceParsingValue flag to skip malformed or otherwise unparseable
 *                     input where possible
 * @throws IOException If there is an error reading the input stream.
 */
public BaseParser(InputStream input, boolean forceParsingValue) throws IOException {
    this.pdfSource = new PushBackInputStream(new BufferedInputStream(input, 16384),
            Integer.getInteger(PROP_PUSHBACK_SIZE, 65536));
    this.forceParsing = forceParsingValue;
}

From source file:at.gv.egovernment.moa.id.configuration.config.ConfigurationProvider.java

public int getUserRequestCleanUpDelay() {
    String delay = props.getProperty("general.userrequests.cleanup.delay");
    return Integer.getInteger(delay, 12);
}

From source file:org.apache.felix.http.itest.BaseIntegrationTest.java

protected static URL createURL(String path) {
    if (path == null) {
        path = "";
    }/*from   w w w .j a  va  2 s .c om*/
    while (path.startsWith("/")) {
        path = path.substring(1);
    }
    int port = Integer.getInteger("org.osgi.service.http.port", 8080);
    try {
        return new URL(String.format("http://localhost:%d/%s", port, path));
    } catch (MalformedURLException e) {
        throw new RuntimeException(e);
    }
}

From source file:xbird.xquery.misc.PagedStringChunk2.java

private Map<MutableString, Long> reconstruct(VarSegments paged) {
    String fileName = paged.getFile().getAbsolutePath() + CACHE_FILE_SUFFIX;
    final Map<MutableString, Long> map = _constructMapCache.get(fileName);
    if (map != null) {
        return map;
    }/*ww  w.j a  v  a  2s  . co m*/
    File cacheFile = new File(fileName);
    if (!cacheFile.exists()) {
        return new LRUMap<MutableString, Long>(Integer.getInteger("xbird.strchk.cmapsize", 32768));
    }
    final FileInputStream fis;
    try {
        fis = new FileInputStream(cacheFile);
    } catch (FileNotFoundException e) {
        throw new IllegalStateException(e);
    }
    final FastBufferedInputStream bis = new FastBufferedInputStream(fis);
    Object obj = ObjectUtils.readObjectQuietly(bis);
    return (Map<MutableString, Long>) obj;
}

From source file:com.partnet.automation.selenium.AbstractConfigurableDriverProvider.java

/**
 * This is the default implementation of getting a web driver.
 * //from  w  w  w.  j  av a 2s.c  o  m
 * Use this as a quick start guide for
 * {@link AbstractConfigurableDriverProvider#getWebDriver(Browser)}
 * 
 * @param browser browser to obtain
 * @return instance of the specific WebDriver
 */
protected WebDriver getDefaultWebDriver(Browser browser) {
    Objects.requireNonNull(browser, "browser cannot be null");

    WebDriver driver;
    boolean useRemoteBrowser = (getRemoteSeleniumUrlString() != null);

    LOG.debug("Initialize: '{}' using remote browser: '{}'", browser, useRemoteBrowser);
    switch (browser) {
    case IE:
        driver = useRemoteBrowser ? getRemoteInternetExplorerWebDriver() : getInternetExplorerWebDriver();
        break;

    case CHROME:
        driver = useRemoteBrowser ? getRemoteChromeWebDriver() : getChromeWebDriver();
        break;

    case FIREFOX:

        driver = useRemoteBrowser ? getRemoteFirefoxWebDriver() : getFirefoxWebDriver();
        break;

    case PHANTOMJS:
        driver = useRemoteBrowser ? getRemotePhantomJsWebDriver() : getPhantomJsWebDriver();
        break;

    case HTMLUNIT:
        if (useRemoteBrowser) {

            // Don't throw here, in case running with a Grid.
            LOG.info("Running HTMUNIT on the grid is NOT supported! If you want to take the time to create "
                    + "a HTTP connection to the grid, you might as well just use PhantomJs. ");
        }

        driver = getHtmlUnitWebDriver();
        break;

    case ANDROID:
        driver = getRemoteAndroidWebDriver();
        break;

    default:
        throw new IllegalArgumentException(String.format("Unsupported browser: '%s'", browser.name()));
    }

    LOG.debug("Using WebDriver implementation of type : {}", driver.getClass());

    if (!browser.isAndroid()) {
        driver.manage().timeouts().pageLoadTimeout(Integer.getInteger(PAGE_LOAD_TIMEOUT_SECONDS, 120),
                TimeUnit.SECONDS);
    }

    return driver;
}

From source file:org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor.java

public ClusterMonitor(Cluster cluster, boolean hasScalingDependents, boolean groupScalingEnabledSubtree,
        String deploymentPolicyId) {

    scheduler = StratosThreadPool.getScheduledExecutorService(AutoscalerConstants.CLUSTER_MONITOR_SCHEDULER_ID,
            50);//from   w w  w.  ja  v a 2  s  .  c om
    int threadPoolSize = Integer.getInteger(AutoscalerConstants.MONITOR_THREAD_POOL_SIZE, 100);
    executorService = StratosThreadPool.getExecutorService(AutoscalerConstants.MONITOR_THREAD_POOL_ID,
            threadPoolSize);
    this.clusterId = cluster.getClusterId();
    readConfigurations();
    this.groupScalingEnabledSubtree = groupScalingEnabledSubtree;
    this.setCluster(new Cluster(cluster));
    this.serviceType = cluster.getServiceName();
    this.monitoringStarted = new AtomicBoolean(false);
    this.hasScalingDependents = hasScalingDependents;
    this.deploymentPolicyId = deploymentPolicyId;
}

From source file:org.apache.stratos.cloud.controller.iaases.openstack.networking.NovaNetworkingApi.java

@Override
public String associatePredefinedAddress(NodeMetadata node, String ip) {
    if (log.isDebugEnabled()) {
        log.debug(String.format("Trying to associate predefined IP address: [node-id] %s [ip] %s", node.getId(),
                ip));// w  ww. j a v  a2  s  .co m
    }

    ComputeServiceContext context = iaasProvider.getComputeService().getContext();
    String region = ComputeServiceBuilderUtil.extractRegion(iaasProvider);

    FloatingIPApi floatingIPApi = context.unwrapApi(NovaApi.class).getFloatingIPExtensionForZone(region).get();

    // get the list of all unassigned IP.
    ArrayList<FloatingIP> unassignedFloatingIPs = Lists
            .newArrayList(Iterables.filter(floatingIPApi.list(), new Predicate<FloatingIP>() {
                @Override
                public boolean apply(FloatingIP floatingIP) {
                    return StringUtils.isEmpty(floatingIP.getFixedIp());
                }
            }));

    boolean isAvailable = false;
    for (FloatingIP floatingIP : unassignedFloatingIPs) {
        if (log.isDebugEnabled()) {
            log.debug("OpenstackNovaIaas:associatePredefinedAddress:iterating over available floatingip:"
                    + floatingIP);
        }
        if (ip.equals(floatingIP.getIp())) {
            if (log.isDebugEnabled()) {
                log.debug(String.format(
                        "OpenstackNovaIaas:associatePredefinedAddress:floating ip in use:%s /ip:%s", floatingIP,
                        ip));
            }
            isAvailable = true;
            break;
        }
    }

    if (isAvailable) {
        // assign ip
        if (log.isDebugEnabled()) {
            log.debug("OpenstackNovaIaas:associatePredefinedAddress:assign floating ip:" + ip);
        }
        // exercise same code as in associateAddress()
        // wait till the fixed IP address gets assigned - this is needed before
        // we associate a public IP

        while (node.getPrivateAddresses() == null) {
            CloudControllerUtil.sleep(1000);
        }

        int retries = 0;
        int retryCount = Integer.getInteger("stratos.public.ip.association.retry.count", 5);
        while (retries < retryCount && !associateIp(floatingIPApi, ip, node.getProviderId())) {
            // wait for 5s
            CloudControllerUtil.sleep(5000);
            retries++;
        }

        NodeMetadataBuilder.fromNodeMetadata(node).publicAddresses(ImmutableSet.of(ip)).build();
        log.info(String.format("Successfully associated predefined IP address: [node-id] %s [ip] %s ",
                node.getId(), ip));
        return ip;
    } else {
        log.warn(String.format("Could not associate predefined IP address: [node-id] %s [ip] %s ", node.getId(),
                ip));
        return null;
    }
}

From source file:org.apache.solr.client.solrj.impl.HttpClientUtil.java

/**
 * Creates new http client by using the provided configuration.
 * //  w  w  w  . j a v  a 2s  . com
 */
public static CloseableHttpClient createClient(final SolrParams params, PoolingHttpClientConnectionManager cm,
        boolean sharedConnectionManager) {
    final ModifiableSolrParams config = new ModifiableSolrParams(params);
    if (logger.isDebugEnabled()) {
        logger.debug("Creating new http client, config:" + config);
    }

    cm.setMaxTotal(params.getInt(HttpClientUtil.PROP_MAX_CONNECTIONS, 10000));
    cm.setDefaultMaxPerRoute(params.getInt(HttpClientUtil.PROP_MAX_CONNECTIONS_PER_HOST, 10000));
    cm.setValidateAfterInactivity(
            Integer.getInteger(VALIDATE_AFTER_INACTIVITY, VALIDATE_AFTER_INACTIVITY_DEFAULT));

    HttpClientBuilder newHttpClientBuilder = HttpClientBuilder.create();

    if (sharedConnectionManager) {
        newHttpClientBuilder.setConnectionManagerShared(true);
    } else {
        newHttpClientBuilder.setConnectionManagerShared(false);
    }

    ConnectionKeepAliveStrategy keepAliveStrat = new ConnectionKeepAliveStrategy() {
        @Override
        public long getKeepAliveDuration(HttpResponse response, HttpContext context) {
            // we only close connections based on idle time, not ttl expiration
            return -1;
        }
    };

    if (httpClientBuilder.getAuthSchemeRegistryProvider() != null) {
        newHttpClientBuilder.setDefaultAuthSchemeRegistry(
                httpClientBuilder.getAuthSchemeRegistryProvider().getAuthSchemeRegistry());
    }
    if (httpClientBuilder.getCookieSpecRegistryProvider() != null) {
        newHttpClientBuilder.setDefaultCookieSpecRegistry(
                httpClientBuilder.getCookieSpecRegistryProvider().getCookieSpecRegistry());
    }
    if (httpClientBuilder.getCredentialsProviderProvider() != null) {
        newHttpClientBuilder.setDefaultCredentialsProvider(
                httpClientBuilder.getCredentialsProviderProvider().getCredentialsProvider());
    }

    newHttpClientBuilder.addInterceptorLast(new DynamicInterceptor());

    newHttpClientBuilder = newHttpClientBuilder.setKeepAliveStrategy(keepAliveStrat).evictIdleConnections(
            (long) Integer.getInteger(EVICT_IDLE_CONNECTIONS, EVICT_IDLE_CONNECTIONS_DEFAULT),
            TimeUnit.MILLISECONDS);

    HttpClientBuilder builder = setupBuilder(newHttpClientBuilder, params);

    HttpClient httpClient = builder.setConnectionManager(cm).build();

    assert ObjectReleaseTracker.track(httpClient);
    return (CloseableHttpClient) httpClient;
}

From source file:com.pushtechnology.consulting.SessionCreator.java

SessionCreator(String connectionString, List<String> topicSelectors, TopicType topicType) {
    LOG.trace("SessionCreator constructor...");

    this.connectionStrings = asList(connectionString.split("[,]"));
    this.topicType = topicType;
    LOG.info("Creating sessions listening to topic selectors: '{}'", join(topicSelectors, ", "));
    for (String topicSelector : topicSelectors) {
        this.topicSelectors.add(Diffusion.topicSelectors().parse(topicSelector));
    }/*from   w w w. j a  v  a2  s .c o m*/

    SessionFactory factory = Diffusion.sessions().connectionTimeout(60 * 1000).recoveryBufferSize(8000)
            .reconnectionStrategy(new ReconnectionStrategy() {

                @Override
                public void performReconnection(final ReconnectionAttempt reconnection) {
                    Benchmarker.globalThreadPool.schedule(new Runnable() {
                        @Override
                        public void run() {
                            reconnection.start();
                        }
                    }, getRandomReconnect(maxReconnectionIntervalSec), SECONDS);
                }

            }).reconnectionTimeout(maximumTimeoutDurationMs).errorHandler(new ErrorHandler() {

                @Override
                public void onError(Session session, SessionError err) {
                    LOG.error("SessionCreator#sessionFactory.onError : '{}'", err.getMessage());
                }

            }).listener(new Listener() {

                @Override
                public void onSessionStateChanged(Session session, State oldState, State newState) {
                    LOG.trace("SessionCreator#sessionFactory.onSessionStateChanged");
                    LOG.trace("Session state changed from '{}' to '{}'", oldState, newState);

                    if (!oldState.isConnected() && newState.isConnected()) {
                        connectedSessions.incrementAndGet();
                    }

                    if (oldState.isConnected() && !newState.isConnected()) {
                        connectedSessions.decrementAndGet();
                    }

                    if (!oldState.isRecovering() && newState.isRecovering()) {
                        recoveringSessions.incrementAndGet();
                    }

                    if (oldState.isRecovering() && !newState.isRecovering()) {
                        recoveringSessions.decrementAndGet();
                    }

                    if (oldState == CONNECTING) {
                        // No not increment closed sessions when the client
                        // failed to connect
                        return;
                    }

                    if (newState.isClosed()) {
                        closedSessions.incrementAndGet();

                        synchronized (sessionSetLock) {
                            // Assumes sessions are only closed when shutting
                            // down
                            // The state listener is called during the close
                            // call
                            // Do not modify the sessions object when iterating
                            // over it
                            if (newState != State.CLOSED_BY_CLIENT) {
                                sessions.remove(session);
                            }
                        }
                    }

                    LOG.trace("Done SessionCreator#sessionFactory.onSessionStateChanged");
                }
            });

    if (Integer.getInteger("bench.input.buffer.size", 0) > 0) {
        factory = factory.inputBufferSize(getInteger("bench.input.buffer.size"));
    }

    if (Integer.getInteger("bench.output.buffer.size", 0) > 0) {
        factory = factory.outputBufferSize(getInteger("bench.output.buffer.size"));
    }
    this.sessionFactory = factory;

    state = INITIALISED;
    LOG.trace("Done SessionCreator constructor...");
}