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

The following examples show how to use com.xxl.job.core.thread.TriggerCallbackThread. 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: XxlJobExecutor.java    From microservices-platform with Apache License 2.0 6 votes vote down vote up
public void start() throws Exception {

        // init logpath
        XxlJobFileAppender.initLogPath(logPath);

        // init admin-client
        initAdminBizList(adminAddresses, accessToken);


        // init JobLogFileCleanThread
        JobLogFileCleanThread.getInstance().start(logRetentionDays);

        // init TriggerCallbackThread
        TriggerCallbackThread.getInstance().start();

        // init executor-server
        port = port>0?port: NetUtil.findAvailablePort(9777);
        ip = (ip!=null&&ip.trim().length()>0)?ip: IpUtil.getIp();
        initRpcProvider(ip, port, appName, accessToken);
    }
 
Example #3
Source File: XxlJobExecutor.java    From microservices-platform with Apache License 2.0 6 votes vote down vote up
public void destroy(){
    // destory jobThreadRepository
    if (jobThreadRepository.size() > 0) {
        for (Map.Entry<Integer, JobThread> item: jobThreadRepository.entrySet()) {
            removeJobThread(item.getKey(), "web container destroy and kill the job.");
        }
        jobThreadRepository.clear();
    }


    // destory JobLogFileCleanThread
    JobLogFileCleanThread.getInstance().toStop();

    // destory TriggerCallbackThread
    TriggerCallbackThread.getInstance().toStop();

    // destory executor-server
    stopRpcProvider();
}
 
Example #4
Source File: XxlJobExecutor.java    From zuihou-admin-boot with Apache License 2.0 6 votes vote down vote up
public void start() throws Exception {

        // init logpath
        XxlJobFileAppender.initLogPath(logPath);

        // init admin-client
        initAdminBizList(adminAddresses, accessToken);


        // init JobLogFileCleanThread
        JobLogFileCleanThread.getInstance().start(logRetentionDays);

        // init TriggerCallbackThread
        TriggerCallbackThread.getInstance().start();

        // init executor-server
        port = port > 0 ? port : NetUtil.findAvailablePort(9999);
        ip = (ip != null && ip.trim().length() > 0) ? ip : IpUtil.getIp();
        initRpcProvider(ip, port, appName, accessToken, registryLazy);
    }
 
Example #5
Source File: XxlJobExecutor.java    From zuihou-admin-boot with Apache License 2.0 6 votes vote down vote up
public void destroy() {
    // destory jobThreadRepository
    if (jobThreadRepository.size() > 0) {
        for (Map.Entry<Integer, JobThread> item : jobThreadRepository.entrySet()) {
            removeJobThread(item.getKey(), "web container destroy and kill the job.");
        }
        jobThreadRepository.clear();
    }


    // destory JobLogFileCleanThread
    JobLogFileCleanThread.getInstance().toStop();

    // destory TriggerCallbackThread
    TriggerCallbackThread.getInstance().toStop();

    // destory executor-server
    stopRpcProvider();
}
 
Example #6
Source File: XxlJobExecutor.java    From zuihou-admin-cloud with Apache License 2.0 6 votes vote down vote up
public void start() throws Exception {

        // init logpath
        XxlJobFileAppender.initLogPath(logPath);

        // init admin-client
        initAdminBizList(adminAddresses, accessToken);


        // init JobLogFileCleanThread
        JobLogFileCleanThread.getInstance().start(logRetentionDays);

        // init TriggerCallbackThread
        TriggerCallbackThread.getInstance().start();

        // init executor-server
        port = port > 0 ? port : NetUtil.findAvailablePort(9999);
        ip = (ip != null && ip.trim().length() > 0) ? ip : IpUtil.getIp();
        initRpcProvider(ip, port, appName, accessToken, registryLazy);
    }
 
Example #7
Source File: XxlJobExecutor.java    From zuihou-admin-cloud with Apache License 2.0 6 votes vote down vote up
public void destroy() {
    // destory jobThreadRepository
    if (jobThreadRepository.size() > 0) {
        for (Map.Entry<Integer, JobThread> item : jobThreadRepository.entrySet()) {
            removeJobThread(item.getKey(), "web container destroy and kill the job.");
        }
        jobThreadRepository.clear();
    }


    // destory JobLogFileCleanThread
    JobLogFileCleanThread.getInstance().toStop();

    // destory TriggerCallbackThread
    TriggerCallbackThread.getInstance().toStop();

    // destory executor-server
    stopRpcProvider();
}
 
Example #8
Source File: XxlJobExecutor.java    From xxl-job with GNU General Public License v3.0 5 votes vote down vote up
public void destroy(){
    // destory executor-server
    stopEmbedServer();

    // destory jobThreadRepository
    if (jobThreadRepository.size() > 0) {
        for (Map.Entry<Integer, JobThread> item: jobThreadRepository.entrySet()) {
            JobThread oldJobThread = removeJobThread(item.getKey(), "web container destroy and kill the job.");
            // wait for job thread push result to callback queue
            if (oldJobThread != null) {
                try {
                    oldJobThread.join();
                } catch (InterruptedException e) {
                    logger.error(">>>>>>>>>>> xxl-job, JobThread destroy(join) error, jobId:{}", item.getKey(), e);
                }
            }
        }
        jobThreadRepository.clear();
    }
    jobHandlerRepository.clear();


    // destory JobLogFileCleanThread
    JobLogFileCleanThread.getInstance().toStop();

    // destory TriggerCallbackThread
    TriggerCallbackThread.getInstance().toStop();

}
 
Example #9
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 #10
Source File: XxlJobExecutor.java    From xxl-job with GNU General Public License v3.0 4 votes vote down vote up
public void start() throws Exception {

        // init logpath
        XxlJobFileAppender.initLogPath(logPath);

        // init invoker, admin-client
        initAdminBizList(adminAddresses, accessToken);


        // init JobLogFileCleanThread
        JobLogFileCleanThread.getInstance().start(logRetentionDays);

        // init TriggerCallbackThread
        TriggerCallbackThread.getInstance().start();

        // init executor-server
        initEmbedServer(address, ip, port, appname, accessToken);
    }