List of usage examples for java.lang InterruptedException printStackTrace
public void printStackTrace()
From source file:com.moss.greenshell.wizard.catastrophe.PostMortemScreen.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setLayout(new BorderLayout()); frame.setSize(800, 600);/* ww w . ja v a2s . com*/ final PostMortemScreen postMortemScreen = new PostMortemScreen( new Throwable("Just testing the PostMortemScreen")); final ProgressMonitorScreen progress = new ProgressMonitorScreen("Waiting for something to fail."); ProcessPanel processPanel = new ProcessPanel(progress); // postMortemScreen.setEnvironment(processPanel); frame.add(processPanel, BorderLayout.CENTER); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); new Thread() { @Override public void run() { try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } progress.done(postMortemScreen); } }.start(); }
From source file:eu.learnpad.simulator.mon.MainMonitoring.java
/** * Read the properties and init the connections to the enterprise service bus * /*from w w w. j av a2 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()) { System.out.println("Running ActiveMQ instance on " + environmentParameters.getProperty("java.naming.provider.url")); ActiveMQRunner anActiveMQInstance = new ActiveMQRunner( environmentParameters.getProperty("java.naming.provider.url")); new Thread(anActiveMQInstance).start(); while (!anActiveMQInstance.isBrokerStarted()) { Thread.sleep(1000); } System.out.println("ActiveMQ is running"); System.out.println("Running GLIMPSE"); 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(); RestNotifier notifierEngine = new RestNotifier(); notifierEngine.start(); //using H2 database DBController databaseController = new H2Controller(Manager.Read(DATABASECONNECTIONSTRINGH2)); //using MYSQL database //DBController databaseController = new MySqlController(Manager.Read(DATABASECONNECTIONSTRINGMYSQL)); LearnerAssessmentManager lam = new LearnerAssessmentManagerImpl(databaseController); lam.start(); try { Thread.sleep(1000); } 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(), lam); manager.start(); } } catch (Exception e) { System.out.println("USAGE: java -jar MainMonitoring.jar \"systemSettings\""); } }
From source file:CountandraServer.java
public static void main(String args[]) { try {/* w w w . ja v a 2s.com*/ System.out.println(args[0]); CommandLineParser parser = new PosixParser(); CommandLine line = parser.parse(options, args); if (line.hasOption("cassandrahostip")) { CountandraUtils.setCassandraHostIp(line.getOptionValue("cassandrahostip")); if (line.hasOption("consistencylevel")) { if (line.hasOption("replicationfactor")) { CassandraStorage.setGlobalParams(line.getOptionValue("cassandrahostip"), line.getOptionValue("consistencylevel")); CassandraDB.setGlobalParams(line.getOptionValue("cassandrahostip"), line.getOptionValue("replicationfactor")); } else { CassandraStorage.setGlobalParams(line.getOptionValue("cassandrahostip"), line.getOptionValue("consistencylevel")); CassandraDB.setGlobalParams(line.getOptionValue("cassandrahostip")); } } else { // no consistency level -- assumed to be ONE if (line.hasOption("replicationfactor")) { CassandraStorage.setGlobalParams(line.getOptionValue("cassandrahostip")); CassandraDB.setGlobalParams(line.getOptionValue("cassandrahostip"), line.getOptionValue("replicationfactor")); } else { CassandraStorage.setGlobalParams(line.getOptionValue("cassandrahostip")); CassandraDB.setGlobalParams(line.getOptionValue("cassandrahostip")); } } } else { CassandraStorage.setGlobalParams(cassandraServerForClient); CassandraDB.setGlobalParams(cassandraServerForClient); } if (line.hasOption("s")) { System.out.println("Starting Cassandra"); // cassandra server CassandraUtils.startupCassandraServer(); } if (line.hasOption("i")) { System.out.print("Checking if Cassandra is initialized"); CassandraDB csdb = new CassandraDB(); while (!csdb.isCassandraUp()) { System.out.print("."); } System.out.println("."); System.out.println("Initializing Basic structures"); CountandraUtils.initBasicDataStructures(); System.out.println("Initialized Basic structures"); } if (line.hasOption("h")) { if (line.hasOption("httpserverport")) { httpPort = Integer.parseInt(line.getOptionValue("httpserverport")); } NettyUtils.startupNettyServer(httpPort); System.out.println("Started Http Server"); } if (line.hasOption("k")) { KafkaUtils.startupKafkaConsumer(); System.out.println("Started Kafka Consumer"); } // Unit Tests if (line.hasOption("t")) { try { Thread.sleep(30000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } org.junit.runner.JUnitCore.main(CountandraTestCases.class.getName()); } } catch (IOException ioe) { System.out.println(ioe); } catch (Exception e) { System.out.println(e); } }
From source file:visualize.Visualize.java
public static void main(String[] args) throws NotEnoughDataPointsException, IllDefinedDataPointsException { XYSeries seriesQ = new XYSeries("quadratic"); XYSeries seriesL = new XYSeries("linear"); XYSeries seriesI = new XYSeries("intepolated"); final ArrayList<Point> pointsQ = new ArrayList<Point>(); for (double x = -5.0; x <= 5.0; x = x + 0.5) pointsQ.add(new Point(new double[] { x, 2.0 * x * x * x - 10 * x * x })); final LinearFunction fl = new LinearFunction(); final HigherOrderPolynomialFunction fq = new HigherOrderPolynomialFunction(3); final InterpolatedPolynomial<LinearFunction, HigherOrderPolynomialFunction> fi = new InterpolatedPolynomial<LinearFunction, HigherOrderPolynomialFunction>( new LinearFunction(), fq.copy(), 0.5); fl.fitFunction(pointsQ);/* www .j a v a 2 s.c o m*/ fq.fitFunction(pointsQ); fi.fitFunction(pointsQ); System.out.println(fl); System.out.println(fq); System.out.println(fi.interpolatedFunction); for (double x = -5.0; x <= 5.0; x = x + 0.5) { seriesQ.add(x, fq.predict(x)); seriesL.add(x, fl.predict(x)); seriesI.add(x, fi.predict(x)); } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(seriesQ); dataset.addSeries(seriesL); dataset.addSeries(seriesI); JFreeChart chart = ChartFactory.createXYLineChart("XY Chart", "x-axis", "y-axis", dataset, PlotOrientation.VERTICAL, true, true, false); final XYPlot plot = chart.getXYPlot(); final XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, new Color(0, 0, 255)); renderer.setSeriesStroke(0, new BasicStroke(0.5f)); renderer.setSeriesPaint(1, new Color(255, 0, 0)); renderer.setSeriesStroke(1, new BasicStroke(0.5f)); renderer.setSeriesPaint(2, new Color(0, 200, 40)); renderer.setSeriesStroke(2, new BasicStroke(1.5f)); //chart.getXYPlot().setRenderer(new XYSplineRenderer(100)); JPanel panel = new JPanel(); ChartPanel chartPanel = new ChartPanel(chart); panel.add(chartPanel); JFrame frame = new JFrame(); frame.setContentPane(panel); frame.validate(); Dimension d = new Dimension(800, 500); frame.setSize(d); frame.setVisible(true); try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("starting"); for (int lambda = 0; lambda <= 100; ++lambda) { fi.setLambda(lambda / 100.0); fi.fitFunction(pointsQ); System.out.println(fi.interpolatedFunction); dataset.getSeries(2).clear(); for (double x = -5.0; x <= 5.0; x = x + 0.5) seriesI.add(x, fi.predict(x)); try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } // makeScreenshot( lambda ); } }
From source file:org.jfree.chart.demo.Main_window.java
public static void main(String[] args) { try {/*from w w w . java 2s .c om*/ UIManager.setLookAndFeel("com.seaglasslookandfeel.SeaGlassLookAndFeel"); // SeaGlassLNFTest window = new SeaGlassLNFTest(); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } Main_window window = new Main_window(); try { Thread.sleep(100000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:ThreadPoolMain.java
public static void main(String[] args) { try {//from w w w . ja va 2 s .c o m ThreadPool pool = new ThreadPool(3); Runnable ra = makeRunnable("RA", 3000); pool.execute(ra); Runnable rb = makeRunnable("RB", 1000); pool.execute(rb); Runnable rc = makeRunnable("RC", 2000); pool.execute(rc); Runnable rd = makeRunnable("RD", 60000); pool.execute(rd); Runnable re = makeRunnable("RE", 1000); pool.execute(re); pool.stopRequestIdleWorkers(); Thread.sleep(2000); pool.stopRequestIdleWorkers(); Thread.sleep(5000); pool.stopRequestAllWorkers(); } catch (InterruptedException ix) { ix.printStackTrace(); } }
From source file:org.atomspace.pi2c.runtime.Server.java
public static void main(String[] args) throws Exception { System.err.println("::: ----------------------------------------------------------------------- :::"); System.err.println("::: ------------------------------ STARTING ------------------------------:::"); System.err.println("::: ----------------------------------------------------------------------- :::"); System.err.println("\n::: SYSTEM-Properties: :::"); Set<?> properties = System.getProperties().keySet(); for (Object object : properties) { System.err.println("::: " + object.toString() + " = " + System.getProperty(object.toString())); }/* w w w . java 2 s . com*/ System.err.println("\n::: ENV-Properties: :::"); properties = System.getenv().keySet(); for (Object object : properties) { System.err.println("::: " + object.toString() + " = " + System.getenv(object.toString())); } windows = System.getProperty("os.name").toLowerCase().startsWith("windows"); linux = System.getProperty("os.name").toLowerCase().startsWith("linux"); sunos = System.getProperty("os.name").toLowerCase().startsWith("sun"); freebsd = System.getProperty("os.name").toLowerCase().startsWith("freebsd"); if (linux || sunos) { //USR2-Signal-Handel lookup internal Server STATUS for Linux or SunOS System.err.println("::: " + new Date() + "::: run unter Linux or SunOS :::"); addUnixSignalStatusHandle(); } else if (freebsd) { System.err.println("::: " + new Date() + "::: run unter FreeBSD :::"); } else if (windows) { //Gracefull Shutdown JFrame for Windows, because can not kill -15 <pid> on Window or in Eclipse Console System.err.println("::: " + new Date() + " ::: run unter windows :::"); addWindowsShutdownHandle(); } else { System.err.println("UNKNOWN OS:" + System.getProperty("os.name")); } status = STATUS_STARTING; Server server = new Server(); Thread serverThread = new Thread(server); serverThread.start(); //Thread can stop by Shutdown-Hook while (true) { try { Thread.sleep(10000); } catch (InterruptedException e) { e.printStackTrace(); break; } } }
From source file:edu.stanford.junction.director.JAVADirector.java
public static void main(String[] argv) { ActivityScript script = new ActivityScript(); script.setActivityID(JunctionMaker.DIRECTOR_ACTIVITY); //script.addRolePlatform("director", "java", null); //script.addRolePlatform("director","web", null); ////from w w w . j a va 2s . c o m script.setFriendlyName("Activity Director"); // TODO: These should be in a "carrier" field // ( carrier; implementation; provider; ... ) script.setSessionID(DIRECTOR_SESSION); JunctionActor director = new JAVADirector(); try { Junction jx = mMaker.newJunction(URI.create("junction://prpl.stanford.edu/jxservice"), director); System.out.println("Launched director on " + jx.getInvitationURI()); synchronized (director) { try { director.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } } catch (JunctionException e) { e.printStackTrace(System.err); } }
From source file:org.belio.service.gateway.AirtelCharging.java
public static void main(String args[]) { // new AirtelCharging().chargeSms(new Outbox()); new Thread(new Runnable() { @Override//from ww w . j a v a 2 s. co m public void run() { try { // System.out.println(url); long before, sleepDuration, operationTime; int tps = 6500; for (int i = 0; i < 100; i++) { before = System.currentTimeMillis(); // do your operations operationTime = (long) (tps * Math.random()); System.out.print("Doing operations for " + operationTime + "ms\t"); Thread.sleep(operationTime); // sleep for up to 1000ms sleepDuration = Math.min(1000, Math.max(1000 - (System.currentTimeMillis() - before), 0)); Thread.sleep(sleepDuration); System.out.println("wait\t" + sleepDuration + "ms =\telapsed " + (operationTime + sleepDuration) + (operationTime > 1000 ? "<" : "")); } } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }).start(); }
From source file:RegUnsol.java
public static void main(String[] args) { // Set up environment for creating initial context Hashtable<String, Object> env = new Hashtable<String, Object>(11); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://localhost:389/o=JNDItutorial"); try {//from w w w .j av a 2 s . c om // Get event context for registering listener EventContext ctx = (EventContext) (new InitialContext(env).lookup("ou=People")); // Create listener NamingListener listener = new UnsolListener(); // Register listener with context (all targets equivalent) ctx.addNamingListener("", EventContext.ONELEVEL_SCOPE, listener); // Wait 1 minutes for listener to receive events try { Thread.sleep(60000); } catch (InterruptedException e) { System.out.println("sleep interrupted"); } // Not strictly necessary if we're going to close context anyhow ctx.removeNamingListener(listener); // Close context when we're done ctx.close(); } catch (NamingException e) { e.printStackTrace(); } }