List of usage examples for java.util.logging Level parse
public static synchronized Level parse(String name) throws IllegalArgumentException
From source file:org.cloudifysource.esc.driver.provisioning.ElasticMachineProvisioningCloudifyAdapter.java
private void installAndStartAgent(final MachineDetails machineDetails, final GSAReservationId reservationId, final long end) throws TimeoutException, InterruptedException, ElasticMachineProvisioningException, ElasticGridServiceAgentProvisioningException { final AgentlessInstaller installer = new AgentlessInstaller(); InstallationDetails installationDetails; try {//from ww w. j a v a 2 s . c o m // since only agents are started by this method, server-security is // set to false installationDetails = createInstallationDetails(cloud, machineDetails, reservationId); } catch (final FileNotFoundException e) { throw new ElasticGridServiceAgentProvisioningException( "Failed to create installation details for agent: " + e.getMessage(), e); } logger.info("Starting agentless installation process on started machine with installation details: " + installationDetails); // Update the logging level of jsch used by the AgentlessInstaller Logger.getLogger(AgentlessInstaller.SSH_LOGGER_NAME) .setLevel(Level.parse(cloud.getProvider().getSshLoggingLevel())); // Execute agentless installation on the remote machine try { installer.installOnMachineWithIP(installationDetails, remainingTimeTill(end), TimeUnit.MILLISECONDS); } catch (final InstallerException e) { throw new ElasticGridServiceAgentProvisioningException( "Failed to install Cloudify Agent on newly provisioned machine: " + e.getMessage(), e); } }
From source file:org.cloudifysource.esc.shell.installer.CloudGridAgentBootstrapper.java
private MachineDetails[] startManagememntProcesses(final MachineDetails[] machines, final String securityProfile, final String keystorePassword, final long endTime) throws InterruptedException, TimeoutException, InstallerException, IOException { final AgentlessInstaller installer = new AgentlessInstaller(); installer.addListener(new CliAgentlessInstallerListener(this.verbose)); // Update the logging level of jsch used by the AgentlessInstaller Logger.getLogger(AgentlessInstaller.SSH_LOGGER_NAME) .setLevel(Level.parse(cloud.getProvider().getSshLoggingLevel())); final ComputeTemplate template = cloud.getCloudCompute().getTemplates() .get(cloud.getConfiguration().getManagementMachineTemplate()); // fixConfigRelativePaths(cloud, template); final int numOfManagementMachines = machines.length; final InstallationDetails[] installations = createInstallationDetails(numOfManagementMachines, machines, template, securityProfile, keystorePassword); // only one machine should try and deploy the WebUI and Rest Admin unless // noWebServices is true //Used for ESM testing purposes. if (installations.length > 0) { if (isNoWebServices()) { installations[0].setNoWebServices(true); }/*from w ww. jav a 2 s.co m*/ if (isNoManagementSpace()) { installations[0].setNoManagementSpace(true); } } //They were installed by the first management machine //and will automatically deployed on the other machines. for (int i = 1; i < installations.length; i++) { installations[i].setNoWebServices(true); installations[i].setNoManagementSpace(true); } final String lookup = createLocatorsString(installations); for (final InstallationDetails detail : installations) { detail.setLocator(lookup); } // executes the agentless installer on all of the machines, // asynchronously installOnMachines(endTime, installer, numOfManagementMachines, installations); return machines; }
From source file:com.delcyon.capo.Configuration.java
@SuppressWarnings({ "unchecked", "static-access" }) public Configuration(String... programArgs) throws Exception { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); documentBuilder = documentBuilderFactory.newDocumentBuilder(); options = new Options(); // the enum this is a little complicated, but it gives us a nice // centralized place to put all of the system parameters // and lets us iterate of the list of options and preferences PREFERENCE[] preferences = PREFERENCE.values(); for (PREFERENCE preference : preferences) { // not the most elegant, but there is no default constructor, but // the has arguments value is always there OptionBuilder optionBuilder = OptionBuilder.hasArg(preference.hasArgument); if (preference.hasArgument == true) { String[] argNames = preference.arguments; for (String argName : argNames) { optionBuilder = optionBuilder.withArgName(argName); }/*from w w w. ja va2s . c o m*/ } optionBuilder = optionBuilder.withDescription(preference.getDescription()); optionBuilder = optionBuilder.withLongOpt(preference.getLongOption()); options.addOption(optionBuilder.create(preference.getOption())); preferenceHashMap.put(preference.toString(), preference); } //add dynamic options Set<String> preferenceProvidersSet = CapoApplication.getAnnotationMap() .get(PreferenceProvider.class.getCanonicalName()); if (preferenceProvidersSet != null) { for (String className : preferenceProvidersSet) { Class preferenceClass = Class.forName(className).getAnnotation(PreferenceProvider.class) .preferences(); if (preferenceClass.isEnum()) { Object[] enumObjects = preferenceClass.getEnumConstants(); for (Object enumObject : enumObjects) { Preference preference = (Preference) enumObject; //filter out any preferences that don't belong on this server or client. if (preference.getLocation() != Location.BOTH) { if (CapoApplication.isServer() == true && preference.getLocation() == Location.CLIENT) { continue; } else if (CapoApplication.isServer() == false && preference.getLocation() == Location.SERVER) { continue; } } preferenceHashMap.put(preference.toString(), preference); boolean hasArgument = false; if (preference.getArguments() == null || preference.getArguments().length == 0) { hasArgument = false; } else { hasArgument = true; } OptionBuilder optionBuilder = OptionBuilder.hasArg(hasArgument); if (hasArgument == true) { String[] argNames = preference.getArguments(); for (String argName : argNames) { optionBuilder = optionBuilder.withArgName(argName); } } optionBuilder = optionBuilder.withDescription(preference.getDescription()); optionBuilder = optionBuilder.withLongOpt(preference.getLongOption()); options.addOption(optionBuilder.create(preference.getOption())); } } } } // create parser CommandLineParser commandLineParser = new GnuParser(); this.commandLine = commandLineParser.parse(options, programArgs); Preferences systemPreferences = Preferences .systemNodeForPackage(CapoApplication.getApplication().getClass()); String capoDirString = null; while (true) { capoDirString = systemPreferences.get(PREFERENCE.CAPO_DIR.longOption, null); if (capoDirString == null) { systemPreferences.put(PREFERENCE.CAPO_DIR.longOption, PREFERENCE.CAPO_DIR.defaultValue); capoDirString = PREFERENCE.CAPO_DIR.defaultValue; try { systemPreferences.sync(); } catch (BackingStoreException e) { //e.printStackTrace(); if (systemPreferences.isUserNode() == false) { System.err.println("Problem with System preferences, trying user's"); systemPreferences = Preferences .userNodeForPackage(CapoApplication.getApplication().getClass()); continue; } else //just bail out { throw e; } } } break; } disableAutoSync = hasOption(PREFERENCE.DISABLE_CONFIG_AUTOSYNC); File capoDirFile = new File(capoDirString); if (capoDirFile.exists() == false) { if (disableAutoSync == false) { capoDirFile.mkdirs(); } } File configDir = new File(capoDirFile, PREFERENCE.CONFIG_DIR.defaultValue); if (configDir.exists() == false) { if (disableAutoSync == false) { configDir.mkdirs(); } } if (disableAutoSync == false) { capoConfigFile = new File(configDir, CONFIG_FILENAME); if (capoConfigFile.exists() == false) { Document configDocument = CapoApplication.getDefaultDocument("config.xml"); FileOutputStream configFileOutputStream = new FileOutputStream(capoConfigFile); TransformerFactory tFactory = TransformerFactory.newInstance(); Transformer transformer = tFactory.newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.transform(new DOMSource(configDocument), new StreamResult(configFileOutputStream)); configFileOutputStream.close(); } configDocument = documentBuilder.parse(capoConfigFile); } else //going memory only, because of disabled auto sync { configDocument = CapoApplication.getDefaultDocument("config.xml"); } if (configDocument instanceof CDocument) { ((CDocument) configDocument).setSilenceEvents(true); } loadPreferences(); preferenceValueHashMap.put(PREFERENCE.CAPO_DIR.longOption, capoDirString); //print out preferences //this also has the effect of persisting all of the default values if a values doesn't already exist for (PREFERENCE preference : preferences) { if (getValue(preference) != null) { CapoApplication.logger.log(Level.CONFIG, preference.longOption + "='" + getValue(preference) + "'"); } } CapoApplication.logger.setLevel(Level.parse(getValue(PREFERENCE.LOGGING_LEVEL))); }
From source file:net.sf.freecol.FreeCol.java
/** * Sets the log level.//w w w . j a va2 s. c o m * * @param arg The log level to set. */ private static void setLogLevel(String arg) { logLevel = Level.parse(arg.toUpperCase()); }
From source file:com.cyberway.issue.crawler.Heritrix.java
public Object invoke(final String operationName, final Object[] params, final String[] signature) throws ReflectionException { if (operationName == null) { throw new RuntimeOperationsException(new IllegalArgumentException("Operation name cannot be null"), "Cannot call invoke with null operation name"); }/*from w w w .j a v a2 s . c o m*/ // INFO logging of JMX invokes: [#HER-907] if (logger.isLoggable(Level.INFO)) { String paramsString = ""; for (Object o : params) { paramsString.concat("[" + o.toString() + "]"); } logger.info("JMX invoke: " + operationName + " [" + paramsString + "]"); } // The pattern in the below is to match an operation and when found // do a return out of if clause. Doing it this way, I can fall // on to the MethodNotFoundException for case where we've an // attribute but no handler. if (operationName.equals(START_OPER)) { JmxUtils.checkParamsCount(START_OPER, params, 0); start(); return null; } if (operationName.equals(STOP_OPER)) { JmxUtils.checkParamsCount(STOP_OPER, params, 0); stop(); return null; } if (operationName.equals(DESTROY_OPER)) { JmxUtils.checkParamsCount(DESTROY_OPER, params, 0); destroy(); return null; } if (operationName.equals(TERMINATE_CRAWL_JOB_OPER)) { JmxUtils.checkParamsCount(TERMINATE_CRAWL_JOB_OPER, params, 0); return new Boolean(this.jobHandler.terminateCurrentJob()); } if (operationName.equals(REBIND_JNDI_OPER)) { JmxUtils.checkParamsCount(REBIND_JNDI_OPER, params, 0); try { registerContainerJndi(); } catch (MalformedObjectNameException e) { throw new RuntimeOperationsException(new RuntimeException(e)); } catch (UnknownHostException e) { throw new RuntimeOperationsException(new RuntimeException(e)); } catch (NamingException e) { throw new RuntimeOperationsException(new RuntimeException(e)); } return null; } if (operationName.equals(SHUTDOWN_OPER)) { JmxUtils.checkParamsCount(SHUTDOWN_OPER, params, 0); Heritrix.shutdown(); return null; } if (operationName.equals(LOG_OPER)) { JmxUtils.checkParamsCount(LOG_OPER, params, 2); logger.log(Level.parse((String) params[0]), (String) params[1]); return null; } if (operationName.equals(INTERRUPT_OPER)) { JmxUtils.checkParamsCount(INTERRUPT_OPER, params, 1); return interrupt((String) params[0]); } if (operationName.equals(START_CRAWLING_OPER)) { JmxUtils.checkParamsCount(START_CRAWLING_OPER, params, 0); startCrawling(); return null; } if (operationName.equals(STOP_CRAWLING_OPER)) { JmxUtils.checkParamsCount(STOP_CRAWLING_OPER, params, 0); stopCrawling(); return null; } if (operationName.equals(ADD_CRAWL_JOB_OPER)) { JmxUtils.checkParamsCount(ADD_CRAWL_JOB_OPER, params, 4); try { return addCrawlJob((String) params[0], (String) params[1], checkForEmptyPlaceHolder((String) params[2]), checkForEmptyPlaceHolder((String) params[3])); } catch (IOException e) { throw new RuntimeOperationsException(new RuntimeException(e)); } catch (FatalConfigurationException e) { throw new RuntimeOperationsException(new RuntimeException(e)); } } if (operationName.equals(DELETE_CRAWL_JOB_OPER)) { JmxUtils.checkParamsCount(DELETE_CRAWL_JOB_OPER, params, 1); this.jobHandler.deleteJob((String) params[0]); return null; } if (operationName.equals(ADD_CRAWL_JOB_BASEDON_OPER)) { JmxUtils.checkParamsCount(ADD_CRAWL_JOB_BASEDON_OPER, params, 4); return addCrawlJobBasedOn((String) params[0], (String) params[1], checkForEmptyPlaceHolder((String) params[2]), checkForEmptyPlaceHolder((String) params[3])); } if (operationName.equals(ALERT_OPER)) { JmxUtils.checkParamsCount(ALERT_OPER, params, 1); SinkHandlerLogRecord slr = null; if (this.alertManager.getCount() > 0) { // This is creating a vector of all alerts just so I can then // use passed index into resultant vector -- needs to be // improved. slr = (SinkHandlerLogRecord) this.alertManager.getAll().get(((Integer) params[0]).intValue()); } return (slr != null) ? slr.toString() : null; } if (operationName.equals(PENDING_JOBS_OPER)) { JmxUtils.checkParamsCount(PENDING_JOBS_OPER, params, 0); try { return makeJobsTabularData(getJobHandler().getPendingJobs()); } catch (OpenDataException e) { throw new RuntimeOperationsException(new RuntimeException(e)); } } if (operationName.equals(COMPLETED_JOBS_OPER)) { JmxUtils.checkParamsCount(COMPLETED_JOBS_OPER, params, 0); try { return makeJobsTabularData(getJobHandler().getCompletedJobs()); } catch (OpenDataException e) { throw new RuntimeOperationsException(new RuntimeException(e)); } } if (operationName.equals(CRAWLEND_REPORT_OPER)) { JmxUtils.checkParamsCount(CRAWLEND_REPORT_OPER, params, 2); try { return getCrawlendReport((String) params[0], (String) params[1]); } catch (IOException e) { throw new RuntimeOperationsException(new RuntimeException(e)); } } throw new ReflectionException(new NoSuchMethodException(operationName), "Cannot find the operation " + operationName); }