List of usage examples for java.lang System getProperty
public static String getProperty(String key)
From source file:examples.ssh.RudimentaryPTY.java
public static void main(String... args) throws IOException { SSHClient ssh = new SSHClient(); ssh.loadKnownHosts();//from w ww .ja va 2 s. co m ssh.connect("localhost"); Shell shell = null; try { ssh.authPublickey(System.getProperty("user.name")); Session session = ssh.startSession(); session.allocateDefaultPTY(); shell = session.startShell(); new Pipe("stdout", shell.getInputStream(), System.out) // .bufSize(shell.getLocalMaxPacketSize()) // .start(); new Pipe("stderr", shell.getErrorStream(), System.err) // .bufSize(shell.getLocalMaxPacketSize()) // .start(); // Now make System.in act as stdin. To exit, hit Ctrl+D (since that results in an EOF on System.in) // This is kinda messy because java only allows console input after you hit return // But this is just an example... a GUI app could implement a proper PTY Pipe.pipe(System.in, shell.getOutputStream(), shell.getRemoteMaxPacketSize(), false); } finally { if (shell != null) shell.close(); ssh.disconnect(); } }
From source file:com.revo.deployr.client.example.data.io.auth.stateful.exec.RepoFileInRepoFileOut.java
public static void main(String args[]) throws Exception { RClient rClient = null;/* w ww . j a v a2s . com*/ RProject rProject = null; try { /* * Determine DeployR server endpoint. */ String endpoint = System.getProperty("endpoint"); log.info("[ CONFIGURATION ] Using endpoint=" + endpoint); /* * Establish RClient connection to DeployR server. * * An RClient connection is the mandatory starting * point for any application using the client library. */ rClient = RClientFactory.createClient(endpoint); log.info("[ CONNECTION ] Established anonymous " + "connection [ RClient ]."); /* * Build a basic authentication token. */ RAuthentication rAuth = new RBasicAuthentication(System.getProperty("username"), System.getProperty("password")); /* * Establish an authenticated handle with the DeployR * server, rUser. Following this call the rClient * connection is operating as an authenticated connection * and all calls on rClient inherit the access permissions * of the authenticated user, rUser. */ RUser rUser = rClient.login(rAuth); log.info("[ AUTHENTICATION ] Upgraded to authenticated " + "connection [ RUser ]."); /* * Create a temporary project (R session). * * Optionally: * ProjectCreationOptions options = * new ProjectCreationOptions(); * * Populate options as needed, then: * * rProject = rUser.createProject(options); */ rProject = rUser.createProject(); log.info("[ GO STATEFUL ] Created stateful temporary " + "R session [ RProject ]."); /* * Create a ProjectExecutionOptions instance * to specify data inputs and output to the * execution of the repository-managed R script. * * 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. */ ProjectExecutionOptions options = new ProjectExecutionOptions(); /* * Preload from the DeployR repository the following * binary R object input file: * /testuser/example-data-io/hipStar.rData */ ProjectPreloadOptions preloadWorkspace = new ProjectPreloadOptions(); preloadWorkspace.filename = "hipStar.rData"; preloadWorkspace.directory = "example-data-io"; preloadWorkspace.author = "testuser"; options.preloadWorkspace = preloadWorkspace; log.info("[ DATA INPUT ] Repository binary file input " + "set on execution, [ ProjectExecutionOptions.preloadWorkspace ]."); /* * Request storage of entire workspace as a * binary rData file to the DeployR-repository * following the execution. * * Alternatively, you could use storageOptions.objects * to store individual objects from the workspace. */ ProjectStorageOptions storageOptions = new ProjectStorageOptions(); // Use random file name for this example. storageOptions.workspace = Long.toHexString(Double.doubleToLongBits(Math.random())); storageOptions.directory = "example-data-io"; options.storageOptions = storageOptions; log.info("[ EXEC OPTION ] Repository storage request " + "set on execution [ ProjectExecutionOptions.storageOptions ]."); /* * Execute a public analytics Web service as an authenticated * user based on a repository-managed R script: * /testuser/example-data-io/dataIO.R */ RProjectExecution exec = rProject.executeScript("dataIO.R", "example-data-io", "testuser", null, options); log.info("[ EXECUTION ] Stateful R script " + "execution completed [ RProjectExecution ]."); /* * Retrieve repository-managed file(s) that were * generated by the execution per ProjectStorageOptions. * * Outputs generated by an execution can be used in any * number of ways by client applications, including: * * 1. Use output data to perform further calculations. * 2. Display output data to an end-user. * 3. Write output data to a database. * 4. Pass output data along to another Web service. * 5. etc. */ List<RRepositoryFile> repoFiles = exec.about().repositoryFiles; for (RRepositoryFile repoFile : repoFiles) { log.info("[ DATA OUTPUT ] Retrieved repository " + "file output " + repoFile.about().filename + " [ RRepositoryFile ]."); InputStream fis = null; try { fis = repoFile.download(); } catch (Exception ex) { log.warn("Repository-managed file download " + ex); } finally { IOUtils.closeQuietly(fis); try { // Clean-up after example. repoFile.delete(); } catch (Exception dex) { log.warn("Repository-managed file delete " + dex); } } } } catch (Exception ex) { log.warn("Unexpected runtime exception=" + ex); } finally { try { if (rProject != null) { /* * Close rProject before application exits. */ rProject.close(); } } catch (Exception fex) { } try { if (rClient != null) { /* * Release rClient connection before application exits. */ rClient.release(); } } catch (Exception fex) { } } }
From source file:com.revo.deployr.client.example.data.io.auth.stateful.preload.RepoFileInRepoFileOut.java
public static void main(String args[]) throws Exception { RClient rClient = null;//from w w w .j av a 2s .co m RProject rProject = null; try { /* * Determine DeployR server endpoint. */ String endpoint = System.getProperty("endpoint"); log.info("[ CONFIGURATION ] Using endpoint=" + endpoint); /* * Establish RClient connection to DeployR server. * * An RClient connection is the mandatory starting * point for any application using the client library. */ rClient = RClientFactory.createClient(endpoint); log.info("[ CONNECTION ] Established anonymous " + "connection [ RClient ]."); /* * Build a basic authentication token. */ RAuthentication rAuth = new RBasicAuthentication(System.getProperty("username"), System.getProperty("password")); /* * Establish an authenticated handle with the DeployR * server, rUser. Following this call the rClient * connection is operating as an authenticated connection * and all calls on rClient inherit the access permissions * of the authenticated user, rUser. */ RUser rUser = rClient.login(rAuth); log.info("[ AUTHENTICATION ] Upgraded to authenticated " + "connection [ RUser ]."); /* * Create a ProjectCreationOptions instance * to specify data inputs that "pre-heat" the R session * workspace or working directory for your project. */ ProjectCreationOptions creationOpts = new ProjectCreationOptions(); /* * Preload from the DeployR repository the following * binary R object input file: * /testuser/example-data-io/hipStar.rData */ ProjectPreloadOptions preloadWorkspace = new ProjectPreloadOptions(); preloadWorkspace.filename = "hipStar.rData"; preloadWorkspace.directory = "example-data-io"; preloadWorkspace.author = "testuser"; creationOpts.preloadWorkspace = preloadWorkspace; log.info("[ PRELOAD INPUT ] Repository binary file input " + "set on project creation, [ ProjectCreationOptions.preloadWorkspace ]."); /* * Create a temporary project (R session) passing a * ProjectCreationOptions to "pre-heat" data into the * workspace and/or working directory. */ rProject = rUser.createProject(creationOpts); log.info("[ GO STATEFUL ] Created stateful temporary " + "R session [ RProject ]."); /* * Create a ProjectExecutionOptions instance * to specify data inputs and output to the * execution of the repository-managed R script. * * 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. */ ProjectExecutionOptions execOpts = new ProjectExecutionOptions(); /* * Request storage of entire workspace as a * binary rData file to the DeployR-repository * following the execution. * * Alternatively, you could use storageOptions.objects * to store individual objects from the workspace. */ ProjectStorageOptions storageOptions = new ProjectStorageOptions(); // Use random file name for this example. storageOptions.workspace = Long.toHexString(Double.doubleToLongBits(Math.random())); storageOptions.directory = "example-data-io"; execOpts.storageOptions = storageOptions; log.info("[ EXEC OPTION ] Repository storage request " + "set on execution [ ProjectExecutionOptions.storageOptions ]."); /* * Execute a public analytics Web service as an authenticated * user based on a repository-managed R script: * /testuser/example-data-io/dataIO.R */ RProjectExecution exec = rProject.executeScript("dataIO.R", "example-data-io", "testuser", null, execOpts); log.info("[ EXECUTION ] Stateful R script " + "execution completed [ RProjectExecution ]."); /* * Retrieve repository-managed file(s) that were * generated by the execution per ProjectStorageOptions. * * Outputs generated by an execution can be used in any * number of ways by client applications, including: * * 1. Use output data to perform further calculations. * 2. Display output data to an end-user. * 3. Write output data to a database. * 4. Pass output data along to another Web service. * 5. etc. */ List<RRepositoryFile> repoFiles = exec.about().repositoryFiles; for (RRepositoryFile repoFile : repoFiles) { log.info("[ DATA OUTPUT ] Retrieved repository " + "file output " + repoFile.about().filename + " [ RRepositoryFile ]."); InputStream fis = null; try { fis = repoFile.download(); } catch (Exception ex) { log.warn("Repository-managed file download " + ex); } finally { IOUtils.closeQuietly(fis); try { // Clean-up after example. repoFile.delete(); } catch (Exception dex) { log.warn("Repository-managed file delete " + dex); } } } } catch (Exception ex) { log.warn("Unexpected runtime exception=" + ex); } finally { try { if (rProject != null) { /* * Close rProject before application exits. */ rProject.close(); } } catch (Exception fex) { } try { if (rClient != null) { /* * Release rClient connection before application exits. */ rClient.release(); } } catch (Exception fex) { } } }
From source file:com.fusesource.examples.activemq.VirtualConsumer.java
public static void main(String args[]) { Connection connection = null; try {//from w ww. j av a 2s . c o m // JNDI lookup of JMS Connection Factory and JMS Destination Context context = new InitialContext(); ConnectionFactory factory = (ConnectionFactory) context.lookup(CONNECTION_FACTORY_NAME); connection = factory.createConnection(); connection.setClientID(System.getProperty("clientID")); connection.start(); Session session = connection.createSession(NON_TRANSACTED, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue(System.getProperty("queue")); MessageConsumer consumer = session.createConsumer(queue); LOG.info("Start consuming messages from " + queue + " with " + MESSAGE_TIMEOUT_MILLISECONDS + "ms timeout"); // Synchronous message consumer int i = 1; while (true) { Message message = consumer.receive(MESSAGE_TIMEOUT_MILLISECONDS); if (message != null) { if (message instanceof TextMessage) { String text = ((TextMessage) message).getText(); LOG.info("Got " + (i++) + ". message: " + text); } } else { break; } } consumer.close(); session.close(); } catch (Throwable t) { LOG.error(t); } finally { // Cleanup code // In general, you should always close producers, consumers, // sessions, and connections in reverse order of creation. // For this simple example, a JMS connection.close will // clean up all other resources. if (connection != null) { try { connection.close(); } catch (JMSException e) { LOG.error(e); } } } }
From source file:com.fusesource.examples.activemq.DurableSubscriber.java
public static void main(String args[]) { Connection connection = null; try {//from w w w . ja v a2 s .c om // JNDI lookup of JMS Connection Factory and JMS Destination Context context = new InitialContext(); ConnectionFactory factory = (ConnectionFactory) context.lookup(CONNECTION_FACTORY_NAME); connection = factory.createConnection(); connection.setClientID(System.getProperty("clientID")); connection.start(); Session session = connection.createSession(NON_TRANSACTED, Session.CLIENT_ACKNOWLEDGE); String topicName = System.getProperty("topic"); Topic topic = session.createTopic(topicName); MessageConsumer consumer = session.createDurableSubscriber(topic, "Test_Durable_Subscriber"); LOG.info("Start consuming messages from " + topicName + " with " + MESSAGE_TIMEOUT_MILLISECONDS + "ms timeout"); // Synchronous message consumer int i = 1; while (true) { Message message = consumer.receive(MESSAGE_TIMEOUT_MILLISECONDS); if (message != null) { if (message instanceof TextMessage) { String text = ((TextMessage) message).getText(); LOG.info("Got " + (i++) + ". message: " + text); } } else { break; } } consumer.close(); session.close(); } catch (Throwable t) { LOG.error(t); } finally { // Cleanup code // In general, you should always close producers, consumers, // sessions, and connections in reverse order of creation. // For this simple example, a JMS connection.close will // clean up all other resources. if (connection != null) { try { connection.close(); } catch (JMSException e) { LOG.error(e); } } } }
From source file:com.revo.deployr.client.example.data.io.auth.discrete.exec.EncodedDataInBinaryFileOut.java
public static void main(String args[]) throws Exception { RClient rClient = null;//from w ww . j ava2 s . c om try { /* * Determine DeployR server endpoint. */ String endpoint = System.getProperty("endpoint"); log.info("[ CONFIGURATION ] Using endpoint=" + endpoint); /* * Establish RClient connection to DeployR server. * * An RClient connection is the mandatory starting * point for any application using the client library. */ rClient = RClientFactory.createClient(endpoint); log.info("[ CONNECTION ] Established anonymous " + "connection [ RClient ]."); /* * Build a basic authentication token. */ RAuthentication rAuth = new RBasicAuthentication(System.getProperty("username"), System.getProperty("password")); /* * Establish an authenticated handle with the DeployR * server, rUser. Following this call the rClient * connection is operating as an authenticated connection * and all calls on rClient inherit the access permissions * of the authenticated user, rUser. */ RUser rUser = rClient.login(rAuth); log.info("[ AUTHENTICATION ] Upgraded to authenticated " + "connection [ RUser ]."); /* * Create the AnonymousProjectExecutionOptions object * to specify data inputs and output to the script. * * 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. */ AnonymousProjectExecutionOptions options = new AnonymousProjectExecutionOptions(); /* * Simulate application generated data. This data * is first encoded using the RDataFactory before * being passed as an input on the execution. * * This encoded R input is automatically converted * into a workspace object before script execution. */ RData generatedData = simulateGeneratedData(); if (generatedData != null) { List<RData> rinputs = Arrays.asList(generatedData); options.rinputs = rinputs; } log.info("[ DATA INPUT ] DeployR-encoded R input " + "set on execution, [ ProjectExecutionOptions.rinputs ]."); /* * Execute an analytics Web service as an authenticated * user based on a repository-managed R script: * /testuser/example-data-io/dataIO.R */ RScriptExecution exec = rClient.executeScript("dataIO.R", "example-data-io", "testuser", null, options); log.info("[ EXECUTION ] Discrete R script " + "execution completed [ RScriptExecution ]."); /* * Retrieve the working directory file (artifact) called * hip.rData that was generated by the execution. * * Outputs generated by an execution can be used in any * number of ways by client applications, including: * * 1. Use output data to perform further calculations. * 2. Display output data to an end-user. * 3. Write output data to a database. * 4. Pass output data along to another Web service. * 5. etc. */ List<RProjectFile> wdFiles = exec.about().artifacts; for (RProjectFile wdFile : wdFiles) { if (wdFile.about().filename.equals("hip.rData")) { log.info("[ DATA OUTPUT ] Retrieved working directory " + "file output " + wdFile.about().filename + " [ RProjectFile ]."); InputStream fis = null; try { fis = wdFile.download(); } catch (Exception ex) { log.warn("Working directory binary file " + ex); } finally { IOUtils.closeQuietly(fis); } } } } catch (Exception ex) { log.warn("Unexpected runtime exception=" + ex); } finally { try { if (rClient != null) { /* * Release rClient connection before application exits. */ rClient.release(); } } catch (Exception fex) { } } }
From source file:com.revo.deployr.client.example.data.io.auth.discrete.exec.ExternalDataInDataFileOut.java
public static void main(String args[]) throws Exception { RClient rClient = null;//w w w.j av a 2s.c o m try { /* * Determine DeployR server endpoint. */ String endpoint = System.getProperty("endpoint"); log.info("[ CONFIGURATION ] Using endpoint=" + endpoint); /* * Establish RClient connection to DeployR server. * * An RClient connection is the mandatory starting * point for any application using the client library. */ rClient = RClientFactory.createClient(endpoint); log.info("[ CONNECTION ] Established anonymous " + "connection [ RClient ]."); /* * Build a basic authentication token. */ RAuthentication rAuth = new RBasicAuthentication(System.getProperty("username"), System.getProperty("password")); /* * Establish an authenticated handle with the DeployR * server, rUser. Following this call the rClient * connection is operating as an authenticated connection * and all calls on rClient inherit the access permissions * of the authenticated user, rUser. */ RUser rUser = rClient.login(rAuth); log.info("[ AUTHENTICATION ] Upgraded to authenticated " + "connection [ RUser ]."); /* * Create the AnonymousProjectExecutionOptions object * to specify data inputs and output to the script. * * 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. */ AnonymousProjectExecutionOptions options = new AnonymousProjectExecutionOptions(); /* * Load an R object literal "hipStarUrl" into the * workspace prior to script 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); options.rinputs = rinputs; log.info("[ DATA INPUT ] External data source input " + "set on execution, [ ProjectExecutionOptions.rinputs ]."); /* * Execute an analytics Web service as an authenticated * user based on a repository-managed R script: * /testuser/example-data-io/dataIO.R */ RScriptExecution exec = rClient.executeScript("dataIO.R", "example-data-io", "testuser", null, options); log.info("[ EXECUTION ] Discrete R script " + "execution completed [ RScriptExecution ]."); /* * Retrieve the working directory file (artifact) called * hip.csv that was generated by the execution. * * Outputs generated by an execution can be used in any * number of ways by client applications, including: * * 1. Use output data to perform further calculations. * 2. Display output data to an end-user. * 3. Write output data to a database. * 4. Pass output data along to another Web service. * 5. etc. */ List<RProjectFile> wdFiles = exec.about().artifacts; for (RProjectFile wdFile : wdFiles) { if (wdFile.about().filename.equals("hip.csv")) { log.info("[ DATA OUTPUT ] Retrieved working directory " + "file output " + wdFile.about().filename + " [ RProjectFile ]."); InputStream fis = null; try { fis = wdFile.download(); } catch (Exception ex) { log.warn("Working directory data file " + ex); } finally { IOUtils.closeQuietly(fis); } } } } catch (Exception ex) { log.warn("Unexpected runtime exception=" + ex); } finally { try { if (rClient != null) { /* * Release rClient connection before application exits. */ rClient.release(); } } catch (Exception fex) { } } }
From source file:examples.ssh.RemotePF.java
public static void main(String... args) throws Exception { SSHClient client = new SSHClient(); client.loadKnownHosts();/*www. j ava2 s.c o m*/ client.connect("localhost"); try { client.authPublickey(System.getProperty("user.name")); /* * We make _server_ listen on port 8080, which forwards all connections to us as a channel, and we further * forward all such channels to google.com:80 */ client.getRemotePortForwarder().bind(new Forward(8080), // new SocketForwardingConnectListener(new InetSocketAddress("google.com", 80))); // Something to hang on to so forwarding stays client.getTransport().join(); } finally { client.disconnect(); } }
From source file:com.mobius.software.mqtt.performance.controller.ControllerRunner.java
public static void main(String[] args) { try {// www .j a va2 s. co m /*URI baseURI = URI.create(args[0].replace("-baseURI=", "")); configFile = args[1].replace("-configFile=", "");*/ String userDir = System.getProperty("user.dir"); System.out.println("user.dir: " + userDir); setConfigFilePath(userDir + "/config.properties"); Properties prop = new Properties(); prop.load(new FileInputStream(configFile)); System.out.println("properties loaded..."); String hostname = prop.getProperty("hostname"); Integer port = Integer.parseInt(prop.getProperty("port")); URI baseURI = new URI(null, null, hostname, port, null, null, null); configureConsoleLogger(); System.out.println("starting http server..."); JerseyServer server = new JerseyServer(baseURI); System.out.println("http server started"); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.print("press any key to stop: "); br.readLine(); server.terminate(); } catch (Throwable e) { logger.error("AN ERROR OCCURED: " + e.getMessage()); e.printStackTrace(); } finally { System.exit(0); } }
From source file:io.starter.reactjs.ignite.Generator.java
public static void main(String[] args) throws Exception { String appWorkBookPath = System.getProperty("user.dir") + "/src/main/resources/templates/IgniteReact.xlsx"; WorkBookHandle appWorkBook = new WorkBookHandle(appWorkBookPath); Generator.initFromSpreadsheet(appWorkBook); }