List of usage examples for java.lang InterruptedException printStackTrace
public void printStackTrace()
From source file:kafka.examples.producer.CustomPartitionerExample.java
public static void main(String[] args) { ArgumentParser parser = argParser(); try {// ww w. ja v a2s.co m Namespace res = parser.parseArgs(args); /* parse args */ String brokerList = res.getString("bootstrap.servers"); String topic = res.getString("topic"); Boolean syncSend = res.getBoolean("syncsend"); long noOfMessages = res.getLong("messages"); long delay = res.getLong("delay"); String messageType = res.getString("messagetype"); Properties producerConfig = new Properties(); producerConfig.put("bootstrap.servers", brokerList); producerConfig.put("client.id", "basic-producer"); producerConfig.put("acks", "all"); producerConfig.put("retries", "3"); producerConfig.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.ByteArraySerializer"); producerConfig.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.ByteArraySerializer"); producerConfig.put(ProducerConfig.PARTITIONER_CLASS_CONFIG, "kafka.examples.producer.CustomPartitioner"); SimpleProducer<byte[], byte[]> producer = new SimpleProducer<>(producerConfig, syncSend); for (int i = 0; i < noOfMessages; i++) { producer.send(topic, getKey(i), getEvent(messageType, i)); try { Thread.sleep(delay); } catch (InterruptedException e) { e.printStackTrace(); } } producer.close(); } catch (ArgumentParserException e) { if (args.length == 0) { parser.printHelp(); System.exit(0); } else { parser.handleError(e); System.exit(1); } } }
From source file:it.cnr.isti.labse.glimpse.MainMonitoring.java
/** * Read the properties and init the connections to the enterprise service bus * //from w w w .ja v a 2 s. c om * @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); 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 EventsBuffer<GlimpseBaseEvent<?>> buffer = new EventsBufferImpl<GlimpseBaseEvent<?>>(); //The complex event engine that will be used (in this case drools) ComplexEventProcessor engine = new ComplexEventProcessorImpl(Manager.Read(MANAGERPARAMETERFILE), buffer, connFact, initConn); engine.start(); try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } //the manager of all the architecture GlimpseManager manager = new GlimpseManager(Manager.Read(MANAGERPARAMETERFILE), connFact, initConn, engine.getRuleManager()); manager.start(); } } catch (Exception e) { System.out.println("USAGE: java -jar MainMonitoring.jar \"systemSettings\""); } }
From source file:kafka.examples.producer.BasicPartitionExample.java
public static void main(String[] args) { ArgumentParser parser = argParser(); try {/*from w w w.j a va 2 s . c o m*/ Namespace res = parser.parseArgs(args); /* parse args */ String brokerList = res.getString("bootstrap.servers"); String topic = res.getString("topic"); Boolean syncSend = res.getBoolean("syncsend"); long noOfMessages = res.getLong("messages"); long delay = res.getLong("delay"); String messageType = res.getString("messagetype"); Properties producerConfig = new Properties(); producerConfig.put("bootstrap.servers", brokerList); producerConfig.put("client.id", "basic-producer"); producerConfig.put("acks", "all"); producerConfig.put("retries", "3"); producerConfig.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.ByteArraySerializer"); producerConfig.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.ByteArraySerializer"); SimpleProducer<byte[], byte[]> producer = new SimpleProducer<>(producerConfig, syncSend); for (int i = 0; i < noOfMessages; i++) { if (i % 2 == 0) producer.send(topic, 0, getKey(i), getEvent(messageType, i)); // send even numbered messages else producer.send(topic, 1, getKey(i), getEvent(messageType, i)); // send odd numbered messages try { Thread.sleep(delay); } catch (InterruptedException e) { e.printStackTrace(); } } producer.close(); } catch (ArgumentParserException e) { if (args.length == 0) { parser.printHelp(); System.exit(0); } else { parser.handleError(e); System.exit(1); } } }
From source file:com.zb.app.common.util.PushSMSUtils.java
public static void main(String[] args) { for (int i = 1; i < 11; i++) { PushSMSUtils pushUtils = new PushSMSUtils(); System.out.println(//from w w w . j a v a2s. c o m ",!!!???,! " + i + ",Test Start!"); pushUtils.sendPushMsg("?[??3]???", "15001968175", "18616799662", "18912386146"); System.out.println( ",!!!???,! " + i + ",Test End!"); System.out.println("Now,start sleep!"); try { Thread.sleep(1000 * 180); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("Now,sleep end!"); } }
From source file:com.fjn.helper.frameworkex.apache.commons.pool.connectionPool.ConnectionManager.java
public static void main(String[] args) { final ConnectionManager mgr = new ConnectionManager(); mgr.connFactory = new ConnectionFactory(); mgr.connFactory.setDriverClass("com.mysql.jdbc.Driver"); mgr.connFactory.setPassword("mysql"); mgr.connFactory.setUsername("mysql"); mgr.connFactory.setUrl("url:localhost:3306"); // ?URL mgr.initConnectionPool(1000, 50, 5, 1000 * 60); mgr.pool = mgr.connPoolFactory.createPool(); final AtomicInteger count = new AtomicInteger(0); int threadNum = Runtime.getRuntime().availableProcessors(); ExecutorService client = Executors.newFixedThreadPool(threadNum); for (int i = 0; i < threadNum; i++) { client.submit(new Runnable() { @Override/*from w ww . j ava 2 s .c o m*/ public void run() { while (true && count.get() < 100) { try { Thread.sleep(500); } catch (InterruptedException e1) { e1.printStackTrace(); } Connection connection = null; try { connection = (Connection) mgr.pool.borrowObject(); try { int value = count.incrementAndGet(); if (value < 100) { String threadName = Thread.currentThread().getName(); int activeNum = mgr.pool.getNumActive(); int idleNum = mgr.pool.getNumIdle(); String content = "ThreadName: " + threadName + "\t SQL: " + "insert into tableA ( ct ) values ('" + value + "'); \t activeNum=" + activeNum + "\t idleNum=" + idleNum; System.out.println(content); } } catch (Exception e) { mgr.pool.invalidateObject(connection); connection = null; } finally { // make sure the object is returned to the pool if (null != connection) { mgr.pool.returnObject(connection); } } } catch (Exception e) { // failed to borrow an object } } } }); } }
From source file:com.github.liyp.test.TestMain.java
@SuppressWarnings("unchecked") public static void main(String[] args) { // add a shutdown hook to stop the server Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override/*from ww w . j av a 2s .c o m*/ public void run() { System.out.println("########### shoutdown begin...."); try { Thread.sleep(10000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("########### shoutdown end...."); } })); System.out.println(args.length); Iterator<String> iterator1 = IteratorUtils .arrayIterator(new String[] { "one", "two", "three", "11", "22", "AB" }); Iterator<String> iterator2 = IteratorUtils.arrayIterator(new String[] { "a", "b", "c", "33", "ab", "aB" }); Iterator<String> chainedIter = IteratorUtils.chainedIterator(iterator1, iterator2); System.out.println("=================="); Iterator<String> iter = IteratorUtils.filteredIterator(chainedIter, new Predicate() { @Override public boolean evaluate(Object arg0) { System.out.println("xx:" + arg0.toString()); String str = (String) arg0; return str.matches("([a-z]|[A-Z]){2}"); } }); while (iter.hasNext()) { System.out.println(iter.next()); } System.out.println("==================="); System.out.println("asas".matches("[a-z]{4}")); System.out.println("Y".equals(null)); System.out.println(String.format("%02d", 1000L)); System.out.println(ArrayUtils.toString(splitAndTrim(" 11, 21,12 ,", ","))); System.out.println(new ArrayList<String>().toString()); JSONObject json = new JSONObject("{\"keynull\":null}"); json.put("bool", false); json.put("keya", "as"); json.put("key2", 2212222222222222222L); System.out.println(json); System.out.println(json.get("keynull").equals(null)); String a = String.format("{\"id\":%d,\"method\":\"testCrossSync\"," + "\"circle\":%d},\"isEnd\":true", 1, 1); System.out.println(a.getBytes().length); System.out.println(new String[] { "a", "b" }); System.out.println(new JSONArray("[\"aa\",\"\"]")); String data = String.format("%9d %s", 1, RandomStringUtils.randomAlphanumeric(10)); System.out.println(data.getBytes().length); System.out.println(ArrayUtils.toString("1|2| 3| 333||| 3".split("\\|"))); JSONObject j1 = new JSONObject("{\"a\":\"11111\"}"); JSONObject j2 = new JSONObject(j1.toString()); j2.put("b", "22222"); System.out.println(j1 + " | " + j2); System.out.println("======================"); String regex = "\\d+(\\-\\d+){2} \\d+(:\\d+){2}"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher("2015-12-28 15:46:14 _NC250_MD:motion de\n"); String eventDate = matcher.find() ? matcher.group() : ""; System.out.println(eventDate); }
From source file:PublisherTest.java
public static void main(String[] args) { Subscriber subscriber = SubscriberFactory.create(HOST, 6000, "some-subscriber"); subscriber.subscribe(TestChannelHandler.class); //subscriber.subscribe(TestGsonChannelHandler.class); //subscriber.subscribeMulti(BackendMultiChannelHandler.class); /* CountDownLatch countDownLatch = new CountDownLatch(CLIENTS); //from w w w . ja v a 2 s . c o m for (int i = 0; i < CLIENTS; i++) { new Thread(() -> { Publisher publisher = PublisherFactory.create(HOST, 1337); JSONObject jsonObject = new JSONObject(); jsonObject.put("foo", "bar"); for (int j = 0; j < MESSAGES_PER_CLIENT; j++) { publisher.publish("test", jsonObject); try { Thread.sleep(50); } catch (InterruptedException e) { e.printStackTrace(); } } try { Thread.sleep(6000); } catch (InterruptedException e) { e.printStackTrace(); } publisher.disconnect(); countDownLatch.countDown(); }).start(); } try { countDownLatch.await(); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("Test finished successfully! " + TestChannelHandler.PACKETS + "/" + TOTAL_MESSAGES); subscriber.disconnect();*/ Publisher publisher = PublisherFactory.create(HOST, 6000); JSONObject jsonObject = new JSONObject(); jsonObject.put("foo", "bar"); publisher.publish("test", jsonObject); publisher.publishAll("test", jsonObject, new JSONObject().put("foo", "second")); publisher.publishAll("test", "some-subscriber", jsonObject, new JSONObject().put("foo", "second")); publisher.publishAll("gson", new FooBar("bar"), new FooBar("bar2")); publisher.publishAll("gson", "some-subscriber", new FooBar("bar"), new FooBar("bar2")); JSONObject backendJson = new JSONObject(); backendJson.put("role", "update"); backendJson.put("ping", 5); publisher.async().publish("backend", backendJson); for (int i = 0; i < 20; i++) { publisher.publish("test", new FooBar("bar" + i)); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } subscriber.disconnect(); publisher.disconnect(); }
From source file:com.taobao.tddl.interact.monitor.TotalStatMonitor.java
public static void main(String[] args) { TotalStatMonitor monitor = new TotalStatMonitor(); monitor.start();//from w ww . j a v a 2 s . co m for (int i = 0; i < 1000000000; i++) { TotalStatMonitor.virtualSlotIncrement("tab_slot_1"); TotalStatMonitor.virtualSlotIncrement("tab_slot_2"); } TotalStatMonitor.recieveRuleLog("V1,V2"); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } TotalStatMonitor.recieveRuleLog("V1"); }
From source file:com.twitter.hraven.hadoopJobMonitor.HadoopJobMonitorService.java
public static void main(String[] args) { System.out.println("HadoopJobMonitorService!"); HadoopJobMonitorService hadoopJobMonitorService = new HadoopJobMonitorService(); hadoopJobMonitorService.init();/*from w w w . j a va2s . c o m*/ hadoopJobMonitorService.start(); // Other threads are daemon, so prevent the current thread from exiting while (true) { try { Thread.sleep(10000); } catch (InterruptedException e) { e.printStackTrace(); } } }
From source file:uk.ac.gda.dls.client.views.RunCommandCompositeFactory.java
public static void main(String... args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new BorderLayout()); ICommandRunner iCommandRunner = new ICommandRunner() { @Override/*from w w w. j a v a 2s. c om*/ public boolean runsource(String command, String source) { return false; } @Override public void runScript(File script, String sourceName) { } @Override public void runCommand(String command, String scanObserver) { } @Override public void runCommand(String command) { try { System.out.println(command); Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } @Override public String locateScript(String scriptToRun) { return null; } @Override public String evaluateCommand(String command) { return null; } }; final RunCommandComposite comp = new RunCommandComposite(shell, SWT.NONE, iCommandRunner, "My Label", "My Command", "", "Job Title", "tooltip"); comp.setLayoutData(BorderLayout.NORTH); comp.setVisible(true); shell.pack(); shell.setSize(400, 400); SWTUtils.showCenteredShell(shell); }