List of usage examples for java.lang Integer getInteger
public static Integer getInteger(String nm)
From source file:com.revo.deployr.rbroker.example.data.io.auth.pooled.preload.RepoFileInEncodedDataOut.java
public RepoFileInEncodedDataOut() { RBroker rBroker = null;/*w w w . j av a 2 s. c o m*/ try { /* * Determine DeployR server endpoint. */ String endpoint = System.getProperty("endpoint"); log.info("[ CONFIGURATION ] Using endpoint [ " + endpoint + " ]"); /* * Create the PoolCreationOptions object to specify * preload inputs to preload on broker initialization. * * This options object can be used to pass most standard * execution model parameters when initializing a pool. * All fields are optional. * * See the Standard Execution Model chapter in the * Client Library Tutorial on the DeployR website for * further details. */ PoolCreationOptions poolOptions = new PoolCreationOptions(); /* * Preload from the DeployR repository the following * binary R object input file: * /testuser/example-data-io/hipStar.rData */ PoolPreloadOptions preloadWorkspace = new PoolPreloadOptions(); preloadWorkspace.filename = "hipStar.rData"; preloadWorkspace.directory = "example-data-io"; preloadWorkspace.author = "testuser"; poolOptions.preloadWorkspace = preloadWorkspace; log.info("[ POOL PRELOAD ] Repository binary file input " + "preload, [ PoolCreationOptions.preloadWorkspace ]."); /* * Build configuration to initialize RBroker instance. */ RAuthentication rAuth = new RBasicAuthentication(System.getProperty("username"), System.getProperty("password")); PooledBrokerConfig brokerConfig = new PooledBrokerConfig(endpoint, rAuth, Integer.getInteger("example-max-concurrency"), poolOptions); log.info("[ CONFIGURATION ] Using broker config " + "[ PooledBrokerConfig ]"); /* * Establish RBroker connection to DeployR server. */ rBroker = RBrokerFactory.pooledTaskBroker(brokerConfig); /* * Register asynchronous listeners for task and * broker runtime events. */ rBroker.addTaskListener(this); rBroker.addBrokerListener(this); log.info("[ CONNECTION ] Established authenticated " + "pooled broker [ RBroker ]."); /* * Create the PooledTaskOptions object * to specify task inputs and output to the task. * * This options object can be used to pass standard * execution model parameters on execution calls. All * fields are optional. * * See the Standard Execution Model chapter in the * Client Library Tutorial on the DeployR website for * further details. */ PooledTaskOptions taskOptions = new PooledTaskOptions(); /* * Request the retrieval of the "hip" data.frame and * two vector objects from the workspace following the * task execution. The corresponding R objects are named * as follows: * 'hip', hipDim', 'hipNames'. */ taskOptions.routputs = Arrays.asList("hip", "hipDim", "hipNames"); log.info("[ TASK OPTION ] DeployR-encoded R object request " + "set on task [ PooledTaskOptions.routputs ]."); /* * Declare task for execution on broker based on * repository-managed R script: * /testuser/example-data-io/dataIO.R */ RTask rTask = RTaskFactory.pooledTask("dataIO.R", "example-data-io", "testuser", null, taskOptions); rBroker.submit(rTask); log.info("[ EXECUTION ] Pooled task " + "submitted to broker [ RTask ]."); /* * Simple block on main thread of this sample application * until example RTask execution completes. */ latch.await(); } catch (Exception ex) { log.warn("Unexpected error: ex=" + ex); } finally { /* * Clean-up after example completes. */ if (rBroker != null) { try { rBroker.shutdown(); } catch (Exception bex) { log.warn("RBroker.shutdown ex=" + bex); } } } }
From source file:com.revo.deployr.rbroker.example.data.io.auth.pooled.preload.EncodedDataInBinaryFileOut.java
public EncodedDataInBinaryFileOut() { RBroker rBroker = null;//w ww . j a v a2s .com try { /* * Determine DeployR server endpoint. */ String endpoint = System.getProperty("endpoint"); log.info("[ CONFIGURATION ] Using endpoint [ " + endpoint + " ]"); /* * Create the PoolCreationOptions object to specify * preload inputs to preload on broker initialization. * * This options object can be used to pass most standard * execution model parameters when initializing a pool. * All fields are optional. * * See the Standard Execution Model chapter in the * Client Library Tutorial on the DeployR website for * further details. */ PoolCreationOptions poolOptions = new PoolCreationOptions(); /* * Simulate application generated data. This data * is first encoded using the RDataFactory before * being passed as an input on PoolCreationOptions. * * This encoded R input is automatically converted * into a workspace object on pool initialization. */ RData generatedData = DeployRUtil.simulateGeneratedData(log); if (generatedData != null) { List<RData> rinputs = Arrays.asList(generatedData); poolOptions.rinputs = rinputs; } log.info("[ POOL PRELOAD ] DeployR-encoded R input " + "preload, [ PoolCreationOptions.rinputs ]."); /* * Build configuration to initialize RBroker instance. */ RAuthentication rAuth = new RBasicAuthentication(System.getProperty("username"), System.getProperty("password")); PooledBrokerConfig brokerConfig = new PooledBrokerConfig(endpoint, rAuth, Integer.getInteger("example-max-concurrency"), poolOptions); log.info("[ CONFIGURATION ] Using broker config " + "[ PooledBrokerConfig ]"); /* * Establish RBroker connection to DeployR server. */ rBroker = RBrokerFactory.pooledTaskBroker(brokerConfig); /* * Register asynchronous listeners for task and * broker runtime events. */ rBroker.addTaskListener(this); rBroker.addBrokerListener(this); log.info("[ CONNECTION ] Established authenticated " + "pooled broker [ RBroker ]."); /* * Declare task for execution on broker based on * repository-managed R script: * /testuser/example-data-io/dataIO.R */ RTask rTask = RTaskFactory.pooledTask("dataIO.R", "example-data-io", "testuser", null, null); rBroker.submit(rTask); log.info("[ EXECUTION ] Pooled task " + "submitted to broker [ RTask ]."); /* * Simple block on main thread of this sample application * until example RTask execution completes. */ latch.await(); } catch (Exception ex) { log.warn("Unexpected error: ex=" + ex); } finally { /* * Clean-up after example completes. */ if (rBroker != null) { try { rBroker.shutdown(); } catch (Exception bex) { log.warn("RBroker.shutdown ex=" + bex); } } } }
From source file:com.revo.deployr.rbroker.example.data.io.auth.pooled.preload.ExternalDataInDataFileOut.java
public ExternalDataInDataFileOut() { RBroker rBroker = null;//from w ww .j a v a 2s . c o m try { /* * Determine DeployR server endpoint. */ String endpoint = System.getProperty("endpoint"); log.info("[ CONFIGURATION ] Using endpoint [ " + endpoint + " ]"); /* * Create the PoolCreationOptions object to specify * preload inputs to preload on broker initialization. * * This options object can be used to pass most standard * execution model parameters when initializing a pool. * All fields are optional. * * See the Standard Execution Model chapter in the * Client Library Tutorial on the DeployR website for * further details. */ PoolCreationOptions poolOptions = new PoolCreationOptions(); /* * Load an R object literal "hipStarUrl" into the * workspace on pool initialization. * * The R script checks for the existence of "hipStarUrl" * in the workspace and if present uses the URL path * to load the Hipparcos star dataset from the DAT file * at that location. */ RData hipStarUrl = RDataFactory.createString("hipStarUrl", HIP_DAT_URL); List<RData> rinputs = Arrays.asList(hipStarUrl); poolOptions.rinputs = rinputs; log.info( "[ POOL PRELOAD ] External data source input " + "preload, [ PoolCreationOptions.rinputs ]."); /* * Build configuration to initialize RBroker instance. */ RAuthentication rAuth = new RBasicAuthentication(System.getProperty("username"), System.getProperty("password")); PooledBrokerConfig brokerConfig = new PooledBrokerConfig(endpoint, rAuth, Integer.getInteger("example-max-concurrency"), poolOptions); log.info("[ CONFIGURATION ] Using broker config " + "[ PooledBrokerConfig ]"); /* * Establish RBroker connection to DeployR server. */ rBroker = RBrokerFactory.pooledTaskBroker(brokerConfig); /* * Register asynchronous listeners for task and * broker runtime events. */ rBroker.addTaskListener(this); rBroker.addBrokerListener(this); log.info("[ CONNECTION ] Established authenticated " + "pooled broker [ RBroker ]."); /* * Declare task for execution on broker based on * repository-managed R script: * /testuser/example-data-io/dataIO.R */ RTask rTask = RTaskFactory.pooledTask("dataIO.R", "example-data-io", "testuser", null, null); rBroker.submit(rTask); log.info("[ EXECUTION ] Pooled task " + "submitted to broker [ RTask ]."); /* * Simple block on main thread of this sample application * until example RTask execution completes. */ latch.await(); } catch (Exception ex) { log.warn("Unexpected error: ex=" + ex); } finally { /* * Clean-up after example completes. */ if (rBroker != null) { try { rBroker.shutdown(); } catch (Exception bex) { log.warn("RBroker.shutdown ex=" + bex); } } } }
From source file:org.unitedinternet.cosmo.model.text.XhtmlTicketFormat.java
public Ticket parse(String source, EntityFactory entityFactory) throws ParseException { String key = null;/*from w ww . ja v a 2s . c o m*/ TicketType type = null; Integer timeout = null; try { if (source == null) { throw new ParseException("Source has no XML data", -1); } StringReader sr = new StringReader(source); XMLStreamReader reader = createXmlReader(sr); boolean inTicket = false; while (reader.hasNext()) { reader.next(); if (!reader.isStartElement()) { continue; } if (hasClass(reader, "ticket")) { if (LOG.isDebugEnabled()) { LOG.debug("found ticket element"); } inTicket = true; continue; } if (inTicket && hasClass(reader, "key")) { if (LOG.isDebugEnabled()) { LOG.debug("found key element"); } key = reader.getElementText(); if (StringUtils.isBlank(key)) { handleParseException("Key element must not be empty", reader); } continue; } if (inTicket && hasClass(reader, "type")) { if (LOG.isDebugEnabled()) { LOG.debug("found type element"); } String typeId = reader.getAttributeValue(null, "title"); if (StringUtils.isBlank(typeId)) { handleParseException("Ticket type title must not be empty", reader); } type = TicketType.createInstance(typeId); continue; } if (inTicket && hasClass(reader, "timeout")) { if (LOG.isDebugEnabled()) { LOG.debug("found timeout element"); } String timeoutString = reader.getAttributeValue(null, "title"); if (StringUtils.isBlank(timeoutString)) { timeout = null; } else { timeout = Integer.getInteger(timeoutString); } continue; } } if (type == null || key == null) { handleParseException("Ticket must have type and key", reader); } reader.close(); } catch (XMLStreamException e) { handleXmlException("Error reading XML", e); } Ticket ticket = entityFactory.createTicket(type); ticket.setKey(key); if (timeout == null) { ticket.setTimeout(Ticket.TIMEOUT_INFINITE); } else { ticket.setTimeout(timeout); } return ticket; }
From source file:com.smash.revolance.ui.cmdline.Commands.java
private int execStatusCmd(File workingDir, String[] opts) { try {/*from w ww. j a v a 2s. com*/ System.out.println("Retrieving server status"); DefaultHttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet( "http://localhost:" + Integer.getInteger("port").intValue() + "/ui-monitoring-server/status"); client.execute(request); // throw an IOException when System.out.println("server is started"); return 0; } catch (HttpHostConnectException e) { System.out.println("server is stopped"); return 1; } catch (Exception e) { return 2; } }
From source file:org.wisdom.configuration.ConfigurationImpl.java
/** * Get a property as Integer or null if not there / or property no integer. * * @param key the key/*from w ww. j a va 2 s. c o m*/ * @return the property or {@literal null} if not there or property no integer */ @Override public Integer getInteger(String key) { Integer v = Integer.getInteger(key); if (v == null) { try { return configuration.getInt(key); } catch (NoSuchElementException e) { //NOSONAR return null; } } else { return v; } }
From source file:us.mn.state.health.lims.reports.action.implementation.ExportProjectByDate.java
/** * @return true, if location is not blank or "0" is is found in the DB; * false otherwise/*from www .j av a2 s . co m*/ */ private boolean validateProject() { if (isBlankOrNull(projectStr) || "0".equals(Integer.getInteger(projectStr))) { add1LineErrorMessage("report.error.message.project.missing"); return false; } ProjectDAO dao = new ProjectDAOImpl(); project = dao.getProjectById(projectStr); if (project == null) { add1LineErrorMessage("report.error.message.project.missing"); return false; } return true; }
From source file:com.revo.deployr.rbroker.example.data.io.auth.pooled.preload.MultipleDataInMultipleDataOut.java
public MultipleDataInMultipleDataOut() { RBroker rBroker = null;//w w w . j av a2 s . c om try { /* * Determine DeployR server endpoint. */ String endpoint = System.getProperty("endpoint"); log.info("[ CONFIGURATION ] Using endpoint [ " + endpoint + " ]"); /* * Create the PoolCreationOptions object to specify * preload inputs to preload on broker initialization. * * This options object can be used to pass most standard * execution model parameters when initializing a pool. * All fields are optional. * * See the Standard Execution Model chapter in the * Client Library Tutorial on the DeployR website for * further details. */ PoolCreationOptions poolOptions = new PoolCreationOptions(); /* * Preload from the DeployR repository the following * binary R object input file: * /testuser/example-data-io/hipStar.rData */ PoolPreloadOptions preloadWorkspace = new PoolPreloadOptions(); preloadWorkspace.filename = "hipStar.rData"; preloadWorkspace.directory = "example-data-io"; preloadWorkspace.author = "testuser"; poolOptions.preloadWorkspace = preloadWorkspace; log.info("[ POOL PRELOAD ] Repository binary file input " + "preload, [ PoolCreationOptions.preloadWorkspace ]."); /* * Load an R object literal "hipStarUrl" into the * workspace prior to task execution. * * The R script checks for the existence of "hipStarUrl" * in the workspace and if present uses the URL path * to load the Hipparcos star dataset from the DAT file * at that location. */ RData hipStarUrl = RDataFactory.createString("hipStarUrl", HIP_DAT_URL); List<RData> rinputs = Arrays.asList(hipStarUrl); poolOptions.rinputs = rinputs; log.info( "[ POOL PRELOAD ] External data source input " + "preload, [ PoolCreationOptions.rinputs ]."); /* * Build configuration to initialize RBroker instance. */ RAuthentication rAuth = new RBasicAuthentication(System.getProperty("username"), System.getProperty("password")); PooledBrokerConfig brokerConfig = new PooledBrokerConfig(endpoint, rAuth, Integer.getInteger("example-max-concurrency"), poolOptions); log.info("[ CONFIGURATION ] Using broker config " + "[ PooledBrokerConfig ]"); /* * Establish RBroker connection to DeployR server. */ rBroker = RBrokerFactory.pooledTaskBroker(brokerConfig); /* * Register asynchronous listeners for task and * broker runtime events. */ rBroker.addTaskListener(this); rBroker.addBrokerListener(this); log.info("[ CONNECTION ] Established authenticated " + "pooled broker [ RBroker ]."); /* * MultipleDataInMultipleDataOut Example Note: * * The inputs sent on this example are contrived * and superfluous as the hipStar.rData binary R * object input and the hipStarUrl input perform * the exact same purpose...to load the Hip STAR * dataset into the workspace ahead of execution. * * The example is provided to simply demonstrate * the mechanism of specifying multiple inputs. */ /* * Create the PooledTaskOptions object * to specify task inputs and output to the task. * * This options object can be used to pass standard * execution model parameters on execution calls. All * fields are optional. * * See the Standard Execution Model chapter in the * Client Library Tutorial on the DeployR website for * further details. */ PooledTaskOptions taskOptions = new PooledTaskOptions(); /* * Request the retrieval of the "hip" data.frame and * two vector objects from the workspace following the * task execution. The corresponding R objects are named * as follows: * 'hip', hipDim', 'hipNames'. */ taskOptions.routputs = Arrays.asList("hip", "hipDim", "hipNames"); log.info("[ TASK OPTION ] DeployR-encoded R object request " + "set on task [ PooledTaskOptions.routputs ]."); /* * Declare task for execution on broker based on * repository-managed R script: * /testuser/example-data-io/dataIO.R */ RTask rTask = RTaskFactory.pooledTask("dataIO.R", "example-data-io", "testuser", null, taskOptions); rBroker.submit(rTask); log.info("[ EXECUTION ] Pooled task " + "submitted to broker [ RTask ]."); /* * Simple block on main thread of this sample application * until example RTask execution completes. */ latch.await(); } catch (Exception ex) { log.warn("Unexpected error: ex=" + ex); } finally { /* * Clean-up after example completes. */ if (rBroker != null) { try { rBroker.shutdown(); } catch (Exception bex) { log.warn("RBroker.shutdown ex=" + bex); } } } }
From source file:com.smash.revolance.ui.cmdline.Commands.java
private int execStartCmd(final File workingDir, final String[] opts) { new Thread(new Runnable() { @Override/*from w w w . j a v a 2s .co m*/ public void run() { Server server = new Server(); Connector connector = new SelectChannelConnector(); connector.setPort(Integer.getInteger("port").intValue()); server.setConnectors(new Connector[] { connector }); String war = workingDir + "/" + System.getProperty("war"); WebAppContext webapp = new WebAppContext(war, "/ui-monitoring-server"); server.setHandler(webapp); try { System.out.println("Starting server"); server.start(); System.out.println("Starting server [Done]"); server.join(); } catch (Exception e) { e.printStackTrace(); } } }).run(); return 0; }
From source file:org.wisdom.configuration.ConfigurationImpl.java
/** * Get a Integer property or a default value when property cannot be found * in any configuration file./*from w w w .j av a 2 s . c om*/ * * @param key the key used in the configuration file. * @param defaultValue Default value returned, when value cannot be found in * configuration. * @return the value of the key or the default value. */ @Override public Integer getIntegerWithDefault(String key, Integer defaultValue) { Integer v = Integer.getInteger(key); if (v == null) { return configuration.getInt(key, defaultValue); } return v; }