List of usage examples for java.lang InterruptedException printStackTrace
public void printStackTrace()
From source file:awskinesis.AmazonKinesisApplicationSample.java
public static void main(String[] args) throws Exception { init();/*from w w w . ja v a2 s . c o m*/ if (args.length == 1 && "delete-resources".equals(args[0])) { deleteResources(); return; } String workerId = InetAddress.getLocalHost().getCanonicalHostName() + ":" + UUID.randomUUID(); KinesisClientLibConfiguration kinesisClientLibConfiguration = new KinesisClientLibConfiguration( SAMPLE_APPLICATION_NAME, SAMPLE_APPLICATION_STREAM_NAME, credentialsProvider, workerId) .withRegionName("cn-north-1"); kinesisClientLibConfiguration.withInitialPositionInStream(SAMPLE_APPLICATION_INITIAL_POSITION_IN_STREAM); IRecordProcessorFactory recordProcessorFactory = new AmazonKinesisApplicationRecordProcessorFactory(); final Worker worker = new Worker(recordProcessorFactory, kinesisClientLibConfiguration); System.out.printf("Running %s to process stream %s as worker %s...\n", SAMPLE_APPLICATION_NAME, SAMPLE_APPLICATION_STREAM_NAME, workerId); int exitCode = 0; try { worker.run(); } catch (Throwable t) { System.err.println("Caught throwable while processing data."); t.printStackTrace(); exitCode = 1; } // add a shutdown hook to stop the server Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override public void run() { LOG.info("########### shoutdown begin...."); worker.shutdown(); try { Thread.sleep(10000); } catch (InterruptedException e) { e.printStackTrace(); } LOG.info("########### shoutdown end...."); } })); System.exit(exitCode); }
From source file:ca.brood.tunneller.Tunneller.java
public static void main(String[] args) { //For testing Tunneller.windowsService(new String[0]); try {/*from w w w. j av a 2 s .c o m*/ Thread.sleep(10000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } //To stop, uncomment this: String[] stop = new String[1]; stop[0] = "stop"; Tunneller.windowsService(stop); }
From source file:example.ReceiveNumbers.java
/** * @param args// w ww. j ava 2 s .c om * @throws MalformedURLException * @throws JSONException */ public static void main(String[] args) throws MalformedURLException, JSONException { // TODO Auto-generated method stub JSONObject previousSub = new JSONObject( "{'id':'test-java-666','desc':'test-java-666', 'subkey':'GPS-71454020-queu'}"); MyAEONCallbacks myCallBack = new MyAEONCallbacks(); final AEONSDK sdk = new AEONSDK(Config.SUB_URL, Config.YOUR_ID, Config.YOUR_DESC); //final AEONSDK sdk = new AEONSDK(Config.SUB_URL, previousSub); JSONObject subscription = sdk.subscribe(myCallBack); if (subscription == null) { System.out.println("Something went wrong I dont have a subscription"); return; } System.out.println("subscription received " + subscription.toString()); try { TimeUnit.SECONDS.sleep(3); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } /* sdk.deleteSubscription(); System.out.println("Deleted subscription: if some one is publish in the channel you will lost it for ever."); try { TimeUnit.SECONDS.sleep(3); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("Ok, lets have another new subscription."); subscription = sdk.subscribe(myCallBack); */ ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor(); exec.scheduleAtFixedRate(new Runnable() { boolean paused = false; @Override public void run() { System.out.println("Ok lets make a little break of 5 seconds. After that the subscription" + " will continue. And messages published while our break will be delivered inmediatly"); if (!paused) { sdk.pauseSusbscription(); paused = true; } else { sdk.continueSubscription(); paused = false; } } }, 1, 5, TimeUnit.SECONDS); }
From source file:cz.alej.michalik.totp.util.TOTP.java
/** * Ukzka TOTP pro zprvu "12345678901234567890" *//* ww w.j a v a 2 s. co m*/ public static void main(String[] args) { // GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ v base32 String secret = "12345678901234567890"; System.out.printf("Heslo je: %s \nV Base32 to je: %s\n", secret, new Base32().encodeToString(secret.getBytes())); TOTP t = new TOTP(secret.getBytes()); System.out.printf("%s\n", t); while (true) { int time = Integer.valueOf(new SimpleDateFormat("ss").format(new Date())); if (time % 30 == 0) { System.out.printf("%s\n", t); } try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } }
From source file:com.doculibre.constellio.solr.context.SolrCoreContext.java
public static void main(String args[]) { HttpSolrServer server = new HttpSolrServer("http://localhost:8983/solr"); server.setConnectionTimeout(1000);//from w w w. ja v a2 s.co m server.setSoTimeout(1000); try { Thread.sleep(5000); } catch (InterruptedException e1) { e1.printStackTrace(); } try { server.ping(); } catch (SolrServerException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.clustercontrol.selfcheck.monitor.RAMSwapOutMonitor.java
/** * ?/*ww w . j a v a 2 s .c o m*/ */ public static void main(String[] args) { long swapOut = new RAMSwapOutMonitor().getSwapOut(); try { Thread.sleep(1500); } catch (InterruptedException e) { e.printStackTrace(); } swapOut = new RAMSwapOutMonitor().getSwapOut(); System.out.println("Usage : " + swapOut); }
From source file:fr.cls.atoll.motu.web.servlet.MotuServletTester.java
public static void main(String[] args) throws Exception { // // String [] envp = new String[2]; // // envp[0] = "http.proxyHost=proxy-bureautique.cls.fr"; // // envp[1] = "http.proxyPort=8080"; //String cmd = "c:\\temp\\wget -O c:\\temp\\log.xml \"http://atoll-dev.cls.fr:31080/mis-gateway-servlet/Motu?action=describeProduct&data=http://atoll-misgw.vlandata.cls.fr:42080/thredds/dodsC/dataset-armor-3d-ran-v1-myocean&xmlfile=http://atoll-misgw.vlandata.cls.fr:42080/thredds/cls-myocean/armor-3d-ran-v1.xml\""; //String cmd = "c:\\temp\\wget --help"; // //Runtime.getRuntime().exec(cmd, envp); //Process process = Runtime.getRuntime().exec(cmd); //IOUtils.copy(process.getErrorStream(), System.out); // // ww w .ja va 2 s . c o m // // System.out.println(System.getProperties().toString()); // "http://atoll-dev.cls.fr:31080/mis-gateway-servlet/Motu?action=productdownload&service=http://purl.org/myocean/ontology/service/database#cls-toulouse-fr-armor-motu-rest&product=dataset-armor-3d-ran-v1-myocean&nexturl=+&x_lo=0.0&x_hi=20&y_lo=-15&y_hi=10&output=netcdf®ion=0.0%2C20.0%2C-15.0%2C10.0&yhi_text=10&xlo_text=0&xhi_text=20&ylo_text=-15&t_lo_0=2009-12-16&t_lo=2009-12-16&t_hi_0=2009-12-30&t_hi=2009-12-30&z_lo_0=Surface&z_lo=Surface&z_hi_0=Surface&z_hi=Surface&variable=salinity&variable=temperature&mode=console"; System.out.println("START"); List<Client> clients = new ArrayList<Client>(); MotuServletTester motuServletTester = new MotuServletTester(); String servletUrl = "http://atoll-dev.cls.fr:31080/mis-gateway-servlet/Motu"; String cmd = "c:\\temp\\wget \"" + servletUrl + "?action=describeProduct&data=http://atoll-misgw.vlandata.cls.fr:42080/thredds/dodsC/dataset-armor-3d-ran-v1-myocean&xmlfile=http://atoll-misgw.vlandata.cls.fr:42080/thredds/cls-myocean/armor-3d-ran-v1.xml\""; Client client1 = motuServletTester.new Client("CLIENT 1", 1000, servletUrl, cmd); //clients.add(client1); cmd = "c:\\temp\\wget -O c:\\temp\\test.nc \"" + servletUrl //+ "?action=productdownload&service=http://purl.org/myocean/ontology/service/database#cls-toulouse-fr-armor-motu-rest&product=dataset-armor-3d-ran-v1-myocean&nexturl=+&x_lo=0.0&x_hi=20&y_lo=-15&y_hi=10&output=netcdf®ion=0.0%2C20.0%2C-15.0%2C10.0&yhi_text=10&xlo_text=0&xhi_text=20&ylo_text=-15&t_lo_0=2009-12-16&t_lo=2009-12-16&t_hi_0=2009-12-30&t_hi=2009-12-30&z_lo_0=Surface&z_lo=Surface&z_hi_0=Surface&z_hi=Surface&variable=salinity&variable=temperature&mode=console\""; //+ "?action=productdownload&service=http%3A%2F%2Fpurl.org%2Fmyocean%2Fontology%2Fservice%2Fdatabase%23cls-toulouse-fr-armor-motu-rest&product=dataset-armor-3d-ran-v1-myocean&nexturl=+&x_lo=0.0&x_hi=20&y_lo=-15&y_hi=10&output=netcdf®ion=0.0%2C20.0%2C-15.0%2C10.0&yhi_text=10&xlo_text=0&xhi_text=20&ylo_text=-15&t_lo_0=2009-12-16&t_lo=2009-12-16&t_hi_0=2009-12-30&t_hi=2009-12-30&z_lo_0=Surface&z_lo=Surface&z_hi_0=Surface&z_hi=Surface&variable=salinity&variable=temperature&mode=status\""; + "?action=productdownload&service=http%3A%2F%2Fpurl.org%2Fmyocean%2Fontology%2Fservice%2Fdatabase%23cls-toulouse-fr-armor-motu-rest&product=dataset-armor-3d-ran-v1-myocean&nexturl=+&x_lo=0.0&x_hi=20&y_lo=-15&y_hi=10&output=netcdf®ion=0.0%2C20.0%2C-15.0%2C10.0&yhi_text=10&xlo_text=0&xhi_text=20&ylo_text=-15&t_lo_0=2009-04-08&t_lo=2009-04-08&t_hi_0=2009-12-30&t_hi=2009-12-30&z_lo_0=Surface&z_lo=Surface&z_hi_0=50&z_hi=50&variable=salinity&variable=temperature&mode=status\""; String cmd2 = "c:\\temp\\wget -O c:\\temp\\test.nc \"" + servletUrl //+ "?action=productdownload&service=http://purl.org/myocean/ontology/service/database#cls-toulouse-fr-armor-motu-rest&product=dataset-armor-3d-ran-v1-myocean&nexturl=+&x_lo=0.0&x_hi=20&y_lo=-15&y_hi=10&output=netcdf®ion=0.0%2C20.0%2C-15.0%2C10.0&yhi_text=10&xlo_text=0&xhi_text=20&ylo_text=-15&t_lo_0=2009-12-16&t_lo=2009-12-16&t_hi_0=2009-12-30&t_hi=2009-12-30&z_lo_0=Surface&z_lo=Surface&z_hi_0=Surface&z_hi=Surface&variable=salinity&variable=temperature&mode=console\""; //+ "?action=productdownload&service=http%3A%2F%2Fpurl.org%2Fmyocean%2Fontology%2Fservice%2Fdatabase%23cls-toulouse-fr-armor-motu-rest&product=dataset-armor-3d-ran-v1-myocean&nexturl=+&x_lo=0.0&x_hi=20&y_lo=-15&y_hi=10&output=netcdf®ion=0.0%2C20.0%2C-15.0%2C10.0&yhi_text=10&xlo_text=0&xhi_text=20&ylo_text=-15&t_lo_0=2009-12-16&t_lo=2009-12-16&t_hi_0=2009-12-30&t_hi=2009-12-30&z_lo_0=Surface&z_lo=Surface&z_hi_0=Surface&z_hi=Surface&variable=salinity&variable=temperature&mode=status\""; + "?action=productdownload&service=http%3A%2F%2Fpurl.org%2Fmyocean%2Fontology%2Fservice%2Fdatabase%23cls-toulouse-fr-armor-motu-rest&product=dataset-armor-3d-ran-v1-myocean&nexturl=+&x_lo=0.0&x_hi=20&y_lo=-15&y_hi=10&output=netcdf®ion=0.0%2C20.0%2C-15.0%2C10.0&yhi_text=10&xlo_text=0&xhi_text=20&ylo_text=-15&t_lo_0=2009-04-08&t_lo=2009-04-08&t_hi_0=2009-12-30&t_hi=2009-12-30&z_lo_0=Surface&z_lo=Surface&z_hi_0=50&z_hi=50&variable=salinity&variable=temperature&mode=status\""; Client client2 = motuServletTester.new Client("CLIENT 2", 1000, servletUrl, cmd); clients.add(client2); Client client2b = motuServletTester.new Client("CLIENT 2b", 1000, servletUrl, cmd); clients.add(client2b); Client client2c = motuServletTester.new Client("CLIENT 2c", 1000, servletUrl, cmd); clients.add(client2c); for (Client c : clients) { c.start(); } System.out.println("STARTED"); try { Thread.sleep(10000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("ENDING"); for (Client c : clients) { c.running = false; } System.out.println("ENDED"); }
From source file:it.cnr.isti.labsedc.glimpse.MainMonitoring.java
/** * Read the properties and init the connections to the enterprise service bus * /*from w w w.j a v a2 s . co m*/ * @param is the systemSettings file */ public static void main(String[] args) { try { FileOutputStream fos = new FileOutputStream("glimpseLog.log"); PrintStream ps = new PrintStream(fos); System.setErr(ps); Logger log = Logger.getLogger(MainMonitoring.class.getName()); log.debug("Hello this is an debug message"); log.info("Hello this is an info message"); if (MainMonitoring.initProps(args[0]) && MainMonitoring.init()) { SplashScreen.Show(); System.out.println("Please wait until setup is done..."); //the buffer where the events are stored to be analyzed, in this version //the buffer object is not used because Drools has it's own eventStream object EventsBuffer<GlimpseBaseEvent<?>> buffer = new EventsBufferImpl<GlimpseBaseEvent<?>>(); //The complex event engine that will be used (in this case drools) ComplexEventProcessor engineOne = new ComplexEventProcessorImpl(Manager.Read(MANAGERPARAMETERFILE), buffer, connFact, initConn); engineOne.start(); try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } RuleTemplateManager templateManager = new RuleTemplateManager(DROOLSRULEREQUESTTEMPLATE1, DROOLSRULEREQUESTTEMPLATE2, DROOLSRULEREQUESTTEMPLATE3_1, DROOLSRULEREQUESTTEMPLATE3_2); //the component in charge to locate services and load specific rules. ServiceLocatorFactory.getServiceLocatorParseViolationReceivedFromBSM(engineOne, templateManager, REGEXPATTERNFILEPATH).start(); //start MailNotifier component MailNotification mailer = new MailNotification(Manager.Read(MAILNOTIFICATIONSETTINGSFILEPATH)); mailer.start(); //the manager of all the architecture GlimpseManager manager = new GlimpseManager(Manager.Read(MANAGERPARAMETERFILE), connFact, initConn, engineOne.getRuleManager()); manager.start(); } } catch (Exception e) { System.out.println("USAGE: java -jar MainMonitoring.jar \"systemSettings\""); } }
From source file:eu.learnpad.simulator.mon.MyGlimpseProbe_SimMonLearnPAd.java
public static void main(String[] args) throws UnknownHostException { MyGlimpseProbe_SimMonLearnPAd aGenericProbe = new MyGlimpseProbe_SimMonLearnPAd( Manager.createProbeSettingsPropertiesObject( "org.apache.activemq.jndi.ActiveMQInitialContextFactory", "tcp://localhost:61616", "system", "manager", "TopicCF", "jms.probeTopic", false, "probeName", "probeTopic")); DebugMessages.println(TimeStamp.getCurrentTime(), MyGlimpseProbe_SimMonLearnPAd.class.getName(), "Sending a set of events:\nsimstart, processstart, taskstart, taskfailed, taskstart, taskend, processend, sessionscoreupdate, simendinfinite"); try {// ww w.j ava 2 s .c om AbstractEvent event; event = new SimulationStartEvent(); aGenericProbe.generateAndSendExample_GlimpseBaseEvents_StringPayload("SIMULATION_START", event); Thread.sleep(2000); event = new ProcessStartEvent(); aGenericProbe.generateAndSendExample_GlimpseBaseEvents_StringPayload("PROCESS_START", event); Thread.sleep(2000); event = new TaskStartEvent(); aGenericProbe.generateAndSendExample_GlimpseBaseEvents_StringPayload("TASK_START", event); Thread.sleep(2000); event = new TaskFailedEvent(); aGenericProbe.generateAndSendExample_GlimpseBaseEvents_StringPayload("TASK_FAILED", event); Thread.sleep(2000); event = new TaskStartEvent(); aGenericProbe.generateAndSendExample_GlimpseBaseEvents_StringPayload("TASK_START", event); Thread.sleep(2000); event = new TaskEndEvent(); aGenericProbe.generateAndSendExample_GlimpseBaseEvents_StringPayload("TASK_END", event); Thread.sleep(2000); event = new ProcessEndEvent(); aGenericProbe.generateAndSendExample_GlimpseBaseEvents_StringPayload("PROCESS_END", event); Thread.sleep(2000); event = new SessionScoreUpdateEvent(); aGenericProbe.generateAndSendExample_GlimpseBaseEvents_StringPayload("SESSION_SCORE_UPDATE", event); Thread.sleep(2000); event = new SimulationEndEvent(); aGenericProbe.generateAndSendExample_GlimpseBaseEvents_StringPayload("SIMULATION_END", event); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:io.prometheus.client.examples.random.Main.java
public static void main(final String[] arguments) { Registry.defaultInitialize(); final Server server = new Server(8181); final ServletContextHandler context = new ServletContextHandler(); context.setContextPath("/"); server.setHandler(context);/* ww w . j a v a 2 s . com*/ context.addServlet(new ServletHolder(new MetricsServlet()), "/"); new Thread() { @Override public void run() { final RandomDataImpl randomData = new RandomDataImpl(); try { while (true) { rpcLatency.add(ImmutableMap.of("service", "foo"), randomData.nextLong(0, 200)); rpcLatency.add(ImmutableMap.of("service", "bar"), (float) randomData.nextGaussian(100, 20)); rpcLatency.add(ImmutableMap.of("service", "zed"), (float) randomData.nextExponential(100)); rpcCalls.increment(ImmutableMap.of("service", "foo")); rpcCalls.increment(ImmutableMap.of("service", "bar")); rpcCalls.increment(ImmutableMap.of("service", "zed")); Thread.sleep(1000); } } catch (final InterruptedException e) { } } }.start(); try { server.start(); server.join(); } catch (Exception e) { e.printStackTrace(); } }