Field of the Invention
The present invention relates to a technique for controlling execution of a task when a plurality of modules such as schedulers exist.
Description of the Related Art
Conventionally, when data processing is executed by a computer, a technique is known in which a module such as a scheduler manages a plurality of tasks corresponding to each data processing to control a processing order by using a queue (e.g., Japanese Patent Application Laid-Open No. 2009-176146). Herein, “task” is a unit of processing managed by a queue, which is also referred to as “job”. There is also a system in which task execution control modules such as a plurality of schedulers registers tasks in a common queue to process the tasks in sequence.
Further, in recent years, a system called “cloud computing” which provides applications and services through a technique using virtualization technology can be established on a network such as the internet. In the above-described system, a technique called blue-green deployment is provided as a method for upgrading a version without stopping the applications and the services.
In the blue-green deployment, two execution environments called a blue environment and a green environment are provided, and systems are established by operating the applications and the services in the respective environments. Herein, when the above technique is employed to upgrade the version, upgraded applications and services are operated in the green environment.
A system established in the blue environment is currently released on the internet, and a request from the outside of the system is transferred to the system established in the blue environment via a router or a domain name system (DNS) to be processed therewith. In the blue-green deployment, a processing/execution environment of the request is switched by changing setting of the router and transferring the request from the outside of the system to a system established in the green environment, so as to realize version upgrade of the system. In addition, in order to enable a user to use a processing result or data accumulated so far even after the version upgrade, the systems established in respective environments are configured to share the database.
Assume that above-described schedulers operate to realize data processing relating to a plurality of tasks in the systems established in the blue environment and the green environment by using a database shared by these environments. A task that defines processing corresponding to a request from the outside of the system and a task that defines processing necessary to be executed periodically are managed thereby.
However, for example, the scheduler operating in the system in the blue environment may attempt to manage a task by using the database shared with the green environment without taking the switch-over of the processing environment into consideration. In such a case, there is a problem in that the scheduler operating in the system in the green environment takes out a task that should be originally handled by the scheduler operating in the system in the blue environment and executes that task in the system in the green environment.
Accordingly, in accordance with an aspect of the present invention, a method is provided for ensuring an execution control module for executing each task in a case where a plurality of execution control modules respectively operating in a plurality of environments performs execution control of tasks managed by a database shared therewith.
According to another aspect of the present invention, a system establishing one or more execution environments in which a task corresponding to task information managed in a database is executed, includes execution control units respectively operating in a plurality of execution environments which are configured to control execution of a task corresponding to task information conforming to a first condition from among the task information managed in the database which is associated with identification information of the execution control units. In a plurality of the execution control units respectively operating in a plurality of the execution environments, a first mode is set to any one execution control unit as an operation mode whereas a second mode different from the first mode is set to the other execution control units as operation modes, and the execution control unit to which the first mode is set also acquires task information conforming to a second condition different from the first condition from the database and controls execution of a task corresponding to the acquired task information.
Further features of the present invention will become apparent from the following description of exemplary embodiments with reference to the attached drawings.
Hereinafter, an exemplary embodiment embodying the present invention will be described with reference to the appended drawings.
A client 101 is a terminal through which a user uses a service provided by a production environment (blue environment 103) of the system. The client 101 accesses a system 100 to transmit a request by using a web browser. A plurality of clients that uses the service provided by the system 100 may exist outside the system 100 in addition to the client 101. In such a case, these clients respectively transmit requests to the system 100.
A router 102 receives a request with respect to the system 100 from the client 101 and transfers the request to the appropriate execution environment. At present, because two execution environments operate in the system 100 while the blue environment 103 is released as a production environment, the router 102 transfers a request from the client 101 to the blue environment 103. Herein, the execution environment such as the blue environment 103 which releases the service to the client 101 outside the system 100 is called as “production environment”. On the other hand, a green environment 107 which does not release the service to the client 101 outside the system 100 is called as “test environment” or “preliminary environment”. Although the green environment 107 does not release the service to the client 101 outside the system 100, internal configurations thereof are usually operating, so that a system administrator can use the system by accessing thereto. Further, the green environment 107 may be provided more than one. In addition, each of the environments such as the blue environment 103 and the green environment 107 includes a unique environment identifier as attribute information. The configuration such as a scheduler included in each of the environments can refer to the environment identifier.
The blue environment 103 is configured of a web server 104, an application server 105, and a scheduler 106. A plurality of the web servers 104 and the application servers 105 may be established, and these servers 104 and 105 are realized with virtual machines operating on one or more server computer.
The web server 104 receives a request from the client 101, calls the application server 105 as necessary, and returns a processing result of the request to the client 101. The application server 105 receives a request from the web server 104 or the scheduler 106, executes processing according to the request, and returns a processing result to a calling source. Further, the application server 105 operates data within a database 111 as necessary before or after receiving the request.
The scheduler 106 receives task information as a request from the web server 104 or the application server 105 via a predetermined web application program interface (API), and stores the task information in the database 111. In the database 111, the task information is managed by a task information table. The scheduler 106 periodically refers to the task information table and executes a task corresponding to the task information according to schedule information of the task information being managed. For example, the scheduler 106 executes a task by calling a function of the application server 105.
The database 111 is accessible from applications, services, or schedulers within the systems in both the blue environment 103 and the green environment 107.
Basically, the green environment 107 has a configuration similar to that of the blue environment 103. However, a version of the application or the service operating in the green environment 107 (e.g., a program operating on a web server 108 or an application server 109) is different. A scheduler 110 having a function similar to that of the scheduler 106 is operating in the green environment 107.
A switching control unit 112 executes environment switching processing for switching a processing environment of the request from the client 101, from the blue environment 103 to the green environment 107. This environment switching processing is executed according to an instruction input by the administrator of the system 100, or automatically executed according to a schedule previously set thereto. In addition, to test an operation, each constituent element included in the green environment 107 is operated concurrently with constituent elements in the blue environment 103 for a predetermined period. During the operational test, the scheduler 110 operates internal task execution control, and a request manually input by the administrator is executed by the web server 108 or the application server 109. When the operational test is sufficiently completed, the switching control unit 112 executes environment switching processing at a timing described above.
A load balancer (LB) 306 executes load distribution by allocating the requests from the client 101 to the web servers 301 to 303. Further, a LB 307 executes load distribution by allocating the requests from the web servers 301 to 303 and the scheduler 106 to any of the application servers 304 and 305. The web server 301 to 303, the application servers 304 and 305, and the scheduler are realized as virtual machines.
The scheduler in
A plurality of virtual machines 408, 409, and 410 operate within the virtual server 401. The virtual machine 408, 409, or 410 emulates a host computer, and an operating system 412 and an application 411 running on the operating system 412 operate therein. A virtual NIC 413 emulates a communication controller and executes data transmission/reception with other virtual NICs connected to the network via a virtual switch 407 and the NIC 420. The virtual switch 407 is software that emulates a switching hub, and controls communication between the virtual NICs within the virtual machines 408 to 410 and the NIC 420 within the virtual server 401. Software that realizes the virtual machines 408 to 410 in the virtual server 401 is called as “hypervisor”. The controller 406 manages settings of the virtual machines 408 to 410 and the virtual switch 407 within the virtual server 401. For example, the controller 406 increases or decreases the number of web servers or application servers according to a load. Further, the controller 406 monitors the application 411 operating in the virtual machine 408, and stops the virtual machine 408 if any failure is detected in the application 411.
The scheduler 106 stores task information in the database 111 and controls execution of a task according to the task information. The web server 104 and the application server 105 can instruct the scheduler 106 to register or change the task via the web API.
Herein, Table 1 illustrates contents (format) of the task information stored and managed in the database 111.
“Scheduler Identifier (ID)” is identification information (string of letters) uniquely identifying an instance of each scheduler generated from a universally unique identifier (UUID) when each of the schedulers is activated. The instances of different schedulers have different scheduler IDs. For example, the scheduler 106 sets its own scheduler ID when the task information is added or changed.
“Task Name” is a string of letters uniquely identifying the task information stored in the database 111 specified by a registration source of the task information.
“Scheduled Execution Date/Time” is schedule information at which a task according to the task information is to be executed. The scheduled execution date/time is specified by “Year/Month/Date/Time”. If the task information indicates a repetitive task, “Scheduled Execution Date/Time” is calculated from a repetition setting described below at a time that the task is registered or executed. If the task is not the repetitive task, “Scheduled Execution Date/Time” is specified by a registration source of the task information.
“Repetition Setting” is a repetition setting for repeatedly executing a task. The repetition setting is expressed in a JavaScript Object Notation (JSON) format and specified by a registration source of the task information. In the item “Repetition Setting”, ending date/time that indicates an ending point of the repetition period may be specified together. When “Repetition Setting” is not specified, the task is executed only one time according to the schedule specified in “Scheduled Execution Date/Time”.
“Task Type” is an execution method of the task. For example, the scheduler 106 (110) provides the following two execution methods for the task.
1. Message Queue (MQ): Instructing the application server 105 (109) that receives a message from a message queue to execute the task by transmitting the message corresponding to the task to the message queue.
2. Web API Call (HyperText Transfer Protocol (HTTP)): Instructing the application server 105 (109) to execute the task by calling a web API provided by the application server 105 (109).
“Detail” is a setting detail expressed in a JSON format which is used when the scheduler 106 (110) instructs the application server 105 (109) to execute the task. The scheduler 106 (110) instructs the application server 105 (109) to execute the task by using “Task Type” and “Detail”.
In
“target” indicates a name that is used when an address of a calling destination of the web API (i.e., schema, host, or port) is acquired from the blue environment 103 or the green environment 107. Because the address of the application server 105 (109) varies in the environment 103 (107), the scheduler 106 (110) acquires the address of the application server 105 (109) from the environment 103 (107).
“path” indicates a path for a uniform resource locator (URL) of the web API call. For example, if an address that can be acquired from the environment 103 (107) by specifying “target” is “http://192.168.11.30:8080”, a URL for calling the above web API is “http://192.168.11.30:8080/send”. In the above example, data “jp” is transmitted to this URL in plain text through a POST method. For example, the application server 105 (109) that receives the above request executes processing such as transmitting a mail in a transmission queue to a client whose region is “jp”.
Processing of task execution control executed by the scheduler 106 or 110 will be described with reference to
In step S601, the scheduler 106 (110) determines whether predetermined time (e.g., one-minute) has passed. If predetermined time has passed (YES in step S601), the processing proceeds to step S602. In step S602, the scheduler 106 (110) calls task activation processing.
First, in step S603, the scheduler 106 (110) refers to the task information to which its own scheduler ID is set, from the task information table stored in the database 111. Then, as a first condition, from among the task information, the scheduler 106 (110) identifies the task information in which schedule information (Year/Month/Date/Time) on or before the current date/time is specified in the item “Scheduled Execution Date/Time”, and acquires that task information from the data base 111. A plurality of pieces of task information may be acquired from the task information table.
In step S604, the scheduler 106 (110) executes execution processing of a task corresponding to the task information acquired in step S603. When a plurality of pieces of task information is acquired, the execution processing is executed with respect to each of the tasks. Details of the task execution processing will be described below in detail with reference to
In step S605, the scheduler 106 (110) checks the current mode of its own. An operation mode of the scheduler 106 (110) takes a value that represents either a “main” or “sub” mode. An operation mode of the scheduler 106 (110) in a production environment takes a value representing the “main” mode. An operation mode of the scheduler 106 (110) in a preliminary environment takes a value representing the “sub” mode. In step S605, if the current operation mode is not the “main” mode (NO in step S605), the processing is ended, and if the current operation mode is the “main” mode (YES in step S605), the processing proceeds to step S606.
In step S606, as a second condition, the scheduler 106 (110) identifies the task information in which schedule information on or before date/time which is predetermined time (e.g., 3 minutes) earlier than the current date/time is specified in the item “Scheduled Execution Date/Time”, and acquires that task information from the database 111. In step S607, execution processing of a task corresponding to the task information acquired in step S606 is executed by the scheduler 106 (110). Then, the processing is ended.
In addition, if the above predetermined time in step S601 is X minutes whereas the predetermined time in step S606 is Y minutes, values of “X” and “Y” can be optionally specified to satisfy the following relationship. Herein, the maximum time expected to be necessary to start the task activation processing (
Y>(2×X)+α Relational Expression:
For example, if the blue environment 103 is the production environment, the scheduler 106 executes the processing in step S606. At this time, in a period between the current date/time and the date/time which is the predetermined time (Y minutes) earlier than the current date/time, it is ensured that the scheduler 110 operating in the sub mode executes the processing in steps S603 and S604 according to the above-described relational expression.
Accordingly, the task information acquired in step S606 is the task information in which identification information different from any of the scheduler IDs of the schedulers 106 and 110 is set to “Scheduler ID”. Further, the scheduler 106 will not acquire the task information by mistake that is to be processed by the scheduler 110.
The task information acquired in the above situation is the task information registered in the database 111 under an environment (not illustrated) used in the past which is different from the blue environment 103 or the green environment 107 illustrated in
In step S702, the scheduler 106 (110) determines a task type of the task information. If the task type is “Message Queue (MQ)” (YES in step S702), the processing proceeds to step S703. In step S703, the scheduler 106 (110) registers a message in a message queue according to the content specified in the item “Detail” of the task information. On the other hand, if the task type is “Web API Call (HTTP)” (NO in step S702), the processing proceeds to step S704. In step S704, the scheduler 106 (110) generates a packet including a specified method and a main message according to the content specified in the item “Detail” of the task information and transmits the packet to the specified URL. Through the processing in step S703 or S704, the task is executed by the application server 105 (109).
In step S705, the scheduler 106 (110) determines whether the repetition setting is specified in the item “Repetition Setting” of the task information. If the repetition setting is not specified (NO in step S705), the processing proceeds to step S706. If the repetition setting is specified (YES in step S705), the processing proceeds to step S707.
In step S706, the scheduler 106 (110) cancels the task information as a processing target stored in the database 111 and ends the processing. Herein, for example, the scheduler 106 (110) may cancel the task information by deleting the task information from the database 111 or setting the schedule information that is assumed as not executable, such as YEAR 9999″, to the item “Scheduled Execution Date/Time” of the task information. With this processing, the cancelled task information will not be acquired in the above-described processing in steps S603 and S606.
In step S707, the scheduler 106 (110) calculates a next execution timing (Year/Month/Date/Time) from the content specified in the item “Repetition Setting” of the task information. Next, in step S708, if the ending date/time is specified in the item “Repetition Setting” of the task information, the scheduler 106 or 110 compares the next execution timing calculated in step S707 with the ending date/time. As a result of the comparison in step S708, if the next execution timing is on or after the ending date/time (YES in step S708), the processing proceeds to step S706. If the next execution timing is before the ending date/time (NO in step S708), the processing proceeds to step S709. In addition, if the ending date/time is not set thereto, the processing in step S708 is omitted, so that the processing proceeds to step S709.
In step S709, the scheduler 106 or 110 uses its own scheduler ID and the next execution timing calculated in step S707 to update the information specified in “Scheduler ID” and “Scheduled Execution Date/Time” of the processing target task information stored in the database 111.
Table 2 is a specific example of the task information table stored and managed in the database 111. The content managed by the task information table may include information other than the content included in this example.
Pieces of task information associated with instances of at least three different schedulers (“scheduler IDs” are “550e8400”, “8761d91a”, and “619c82b9”) are registered in the above task information table. Further, “Repetition Setting” is not specified with respect to the task information having a task name “check”.
For example, it is assumed that the scheduler 106 of the blue environment 103 calls the task activation processing illustrated in
Herein, task execution control that is executed according to the task information included in the above task information table will be specifically described.
When the current time has reached 12:23:30 in May 12, 2015, the scheduler 110 acquires task information having a task name “check” in step S603 of
Next, when the current time has reached 12:24:00, the scheduler 106 acquires task information having a task name “sendmail” in step S603 of
Subsequently, in step S606, the scheduler 106 further executes acquisition processing of task information because the operation mode thereof is the “main” mode. Herein, task information having a task name “aggregate”, in which the date/time on or before May 12, 2015, 12:21:00 (i.e., 3 minutes before the current time) is set to “Scheduled Execution Date/Time”, is acquired. In step S607, the scheduler 106 executes a task corresponding to the acquired task information having the task name “aggregate” associated with the scheduler ID “8761d91a”. When the scheduler 106 executes the task corresponding to the task information having the task name “aggregate”, “Scheduled Execution Date/Time” and “Scheduler ID” are updated with respect to the corresponding task information included in the above task information table in step S709 of
By updating the information specified in “Scheduler ID”, the scheduler 106 can execute the task corresponding to the task information having the task name “aggregate” at a timing of step S604 next time and from then onward.
In step S801, the switching control unit 112 stops the scheduler 106 within the blue environment 103 serving as a production environment. The scheduler 106 releases the service to the client 101 outside the system 100. Specifically, the scheduler 106 (110) of the environment 103 (107) provides a web API for stopping the processing, so that the switching control unit 112 calls the web API of the scheduler 106. After the processing for stopping the scheduler 106 is executed, all processings in
In step S802, in order to switch the production environment to the green environment 107, the switching control unit 112 changes a setting of the router 102. In step S803, the switching control unit 112 changes the operation mode of the scheduler 110 in the green environment 107 to “main”. Specifically, the scheduler 106 (110) of the environment 103 (107) provides a web API for changing the operation mode, so that the switching control unit 112 calls the web API of the scheduler 110 to change the operation mode.
Processing for determining the operation mode of the scheduler 106 (110) will be described with reference to
In step S901, the scheduler 106 or 110 changes its own operation mode to a specified mode. Next, in step S902, the scheduler 106 or 110 determines whether the operation mode after making a change is the “main” mode. If the operation mode is the “main” mode (YES in step S902), the processing proceeds to step S903. If the operation mode is not the “main” mode (NO in step S902), the processing is ended.
In step S903, the scheduler 106 or 110 acquires the environment identifier indicating its own operating environment, writes the acquired environment identifier into the database 111, and ends the processing. Through the processing in step S903, the environment identifier of the current production environment is managed in the database 111.
In step S905, the scheduler 106 or 110 acquires the environment identifier from the database 111. This is a value written into the database 111 in step S903 by the scheduler whose operation mode is the “main” mode.
In step S906, the scheduler 106 or 110 compares the environment identifier of its own operating environment with the environment identifier acquired in step S905. As a result of the comparison, if the environment identifiers conform to each other (YES in step S906), the processing proceeds to step S907. If the environment identifiers do not conform to each other (NO in step S906), the processing proceeds to step S908.
In step S907, the scheduler 106 or 110 sets the own operation mode to “main”. On the other hand, in step S908, the scheduler 106 or 110 sets the own operation mode to “sub”.
According to this processing, for example, if the scheduler 106 operating in the “main” operation mode is stopped for some reason and activated again, the operation mode of the reactivated scheduler 106 is set to the “main” mode. Further, in the system 100 according to the present invention which provides web applications and services in a virtual environment, an operational status of the application in each virtual machine is monitored. In a case where a problem is found in the operation of the application through the monitoring processing, the virtual machine in which that application operates is canceled, and the application is rearranged by newly creating a virtual machine including the application. At this time, the scheduler ID for identifying the scheduler 106 is different from the scheduler ID before reactivation.
In step S1001, the scheduler 106 or 110 receives a request for registering the task information and takes out the task information as a registration target from the request. The request is received through the web API. The content of the task information to be taken out includes the information about items such as “Task Name” for uniquely identifying a task, “Scheduled Execution Date/Time”, “Repetition Setting”, “Task Type”, and “Detail”. Herein, if the task is not a repetitive task, there is no information about the item “Repetition Setting”. Further, if the task is a repetitive task, there is no information about the item “Scheduled Execution Date/Time”.
In step S1002, the scheduler 106 or 110 checks whether the task information having the information specified by the item “Task Name” of the task information taken out in step S1001 has already been registered and is present in the database 111. After checking, if the task information has not yet been registered in the database 111 (NO in step S1002), the processing proceeds to step S1003. If the task information has already been registered in the database 111 (YES in step S1002), the processing is ended without registering the task information.
In step S1003, the scheduler 106 or 110 determines whether the repetition setting is specified in the item “Repetition Setting” of the task information taken out in step S1001. If the task is the repetitive task to which the repetition is set (YES in step S1003), the processing proceeds to step S1004. If the repetition is not set to the task (NO in step S1003), the processing proceeds to step S1005.
In step S1004, the scheduler 106 or 110 calculates the next execution timing (Year/Month/Date/Time) from the content specified in the item “Repetition Setting” of the task information taken out in step S1001. Subsequently, the scheduler 106 or 110 sets the schedule information indicating the next execution timing acquired from the above calculation to the item “Scheduled Execution Date/Time” of the task information.
In step S1005, the scheduler 106 or 110 sets the identification information for identifying itself to the item “Scheduler ID”, stores the task information in the database 111, and ends the processing. The task information stored in the database 111 is managed by the above-described task information table.
The present invention also includes a device, a system, or a method realized by appropriately combining the above-described exemplary embodiments.
Embodiment(s) of the present invention can also be realized by a computer of a system or apparatus that reads out and executes computer executable instructions (e.g., one or more programs) recorded on a storage medium (which may also be referred to more fully as a ‘non-transitory computer-readable storage medium’) to perform the functions of one or more of the above-described embodiment(s) and/or that includes one or more circuits (e.g., application specific integrated circuit (ASIC)) for performing the functions of one or more of the above-described embodiment(s), and by a method performed by the computer of the system or apparatus by, for example, reading out and executing the computer executable instructions from the storage medium to perform the functions of one or more of the above-described embodiment(s) and/or controlling the one or more circuits to perform the functions of one or more of the above-described embodiment(s). The computer may comprise one or more processors (e.g., central processing unit (CPU), micro processing unit (MPU)) and may include a network of separate computers or separate processors to read out and execute the computer executable instructions. The computer executable instructions may be provided to the computer, for example, from a network or the storage medium. The storage medium may include, for example, one or more of a hard disk, a random-access memory (RAM), a read only memory (ROM), a storage of distributed computing systems, an optical disk (such as a compact disc (CD), digital versatile disc (DVD), or Blu-ray Disc (BD)™), a flash memory device, a memory card, and the like.
While the present invention has been described with reference to exemplary embodiments, it is to be understood that the invention is not limited to the disclosed exemplary embodiments. The scope of the following claims is to be accorded the broadest interpretation so as to encompass all such modifications and equivalent structures and functions.
This application claims the benefit of Japanese Patent Application No. 2015-140048, filed Jul. 13, 2015, which is hereby incorporated by reference herein in its entirety.
Number | Date | Country | Kind |
---|---|---|---|
2015-140048 | Jul 2015 | JP | national |