List of usage examples for java.lang Boolean getBoolean
public static boolean getBoolean(String name)
From source file:org.codehaus.groovy.grails.web.context.GrailsConfigUtils.java
/** * Checks if a Config parameter is true or a System property with the same name is true * * @param application/*from w w w .j a v a 2 s . co m*/ * @param propertyName * @return true if the Config parameter is true or the System property with the same name is true */ public static boolean isConfigTrue(GrailsApplication application, String propertyName) { return ((application != null && application.getFlatConfig() != null && DefaultTypeTransformation.castToBoolean(application.getFlatConfig().get(propertyName))) || Boolean.getBoolean(propertyName)); }
From source file:org.apache.solr.core.ZkContainer.java
public void initZooKeeper(final CoreContainer cc, String solrHome, String zkHost, int zkClientTimeout, String hostPort, String hostContext, String host, int leaderVoteWait, boolean genericCoreNodeNames, int distribUpdateConnTimeout, int distribUpdateSoTimeout) { ZkController zkController = null;/*from w w w . j ava2 s . c o m*/ // if zkHost sys property is not set, we are not using ZooKeeper String zookeeperHost; if (zkHost == null) { zookeeperHost = System.getProperty("zkHost"); } else { zookeeperHost = zkHost; } String zkRun = System.getProperty("zkRun"); this.zkClientTimeout = zkClientTimeout; this.hostPort = hostPort; this.hostContext = hostContext; this.host = host; this.leaderVoteWait = leaderVoteWait; this.genericCoreNodeNames = genericCoreNodeNames; this.distribUpdateConnTimeout = distribUpdateConnTimeout; this.distribUpdateSoTimeout = distribUpdateSoTimeout; if (zkRun == null && zookeeperHost == null) return; // not in zk mode // BEGIN: SOLR-4622: deprecated hardcoded defaults for hostPort & hostContext if (null == hostPort) { // throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, // "'hostPort' must be configured to run SolrCloud"); log.warn("Solr 'hostPort' has not be explicitly configured, using hardcoded default of " + DEFAULT_HOST_PORT + ". This default has been deprecated and will be removed in future versions of Solr, please configure this value explicitly"); hostPort = DEFAULT_HOST_PORT; } if (null == hostContext) { // throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, // "'hostContext' must be configured to run SolrCloud"); log.warn("Solr 'hostContext' has not be explicitly configured, using hardcoded default of " + DEFAULT_HOST_CONTEXT + ". This default has been deprecated and will be removed in future versions of Solr, please configure this value explicitly"); hostContext = DEFAULT_HOST_CONTEXT; } // END: SOLR-4622 // zookeeper in quorum mode currently causes a failure when trying to // register log4j mbeans. See SOLR-2369 // TODO: remove after updating to an slf4j based zookeeper System.setProperty("zookeeper.jmx.log4j.disable", "true"); if (zkRun != null) { String zkDataHome = System.getProperty("zkServerDataDir", solrHome + "zoo_data"); String zkConfHome = System.getProperty("zkServerConfDir", solrHome); zkServer = new SolrZkServer(zkRun, zookeeperHost, zkDataHome, zkConfHome, hostPort); zkServer.parseConfig(); zkServer.start(); // set client from server config if not already set if (zookeeperHost == null) { zookeeperHost = zkServer.getClientString(); } } int zkClientConnectTimeout = 15000; if (zookeeperHost != null) { // we are ZooKeeper enabled try { // If this is an ensemble, allow for a long connect time for other servers to come up if (zkRun != null && zkServer.getServers().size() > 1) { zkClientConnectTimeout = 24 * 60 * 60 * 1000; // 1 day for embedded ensemble log.info("Zookeeper client=" + zookeeperHost + " Waiting for a quorum."); } else { log.info("Zookeeper client=" + zookeeperHost); } String confDir = System.getProperty("bootstrap_confdir"); boolean boostrapConf = Boolean.getBoolean("bootstrap_conf"); if (!ZkController.checkChrootPath(zookeeperHost, (confDir != null) || boostrapConf)) { throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "A chroot was specified in ZkHost but the znode doesn't exist. "); } zkController = new ZkController(cc, zookeeperHost, zkClientTimeout, zkClientConnectTimeout, host, hostPort, hostContext, leaderVoteWait, genericCoreNodeNames, distribUpdateConnTimeout, distribUpdateSoTimeout, new CurrentCoreDescriptorProvider() { @Override public List<CoreDescriptor> getCurrentDescriptors() { List<CoreDescriptor> descriptors = new ArrayList<CoreDescriptor>( cc.getCoreNames().size()); Collection<SolrCore> cores = cc.getCores(); for (SolrCore core : cores) { descriptors.add(core.getCoreDescriptor()); } return descriptors; } }); if (zkRun != null && zkServer.getServers().size() > 1 && confDir == null && boostrapConf == false) { // we are part of an ensemble and we are not uploading the config - pause to give the config time // to get up Thread.sleep(10000); } if (confDir != null) { File dir = new File(confDir); if (!dir.isDirectory()) { throw new IllegalArgumentException( "bootstrap_confdir must be a directory of configuration files"); } String confName = System.getProperty( ZkController.COLLECTION_PARAM_PREFIX + ZkController.CONFIGNAME_PROP, "configuration1"); zkController.uploadConfigDir(dir, confName); } if (boostrapConf) { ZkController.bootstrapConf(zkController.getZkClient(), cc, solrHome); } } catch (InterruptedException e) { // Restore the interrupted status Thread.currentThread().interrupt(); log.error("", e); throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "", e); } catch (TimeoutException e) { log.error("Could not connect to ZooKeeper", e); throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "", e); } catch (IOException e) { log.error("", e); throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "", e); } catch (KeeperException e) { log.error("", e); throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "", e); } } this.zkController = zkController; }
From source file:com.netflix.conductor.server.ConductorServer.java
public synchronized void start(int port, boolean join) throws Exception { if (server != null) { throw new IllegalStateException("Server is already running"); }/*w w w . j ava 2s .c o m*/ Guice.createInjector(sm); //Swagger String resourceBasePath = Main.class.getResource("/swagger-ui").toExternalForm(); this.server = new Server(port); ServletContextHandler context = new ServletContextHandler(); context.addFilter(GuiceFilter.class, "/*", EnumSet.allOf(DispatcherType.class)); context.setResourceBase(resourceBasePath); context.setWelcomeFiles(new String[] { "index.html" }); server.setHandler(context); DefaultServlet staticServlet = new DefaultServlet(); context.addServlet(new ServletHolder(staticServlet), "/*"); server.start(); System.out.println("Started server on http://localhost:" + port + "/"); try { boolean create = Boolean.getBoolean("loadSample"); if (create) { System.out.println("Creating kitchensink workflow"); createKitchenSink(port); } } catch (Exception e) { logger.error(e.getMessage(), e); } if (join) { server.join(); } }
From source file:eu.eidas.auth.engine.metadata.impl.BaseMetadataFetcher.java
/** * Override this method to plug your own SSLSocketFactory. * <p>/* w w w .ja v a2 s . c o m*/ * This default implementation relies on the default one from the JVM, i.e. using the default trustStore * ($JRE/lib/security/cacerts). * * @return the SecureProtocolSocketFactory instance to be used to connect to https metadata URLs. */ @Nonnull protected SecureProtocolSocketFactory newSslSocketFactory() { HostnameVerifier hostnameVerifier; if (!Boolean.getBoolean(DefaultBootstrap.SYSPROP_HTTPCLIENT_HTTPS_DISABLE_HOSTNAME_VERIFICATION)) { hostnameVerifier = new StrictHostnameVerifier(); } else { hostnameVerifier = org.apache.commons.ssl.HostnameVerifier.ALLOW_ALL; } TLSProtocolSocketFactory tlsProtocolSocketFactory = new TLSProtocolSocketFactory(null, null, hostnameVerifier) { @Override protected void verifyHostname(Socket socket) throws SSLException { if (socket instanceof SSLSocket) { SSLSocket sslSocket = (SSLSocket) socket; try { sslSocket.startHandshake(); } catch (IOException e) { throw new SSLException(e); } SSLSession sslSession = sslSocket.getSession(); if (!sslSession.isValid()) { throw new SSLException("SSLSession was invalid: Likely implicit handshake failure: " + "Set system property javax.net.debug=all for details"); } super.verifyHostname(sslSocket); } } }; Protocol.registerProtocol("https", new Protocol("https", tlsProtocolSocketFactory, 443)); return tlsProtocolSocketFactory; }
From source file:net.es.nsi.topology.translator.Options.java
/** * Process the "debug" command line and system property option. * * @param cmd Commands entered by the user. * @return true if debug is enabled, false otherwise. *///from w w w . j a v a2 s . c o m private boolean getDebug(CommandLine cmd) { boolean sys = Boolean.getBoolean(System.getProperty(Properties.SYSTEM_PROPERTY_DEBUG, "false")); boolean com = cmd.hasOption(ARGNAME_DEBUG); return (sys | com); }
From source file:org.apache.cassandra.utils.JMXServerUtils.java
private static Map<String, Object> configureJmxSocketFactories(InetAddress serverAddress, boolean localOnly) { Map<String, Object> env = new HashMap<>(); if (Boolean.getBoolean("com.sun.management.jmxremote.ssl")) { boolean requireClientAuth = Boolean.getBoolean("com.sun.management.jmxremote.ssl.need.client.auth"); String[] protocols = null; String protocolList = System.getProperty("com.sun.management.jmxremote.ssl.enabled.protocols"); if (protocolList != null) { System.setProperty("javax.rmi.ssl.client.enabledProtocols", protocolList); protocols = StringUtils.split(protocolList, ','); }/* w w w . j av a 2 s . co m*/ String[] ciphers = null; String cipherList = System.getProperty("com.sun.management.jmxremote.ssl.enabled.cipher.suites"); if (cipherList != null) { System.setProperty("javax.rmi.ssl.client.enabledCipherSuites", cipherList); ciphers = StringUtils.split(cipherList, ','); } SslRMIClientSocketFactory clientFactory = new SslRMIClientSocketFactory(); SslRMIServerSocketFactory serverFactory = new SslRMIServerSocketFactory(ciphers, protocols, requireClientAuth); env.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE, serverFactory); env.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, clientFactory); env.put("com.sun.jndi.rmi.factory.socket", clientFactory); logJmxSslConfig(serverFactory); } else if (localOnly) { env.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE, new RMIServerSocketFactoryImpl(serverAddress)); } return env; }
From source file:x10.x10rt.yarn.Client.java
public void run() throws IOException, YarnException { yarnClient.start();/* w w w. java 2 s .c o m*/ YarnClusterMetrics clusterMetrics = yarnClient.getYarnClusterMetrics(); // print out cluster information LOG.info("Got Cluster metric info from ASM, numNodeManagers=" + clusterMetrics.getNumNodeManagers()); List<NodeReport> clusterNodeReports = yarnClient.getNodeReports(NodeState.RUNNING); LOG.info("Got Cluster node info from ASM"); for (NodeReport node : clusterNodeReports) { LOG.info("Got node report from ASM for" + ", nodeId=" + node.getNodeId() + ", nodeAddress" + node.getHttpAddress() + ", nodeRackName" + node.getRackName() + ", nodeNumContainers" + node.getNumContainers()); } QueueInfo queueInfo = yarnClient.getQueueInfo(this.amQueue); LOG.info("Queue info" + ", queueName=" + queueInfo.getQueueName() + ", queueCurrentCapacity=" + queueInfo.getCurrentCapacity() + ", queueMaxCapacity=" + queueInfo.getMaximumCapacity() + ", queueApplicationCount=" + queueInfo.getApplications().size() + ", queueChildQueueCount=" + queueInfo.getChildQueues().size()); List<QueueUserACLInfo> listAclInfo = yarnClient.getQueueAclsInfo(); for (QueueUserACLInfo aclInfo : listAclInfo) { for (QueueACL userAcl : aclInfo.getUserAcls()) { LOG.info("User ACL Info for Queue" + ", queueName=" + aclInfo.getQueueName() + ", userAcl=" + userAcl.name()); } } // Get a new application id YarnClientApplication app = yarnClient.createApplication(); GetNewApplicationResponse appResponse = app.getNewApplicationResponse(); int maxMem = appResponse.getMaximumResourceCapability().getMemory(); LOG.info("Max mem capabililty of resources in this cluster " + maxMem); int maxVCores = appResponse.getMaximumResourceCapability().getVirtualCores(); LOG.info("Max virtual cores capabililty of resources in this cluster " + maxVCores); // set the application name ApplicationSubmissionContext appContext = app.getApplicationSubmissionContext(); final ApplicationId appId = appContext.getApplicationId(); appContext.setKeepContainersAcrossApplicationAttempts(false); appContext.setApplicationName(appName); Map<String, LocalResource> localResources = new HashMap<String, LocalResource>(); LOG.info("Copy App Master jar from local filesystem and add to local environment"); // Copy the application master jar to the filesystem // Create a local resource to point to the destination jar path FileSystem fs = FileSystem.get(conf); StringBuilder x10jars = new StringBuilder(); boolean isNative = Boolean.getBoolean(ApplicationMaster.X10_YARN_NATIVE); String[] jarfiles = classPath.split(":"); // upload jar files for (String jar : jarfiles) { if (jar.endsWith(".jar")) { String nopath = jar.substring(jar.lastIndexOf('/') + 1); LOG.info("Uploading " + nopath + " to " + fs.getUri()); x10jars.append(addToLocalResources(fs, jar, nopath, appId.toString(), localResources, null)); if (isNative) { // add the user's program. LOG.info("Uploading application " + appName + " to " + fs.getUri()); x10jars.append(':'); x10jars.append(addToLocalResources(fs, args[mainClassArg], appName, appId.toString(), localResources, null)); break; // no other jar files are needed beyond the one holding ApplicationMaster, which is the first one } else x10jars.append(':'); } } StringBuilder uploadedFiles = new StringBuilder(); // upload any files specified via -upload argument to the x10 script String upload = System.getProperty(ApplicationMaster.X10_YARNUPLOAD); if (upload != null) { String[] files = upload.split(","); for (String file : files) { String nopath = file.substring(file.lastIndexOf('/') + 1); LOG.info("Uploading file " + nopath + " to " + fs.getUri()); uploadedFiles.append(addToLocalResources(fs, file, nopath, appId.toString(), localResources, null)); uploadedFiles.append(','); } } LOG.info("Set the environment for the application master"); Map<String, String> env = new HashMap<String, String>(); //env.putAll(System.getenv()); // copy all environment variables from the client side to the application side // copy over existing environment variables for (String key : System.getenv().keySet()) { if (!key.startsWith("BASH_FUNC_") && !key.equals("LS_COLORS")) // skip some env.put(ApplicationMaster.X10YARNENV_ + key, System.getenv(key)); } String places = System.getenv(ApplicationMaster.X10_NPLACES); env.put(ApplicationMaster.X10_NPLACES, (places == null) ? "1" : places); String cores = System.getenv(ApplicationMaster.X10_NTHREADS); env.put(ApplicationMaster.X10_NTHREADS, (cores == null) ? "0" : cores); env.put(ApplicationMaster.X10_HDFS_JARS, x10jars.toString()); // At some point we should not be required to add // the hadoop specific classpaths to the env. // It should be provided out of the box. // For now setting all required classpaths including // the classpath to "." for the application jar StringBuilder classPathEnv = new StringBuilder(Environment.CLASSPATH.$$()) .append(ApplicationConstants.CLASS_PATH_SEPARATOR).append("./*"); for (String c : conf.getStrings(YarnConfiguration.YARN_APPLICATION_CLASSPATH, YarnConfiguration.DEFAULT_YARN_CROSS_PLATFORM_APPLICATION_CLASSPATH)) { classPathEnv.append(ApplicationConstants.CLASS_PATH_SEPARATOR); classPathEnv.append(c.trim()); } env.put("CLASSPATH", classPathEnv.toString()); LOG.info("Completed setting up the ApplicationManager environment " + env.toString()); // Set the necessary command to execute the application master Vector<CharSequence> vargs = new Vector<CharSequence>(this.args.length + 30); // Set java executable command LOG.info("Setting up app master command"); vargs.add(Environment.JAVA_HOME.$$() + "/bin/java"); // Set Xmx based on am memory size vargs.add("-Xmx" + amMemory + "m"); // propigate the native flag if (isNative) vargs.add("-DX10_YARN_NATIVE=true"); if (upload != null) vargs.add("-D" + ApplicationMaster.X10_YARNUPLOAD + "=" + uploadedFiles.toString()); vargs.add("-D" + ApplicationMaster.X10_YARN_MAIN + "=" + appName); vargs.add("-Dorg.apache.commons.logging.simplelog.showdatetime=true"); // Set class name vargs.add(appMasterMainClass); // add java arguments for (int i = 0; i < mainClassArg; i++) { if (i != classPathArg) // skip the classpath, as it gets reworked vargs.add(args[i]); } // add our own main class wrapper if (!isNative) vargs.add(X10MainRunner.class.getName()); // add remaining application command line arguments for (int i = mainClassArg; i < args.length; i++) vargs.add(args[i]); vargs.add("1>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/AppMaster.stdout"); vargs.add("2>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/AppMaster.stderr"); // Get final commmand StringBuilder command = new StringBuilder(); for (CharSequence str : vargs) { command.append(str).append(" "); } LOG.info("Completed setting up app master command " + command.toString()); List<String> commands = new ArrayList<String>(); commands.add(command.toString()); // Set up the container launch context for the application master ContainerLaunchContext amContainer = ContainerLaunchContext.newInstance(localResources, env, commands, null, null, null); // Set up resource type requirements // For now, both memory and vcores are supported, so we set memory and // vcores requirements Resource capability = Resource.newInstance(amMemory, amVCores); appContext.setResource(capability); appContext.setAMContainerSpec(amContainer); // kill the application if the user hits ctrl-c Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override public void run() { System.out.println(); System.out.println("Exiting..."); forceKillApplication(appId); } })); LOG.info("Submitting application to ASM"); yarnClient.submitApplication(appContext); // Monitor the application monitorApplication(appId); // delete jar files uploaded earlier cleanupLocalResources(fs, appId.toString()); }
From source file:org.openpnp.model.Configuration.java
public void load() throws Exception { boolean forceSave = false; boolean overrideUserConfig = Boolean.getBoolean("overrideUserConfig"); try {/* w w w .j a v a2 s .c om*/ File file = new File(configurationDirectory, "packages.xml"); if (overrideUserConfig || !file.exists()) { logger.info("No packages.xml found in configuration directory, loading defaults."); file = File.createTempFile("packages", "xml"); FileUtils.copyURLToFile(ClassLoader.getSystemResource("config/packages.xml"), file); forceSave = true; } loadPackages(file); } catch (Exception e) { String message = e.getMessage(); if (e.getCause() != null && e.getCause().getMessage() != null) { message = e.getCause().getMessage(); } throw new Exception("Error while reading packages.xml (" + message + ")", e); } try { File file = new File(configurationDirectory, "parts.xml"); if (overrideUserConfig || !file.exists()) { logger.info("No parts.xml found in configuration directory, loading defaults."); file = File.createTempFile("parts", "xml"); FileUtils.copyURLToFile(ClassLoader.getSystemResource("config/parts.xml"), file); forceSave = true; } loadParts(file); } catch (Exception e) { String message = e.getMessage(); if (e.getCause() != null && e.getCause().getMessage() != null) { message = e.getCause().getMessage(); } throw new Exception("Error while reading parts.xml (" + message + ")", e); } try { File file = new File(configurationDirectory, "machine.xml"); if (overrideUserConfig || !file.exists()) { logger.info("No machine.xml found in configuration directory, loading defaults."); file = File.createTempFile("machine", "xml"); FileUtils.copyURLToFile(ClassLoader.getSystemResource("config/machine.xml"), file); forceSave = true; } loadMachine(file); } catch (Exception e) { String message = e.getMessage(); if (e.getCause() != null && e.getCause().getMessage() != null) { message = e.getCause().getMessage(); } throw new Exception("Error while reading machine.xml (" + message + ")", e); } loaded = true; for (ConfigurationListener listener : listeners) { listener.configurationLoaded(this); } if (forceSave) { logger.info("Defaults were loaded. Saving to configuration directory."); configurationDirectory.mkdirs(); save(); } for (ConfigurationListener listener : listeners) { listener.configurationComplete(this); } }
From source file:com.boundary.sdk.event.snmp.MIBCompiler.java
/** * Execute the compilation of the MIBs.//from w w w. j a v a2s . c o m * * @param args Arguments passed on the command line * @throws IOException thrown by MIB compilation */ public void execute(String[] args) throws IOException { // Handle the command line arguments parseCommandLineOptions(args); // Check to see DEBUG = Boolean.getBoolean(cmd.getOptionValue("d")); setUpdateExisting(cmd.hasOption("u")); // Set the strictness of the MIB compilation based on the // command line arguments setCompilerStrictness(); // Set the SNMP4J compiler license if provided, required for // MIBs using the enterprise branch getCompilerLicense(); // If we have our MIBs to compile and store the // results the proceed with the compilation if (setInputMIBs() && setOutputDirectory()) { // Write debug information before compilation Log.info("Input MIB file(s)/directory: " + mibPath); Log.info("Output MIB directory: " + mibTargetDir); Log.info("Compile Leniently: " + isCompileLeniently()); // Initialize the SMI Manager initialize(); // Compile the MIBs compile(mibPath); } else { usage(); } }
From source file:org.b5chat.crossfire.plugin.admin.AdminConsolePlugin.java
private void createWebAppContext() { ServletContextHandler context;/*from w w w . j av a 2 s. c om*/ // Add web-app. Check to see if we're in development mode. If so, we don't // add the normal web-app location, but the web-app in the project directory. if (Boolean.getBoolean("developmentMode")) { System.out.println(LocaleUtils.getLocalizedString("admin.console.devmode")); context = new WebAppContext(contexts, pluginDir.getParentFile().getParentFile().getParentFile().getParent() + File.separator + "src" + File.separator + "web", "/"); } else { context = new WebAppContext(contexts, pluginDir.getAbsoluteFile() + File.separator + "webapp", "/"); } context.setWelcomeFiles(new String[] { "index.jsp" }); }