CN107621975A - Timer logic implementation method based on JAVA TIMER high availability - Google Patents

Timer logic implementation method based on JAVA TIMER high availability Download PDF

Info

Publication number
CN107621975A
CN107621975A CN201710813834.8A CN201710813834A CN107621975A CN 107621975 A CN107621975 A CN 107621975A CN 201710813834 A CN201710813834 A CN 201710813834A CN 107621975 A CN107621975 A CN 107621975A
Authority
CN
China
Prior art keywords
timer
time
task
run
logic
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201710813834.8A
Other languages
Chinese (zh)
Other versions
CN107621975B (en
Inventor
林宇
范叔亮
赖庆鑫
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
CHINA YOUKE COMMUNICATION TECHNOLOGY Co Ltd
Original Assignee
CHINA YOUKE COMMUNICATION TECHNOLOGY Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by CHINA YOUKE COMMUNICATION TECHNOLOGY Co Ltd filed Critical CHINA YOUKE COMMUNICATION TECHNOLOGY Co Ltd
Priority to CN201710813834.8A priority Critical patent/CN107621975B/en
Publication of CN107621975A publication Critical patent/CN107621975A/en
Application granted granted Critical
Publication of CN107621975B publication Critical patent/CN107621975B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

It is an object of the invention to provide a kind of timer logic implementation method based on JAVA TIMER high availability, by fighting for mechanism, ensure that an only scheduler module gets the operation power of task in the same time, so that the operation of service logic meets the expectation of user;Simultaneously, dispose multiple business execution modules, if a business execution module breaks down and can not performed, the logic of execution can be transferred on the server of another deployment business execution module by changing URL addresses, substantially increase the resume speed of failure.

Description

Timer logic implementation method based on JAVA TIMER high availability
Technical field
The present invention relates to a kind of timer logic implementation method based on JAVA TIMER high availability.
Background technology
Existing software product is mostly used for client's production environment, and service is provided for customer business purposes.This requires soft Part product and framework have very high availability, can recover in time in failure, while reduce artificial intervention.There is a kind of answer With scene, it is necessary to which timing performs specific the Logic of Tasks, realized in software development generally by timer.In JAVA Middle timer is most to be achieved in that by TIMER and third-party Spring Quartz, and task code is performed in timing On, both of which is without what problem, it might even be possible to says that the execution time of task is very accurate.It can work as and be deployed to production environment When, how to improve timer availability and failover capability just into a problem.
Which kind of existing software timer, no matter realized by technology, usually by task scheduling logical AND service logic Merging writes on together, so results in a problem:Once the server for disposing timer breaks down, then whole timer It will be stopped, availability is not high.And if timer is disposed into multiple services, then how to be assisted between identical timer Key degree, turn into a problem again, because the same time only needs a timer and performs service logic, multiple timings Device performs identical service logic and is possible to that original logical miss can be caused.
The content of the invention
The present invention provides a kind of timer logic implementation method based on JAVA TIMER high availability, it is intended to improves timing The availability of device, timer dispatching is separated with service logic, and realize that scheduling of multiple timers for same task is realized.
To achieve the above object, the present invention uses following technical scheme:It is a kind of to be determined based on JAVA TIMER high availability When device logic realization method, it is characterised in that:Comprise the following steps:S1:Timer realized by the way of JAVA TIMER, root According to the parameter of setting, task scheduling is performed at a certain time interval;S2:Business execution module is responsible for specific service logic, The execution of business module only can be just triggered when task scheduling modules are eligible, the major way of execution is:When appoint Be engaged in scheduler module according to oneself when realizing that logic decision task can perform, transmission HTTP request to business execution module JSP On the page, the execution of service logic is entered using JSP as entrance.S3:It is fixed according to the principle of fighting between identical timer, deployment When device task scheduling execution module on N platform application servers, the timed task scheduler module on N platform application servers passes through The mechanism of fighting for fights for the operation authority of corresponding task, after having task scheduling modules to fight for running authority, according to the industry of configuration Business execution module URL addresses carry out HTTP access, to perform service logic;N is the natural number more than or equal to 2.
Compared with prior art, the present invention has advantages below:By fighting for mechanism, ensured that only in the same time One scheduler module gets the operation power of task, so that the operation of service logic meets the expectation of user;Meanwhile deployment is multiple Business execution module, if a business execution module breaks down and can not performed, it be able to will be held by changing URL addresses Capable logic is transferred on the server of another deployment business execution module, substantially increases the resume speed of failure.
Brief description of the drawings
Fig. 1 is the block schematic illustration of one embodiment of the invention.
Embodiment
Explanation is further explained to the present invention with specific embodiment below in conjunction with the accompanying drawings.
It is an object of the invention to provide a kind of timer logic implementation method based on JAVA TIMER high availability.It is wrapped Include following steps:S1:Timer realized by the way of JAVA TIMER, according to the parameter of setting, at a certain time interval Perform task scheduling;S2:Business execution module is responsible for specific service logic, only when task scheduling modules are qualified Hou Caihui triggers the execution of business module, and the major way of execution is:When task scheduling modules realize that logic is sentenced according to oneself Determine task it is executable when, send HTTP request to the JSP of business execution module, enter business by entrance of JSP The execution of logic.S3:Principle is fought for according between identical timer, the task scheduling execution module for disposing timer should to N platforms With on server, the operation that the timed task scheduler module on N platform application servers fights for corresponding task by fighting for mechanism is weighed Limit, after there are task scheduling modules to fight for running authority, HTTP visits are carried out according to the business execution module URL addresses of configuration Ask, to perform service logic;N is the natural number more than or equal to 2.
In an embodiment of the present invention, the S1 task schedulings that TIMER is performed in the time interval of setting include following step Suddenly:
S11:According to incoming TIMER thread number THREAD_MODE, THREAD_MODE corresponding to Query Task Info table Record;
S12:The record that traversal queries arrive, comparison task run time next time NEXT_TIME and current time, if current time Next TIMER task schedulings cycle is then exited into less than NEXT_TIME, if greater than NEXT_TIME, then it is real to change task When state table real-time running state RUN_STATUS be " RUN ";
S13:When current time is more than NEXT_TIME, sends in the URL address fields that HTTP request performs to service logic and configure URL, perform service logic;
S14:Run time next time is calculated automatically and is updated according to task run period field and NEXT_TIME fields arrives Time in NEXT_TIME, originally NEXT_TIME fields is updated into last time Runtime LAST_TIME field;
S15:The real-time running state RUN_STATUS of more new task real-time status table is " stopping ";
S16:This operation result is recorded to task running log table.
Each TIMER performs the task of oneself according to S11-S16 repeatedly, if multiple timer services are disposed, more Between individual timer thread, according to principle is fought for, the RUN_STATUS fields of real-time status table are first updated to the timing of " RUN " Device obtains the operation power of task, and other timed task threads that there is no operation power then return to the first step of the cycle of operation and started Run repeatedly.
In order to improve availability, while artificial involvement level is reduced, general thought of the invention is exactly to improve timer Scheduling logic, and scheduling is separated with service logic.Realize that multiple timers can for the height of same service logic simultaneously Realized with property.
Overall module can be divided into:Task scheduling modules, business logic modules, it will introduce respectively below.
(1) task scheduling modules
This module mainly realizes the scheduling feature of task, and the main table being related to has:
1、UCSS_POS_HTTP_CONFIG:Mission bit stream table
The URL of business module, the schedule information and task status of task etc. are configured with, primary fields and function are:
The URL addresses that l EXECUATE_URL service logics perform
L LAST_TIME task last time run times
L NEXT_TIME task run times next time
In the l RUN_CYCLE task run cycles, the time that can draw NEXT_TIME is added with LAST_TIME
L RUN_STATUS task effective statuses
L THREAD_MODE thread numbers, each task are only derived from the task run under own thread number
2、UCSS_POS_HTTP_STATE:Task real-time status table
Can be as follows with the real-time status of some task of real time inspection, primary fields and function from table:
LRUN_STATUS task real-time running states
L RUN_TIME task runs spend the time
3、UCSS_POS_HTTP_RUN_LOG:Task run log sheet
For recording the operation result of every subtask and spending the time, primary fields and function are as follows
L RUN_TIME Runtimes, the time spent by this tasks carrying
L RUN_RETURN task run results, call business module URL, that is, access what is configured in EXECUATE_URL fields The conditional code returned after URL
Main table and function field, timer realize that TIMER can basis by the way of JAVA TIMER more than The parameter of setting, runs service logic at a certain time interval.Each TIMER can only run a task, can also Run multiple tasks.In the specific embodiment of the invention, TIMER run time was at intervals of 1 minute, the TIMER in this 1 minute The task scheduling cycle logic of execution is:
1st, THREAD_ is corresponded to according to incoming TIMER THREAD_MODE parameters, inquiry UCSS_POS_HTTP_CONFIG tables MODE record.
2nd, the record that traversal queries arrive, compares NEXT_TIME and current time, if current time is less than NEXT_TIME Next TIMER task schedulings cycle is then exited into, if greater than NEXT_TIME, then changes UCSS_POS_HTTP_STATE The real-time running state RUN_STATUS of table is " RUN "
3rd, when current time is more than NEXT_TIME, at the same judge task status table RUN_STATUS fields whether be " stopping ", If stopping, then the URL that HTTP request configures into EXECUATE_URL fields is sent, perform service logic.If task The RUN_STATUS fields of state table are " operation ", then illustrate that now the task is transported by the task scheduling modules of other timers OK, this task scheduling terminates and exits into next TIMER task schedulings cycle.
4th, run time next time is calculated automatically and is updated according to RUN_CYCLE fields and NEXT_TIME fields arrive Time in NEXT_TIME, originally NEXT_TIME fields is updated into last time run time LAST_TIME field
5th, the real-time running state RUN_STATUS for updating UCSS_POS_HTTP_STATE tables is " stopping ", discharges the fortune of task Row power
6th, this operation result is recorded to UCSS_POS_HTTP_LOG tables, facilitates the operation result of tracking task.
Each TIMER performs the task of oneself according to above logic repeatedly, if multiple timer services are disposed, more Between individual timer thread, according to principle is fought for, the RUN_STATUS fields of real-time status table are first updated to the timing of " RUN " Device obtains the operation power of task, and other timed task threads that there is no operation power then return to the first step of the cycle of operation and started Run repeatedly.So, even if timed task of the deployment wherein on a server breaks down, other timed tasks also can Continue in time, ensure that the high availability of timer.
(2) business execution module
Business execution module is mainly specific service logic, and service code is run according to the expectation of client.Business performs mould Block is not performed actively usually, and the execution of business module only can be just triggered when task scheduling modules are eligible, is held Capable major way is:When task scheduling modules according to oneself when realizing that logic decision task can perform, send HTTP request Onto the JSP of business execution module, the execution of service logic is entered using JSP as entrance.
N is 2 described in a specific embodiment of the invention.According to the logic realization of above timer, and according to identical fixed When device between fight for principle, task of timer scheduler module can be disposed multiple servers, referring to Fig. 1, with 2 services of deployment Illustrate exemplified by device, specific deployment framework is as follows:
Dispose timed task and dispatch execution module to two application servers, the timed task on this two application servers is adjusted Module is spent by the operation authority fought for mechanism and fight for corresponding task presented hereinbefore, fights for running authority when there is scheduler module Afterwards, HTTP access is carried out according to the business execution module URL addresses of configuration, to perform service logic.So, by fighting for machine System, ensure that an only scheduler module gets the operation power of task in the same time, so that the operation symbol of service logic Share the expectation at family.Meanwhile the reason for disposing multiple business execution modules, is:Because the entrance that business execution module performs is URL addresses, so, if a business execution module breaks down and can not performed, it be able to will be held by changing URL addresses Capable logic is transferred on the server of another deployment business execution module, substantially increases the resume speed of failure.
Above is presently preferred embodiments of the present invention, all changes made according to technical solution of the present invention, caused function are made During with scope without departing from technical solution of the present invention, protection scope of the present invention is belonged to.

Claims (4)

  1. A kind of 1. timer logic implementation method based on JAVA TIMER high availability, it is characterised in that:Comprise the following steps:
    S1:Timer TIMER is realized by the way of JAVA TIMER, including task scheduling modules and business execution module; TIMER performs task scheduling at a certain time interval according to the parameter of setting;
    S2:Business execution module is responsible for specific service logic, only can just be touched when task scheduling modules are eligible The execution of sending service module, the major way of execution are:When task scheduling modules realize that logic decision task can according to oneself During execution, HTTP request is sent to the JSP of business execution module, enters holding for service logic by entrance of JSP OK;
    S3:Principle is fought for according between identical timer, disposes the task scheduling execution module of timer to N platform application servers On, the timed task scheduler module on N platform application servers fights for the operation authority of corresponding task by fighting for mechanism, appoints when having Business scheduler module is fought for after running authority, HTTP access is carried out according to the business execution module URL addresses of configuration, to perform industry Business logic;N is the natural number more than or equal to 2.
  2. 2. the timer logic implementation method according to claim 1 based on JAVA TIMER high availability, its feature exist In:The S1 task schedulings that TIMER is performed in the time interval of setting comprise the following steps:
    S11:According to incoming TIMER thread number THREAD_MODE, THREAD_MODE corresponding to Query Task Info table Record;
    S12:The record that traversal queries arrive, comparison task run time next time NEXT_TIME and current time, if current time Next TIMER task schedulings cycle is then exited into less than NEXT_TIME, if greater than NEXT_TIME, then it is real to change task When state table real-time running state RUN_STATUS be " RUN ";
    S13:When current time is more than NEXT_TIME, sends in the URL address fields that HTTP request performs to service logic and configure URL, perform service logic;
    S14:Run time next time is calculated automatically and is updated according to task run period field and NEXT_TIME fields arrives Time in NEXT_TIME, originally NEXT_TIME fields is updated into last time Runtime LAST_TIME field;
    S15:The real-time running state RUN_STATUS of more new task real-time status table is " stopping ";
    S16:This operation result is recorded to task running log table.
  3. 3. the timer logic implementation method according to claim 2 based on JAVA TIMER high availability, its feature exist In:Each TIMER performs the task of oneself according to S11-S16 repeatedly, if disposing multiple timer services, in multiple timings Device cross-thread, according to principle is fought for, the timer that the RUN_STATUS fields of real-time status table are first updated to " RUN " obtains The operation power of task, other timed task threads that there is no operation power then return to the first step of the cycle of operation and start to transport repeatedly OK.
  4. 4. the timer logic implementation method according to claim 1 based on JAVA TIMER high availability, its feature exist In:The N is 2.
CN201710813834.8A 2017-09-11 2017-09-11 TIMER logic implementation method based on JAVA TIMER high availability Active CN107621975B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710813834.8A CN107621975B (en) 2017-09-11 2017-09-11 TIMER logic implementation method based on JAVA TIMER high availability

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710813834.8A CN107621975B (en) 2017-09-11 2017-09-11 TIMER logic implementation method based on JAVA TIMER high availability

Publications (2)

Publication Number Publication Date
CN107621975A true CN107621975A (en) 2018-01-23
CN107621975B CN107621975B (en) 2020-08-21

Family

ID=61088480

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710813834.8A Active CN107621975B (en) 2017-09-11 2017-09-11 TIMER logic implementation method based on JAVA TIMER high availability

Country Status (1)

Country Link
CN (1) CN107621975B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109254838A (en) * 2018-08-21 2019-01-22 中邮科通信技术股份有限公司 A kind of automation task based on JAVA BeanShell
CN112256416A (en) * 2020-10-22 2021-01-22 上海英方软件股份有限公司 Method and system for realizing complex task scheduling and simultaneously cleaning data

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070288481A1 (en) * 2006-05-16 2007-12-13 Bea Systems, Inc. Ejb cluster timer
US7526551B1 (en) * 2003-10-01 2009-04-28 Sun Microsystems, Inc. System and method for highly available timer service in a J2EE cluster
US7793299B2 (en) * 2005-08-30 2010-09-07 International Business Machines Corporation System and method for scheduling tasks for execution
CN103744724A (en) * 2014-02-19 2014-04-23 互联网域名系统北京市工程研究中心有限公司 Timed task clustering method and device thereof
US20140181305A1 (en) * 2012-12-26 2014-06-26 Microsoft Corporation Schedule based execution with extensible continuation based actions
CN105631006A (en) * 2015-12-28 2016-06-01 杭州东方通信软件技术有限公司 Data scheduling acquisition device and method
CN105955811A (en) * 2016-05-05 2016-09-21 北京思特奇信息技术股份有限公司 System and method for achieving task scheduling based on remote invoking mode
CN106126332A (en) * 2016-06-27 2016-11-16 北京京东尚科信息技术有限公司 Distributed timing task scheduling system and method
CN107092523A (en) * 2017-04-14 2017-08-25 浙江数链科技有限公司 The dispatching method and system of timed task

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7526551B1 (en) * 2003-10-01 2009-04-28 Sun Microsystems, Inc. System and method for highly available timer service in a J2EE cluster
US7793299B2 (en) * 2005-08-30 2010-09-07 International Business Machines Corporation System and method for scheduling tasks for execution
US20070288481A1 (en) * 2006-05-16 2007-12-13 Bea Systems, Inc. Ejb cluster timer
US20140181305A1 (en) * 2012-12-26 2014-06-26 Microsoft Corporation Schedule based execution with extensible continuation based actions
CN103744724A (en) * 2014-02-19 2014-04-23 互联网域名系统北京市工程研究中心有限公司 Timed task clustering method and device thereof
CN105631006A (en) * 2015-12-28 2016-06-01 杭州东方通信软件技术有限公司 Data scheduling acquisition device and method
CN105955811A (en) * 2016-05-05 2016-09-21 北京思特奇信息技术股份有限公司 System and method for achieving task scheduling based on remote invoking mode
CN106126332A (en) * 2016-06-27 2016-11-16 北京京东尚科信息技术有限公司 Distributed timing task scheduling system and method
CN107092523A (en) * 2017-04-14 2017-08-25 浙江数链科技有限公司 The dispatching method and system of timed task

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
张倩,孙瑞: "基于Quzart的定时器插件的设计与实现", 《电脑知识与技术》 *
温立辉: "Java语言定时调度任务之实现", 《福建电脑》 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109254838A (en) * 2018-08-21 2019-01-22 中邮科通信技术股份有限公司 A kind of automation task based on JAVA BeanShell
CN109254838B (en) * 2018-08-21 2021-11-23 中邮科通信技术股份有限公司 JAVA-based automation task of BeanShell
CN112256416A (en) * 2020-10-22 2021-01-22 上海英方软件股份有限公司 Method and system for realizing complex task scheduling and simultaneously cleaning data

Also Published As

Publication number Publication date
CN107621975B (en) 2020-08-21

Similar Documents

Publication Publication Date Title
US11765109B2 (en) Method and system for providing resiliency in interaction servicing across data centers
Vahidinia et al. Cold start in serverless computing: Current trends and mitigation strategies
US20190377604A1 (en) Scalable function as a service platform
US20150026359A1 (en) Methods and systems for reconfiguration and repartitioning of a parallel distributed stream process
US8090974B1 (en) State machine controlled dynamic distributed computing
CN103679392B (en) A kind of task scheduling processing method and system
CN107918556A (en) A kind of timed task performs method and apparatus in the parallel of multiple servers
CN105677462A (en) Distributed task system based on internet of things and business processing method
CN106062716B (en) The method, apparatus and single task system of multitask are realized in single task system
CN105159769A (en) Distributed job scheduling method suitable for heterogeneous computational capability cluster
CN107491346A (en) A kind of task processing method of application, apparatus and system
Zhang et al. Reconfigurable real-time middleware for distributed cyber-physical systems with aperiodic events
CN113220431B (en) Cross-cloud distributed data task scheduling method, device and storage medium
CN110750343B (en) Cluster system timing task scheduling control method and cluster system
CN107621975A (en) Timer logic implementation method based on JAVA TIMER high availability
Simoncelli et al. Stream-monitoring with blockmon: convergence of network measurements and data analytics platforms
CN110300188A (en) Data transmission system, method and apparatus
CN108170417B (en) Method and device for integrating high-performance job scheduling framework in MESOS cluster
CN105260244B (en) A kind of method and apparatus of distributed system task schedule
Kay et al. Real-time control in ROS and ROS 2.0
Lv et al. An attribute-based availability model for large scale IaaS clouds with CARMA
CN109725916B (en) Topology updating system and method for stream processing
Staschulat et al. Budget-based real-time executor for micro-ROS
CN113434323A (en) Task flow control method of data center station and related device
Bernstein et al. Serverless Event-Stream Processing over Virtual Actors.

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant