Cluster server scheduled task to run only one timer design

(1) Only the timing of the deployment of the task code on a server.

(2) plus a specific ip task code at the timing limits, only one server can run ip timer task.

(3) to run scheduled tasks using the shared lock management system database transactions.

   Step one: Create a database table, the table has three fields: status (Table whether the current timer in a runnable state), timestamp (timestamp), serverIP (running timer server IP).

   Step two: Check the machine is running regular tasks. Check Method: update timing of the task table status field is one (1 is executed, 0 is not performed), IP for their IP, if the update fails, then prove the machine performs this timing task, the timing task of the machine to is not performed, the success of the third step.

   The third step: the task execution timing of the specific content, completion of the reduction excute field is zero.

In addition:
  First, let's build a table in the database: timerT, table which has three fields: status (Table whether the current timer in a runnable state), timestamp (timestamp), serverIP (running timer server IP).
      Specific use herein is: When the two servers are up and running, the timer started Server A, then, to read the status field A will timerT the table, when the traffic is logic 0, the timer is performed in this case the timer a, the status need to 1, so that another timer B is not to execute business logic server and the current IP server records to the table, while a new thread to start to modify, on XXX continue to modify the value of the timestamp of the long time interval, when the a service logic been performed, to put the status value 0, so that the timer B can be performed.
  This would solve a problem is this: When one of the timers A hang our another timer B, can the current time is more than than the value of timestap XXX duration, if exceeded, then the timer A has been linked to prove out, then B will be the value of the status changed to 1, the timer serverIP into server IP B is located, and execute business logic.

Guess you like

Origin www.cnblogs.com/lgg20/p/12329568.html