List of usage examples for java.lang Integer getInteger
public static Integer getInteger(String nm, Integer val)
From source file:org.jboss.test.web.test.WebIntegrationUnitTestCase.java
/** Access the http://{host}/jbosstest-not/unrestricted/SecureServlet *///from ww w .j a v a 2 s .co m public void testNotJbosstest() throws Exception { String baseURL = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/'; URL url = new URL(baseURL + "jbosstest-not/unrestricted/SecureServlet"); HttpUtils.accessURL(url, REALM, HttpURLConnection.HTTP_OK); }
From source file:org.elasticsearch.hadoop.rest.commonshttp.CommonsHttpTransport.java
private HostConfiguration setupSocksProxy(Settings settings, HostConfiguration hostConfig) { // set proxy settings String proxyHost = null;//from ww w.j a v a 2 s . co m int proxyPort = -1; String proxyUser = null; String proxyPass = null; if (settings.getNetworkHttpUseSystemProperties()) { proxyHost = System.getProperty("socksProxyHost"); proxyPort = Integer.getInteger("socksProxyPort", -1); proxyUser = System.getProperty("java.net.socks.username"); proxyPass = System.getProperty("java.net.socks.password"); } if (StringUtils.hasText(settings.getNetworkProxySocksHost())) { proxyHost = settings.getNetworkProxySocksHost(); } if (settings.getNetworkProxySocksPort() > 0) { proxyPort = settings.getNetworkProxySocksPort(); } if (StringUtils.hasText(settings.getNetworkProxySocksUser())) { proxyUser = settings.getNetworkProxySocksUser(); } if (StringUtils.hasText(settings.getNetworkProxySocksPass())) { proxyPass = settings.getNetworkProxySocksPass(); } // we actually have a socks proxy, let's start the setup if (StringUtils.hasText(proxyHost)) { proxyInfo = proxyInfo.concat(String.format("[SOCKS proxy %s:%s]", proxyHost, proxyPort)); if (!StringUtils.hasText(proxyUser)) { log.warn(String.format( "SOCKS proxy user specified but no/empty password defined - double check the [%s] property", ConfigurationOptions.ES_NET_PROXY_SOCKS_PASS)); } if (log.isDebugEnabled()) { if (StringUtils.hasText(proxyUser)) { log.debug(String.format("Using authenticated SOCKS proxy [%s:%s]", proxyHost, proxyPort)); } else { log.debug(String.format("Using SOCKS proxy [%s:%s]", proxyHost, proxyPort)); } } // // switch protocol // due to how HttpCommons work internally this dance is best to be kept as is // String schema = settings.getNetworkSSLEnabled() ? "https" : "http"; int port = settings.getNetworkSSLEnabled() ? 443 : 80; SocksSocketFactory socketFactory = new SocksSocketFactory(proxyHost, proxyPort, proxyUser, proxyPass); replaceProtocol(hostConfig, socketFactory, schema, port); } return hostConfig; }
From source file:org.apache.geode.distributed.ServerLauncher.java
private static Integer getDefaultServerPort() { return Integer.getInteger(AbstractCacheServer.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY, CacheServer.DEFAULT_PORT); }
From source file:com.microsoft.tfs.core.config.httpclient.DefaultHTTPClientFactory.java
/** * {@inheritDoc}/* ww w . jav a2s .com*/ */ @Override public void configureClientParams(final HttpClient httpClient, final HttpClientParams params, final ConnectionInstanceData connectionInstanceData) { params.setBooleanParameter("http.protocol.expect-continue", false); //$NON-NLS-1$ params.setParameter(HttpMethodParams.SO_TIMEOUT, Integer.getInteger(SOCKET_TIMEOUT_SECONDS_PROPERTY, SOCKET_TIMEOUT_SECONDS_DEFAULT) * 1000); /* * Setup the user agent */ final String userAgent = getUserAgent(httpClient, connectionInstanceData); if (userAgent != null) { params.setParameter(HttpMethodParams.USER_AGENT, userAgent); } /* * Set the SSL socket factory to accept untrusted certificates, if * requested. */ if (shouldAcceptUntrustedCertificates(connectionInstanceData)) { params.setBooleanParameter(DefaultSSLProtocolSocketFactory.ACCEPT_UNTRUSTED_CERTIFICATES_PARAMETER, Boolean.TRUE); } }
From source file:org.jboss.test.web.test.WebIntegrationUnitTestCase.java
/** Deploy a second ear that include a notjbosstest-web.war to test ears with the same war names conflicting.//from www. ja va 2 s . c o m Access the http://{host}/jbosstest-not2/unrestricted/SecureServlet */ public void testNotJbosstest2() throws Exception { try { deploy("jbosstest-web2.ear"); String baseURL = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/'; URL url = new URL(baseURL + "jbosstest-not2/unrestricted/SecureServlet"); HttpUtils.accessURL(url, REALM, HttpURLConnection.HTTP_OK); } finally { undeploy("jbosstest-web2.ear"); } // end of try-finally }
From source file:io.adeptj.runtime.server.Server.java
private Builder workerOptions(Builder builder) { if (Environment.isProd()) { // Note : For a 16 core system, number of worker task core and max threads will be. // 1. core task thread: 128 (16[cores] * 8) // 2. max task thread: 128 * 2 = 256 // Default settings would have set the following. // 1. core task thread: 128 (16[cores] * 8) // 2. max task thread: 128 (Same as core task thread) Config workerOptions = Objects.requireNonNull(this.cfgReference.get()).getConfig(KEY_WORKER_OPTIONS); // defaults to 64 int cfgCoreTaskThreads = workerOptions.getInt(KEY_WORKER_TASK_CORE_THREADS); LOGGER.info("Configured worker task core threads: [{}]", cfgCoreTaskThreads); int availableProcessors = Runtime.getRuntime().availableProcessors(); LOGGER.info("No. of CPU available: [{}]", availableProcessors); int calcCoreTaskThreads = availableProcessors * Integer.getInteger(SYS_PROP_WORKER_TASK_THREAD_MULTIPLIER, WORKER_TASK_THREAD_MULTIPLIER); LOGGER.info("Calculated worker task core threads: [{}]", calcCoreTaskThreads); builder.setWorkerOption(Options.WORKER_TASK_CORE_THREADS, calcCoreTaskThreads > cfgCoreTaskThreads ? calcCoreTaskThreads : cfgCoreTaskThreads); // defaults to double of [worker-task-core-threads] i.e 128 int cfgMaxTaskThreads = workerOptions.getInt(KEY_WORKER_TASK_MAX_THREADS); LOGGER.info("Configured worker task max threads: [{}]", cfgCoreTaskThreads); int calcMaxTaskThreads = calcCoreTaskThreads * Integer.getInteger(SYS_PROP_SYS_TASK_THREAD_MULTIPLIER, SYS_TASK_THREAD_MULTIPLIER); LOGGER.info("Calculated worker task max threads: [{}]", cfgCoreTaskThreads); builder.setWorkerOption(Options.WORKER_TASK_MAX_THREADS, calcMaxTaskThreads > cfgMaxTaskThreads ? calcMaxTaskThreads : cfgMaxTaskThreads); LOGGER.info("Undertow Worker Options optimized for AdeptJ Runtime [PROD] mode."); }//from w w w.j av a2 s. c o m return builder; }
From source file:org.jboss.test.web.test.WebIntegrationUnitTestCase.java
/** Deploy a bad war and then redploy with a fixed war to test failed war * cleanup.//from w ww .ja va 2s. co m * Access the http://{host}/redeploy/index.html */ public void testBadWarRedeploy() throws Exception { try { deploy("bad-web.war"); fail("The bad-web.war deployment did not fail"); } catch (Exception e) { getLog().debug("bad-web.war failed as expected", e); } finally { undeploy("bad-web.war"); } // end of try-finally try { deploy("good-web.war"); String baseURL = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/'; URL url = new URL(baseURL + "redeploy/index.html"); HttpUtils.accessURL(url, REALM, HttpURLConnection.HTTP_OK); } finally { undeploy("good-web.war"); } // end of try-finally }
From source file:org.jboss.test.web.test.WebIntegrationUnitTestCase.java
/** Test of a war that accesses classes referred to via the war manifest * classpath. Access the http://{host}/manifest/classpath.jsp *///from w ww. ja v a 2s. c om public void testWarManifest() throws Exception { deploy("manifest-web.ear"); try { String baseURL = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/'; URL url = new URL(baseURL + "manifest/classpath.jsp"); HttpMethodBase request = HttpUtils.accessURL(url); Header errors = request.getResponseHeader("X-Exception"); log.info("X-Exception: " + errors); assertTrue("X-Exception(" + errors + ") is null", errors == null); } finally { undeploy("manifest-web.ear"); } }
From source file:com.adeptj.runtime.server.Server.java
/** * Chaining of Undertow {@link HttpHandler} instances as follows. * <p>//from w ww . ja va2 s . c om * 1. GracefulShutdownHandler * 2. RequestLimitingHandler * 3. AllowedMethodsHandler * 4. PredicateHandler which resolves to either RedirectHandler or SetHeadersHandler * 5. RequestBufferingHandler if request buffering is enabled, wrapped in SetHeadersHandler * 5. And Finally ServletInitialHandler * * @param servletInitialHandler the {@link io.undertow.servlet.handlers.ServletInitialHandler} * @return GracefulShutdownHandler as the root handler */ private GracefulShutdownHandler rootHandler(HttpHandler servletInitialHandler) { Config cfg = Objects.requireNonNull(this.cfgReference.get()); Map<HttpString, String> headers = new HashMap<>(); headers.put(HttpString.tryFromString(Constants.HEADER_SERVER), cfg.getString(Constants.KEY_HEADER_SERVER)); if (Environment.isDev()) { headers.put(HttpString.tryFromString(Constants.HEADER_X_POWERED_BY), Version.getFullVersionString()); } HttpHandler headersHandler = Boolean.getBoolean(ServerConstants.SYS_PROP_ENABLE_REQ_BUFF) ? new SetHeadersHandler(new RequestBufferingHandler(servletInitialHandler, Integer.getInteger(ServerConstants.SYS_PROP_REQ_BUFF_MAX_BUFFERS, cfg.getInt(Constants.KEY_REQ_BUFF_MAX_BUFFERS))), headers) : new SetHeadersHandler(servletInitialHandler, headers); return Handlers.gracefulShutdown(new RequestLimitingHandler( Integer.getInteger(ServerConstants.SYS_PROP_MAX_CONCUR_REQ, cfg.getInt(Constants.KEY_MAX_CONCURRENT_REQS)), new AllowedMethodsHandler( Handlers.predicate(exchange -> Constants.CONTEXT_PATH.equals(exchange.getRequestURI()), Handlers.redirect(Constants.TOOLS_DASHBOARD_URI), headersHandler), this.allowedMethods(cfg)))); }
From source file:org.jahia.services.content.impl.jackrabbit.RepositoryMigrator.java
private void performMigration(JahiaRepositoryConfig sourceCfg, JahiaRepositoryConfig targetCfg) throws RepositoryException { logger.info("Start migrating repository..."); long globalTimer = System.currentTimeMillis(); RepositoryImpl source = JahiaRepositoryImpl.create(sourceCfg); RepositoryImpl target = JahiaRepositoryImpl.create(targetCfg); int batchSize = Integer.getInteger("jahia.jackrabbit.persistenceCopierBatchSize", 500); try {//from w w w .j av a2 s. c o m if (batchSize <= 1) { new RepositoryCopier(source, target).copy(); } else { new JahiaRepositoryCopier(source, target, batchSize).copy(); } } finally { target.shutdown(); source.shutdown(); } logger.info("Repository data migrated in {} ms", (System.currentTimeMillis() - globalTimer)); }