Distributed Task Scheduling Framework - Introduction to SkySchedule (2)

Overview

 

After the release of SkySchedule (see "Distributed Task Schedule --Introduction to SkySchedule " ), some users have been using it and received some feedback. For example , the .properties configuration file found by iteye netizen sxp2558 uses "user.name" as the key , which will be overwritten by the system variable "user.name" , and the " host name " is actually obtained . This problem has been fixed.

 

The problem with the most feedback at present is that SkySchedule has no management interface, which makes it inconvenient to view the current task assignment. Today I took the time to write a simple management page. Due to the limited level of front-end technology, it is relatively simple. The following is a brief demonstration. If you don't know the working principle of SkySchedule , please move to the previous introduction article "Distributed Task Scheduling Framework --Introduction to SkySchedule " .

 

Preparation Phase

 

First get the latest code from github : https://github.com/gantianxing/skySchedule.git ;

Use jdk1.8 +maven to compile and package;

Then deploy the war package sky-server-1.0-SNAPSHOT.war corresponding to the sky-server sub-project of the SkySchedule server to tomcat8 , and start the program;

 

Visit the server management page http://localhost:8080/ , the initial interface is as follows:



 

 

Since the client has not yet been connected, the client list here is empty.

 

add a client

 

Here is the sky-test project to simulate the client project ( in actual work, please introduce the client jar package corresponding to the sky-client project in the project that you need to do " distributed task scheduling " : sky-client-1.0-SNAPSHOT.jar ) .

 

Modify the values ​​corresponding to server.ip.port and group.id in the client configuration file SkySchedule-client.properties :

server.ip.port is the ip and port of the server netty , ip is the ip corresponding to the server just started , and the port defaults to 9991 . If there are multiple server instances, please use "," intervals.

 

group.id can be understood as a client group, each system corresponds to a group id , and there are multiple clients under each group id . Distributed task scheduling is to evenly distribute a batch of tasks to these clients for execution. I configured here The first group.id=1000 , first start a sky-test instance, refresh the server management page http://localhost:8080/ ( automatically refresh every 15 seconds ) , the page content is as follows:



 

 

Now there is only one client node, and the sql statement to get the task is select * from xxx where id%1=0 , and the client will execute all the tasks in the xxx task table. Here the client id is composed of client ip:uuid ( 192.168.21.1 is ip , data uuid is 1590479018 ).

 

Add multiple clients

 

Now add another client instance with group.id of 1000 (start a tomcat instance on the machine with ip of 10.14.140.6 ), refresh the server management page http://localhost:8080/ again , the page content is as follows:



 

 

Now there are two client nodes, in which the client whose ip is 192.168.21.1 will execute the task whose id mantissa in the task table is even, and the client whose ip is 10.14.140.6 will execute the task whose id mantissa is odd in the task table.

 

By analogy, if another instance is started, the tasks in the task table will be divided into three parts to be executed by different clients. If there are many tasks, you can add more client instances. Note that the group.id of these client instances must be the same to execute the tasks in the same task table.

 

reduce clients

 

Due to the decrease in business volume, the number of tasks in the task table will decrease accordingly. At this time, there may be fewer clients to meet the business requirements. At this time, you can directly log off some clients, and SkySchedule will automatically sense the change in the number of clients and reassign tasks.

 

In the same scenario, a certain client suddenly fails and goes down . At this time, SkySchedule will automatically sense and re-assign tasks. If the failure of the client is removed, after the client restarts, SkySchedule will also automatically sense and reassign the task again.

 

For example, stop the client whose ip is 10.14.140.6 , refresh the server management page http://localhost:8080/ , the page content is as follows:



 

 

At this time, all tasks will be distributed to 192.168.21.1 ( the principle is still id%1=0) .

 

What if there are multiple systems or multiple task tables to implement distributed scheduling, which can be achieved by adding different group.id , as follows:

 

 

Add multiple client groups

 

Assuming that there is another system that also needs to access "distributed task scheduling", you can configure the group.id in the configuration file SkySchedule-client.properties of this system to another value (do not duplicate the existing one).

 

For example, the test here is still sky-test , just set the group.id to 2000 , start a tomcat instance again, refresh the server management page http://localhost:8080/ , the page content is as follows:



 

 

By analogy, more client systems can be connected to perform non-interfering distributed task scheduling.

 

finally

 

The server management page http://localhost:8080/ will automatically refresh every 15 seconds to get the latest client list. If you need to adjust this time interval, you can modify the relevant code in hello.jsp in the sky-server subproject by yourself:

// Loop execution, execute check every 15 seconds
window.setInterval(check, 15000);

 

The introduction to the use of the SkySchedule management page is so far. If you have any questions, comments or suggestions, please leave a message to exchange, thank you.

 

Please indicate the source:

http://moon-walker.iteye.com/blog/2391954

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326990520&siteId=291194637