List of usage examples for java.lang ThreadGroup ThreadGroup
public ThreadGroup(String name)
From source file:org.springframework.osgi.extender.internal.support.ExtenderConfiguration.java
private TaskExecutor createDefaultTaskExecutor() { // create thread-pool for starting contexts ThreadGroup threadGroup = new ThreadGroup( "spring-osgi-extender[" + ObjectUtils.getIdentityHexString(this) + "]-threads"); threadGroup.setDaemon(false);/*from w ww . j av a 2s . c o m*/ SimpleAsyncTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor(); taskExecutor.setThreadGroup(threadGroup); taskExecutor.setThreadNamePrefix("SpringOsgiExtenderThread-"); isTaskExecutorManagedInternally = true; return taskExecutor; }
From source file:org.apache.hedwig.server.netty.PubSubServer.java
/** * Starts the hedwig server on the given port * * @param port//from w w w .java 2 s . c o m * @throws ConfigurationException * if there is something wrong with the given configuration * @throws IOException * @throws InterruptedException * @throws ConfigurationException */ public PubSubServer(final ServerConfiguration serverConfiguration, final org.apache.hedwig.client.conf.ClientConfiguration clientConfiguration, final Thread.UncaughtExceptionHandler exceptionHandler) throws ConfigurationException { // First validate the serverConfiguration this.conf = serverConfiguration; serverConfiguration.validate(); // Validate the client configuration this.clientConfiguration = clientConfiguration; clientConfiguration.validate(); // We need a custom thread group, so that we can override the uncaught // exception method tg = new ThreadGroup("hedwig") { @Override public void uncaughtException(Thread t, Throwable e) { exceptionHandler.uncaughtException(t, e); } }; // ZooKeeper threads register their own handler. But if some work that // we do in ZK threads throws an exception, we want our handler to be // called, not theirs. SafeAsyncCallback.setUncaughtExceptionHandler(exceptionHandler); }
From source file:org.eclipse.gemini.blueprint.extender.internal.support.ExtenderConfiguration.java
private TaskExecutor createDefaultTaskExecutor() { // create thread-pool for starting contexts ThreadGroup threadGroup = new ThreadGroup( "eclipse-gemini-blueprint-extender[" + ObjectUtils.getIdentityHexString(this) + "]-threads"); threadGroup.setDaemon(false);//from w w w . ja v a 2s . co m SimpleAsyncTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor(); taskExecutor.setThreadGroup(threadGroup); taskExecutor.setThreadNamePrefix("EclipseGeminiBlueprintExtenderThread-"); isTaskExecutorManagedInternally = true; return taskExecutor; }
From source file:org.apache.jxtadoop.hdfs.server.datanode.DataNode.java
/** * This method starts the data node with the specified conf. * //from www . ja v a2s . co m * @param conf - the configuration * if conf's CONFIG_PROPERTY_SIMULATED property is set * then a simulated storage based data node is created. * * @param dataDirs - only for a non-simulated storage data node * @throws IOException */ void startDataNode(Configuration conf, AbstractList<File> dataDirs) throws IOException { dnpeer.initialize(); dnpeer.start(); while (dnpeer.getRpcSocketAddress() == null) { try { Thread.sleep(1000); } catch (InterruptedException e) { } } LOG.debug("Datanode peer ID : " + dnpeer.getPeerID().toString()); // use configured nameserver & interface to get local hostname /*if (conf.get("slave.host.name") != null) { machineName = conf.get("slave.host.name"); } if (machineName == null) { machineName = DNS.getDefaultHost( conf.get("dfs.datanode.dns.interface","default"), conf.get("dfs.datanode.dns.nameserver","default")); }*/ machineName = dnpeer.getPeerIDwithoutURN(); LOG.debug("Datanode registration name : " + machineName); // this.socketTimeout = conf.getInt("dfs.socket.timeout", // HdfsConstants.READ_TIMEOUT); //this.socketWriteTimeout = conf.getInt("dfs.datanode.socket.write.timeout", // HdfsConstants.WRITE_TIMEOUT); /* Based on results on different platforms, we might need set the default * to false on some of them. */ this.transferToAllowed = conf.getBoolean("dfs.datanode.transferTo.allowed", true); this.writePacketSize = conf.getInt("dfs.write.packet.size", 64 * 1024); /*String address = NetUtils.getServerAddress(conf, "dfs.datanode.bindAddress", "dfs.datanode.port", "dfs.datanode.address"); InetSocketAddress socAddr = NetUtils.createSocketAddr(address); int tmpPort = socAddr.getPort();*/ storage = new DataStorage(); // construct registration // this.dnRegistration = new DatanodeRegistration(machineName + ":" + tmpPort); this.dnRegistration = new DatanodeRegistration(machineName); // connect to name node //this.namenode = (DatanodeProtocol) RPC.waitForProxy(DatanodeProtocol.class, // DatanodeProtocol.versionID, nameNodeAddr, conf); this.namenode = (DatanodeProtocol) RPC.waitForProxy(DatanodeProtocol.class, DatanodeProtocol.versionID, dnpeer.getPeerGroup(), dnpeer.getRpcSocketAddress(), conf); // get version and id info from the name-node NamespaceInfo nsInfo = handshake(); StartupOption startOpt = getStartupOption(conf); assert startOpt != null : "Startup option must be set."; boolean simulatedFSDataset = conf.getBoolean("dfs.datanode.simulateddatastorage", false); if (simulatedFSDataset) { setNewStorageID(dnRegistration); dnRegistration.storageInfo.layoutVersion = FSConstants.LAYOUT_VERSION; dnRegistration.storageInfo.namespaceID = nsInfo.namespaceID; // it would have been better to pass storage as a parameter to // constructor below - need to augment ReflectionUtils used below. conf.set("StorageId", dnRegistration.getStorageID()); try { //Equivalent of following (can't do because Simulated is in test dir) // this.data = new SimulatedFSDataset(conf); this.data = (FSDatasetInterface) ReflectionUtils.newInstance( Class.forName("org.apache.jxtadoop.hdfs.server.datanode.SimulatedFSDataset"), conf); } catch (ClassNotFoundException e) { throw new IOException(StringUtils.stringifyException(e)); } } else { // real storage // read storage info, lock data dirs and transition fs state if necessary storage.recoverTransitionRead(nsInfo, dataDirs, startOpt); // adjust this.dnRegistration.setStorageInfo(storage); // initialize data node internal structure this.data = new FSDataset(storage, conf); } // find free port /*ServerSocket ss = (socketWriteTimeout > 0) ? ServerSocketChannel.open().socket() : new ServerSocket(); Server.bind(ss, socAddr, 0); ss.setReceiveBufferSize(DEFAULT_DATA_SOCKET_SIZE); // adjust machine name with the actual port tmpPort = ss.getLocalPort(); selfAddr = new InetSocketAddress(ss.getInetAddress().getHostAddress(), tmpPort); this.dnRegistration.setName(machineName + ":" + tmpPort);*/ JxtaServerSocket ss = new JxtaServerSocket(dnpeer.getPeerGroup(), dnpeer.getInfoPipeAdvertisement(), Integer.parseInt(conf.get("hadoop.p2p.info.backlog")), Integer.parseInt(conf.get("hadoop.p2p.info.timeout"))); LOG.info("Opened info server"); this.threadGroup = new ThreadGroup("dataXceiverServer"); this.dataXceiverServer = new Daemon(threadGroup, new DataXceiverServer(ss, conf, this)); this.threadGroup.setDaemon(true); // auto destroy when empty this.blockReportInterval = conf.getLong("dfs.blockreport.intervalMsec", BLOCKREPORT_INTERVAL); this.initialBlockReportDelay = conf.getLong("dfs.blockreport.initialDelay", BLOCKREPORT_INITIAL_DELAY) * 1000L; if (this.initialBlockReportDelay >= blockReportInterval) { this.initialBlockReportDelay = 0; LOG.info("dfs.blockreport.initialDelay is greater than " + "dfs.blockreport.intervalMsec." + " Setting initial delay to 0 msec:"); } this.heartBeatInterval = conf.getLong("dfs.heartbeat.interval", HEARTBEAT_INTERVAL) * 1000L; //initialize periodic block scanner String reason = null; if (conf.getInt("dfs.datanode.scan.period.hours", 0) < 0) { reason = "verification is turned off by configuration"; } else if (!(data instanceof FSDataset)) { reason = "verifcation is supported only with FSDataset"; } if (reason == null) { blockScanner = new DataBlockScanner(this, (FSDataset) data, conf); } else { LOG.info("Periodic Block Verification is disabled because " + reason + "."); } myMetrics = new DataNodeMetrics(conf, dnRegistration.getStorageID()); // set service-level authorization security policy if (conf.getBoolean(ServiceAuthorizationManager.SERVICE_AUTHORIZATION_CONFIG, false)) { PolicyProvider policyProvider = (PolicyProvider) (ReflectionUtils.newInstance(conf.getClass( PolicyProvider.POLICY_PROVIDER_CONFIG, HDFSPolicyProvider.class, PolicyProvider.class), conf)); SecurityUtil.setPolicy(new ConfiguredPolicy(conf, policyProvider)); } //init ipc server /*InetSocketAddress ipcAddr = NetUtils.createSocketAddr( conf.get("dfs.datanode.ipc.address")); ipcServer = RPC.getServer(this, ipcAddr.getHostName(), ipcAddr.getPort(), conf.getInt("dfs.datanode.handler.count", 3), false, conf); ipcServer.start(); dnRegistration.setIpcPort(ipcServer.getListenerAddress().getPort()); */ ipcServer = RPC.getServer(this, dnpeer.getPeerGroup(), dnpeer.getServerSocketAddress(), conf.getInt("dfs.datanode.handler.count", 3), false, conf); dnRegistration.setIpcPort(P2PConstants.RPCPIPEID); LOG.info("dnRegistration = " + dnRegistration); }
From source file:org.alfresco.repo.model.filefolder.FileFolderPerformanceTester.java
private void readStructure(final NodeRef parentNodeRef, final int threadCount, final int repetitions, final double[] dumpPoints) { final List<FileInfo> children = fileFolderService.list(parentNodeRef); Runnable runnable = new Runnable() { public void run() { // authenticate authenticate(USERNAME);/* w ww . j av a 2 s . c om*/ for (int i = 0; i < repetitions; i++) { // read the contents of each folder for (final FileInfo fileInfo : children) { final NodeRef folderRef = fileInfo.getNodeRef(); RetryingTransactionCallback<Object> readCallback = new RetryingTransactionCallback<Object>() { public Object execute() throws Exception { List<FileInfo> tmp = null; if (fileInfo.isFolder()) { long start = System.currentTimeMillis(); // read the children of the folder tmp = fileFolderService.list(folderRef); logger.debug("List " + tmp.size() + " items in " + (System.currentTimeMillis() - start) + " msecs"); } else { throw new AlfrescoRuntimeException("Not a folder: " + folderRef); } // done return null; }; }; retryingTransactionHelper.doInTransaction(readCallback, true); } } } }; // kick off the required number of threads logger.debug("\n" + "Starting " + threadCount + " threads reading properties and children of " + children.size() + " folders " + repetitions + " times."); long start = System.currentTimeMillis(); ThreadGroup threadGroup = new ThreadGroup(getName()); Thread[] threads = new Thread[threadCount]; for (int i = 0; i < threadCount; i++) { threads[i] = new Thread(threadGroup, runnable, String.format("FileReader-%02d", i)); threads[i].start(); } // join each thread so that we wait for them all to finish for (int i = 0; i < threads.length; i++) { try { threads[i].join(); } catch (InterruptedException e) { // not too serious - the worker threads are non-daemon } } logger.debug("\nFinished reading in " + (System.currentTimeMillis() - start) + " msecs"); }
From source file:com.adito.server.Main.java
public Integer start(String[] args) { startupStarted = System.currentTimeMillis(); // Inform the wrapper the startup process may take a while if (useWrapper) { WrapperManager.signalStarting(60000); }/*ww w . j a v a 2 s. co m*/ // Parse the command line Integer returnCode = parseCommandLine(args); if (returnCode != null) { if (returnCode.intValue() == 999) { return null; } return returnCode; } // Create the boot progress monitor if (gui) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { } bootProgressMonitor = new SwingBootProgressMonitor(); } else { bootProgressMonitor = new LogBootProgressMonitor(); } // resourceCaches = new HashMap<URL, ResourceCache>(); contextListeners = new ArrayList<ContextListener>(); loadSystemProperties(); initialiseLogging(); /* * Migrate preferences. */ File newPrefDir = new File(ContextHolder.getContext().getConfDirectory(), "prefs"); PREF = PropertyPreferences.SYSTEM_ROOT; try { if (!newPrefDir.exists() && Preferences.systemRoot().node("/com").nodeExists("adito")) { Preferences from = Preferences.systemRoot().node("/com/adito"); log.warn("Migrating preferences"); try { copyNode(from.node("core"), PREF.node("core")); from.node("core").removeNode(); copyNode(from.node("plugin"), PREF.node("plugin")); from.node("plugin").removeNode(); copyNode(from.node("extensions"), PREF.node("extensions")); from.node("extensions").removeNode(); copyNode(from.node("dbupgrader"), PREF.node("dbupgrader")); from.node("dbupgrader").removeNode(); } catch (Exception e) { log.error("Failed to migrate preferences.", e); } try { from.flush(); } catch (BackingStoreException bse) { log.error("Failed to flush old preferences"); } try { PREF.flush(); } catch (BackingStoreException bse) { log.error("Failed to flush new preferences"); } if (log.isInfoEnabled()) { log.info("Flushing preferences"); } } } catch (BackingStoreException bse) { log.error("Failed to migrate preferences.", bse); } // Inform the wrapper the startup process is going ok if (useWrapper) { WrapperManager.signalStarting(60000); } try { clearTemp(); try { hostname = Inet4Address.getLocalHost().getCanonicalHostName(); hostAddress = Inet4Address.getLocalHost().getHostAddress(); } catch (Exception ex) { // This should be fatal, we now rely on the hostname being // available throw new Exception("The host name or address on which this service is running could not " + "be determined. Check you network configuration. One possible cause is " + "a misconfigured 'hosts' file (e.g. on UNIX-like systems this would be " + "/etc/hosts, on Windows XP it would be " + "C:\\Windows\\System32\\Drivers\\Etc\\Hosts)."); } PropertyClassManager.getInstance() .registerPropertyClass(contextConfiguration = new ContextConfig(getClass().getClassLoader())); // Display some information about the system we are running on displaySystemInfo(); // Load the context property definitions loadContextProperties(); // Inform the wrapper the startup process is going ok if (useWrapper) { WrapperManager.signalStarting(60000); } // Configure any HTTP / HTTPS / SOCKS proxy servers configureProxyServers(); PropertyList l = contextConfiguration.retrievePropertyList(new ContextKey("webServer.bindAddress")); getBootProgressMonitor().updateMessage("Creating server lock"); getBootProgressMonitor().updateProgress(6); serverLock = new ServerLock((String) l.get(0)); if (serverLock.isLocked()) { if (!isSetupMode()) { if (serverLock.isSetup()) { throw new Exception("The installation wizard is currently running. " + "Please shut this down by pointing your browser " + "to http://" + getHostname() + ":" + serverLock.getPort() + "/showShutdown.do before attempting to start the server again."); } else { throw new Exception("The server is already running."); } } else { if (!serverLock.isSetup()) { throw new Exception("The server is currently already running. " + "Please shut this down by pointing your browser " + "to https://" + getHostname() + ":" + serverLock.getPort() + "/showShutdown.do before attempting to start the server again."); } else { throw new Exception("The installation wizard is running.."); } } } // Inform the wrapper the startup process is going ok if (useWrapper) { WrapperManager.signalStarting(60000); } Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { serverLock.stop(); } }); // registerKeyStores(); // threadGroup = new ThreadGroup("MainThreadGroup"); if (install) { setupMode(); } else { normalMode(); startHttpServer(); } } catch (Throwable t) { startupException = t; log.error("Failed to start the server. " + t.getMessage(), t); return new Integer(1); } return null; }
From source file:com.sslexplorer.server.Main.java
public Integer start(String[] args) { startupStarted = System.currentTimeMillis(); // Inform the wrapper the startup process may take a while if (useWrapper) { WrapperManager.signalStarting(60000); }/*from ww w . j av a 2 s . c o m*/ // Parse the command line Integer returnCode = parseCommandLine(args); if (returnCode != null) { if (returnCode.intValue() == 999) { return null; } return returnCode; } // Create the boot progress monitor if (gui) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { } bootProgressMonitor = new SwingBootProgressMonitor(); } else { bootProgressMonitor = new LogBootProgressMonitor(); } // resourceCaches = new HashMap<URL, ResourceCache>(); contextListeners = new ArrayList<ContextListener>(); loadSystemProperties(); initialiseLogging(); /* * Migrate preferences. */ File newPrefDir = new File(ContextHolder.getContext().getConfDirectory(), "prefs"); PREF = PropertyPreferences.SYSTEM_ROOT; try { if (!newPrefDir.exists() && Preferences.systemRoot().node("/com").nodeExists("sslexplorer")) { Preferences from = Preferences.systemRoot().node("/com/sslexplorer"); log.warn("Migrating preferences"); try { copyNode(from.node("core"), PREF.node("core")); from.node("core").removeNode(); copyNode(from.node("plugin"), PREF.node("plugin")); from.node("plugin").removeNode(); copyNode(from.node("extensions"), PREF.node("extensions")); from.node("extensions").removeNode(); copyNode(from.node("dbupgrader"), PREF.node("dbupgrader")); from.node("dbupgrader").removeNode(); } catch (Exception e) { log.error("Failed to migrate preferences.", e); } try { from.flush(); } catch (BackingStoreException bse) { log.error("Failed to flush old preferences"); } try { PREF.flush(); } catch (BackingStoreException bse) { log.error("Failed to flush new preferences"); } if (log.isInfoEnabled()) { log.info("Flushing preferences"); } } } catch (BackingStoreException bse) { log.error("Failed to migrate preferences.", bse); } // Inform the wrapper the startup process is going ok if (useWrapper) { WrapperManager.signalStarting(60000); } try { clearTemp(); try { hostname = Inet4Address.getLocalHost().getCanonicalHostName(); hostAddress = Inet4Address.getLocalHost().getHostAddress(); } catch (Exception ex) { // This should be fatal, we now rely on the hostname being // available throw new Exception("The host name or address on which this service is running could not " + "be determined. Check you network configuration. One possible cause is " + "a misconfigured 'hosts' file (e.g. on UNIX-like systems this would be " + "/etc/hosts, on Windows XP it would be " + "C:\\Windows\\System32\\Drivers\\Etc\\Hosts)."); } PropertyClassManager.getInstance() .registerPropertyClass(contextConfiguration = new ContextConfig(getClass().getClassLoader())); // Display some information about the system we are running on displaySystemInfo(); // Load the context property definitions loadContextProperties(); // Inform the wrapper the startup process is going ok if (useWrapper) { WrapperManager.signalStarting(60000); } // Configure any HTTP / HTTPS / SOCKS proxy servers configureProxyServers(); PropertyList l = contextConfiguration.retrievePropertyList(new ContextKey("webServer.bindAddress")); getBootProgressMonitor().updateMessage("Creating server lock"); getBootProgressMonitor().updateProgress(6); serverLock = new ServerLock((String) l.get(0)); if (serverLock.isLocked()) { if (!isSetupMode()) { if (serverLock.isSetup()) { throw new Exception("The installation wizard is currently running. " + "Please shut this down by pointing your browser " + "to http://" + getHostname() + ":" + serverLock.getPort() + "/showShutdown.do before attempting to start the server again."); } else { throw new Exception("The server is already running."); } } else { if (!serverLock.isSetup()) { throw new Exception("The server is currently already running. " + "Please shut this down by pointing your browser " + "to https://" + getHostname() + ":" + serverLock.getPort() + "/showShutdown.do before attempting to start the server again."); } else { throw new Exception("The installation wizard is running.."); } } } // Inform the wrapper the startup process is going ok if (useWrapper) { WrapperManager.signalStarting(60000); } Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { serverLock.stop(); } }); // registerKeyStores(); // threadGroup = new ThreadGroup("MainThreadGroup"); if (install) { setupMode(); } else { normalMode(); startHttpServer(); } } catch (Throwable t) { startupException = t; log.error("Failed to start the server. " + t.getMessage(), t); return new Integer(1); } return null; }
From source file:com.boylesoftware.web.AbstractWebApplication.java
/** * Get executor service. This method is called once during the application * initialization. The executor service is automatically shut down by the * framework when the application goes down. * * <p>Default implementation returns a fixed size thread pool with number * of threads specified by the/*from w w w. j av a 2s. c o m*/ * {@link ApplicationConfiguration#ASYNC_THREADS} application configuration * property. If the application configuration property is undefined, default * number of threads is {@value #DEFAULT_ASYNC_THREADS}. * * @param sc Servlet context. * @param config Application configuration. * * @return The executor service. * * @throws UnavailableException If the executor service is unavailable. * Throwing this exception makes the web-application fail to start. */ @SuppressWarnings("unused") protected ExecutorService getExecutorService(final ServletContext sc, final ApplicationConfiguration config) throws UnavailableException { final ThreadGroup threadGroup = new ThreadGroup("AsyncExecutors"); final int numThreads = config.getConfigProperty(ApplicationConfiguration.ASYNC_THREADS, Integer.class, Integer.valueOf(DEFAULT_ASYNC_THREADS)).intValue(); return Executors.newFixedThreadPool(numThreads, new ThreadFactory() { private int nextThreadNum = 0; @Override public Thread newThread(final Runnable r) { final String threadName = "async-executor-" + (this.nextThreadNum++); LogFactory.getLog(this.getClass()) .debug("starting asynchronous request processing thread " + threadName); return new Thread(threadGroup, r, threadName); } }); }
From source file:com.adito.server.DefaultAditoServerFactory.java
public Integer start(String[] args) { startupStarted = System.currentTimeMillis(); // Inform the wrapper the startup process may take a while if (useWrapper) { WrapperManager.signalStarting(60000); }/*from ww w . j av a 2 s .com*/ // Parse the command line Integer returnCode = parseCommandLine(args); if (returnCode != null) { if (returnCode == 999) { return null; } return returnCode; } // Create the boot progress monitor if (gui) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException e) { } catch (InstantiationException e) { } catch (IllegalAccessException e) { } catch (UnsupportedLookAndFeelException e) { } bootProgressMonitor = new SwingBootProgressMonitor(); } else { bootProgressMonitor = new LogBootProgressMonitor(); } // resourceCaches = new HashMap<URL, ResourceCache>(); contextListeners = new ArrayList<ContextListener>(); loadSystemProperties(); initialiseLogging(); /* * Migrate preferences. */ File newPrefDir = new File(ContextHolder.getContext().getConfDirectory(), "prefs"); PREF = PropertyPreferences.SYSTEM_ROOT; try { if (!newPrefDir.exists() && Preferences.systemRoot().node("/com").nodeExists("adito")) { Preferences from = Preferences.systemRoot().node("/com/adito"); LOG.warn("Migrating preferences"); try { copyNode(from.node("core"), PREF.node("core")); from.node("core").removeNode(); copyNode(from.node("plugin"), PREF.node("plugin")); from.node("plugin").removeNode(); copyNode(from.node("extensions"), PREF.node("extensions")); from.node("extensions").removeNode(); copyNode(from.node("dbupgrader"), PREF.node("dbupgrader")); from.node("dbupgrader").removeNode(); } catch (BackingStoreException e) { LOG.error("Failed to migrate preferences.", e); } try { from.flush(); } catch (BackingStoreException bse) { LOG.error("Failed to flush old preferences"); } try { PREF.flush(); } catch (BackingStoreException bse) { LOG.error("Failed to flush new preferences"); } if (LOG.isInfoEnabled()) { LOG.info("Flushing preferences"); } } } catch (BackingStoreException bse) { LOG.error("Failed to migrate preferences.", bse); } // Inform the wrapper the startup process is going ok if (useWrapper) { WrapperManager.signalStarting(60000); } try { clearTemp(); try { hostname = Inet4Address.getLocalHost().getCanonicalHostName(); hostAddress = Inet4Address.getLocalHost().getHostAddress(); } catch (UnknownHostException ex) { // This should be fatal, we now rely on the hostname being // available throw new Exception("The host name or address on which this service is running could not " + "be determined. Check you network configuration. One possible cause is " + "a misconfigured 'hosts' file (e.g. on UNIX-like systems this would be " + "/etc/hosts, on Windows XP it would be " + "C:\\Windows\\System32\\Drivers\\Etc\\Hosts)."); } PropertyClassManager.getInstance() .registerPropertyClass(contextConfiguration = new ContextConfig(getClass().getClassLoader())); // Display some information about the system we are running on displaySystemInfo(); // Load the context property definitions loadContextProperties(); // Inform the wrapper the startup process is going ok if (useWrapper) { WrapperManager.signalStarting(60000); } // Configure any HTTP / HTTPS / SOCKS proxy servers configureProxyServers(); PropertyList l = contextConfiguration.retrievePropertyList(new ContextKey("webServer.bindAddress")); getBootProgressMonitor().updateMessage("Creating server lock"); getBootProgressMonitor().updateProgress(6); serverLock = new ServerLock(l.get(0)); if (serverLock.isLocked()) { if (!isSetupMode()) { if (serverLock.isSetup()) { throw new Exception("The installation wizard is currently running. " + "Please shut this down by pointing your browser " + "to http://" + getHostname() + ":" + serverLock.getPort() + "/showShutdown.do before attempting to start the server again."); } else { throw new Exception("The server is already running."); } } else { if (!serverLock.isSetup()) { throw new Exception("The server is currently already running. " + "Please shut this down by pointing your browser " + "to https://" + getHostname() + ":" + serverLock.getPort() + "/showShutdown.do before attempting to start the server again."); } else { throw new Exception("The installation wizard is running.."); } } } // Inform the wrapper the startup process is going ok if (useWrapper) { WrapperManager.signalStarting(60000); } Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { serverLock.stop(); } }); // registerKeyStores(); // threadGroup = new ThreadGroup("MainThreadGroup"); if (install) { setupMode(); } else { normalMode(); startHttpServer(); } } catch (Exception t) { startupException = t; LOG.error("Failed to start the server. " + t.getMessage(), t); return 1; } return null; }
From source file:com.jkoolcloud.tnt4j.streams.StreamsAgent.java
/** * Adds listeners to provided streams and runs streams on separate threads. * * @param streams/*from www.ja v a 2s. com*/ * streams to run * @param streamListener * input stream listener * @param streamTasksListener * stream tasks listener */ private static void run(Collection<TNTInputStream<?, ?>> streams, InputStreamListener streamListener, StreamTasksListener streamTasksListener) { if (streamThreads == null) { streamThreads = new ThreadGroup(StreamsAgent.class.getName() + "Threads"); // NON-NLS } StreamThread ft; // final CountDownLatch streamsCompletionSignal = new CountDownLatch(streams.size()); for (TNTInputStream<?, ?> stream : streams) { if (streamListener != null) { stream.addStreamListener(streamListener); } if (streamTasksListener != null) { stream.addStreamTasksListener(streamTasksListener); } stream.output().setProperty(OutputProperties.PROP_TNT4J_CONFIG_ZK_NODE, ZKConfigManager.getZKCfgProperty(ZKConfigManager.PROP_CONF_PATH_TNT4J)); // TODO: tnt4j-kafka settings // ZKConfigManager.getZKCfgProperty(ZKConfigManager.PROP_CONF_PATH_TNT4J_KAFKA); ft = new StreamThread(streamThreads, stream, String.format("%s:%s", stream.getClass().getSimpleName(), stream.getName())); // NON-NLS // ft.addCompletionLatch(streamsCompletionSignal); ft.start(); } // try { // streamsCompletionSignal.await(); // } catch (InterruptedException exc) { // } }