com.xxl.job.core.thread.ExecutorRegistryThread Java Examples

The following examples show how to use com.xxl.job.core.thread.ExecutorRegistryThread. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JettyServer.java    From open-capacity-platform with Apache License 2.0 6 votes vote down vote up
public void destroy() {

		// destroy Registry-Server
		ExecutorRegistryThread.getInstance().toStop();

		// destroy Callback-Server
		TriggerCallbackThread.getInstance().toStop();

		// destroy server
		if (server != null) {
			try {
				server.stop();
				server.destroy();
			} catch (Exception e) {
				logger.error(e.getMessage(), e);
			}
		}
		if (thread.isAlive()) {
			thread.interrupt();
		}

		logger.info(">>>>>>>>>>> xxl-rpc server destroy success, netcon={}", JettyServer.class.getName());
	}
 
Example #2
Source File: JettyServer.java    From open-capacity-platform with Apache License 2.0 4 votes vote down vote up
public void start(final int port, final String ip, final String appName) throws Exception {
	thread = new Thread(new Runnable() {
		@Override
		public void run() {

			// The Server
			server = new Server(new ExecutorThreadPool());  // 非阻塞

			// HTTP connector
			ServerConnector connector = new ServerConnector(server);
			if (ip!=null && ip.trim().length()>0) {
				connector.setHost(ip);	// The network interface this connector binds to as an IP address or a hostname.  If null or 0.0.0.0, then bind to all interfaces.
			}
			connector.setPort(port);
			server.setConnectors(new Connector[]{connector});

			// Set a handler
			HandlerCollection handlerc =new HandlerCollection();
			handlerc.setHandlers(new Handler[]{new JettyServerHandler()});
			server.setHandler(handlerc);

			try {
				// Start server
				server.start();
				logger.info(">>>>>>>>>>> xxl-job jetty server start success at port:{}.", port);

				// Start Registry-Server
				ExecutorRegistryThread.getInstance().start(port, ip, appName);

				// Start Callback-Server
				TriggerCallbackThread.getInstance().start();

				server.join();	// block until thread stopped
				logger.info(">>>>>>>>>>> xxl-rpc server join success, netcon={}, port={}", JettyServer.class.getName(), port);
			} catch (Exception e) {
				logger.error(e.getMessage(), e);
			} finally {
				//destroy();
			}
		}
	});
	thread.setDaemon(true);	// daemon, service jvm, user thread leave >>> daemon leave >>> jvm leave
	thread.start();
}
 
Example #3
Source File: XxlJobExecutor.java    From microservices-platform with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Map<String, String> param) {
    // start registry
    ExecutorRegistryThread.getInstance().start(param.get("appName"), param.get("address"));
}
 
Example #4
Source File: XxlJobExecutor.java    From microservices-platform with Apache License 2.0 4 votes vote down vote up
@Override
public void stop() {
    // stop registry
    ExecutorRegistryThread.getInstance().toStop();
}
 
Example #5
Source File: XxlJobExecutor.java    From zuihou-admin-boot with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Map<String, String> param) {
    // start registry
    ExecutorRegistryThread.getInstance().start(param.get("appName"), param.get("address"), param.get("registryLazy"));
}
 
Example #6
Source File: XxlJobExecutor.java    From zuihou-admin-boot with Apache License 2.0 4 votes vote down vote up
@Override
public void stop() {
    // stop registry
    ExecutorRegistryThread.getInstance().toStop();
}
 
Example #7
Source File: XxlJobExecutor.java    From zuihou-admin-cloud with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Map<String, String> param) {
    // start registry
    ExecutorRegistryThread.getInstance().start(param.get("appName"), param.get("address"), param.get("registryLazy"));
}
 
Example #8
Source File: XxlJobExecutor.java    From zuihou-admin-cloud with Apache License 2.0 4 votes vote down vote up
@Override
public void stop() {
    // stop registry
    ExecutorRegistryThread.getInstance().toStop();
}
 
Example #9
Source File: EmbedServer.java    From xxl-job with GNU General Public License v3.0 4 votes vote down vote up
public void startRegistry(final String appname, final String address) {
    // start registry
    ExecutorRegistryThread.getInstance().start(appname, address);
}
 
Example #10
Source File: EmbedServer.java    From xxl-job with GNU General Public License v3.0 4 votes vote down vote up
public void stopRegistry() {
    // stop registry
    ExecutorRegistryThread.getInstance().toStop();
}