List of usage examples for java.lang System setProperty
public static String setProperty(String key, String value)
From source file:io.sightly.tck.TCK.java
public static void main(String[] args) { CommandLineParser parser = new PosixParser(); Options options = new Options(); options.addOption(OptionBuilder.withLongOpt(CLI_EXTRACT).withDescription(CLI_EXTRACT_DESCRIPTION) .hasOptionalArg().withArgName("DIR").create()); options.addOption(OptionBuilder.withLongOpt(CLI_URL).withDescription(CLI_URL_DESCRIPTION).hasOptionalArg() .withArgName("URL").create()); options.addOption(OptionBuilder.withLongOpt(CLI_AUTH_USER).withDescription(CLI_AUTH_USER_DESCRIPTION) .hasOptionalArg().withArgName("USER").create()); options.addOption(OptionBuilder.withLongOpt(CLI_AUTH_PASS).withDescription(CLI_AUTH_PASS_DESCRIPTION) .hasOptionalArg().withArgName("PASS").create()); try {/* w ww . j a va 2 s . c o m*/ CommandLine line = parser.parse(options, args); if (!line.iterator().hasNext()) { printUsage(options); die(); } else if (line.hasOption(CLI_EXTRACT)) { String extractDir = line.getOptionValue(CLI_EXTRACT); if (StringUtils.isEmpty(extractDir)) { // assume user wants to extract stuff in current directory extractDir = System.getProperty("user.dir"); } INSTANCE.extract(extractDir); LOG.info("Extracted testing resources in folder {}.", extractDir + File.separator + TESTFILES); } else { if (line.hasOption(CLI_URL)) { String url = line.getOptionValue(CLI_URL); if (StringUtils.isEmpty(url)) { LOG.error("Missing value for --" + CLI_URL + " command line option."); printUsage(options); die(); } System.setProperty(Constants.SYS_PROP_SERVER_URL, url); } if (line.hasOption(CLI_AUTH_USER) || line.hasOption(CLI_AUTH_PASS)) { String user = line.getOptionValue(CLI_AUTH_USER); if (StringUtils.isEmpty(user)) { LOG.error("Missing value for --" + CLI_AUTH_USER + " command line option"); printUsage(options); die(); } String pass = line.getOptionValue(CLI_AUTH_PASS); if (StringUtils.isEmpty(pass)) { LOG.error("Missing value for --" + CLI_AUTH_PASS + " command line option"); printUsage(options); die(); } System.setProperty(Constants.SYS_PROP_USER, user); System.setProperty(Constants.SYS_PROP_PASS, pass); } INSTANCE.run(); } } catch (ParseException e) { printUsage(options); die(); } catch (IOException e) { LOG.error("IO Error.", e); die(); } }
From source file:Main.java
public static void setDataDirectory(String dir) { System.setProperty("data.dir", dir); }
From source file:Main.java
/** Initializes the logging configuration for a VSP application. */ public static void initLogging() { System.setProperty("java.util.logging.config.file", "./config/logging.properties"); }
From source file:alluxio.cli.JournalCrashTest.java
/** * Runs the crash test.//w ww . j ava2 s. co m * * @param args no arguments */ public static void main(String[] args) { // Parse the input args. if (!parseInputArgs(args)) { System.exit(EXIT_FAILED); } System.out.println("Stop the current Alluxio cluster..."); stopCluster(); // Set NO_STORE and NO_PERSIST so that this test can work without AlluxioWorker. sCreateFileOptions = CreateFileOptions.defaults().setWriteType(WriteType.NONE); // Set the max retry to avoid long pending for client disconnect. if (System.getProperty(PropertyKey.USER_RPC_RETRY_MAX_NUM_RETRY.toString()) == null) { System.setProperty(PropertyKey.USER_RPC_RETRY_MAX_NUM_RETRY.toString(), "10"); } System.out.println("Start Journal Crash Test..."); long startTimeMs = System.currentTimeMillis(); boolean ret = true; startMaster(); int rounds = 0; while (System.currentTimeMillis() - startTimeMs < sTotalTimeMs) { rounds++; long aliveTimeMs = (long) (Math.random() * sMaxAliveTimeMs) + 100; LOG.info("Round {}: Planning Master Alive Time {}ms.", rounds, aliveTimeMs); System.out.println("Round " + rounds + " : Launch Clients..."); sFileSystem = FileSystem.Factory.get(); try { sFileSystem.delete(new AlluxioURI(sTestDir)); } catch (Exception e) { // Test Directory not exist } // Launch all the client threads. setupClientThreads(); for (Thread thread : sClientThreadList) { thread.start(); } CommonUtils.sleepMs(LOG, aliveTimeMs); System.out.println("Round " + rounds + " : Crash Master..."); killMaster(); for (ClientThread clientThread : sClientThreadList) { clientThread.setIsStopped(true); } for (Thread thread : sClientThreadList) { try { thread.join(); } catch (InterruptedException e) { LOG.error("Error when waiting thread", e); } } System.out.println("Round " + rounds + " : Check Status..."); startMaster(); boolean checkSuccess = false; try { checkSuccess = checkStatus(); } catch (Exception e) { LOG.error("Failed to check status", e); } CliUtils.printPassInfo(checkSuccess); ret &= checkSuccess; } stopCluster(); System.exit(ret ? EXIT_SUCCESS : EXIT_FAILED); }
From source file:Main.java
private static void setSystemProperties(String host, int port) { System.setProperty("http.proxyHost", host); System.setProperty("http.proxyPort", port + ""); /*/*w w w . j a v a 2 s . co m*/ System.setProperty("https.proxyHost", host); System.setProperty("https.proxyPort", port + ""); System.setProperty("socks.proxyHost", host); System.setProperty("socks.proxyPort", port + ""); */ System.getProperty("networkaddress.cache.ttl", "-1"); }
From source file:io.janusproject.Boot.java
/** Main function that is parsing the command line and launching * the first agent./*from w ww . ja va 2 s.c om*/ * * @param args - command line arguments * @see #startJanus(Class, Class, Object...) */ public static void main(String[] args) { try { List<URL> propertyFiles = new ArrayList<>(); Object[] freeArgs = parseCommandLine(args, propertyFiles); if (JanusConfig.getSystemPropertyAsBoolean(JanusConfig.JANUS_LOGO_SHOW_NAME, JanusConfig.JANUS_LOGO_SHOW)) { showJanusLogo(); } if (freeArgs.length == 0) { showError(Locale.getString("NO_AGENT_QUALIFIED_NAME"), //$NON-NLS-1$ null); } String agentToLaunch = freeArgs[0].toString(); freeArgs = Arrays.copyOfRange(freeArgs, 1, freeArgs.length, String[].class); // Load the agent class Class<? extends Agent> agent = loadAgentClass(agentToLaunch); assert (agent != null); // Load property files Properties systemProperties = System.getProperties(); for (URL url : propertyFiles) { try (InputStream stream = url.openStream()) { systemProperties.load(stream); } } // Set the boot agent classname System.setProperty(JanusConfig.BOOT_AGENT, agent.getCanonicalName()); startJanus(null, (Class<? extends Agent>) agent, freeArgs); } catch (Exception e) { showError(Locale.getString("LAUNCHING_ERROR", //$NON-NLS-1$ e.getLocalizedMessage()), e); return; } }
From source file:com.app.server.Main.java
/** * This is the start of the all the services in web server * @param args/*from w w w. ja v a2 s . c o m*/ * @throws IOException * @throws SAXException */ public static void main(String[] args) throws IOException, SAXException { long startTime = System.currentTimeMillis(); Hashtable urlClassLoaderMap = new Hashtable(); Hashtable executorServicesMap = new Hashtable(); Hashtable ataMap = new Hashtable<String, ATAConfig>(); Hashtable messagingClassMap = new Hashtable(); ConcurrentHashMap servletMapping = new ConcurrentHashMap(); Vector deployerList = new Vector(), serviceList = new Vector(); DigesterLoader serverdigesterLoader = DigesterLoader.newLoader(new FromXmlRulesModule() { protected void loadRules() { // TODO Auto-generated method stub try { loadXMLRules(new InputSource(new FileInputStream("./config/serverconfig-rules.xml"))); } catch (FileNotFoundException e) { log.error("Error in loading the xml rules ./config/serverconfig-rules.xml", e); // TODO Auto-generated catch block //e.printStackTrace(); } } }); Digester serverdigester = serverdigesterLoader.newDigester(); final ServerConfig serverconfig = (ServerConfig) serverdigester .parse(new InputSource(new FileInputStream("./config/serverconfig.xml"))); //log.info(messagingconfig); ////log.info(serverconfig.getDeploydirectory()); PropertyConfigurator.configure("log4j.properties"); /*MemcachedClient cache=new MemcachedClient( new InetSocketAddress("localhost", 1000));*/ // Store a value (async) for one hour //c.set("someKey", 36, new String("arun")); // Retrieve a value. System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.naming.java.javaURLContextFactory"); System.setProperty(Context.URL_PKG_PREFIXES, "org.apache.naming"); ExecutorService executor = java.util.concurrent.Executors.newCachedThreadPool(); MBeanServer mbs = MBeanServerFactory.createMBeanServer("singham"); ObjectName name = null; try { mbs.registerMBean(serverconfig, new ObjectName("com.app.server:type=serverinfo")); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } /*try { name = new ObjectName("com.app.server:type=WarDeployer"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } WarDeployer warDeployer=new WarDeployer(serverconfig.getDeploydirectory(),serverconfig.getFarmWarDir(),serverconfig.getClustergroup(),urlClassLoaderMap,executorServicesMap,messagingClassMap,servletMapping,messagingconfig,sessionObjects); warDeployer.setPriority(MIN_PRIORITY); try { mbs.registerMBean(warDeployer, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //warDeployer.start(); executor.execute(warDeployer);*/ final byte[] shutdownBt = new byte[50]; /*WebServerRequestProcessor webserverRequestProcessor=new WebServer().new WebServerRequestProcessor(servletMapping,urlClassLoaderMap,serverSocketChannel,serverconfig.getDeploydirectory(),Integer.parseInt(serverconfig.getShutdownport()),1); webserverRequestProcessor.setPriority(MIN_PRIORITY); try { name = new ObjectName("com.app.server:type=WebServerRequestProcessor"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(webserverRequestProcessor, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //webserverRequestProcessor.start(); executor.execute(webserverRequestProcessor); for(int i=0;i<10;i++){ WebServerRequestProcessor webserverRequestProcessor1=new WebServer().new WebServerRequestProcessor(servletMapping,urlClassLoaderMap,serverSocketChannel,serverconfig.getDeploydirectory(),Integer.parseInt(serverconfig.getShutdownport()),2); webserverRequestProcessor1.setPriority(MIN_PRIORITY); try { name = new ObjectName("com.app.server:type=WebServerRequestProcessor"+(i+1)); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(webserverRequestProcessor1, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } executor.execute(webserverRequestProcessor1); }*/ /*ExecutorServiceThread executorService=new ExecutorServiceThread(serverSocketChannelServices,executorServicesMap,Integer.parseInt(serverconfig.getShutdownport()),ataMap,urlClassLoaderMap,serverconfig.getDeploydirectory(),serverconfig.getServicesdirectory(),serverconfig.getEarservicesdirectory(),serverconfig.getNodesport()); try { name = new ObjectName("com.app.services:type=ExecutorServiceThread"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(executorService, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //executorService.start(); executor.execute(executorService); for(int i=0;i<10;i++){ ExecutorServiceThread executorService1=new ExecutorServiceThread(serverSocketChannelServices,executorServicesMap,Integer.parseInt(serverconfig.getShutdownport()),ataMap,urlClassLoaderMap,serverconfig.getDeploydirectory(),serverconfig.getServicesdirectory(),serverconfig.getEarservicesdirectory(),serverconfig.getNodesport()); try { name = new ObjectName("com.app.services:type=ExecutorServiceThread"+(i+1)); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(executorService1, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } executor.execute(executorService1); }*/ /*WebServerHttpsRequestProcessor webserverHttpsRequestProcessor=new WebServer().new WebServerHttpsRequestProcessor(servletMapping,urlClassLoaderMap,Integer.parseInt(serverconfig.getHttpsport()),serverconfig.getDeploydirectory(),Integer.parseInt(serverconfig.getShutdownport()),serverconfig.getHttpscertificatepath(),serverconfig.getHttpscertificatepasscode(),1); try { name = new ObjectName("com.app.server:type=WebServerHttpsRequestProcessor"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(webserverHttpsRequestProcessor, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } webserverHttpsRequestProcessor.setPriority(MAX_PRIORITY); //webserverRequestProcessor.start(); executor.execute(webserverHttpsRequestProcessor);*/ /* for(int i=0;i<2;i++){ webserverHttpsRequestProcessor=new WebServer().new WebServerHttpsRequestProcessor(urlClassLoaderMap,Integer.parseInt(serverconfig.getHttpsport())+(i+1),serverconfig.getDeploydirectory(),Integer.parseInt(serverconfig.getShutdownport()),serverconfig.getHttpscertificatepath(),serverconfig.getHttpscertificatepasscode(),1); try { name = new ObjectName("com.app.server:type=WebServerHttpsRequestProcessor"+(i+1)); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(webserverHttpsRequestProcessor, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } executor.execute(webserverHttpsRequestProcessor); }*/ /*ATAServer ataServer=new ATAServer(serverconfig.getAtaaddress(),serverconfig.getAtaport(),ataMap); try { name = new ObjectName("com.app.services:type=ATAServer"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(ataServer, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } ataServer.start();*/ /*ATAConfigClient ataClient=new ATAConfigClient(serverconfig.getAtaaddress(),serverconfig.getAtaport(),serverconfig.getServicesport(),executorServicesMap); try { name = new ObjectName("com.app.services:type=ATAConfigClient"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(ataClient, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } ataClient.start();*/ /*MessagingServer messageServer=new MessagingServer(serverconfig.getMessageport(),messagingClassMap); try { name = new ObjectName("com.app.messaging:type=MessagingServer"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(messageServer, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //messageServer.start(); executor.execute(messageServer);*/ /*RandomQueueMessagePicker randomqueuemessagepicker=new RandomQueueMessagePicker(messagingClassMap); try { name = new ObjectName("com.app.messaging:type=RandomQueueMessagePicker"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(randomqueuemessagepicker, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //randomqueuemessagepicker.start(); executor.execute(randomqueuemessagepicker);*/ /*RoundRobinQueueMessagePicker roundrobinqueuemessagepicker=new RoundRobinQueueMessagePicker(messagingClassMap); try { name = new ObjectName("com.app.messaging:type=RoundRobinQueueMessagePicker"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(roundrobinqueuemessagepicker, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //roundrobinqueuemessagepicker.start(); executor.execute(roundrobinqueuemessagepicker);*/ /*TopicMessagePicker topicpicker= new TopicMessagePicker(messagingClassMap); try { name = new ObjectName("com.app.messaging:type=TopicMessagePicker"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(topicpicker, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //topicpicker.start(); executor.execute(topicpicker);*/ try { name = new ObjectName(SARDeployer.OBJECT_NAME); } catch (Exception e) { log.error("Error in creating the object name " + SARDeployer.OBJECT_NAME, e); // TODO Auto-generated catch block //e1.printStackTrace(); } log.info(System.getProperty("user.dir")); try { mbs.createMBean("com.app.server.SARDeployer", name); mbs.invoke(name, "init", new Object[] { deployerList }, new String[] { Vector.class.getName() }); mbs.invoke(name, "init", new Object[] { serviceList, serverconfig, mbs }, new String[] { Vector.class.getName(), ServerConfig.class.getName(), MBeanServer.class.getName() }); mbs.invoke(name, "start", null, null); mbs.invoke(name, "deploy", new Object[] { new URL("file:///" + new File("").getAbsolutePath() + "/config/mbean-service.xml") }, new String[] { URL.class.getName() }); /*name=new ObjectName("com.app.server:type=deployer,service=WARDeployer"); mbs.invoke(name, "deploy", new Object[]{new URL("file:///"+serverconfig.getDeploydirectory()+"/TestDollar2.war")}, new String[]{URL.class.getName()}); mbs.invoke(name, "deploy", new Object[]{new URL("file:///"+serverconfig.getDeploydirectory()+"/StrutsProj.war")}, new String[]{URL.class.getName()});*/ //mbs.registerMBean("", name); } catch (Exception ex) { log.error("Error in SAR DEPLOYER ", ex); // TODO Auto-generated catch block //e1.printStackTrace(); } //scanner.deployPackages(new File[]{new File(serverconfig.getDeploydirectory()+"/AppServer.war")}); try { new NodeResourceReceiver(mbs).start(); } catch (Exception ex) { log.error("Node Receiver start", ex); //e2.printStackTrace(); } long endTime = System.currentTimeMillis(); log.info("Server started in " + ((endTime - startTime) / 1000) + " seconds"); /*try { mbs.invoke(name, "startDeployer", null, null); } catch (InstanceNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (ReflectionException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (MBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } */ /*JarDeployer jarDeployer=new JarDeployer(registry,serverconfig.getServicesdirectory(), serverconfig.getServiceslibdirectory(),serverconfig.getCachedir(),executorServicesMap, urlClassLoaderMap); try { name = new ObjectName("com.app.server:type=JarDeployer"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(jarDeployer, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //jarDeployer.start(); executor.execute(jarDeployer);*/ /*EARDeployer earDeployer=new EARDeployer(registry,serverconfig.getEarservicesdirectory(),serverconfig.getDeploydirectory(),executorServicesMap, urlClassLoaderMap,serverconfig.getCachedir(),warDeployer); try { name = new ObjectName("com.app.server:type=EARDeployer"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(earDeployer, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //earDeployer.start(); executor.execute(earDeployer);*/ /*JVMConsole jvmConsole=new JVMConsole(Integer.parseInt(serverconfig.getJvmConsolePort())); try { name = new ObjectName("com.app.server:type=JVMConsole"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(jvmConsole, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } executor.execute(jvmConsole);*/ /*ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor(); XMLDeploymentScanner xmlDeploymentScanner =new XMLDeploymentScanner(serverconfig.getDeploydirectory(),serverconfig.getServiceslibdirectory()); exec.scheduleAtFixedRate(xmlDeploymentScanner, 0, 1000, TimeUnit.MILLISECONDS);*/ /*EmbeddedJMS embeddedJMS=null; try { embeddedJMS=new EmbeddedJMS(); embeddedJMS.start(); } catch (Exception ex) { // TODO Auto-generated catch block ex.printStackTrace(); } EJBDeployer ejbDeployer=new EJBDeployer(serverconfig.getServicesdirectory(),registry,Integer.parseInt(serverconfig.getServicesregistryport()),embeddedJMS); try { name = new ObjectName("com.app.server:type=EJBDeployer"); } catch (MalformedObjectNameException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { mbs.registerMBean(ejbDeployer, name); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //jarDeployer.start(); executor.execute(ejbDeployer);*/ new Thread() { public void run() { try { ServerSocket serverSocket = new ServerSocket(Integer.parseInt(serverconfig.getShutdownport())); while (true) { Socket sock = serverSocket.accept(); InputStream istream = sock.getInputStream(); istream.read(shutdownBt); String shutdownStr = new String(shutdownBt); String[] shutdownToken = shutdownStr.split("\r\n\r\n"); //log.info(shutdownStr); if (shutdownToken[0].startsWith("shutdown WebServer")) { synchronized (shutDownObject) { shutDownObject.notifyAll(); } } } } catch (Exception e) { log.error("Shutdown error", e); // TODO Auto-generated catch block //e.printStackTrace(); } } }.start(); Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { public void run() { log.info("IN shutdown Hook"); synchronized (shutDownObject) { shutDownObject.notifyAll(); } } })); try { synchronized (shutDownObject) { shutDownObject.wait(); } //executor.shutdownNow(); //serverSocketChannelServices.close(); //embeddedJMS.stop(); } catch (Exception e) { log.error("Error in object wait ", e); // TODO Auto-generated catch block //e1.printStackTrace(); } try { mbs.invoke(name, "stop", null, null); mbs.invoke(name, "destroy", null, null); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } log.info("Halting JVM"); log.info("Exiting JVM"); /*try{ Thread.sleep(10000); } catch(Exception ex){ }*/ //webserverRequestProcessor.stop(); //webserverRequestProcessor1.stop(); /*warDeployer.stop(); executorService.stop(); //ataServer.stop(); //ataClient.stop(); messageServer.stop(); randomqueuemessagepicker.stop(); roundrobinqueuemessagepicker.stop(); topicpicker.stop();*/ /*try { mbs.invoke(new ObjectName("com.app.server:type=SARDeployer"), "destroyDeployer", null, null); } catch (InstanceNotFoundException | MalformedObjectNameException | ReflectionException | MBeanException e) { // TODO Auto-generated catch block e.printStackTrace(); }*/ //earDeployer.stop(); System.exit(0); }
From source file:Main.java
public static synchronized DocumentBuilder getJaxpDocBuilderNNS() throws ParserConfigurationException { try {//from ww w. j a va2 s . c o m System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"); System.setProperty("javax.xml.parsers.SaxParserFactory", "org.apache.xerces.jaxp.SAXParserFactoryImpl"); DocumentBuilderFactory docBuildFactory = DocumentBuilderFactory.newInstance(); docBuildFactory.setAttribute("http://apache.org/xml/features/dom/defer-node-expansion", new Boolean(false)); docBuildFactory.setNamespaceAware(false); docBuildFactory.setValidating(false); return docBuildFactory.newDocumentBuilder(); } catch (ParserConfigurationException pce) { throw new RuntimeException(pce.getMessage()); } }
From source file:alluxio.examples.JournalCrashTest.java
/** * Runs the crash test.// w w w. ja v a 2 s . co m * * Usage: * {@code java -cp * alluxio-<ALLUXIO-VERSION>-jar-with-dependencies.jar alluxio.examples.JournalCrashTest} * * @param args no arguments */ public static void main(String[] args) { // Parse the input args. if (!parseInputArgs(args)) { System.exit(EXIT_FAILED); } System.out.println("Stop the current Alluxio cluster..."); stopCluster(); // Set NO_STORE and NO_PERSIST so that this test can work without AlluxioWorker. sCreateFileOptions = CreateFileOptions.defaults().setWriteType(WriteType.NONE); // Set the max retry to avoid long pending for client disconnect. if (System.getProperty(Constants.MASTER_RETRY_COUNT) == null) { System.setProperty(Constants.MASTER_RETRY_COUNT, "10"); } System.out.println("Start Journal Crash Test..."); long startTimeMs = System.currentTimeMillis(); boolean ret = true; startMaster(); int rounds = 0; while (System.currentTimeMillis() - startTimeMs < sTotalTimeMs) { rounds++; long aliveTimeMs = (long) (Math.random() * sMaxAliveTimeMs) + 100; LOG.info("Round {}: Planning Master Alive Time {}ms.", rounds, aliveTimeMs); System.out.println("Round " + rounds + " : Launch Clients..."); sFileSystem = FileSystem.Factory.get(); try { sFileSystem.delete(new AlluxioURI(sTestDir)); } catch (Exception e) { // Test Directory not exist } // Launch all the client threads. setupClientThreads(); for (Thread thread : sClientThreadList) { thread.start(); } CommonUtils.sleepMs(LOG, aliveTimeMs); System.out.println("Round " + rounds + " : Crash Master..."); killMaster(); for (ClientThread clientThread : sClientThreadList) { clientThread.setIsStopped(true); } for (Thread thread : sClientThreadList) { try { thread.join(); } catch (InterruptedException e) { LOG.error("Error when waiting thread", e); } } System.out.println("Round " + rounds + " : Check Status..."); startMaster(); boolean checkSuccess = false; try { checkSuccess = checkStatus(); } catch (Exception e) { LOG.error("Failed to check status", e); } Utils.printPassInfo(checkSuccess); ret &= checkSuccess; } stopCluster(); System.exit(ret ? EXIT_SUCCESS : EXIT_FAILED); }
From source file:Main.java
@SuppressWarnings("deprecation") protected static void disableConnectionReuseIfNecessary() { // HTTP connection reuse which was buggy pre-froyo if (Integer.parseInt(Build.VERSION.SDK) < Build.VERSION_CODES.FROYO) { System.setProperty("http.keepAlive", "false"); }//from w ww . java2 s . co m }