TWI758736B - Computer program product and apparatus for scheduling and executing jobs employed in parallel-processing environment - Google Patents

Computer program product and apparatus for scheduling and executing jobs employed in parallel-processing environment Download PDF

Info

Publication number
TWI758736B
TWI758736B TW109117550A TW109117550A TWI758736B TW I758736 B TWI758736 B TW I758736B TW 109117550 A TW109117550 A TW 109117550A TW 109117550 A TW109117550 A TW 109117550A TW I758736 B TWI758736 B TW I758736B
Authority
TW
Taiwan
Prior art keywords
job
mentioned
database server
work
record
Prior art date
Application number
TW109117550A
Other languages
Chinese (zh)
Other versions
TW202145002A (en
Inventor
陳瑞泰
Original Assignee
昕力資訊股份有限公司
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 昕力資訊股份有限公司 filed Critical 昕力資訊股份有限公司
Priority to TW109117550A priority Critical patent/TWI758736B/en
Publication of TW202145002A publication Critical patent/TW202145002A/en
Application granted granted Critical
Publication of TWI758736B publication Critical patent/TWI758736B/en

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The disclosure discloses a computer program product for scheduling and executing jobs employed in a parallel-processing environment being loaded and executed by a processing unit of an application server to include program code to: obtain a job from a job item list, in which a status of the job is wait and a scheduled start time is earlier than the current time; provide a job identity and an optimistic lock version of the job to a database server; request the database server to update a record of a job table to increase an optimistic lock version of the record by one, modify an owner of the record with an identity of the application server, and modify a status of the record with running, where the record before being updated needs to include the job identity and the optimistic lock version of the job; and enqueue the job into a queue to execute when receiving an update success message from the database server.

Description

應用在並行處理環境的工作排程與執行的電腦程式產品及裝置Computer program products and devices for job scheduling and execution in parallel processing environments

本發明關連於一種並行處理技術,特別是一種應用在並行處理環境的工作排程與執行的電腦程式產品及裝置。The present invention relates to a parallel processing technology, in particular to a computer program product and device for work scheduling and execution in a parallel processing environment.

伺服器叢集包含一組鬆散或緊密連接在一起工作的伺服器,伺服器叢集中的每個伺服器會被設定為能夠執行相同的任務,由軟體控制和排程。因此,需要一種應用在並行處理環境的工作排程與執行的電腦程式產品及裝置,用於優化整個系統的工作負載。A server cluster consists of a group of servers that work loosely or tightly together. Each server in a server cluster is configured to perform the same tasks, controlled and scheduled by software. Therefore, there is a need for a computer program product and apparatus for work scheduling and execution in a parallel processing environment for optimizing the work load of the entire system.

有鑑於此,如何減輕或消除上述相關領域的缺失,實為有待解決的問題。In view of this, how to alleviate or eliminate the above-mentioned deficiencies in related fields is a problem to be solved.

本說明書涉及一種電腦程式產品,應用在並行處理環境的工作排程與執行,包含能夠被應用程式伺服器的處理單元載入並執行的程式碼:從工作項目清單中取得工作,其中,工作的狀態為等待,且工作的排程開始時間早於目前時間;提供工作的工作識別碼和樂觀鎖版號給資料庫伺服器;請求資料庫伺服器更新工作資料表的紀錄,用於將紀錄的樂觀鎖版號加一,將紀錄的執行者變更為應用程式伺服器的識別碼,以及將紀錄的狀態變更為執行中,其中紀錄在更新前必須包含工作的工作識別碼以及工作的樂觀鎖版號;以及當從資料庫伺服器接收到更新成功的訊息時,將工作入列到佇列來執行。This specification relates to a computer program product for job scheduling and execution in a parallel processing environment, including code that can be loaded and executed by a processing unit of an application server: a job is obtained from a list of work items, wherein the job's The status is waiting, and the scheduled start time of the job is earlier than the current time; provide the job identification code and optimistic lock version number of the job to the database server; request the database server to update the record of the job data table, which is used to convert the record Add one to the optimistic lock version number, change the record's executor to the ID of the application server, and change the record's status to running, where the record must contain the job's job ID and the job's optimistic lock version before updating. number; and when a successful update message is received from the database server, the job is queued for execution.

本說明書更另涉及一種應用在並行處理環境的工作排程與執行的裝置,包含記憶體和處理單元。記憶體配置空間給佇列及儲存工作項目清單。處理單元耦接記憶體,用於從工作項目清單中取得工作,其中,工作的狀態為等待,並且工作的排程開始時間早於目前時間;提供工作的工作識別碼和樂觀鎖版號給資料庫伺服器;請求資料庫伺服器更新工作資料表的紀錄,用於將此紀錄的樂觀鎖版號加一,將此紀錄的執行者變更為處理單元執行的應用程式伺服器的識別碼,以及將此紀錄的狀態變更為執行中,其中此紀錄在更新前必須包含工作的工作識別碼以及工作的樂觀鎖版號;以及當從資料庫伺服器接收到更新成功的訊息時,將工作入列到佇列來執行。The present specification further relates to an apparatus for scheduling and executing tasks in a parallel processing environment, including a memory and a processing unit. Memory allocation space for queuing and storing work item lists. The processing unit is coupled to the memory, and is used to obtain work from the work item list, wherein the state of the work is waiting, and the scheduled start time of the work is earlier than the current time; the work identification code and the optimistic lock version number of the work are provided to the data. the database server; requesting the database server to update the work data table record for incrementing the optimistic lock version number of this record by one, changing the executor of this record to the identifier of the application server executed by the processing unit, and Change the status of this record to running, where the record must contain the job ID of the job and the optimistic lock version number of the job before updating; and enqueue the job when the update success message is received from the database server to the queue to execute.

本發明的其他優點將搭配以下的說明和圖式進行更詳細的解說。Other advantages of the present invention will be explained in more detail in conjunction with the following description and drawings.

以下說明為完成發明的較佳實現方式,其目的在於描述本發明的基本精神,但並不用以限定本發明。實際的發明內容必須參考之後的權利要求範圍。The following description is a preferred implementation manner to complete the invention, and its purpose is to describe the basic spirit of the invention, but it is not intended to limit the invention. Reference must be made to the scope of the following claims for the actual inventive content.

必須了解的是,使用於本說明書中的“包含”、“包括”等詞,用以表示存在特定的技術特徵、數值、方法步驟、作業處理、元件以及/或組件,但並不排除可加上更多的技術特徵、數值、方法步驟、作業處理、元件、組件,或以上的任意組合。It must be understood that the words "comprising" and "including" used in this specification are used to indicate the existence of specific technical features, values, method steps, operation processes, elements and/or components, but do not exclude the possibility of adding More technical features, values, method steps, job processes, elements, components, or any combination of the above.

於權利要求中使用如“第一”、“第二”、“第三”等詞是用來修飾權利要求中的元件,並非用來表示之間具有優先順序,前置關係,或者是一個元件先於另一個元件,或者是執行方法步驟時的時間先後順序,僅用來區別具有相同名字的元件。The use of words such as "first", "second", "third", etc. in the claims is used to modify the elements in the claims, and is not used to indicate that there is a priority order, a preceding relationship between them, or an element Prior to another element, or chronological order in which method steps are performed, is only used to distinguish elements with the same name.

為了讓多部應用程式伺服器可以並行處理工作,可以使用一部資料庫伺服器統籌管理所有需要執行的工作,然後再讓應用程式伺服器請求其中的工作並執行。圖1是依據一些實施方式的多個應用程式伺服器請求資料庫伺服器提供可執行工作的示意圖。在這些實施方式中,伺服器叢集110中的應用程式伺服器112、114和116分別啟動一個計時器113、115和117,週期性地通過網路100向資料庫伺服器130提出請求,用於取得需要執行的工作清單、工作的詳細內容,然後再據以執行。然而,由於應用程式伺服器112、114和116是獨立向資料庫伺服器130提出請求,因此,需要確保每個工作都是由一部應用程式伺服器來執行,而不是被兩部或以上的應用程式伺服器執行。此外,如果應用程式伺服器112、114和116向資料庫伺服器130請求得太頻繁,也會造成資料庫伺服器130太忙碌而產生系統的瓶頸。In order to allow multiple application servers to process work in parallel, a database server can be used to manage all the work that needs to be performed, and then the application servers can request and execute the work. FIG. 1 is a schematic diagram of multiple application servers requesting a database server to provide executable work, according to some embodiments. In these embodiments, application servers 112, 114, and 116 in server cluster 110 start a timer 113, 115, and 117, respectively, to periodically make requests to database server 130 over network 100 for Get a list of tasks that need to be performed, the details of the tasks, and then execute accordingly. However, since application servers 112, 114, and 116 make requests to database server 130 independently, it is necessary to ensure that each job is performed by one application server rather than two or more Application server execution. In addition, if the application servers 112, 114 and 116 make requests to the database server 130 too frequently, the database server 130 will also be too busy and cause a system bottleneck.

為了解決如上的缺點,本發明實施例提出一種讓應用程式伺服器藉由存取工作資料表(Jobs Table)的紀錄來協調並行處理環境的工作排程與執行。圖2係依據本發明實施例的網路系統架構圖。網路系統20包含由多部應用程式伺服器(Application Servers)212、214和216組成的伺服器叢集(Server Cluster)210,其中的每個應用程式伺服器可被設定為能夠執行各式各樣的業務邏輯,可涵蓋但不限於數位銀行管理、網路銀行、行動客服、企業內部流程管理、大數據存儲、大數據資料整合、大數據資料檢索等領域。此外,每個應用程式伺服器還可被設定為能夠提供檔案傳輸通訊協議(File Transfer Protocol,FTP)、超文本傳輸協定(Hypertext Transfer Protocol,HTTP)、超文本傳輸安全協定(Hypertext Transfer Protocol Secure,HTTPS Request)、電子郵件管理的服務,或上述任意組合的服務。網路系統10設置資料庫伺服器(Database Server)230,儲存工作資料表,用於協調應用程式伺服器212、214和216間的工作執行,確保每個工作都是由一部應用程式伺服器來執行。應用程式伺服器212、214和216、資料庫伺服器230之間可透過網路200彼此通訊,網路200可為網際網路(Internet)、有線區域網路(wired Local Area Network,LAN)、無線區域網路、點對點網路(Peer-to-Peer,P2P Network),或以上的任意組合。在這裡需要注意的是,應用程式伺服器212、214和216、資料庫伺服器230也可以指軟體伺服器,執行在一部多核處理器的電腦,本發明並不限定於只能應用在包含伺服器叢集的網路環境中,也可以應用在具並行處理能力的單一電腦中。In order to solve the above disadvantages, an embodiment of the present invention provides an application server to coordinate job scheduling and execution in a parallel processing environment by accessing records in the Jobs Table. FIG. 2 is an architecture diagram of a network system according to an embodiment of the present invention. The network system 20 includes a Server Cluster 210 consisting of a plurality of Application Servers 212, 214 and 216, each of which can be configured to execute a variety of It can cover but not limited to digital bank management, online banking, mobile customer service, enterprise internal process management, big data storage, big data data integration, big data data retrieval and other fields. In addition, each application server can also be configured to provide File Transfer Protocol (FTP), Hypertext Transfer Protocol (HTTP), Hypertext Transfer Protocol Secure (Hypertext Transfer Protocol Secure, HTTPS Request), email-managed services, or any combination of the above. The network system 10 sets up a database server (Database Server) 230 to store a work data table for coordinating work execution among the application servers 212, 214 and 216, ensuring that each work is performed by an application server to execute. The application servers 212, 214 and 216 and the database server 230 can communicate with each other through the network 200, and the network 200 can be the Internet, a wired Local Area Network (LAN), Wireless LAN, Peer-to-Peer (P2P Network), or any combination of the above. It should be noted here that the application servers 212, 214 and 216 and the database server 230 may also refer to software servers, which are executed on a computer with a multi-core processor. In the network environment of server cluster, it can also be applied to a single computer with parallel processing capability.

圖3係依據本發明實施例的運算裝置的系統架構圖。此系統架構可實施於應用程式伺服器212、214和216、資料庫伺服器230中之任一者,至少包含處理單元310。處理單元310可使用多種方式實施,例如以專用硬體電路或通用硬體(例如,單一處理器、具平行處理能力的多處理器、圖形處理器或其他具運算能力的處理器),並且在執行程式碼或軟體時,提供之後所描述的功能。系統架構另包含記憶體350及儲存單元340,記憶體350儲存程式碼執行過程中需要的資料,例如,變數、資料表(Data Tables)等,儲存單元340儲存各式各樣的電子檔案,例如,網頁、文件、音訊檔、視訊檔、資料庫等。系統架構另包含通訊介面360,讓處理單元310可藉以跟其他電子裝置進行溝通。通訊介面360可以是無線電信通訊模組(Wireless Telecommunications Module)、區域網路(Local Area Network, LAN)通訊模組或無線區域網路通訊模組(WLAN)。無線電信通訊模組(Wireless Telecommunications Module)可包含支援2G、3G、4G或以上技術世代的任意組合的調變解調器(Modem)。輸入裝置330可包含鍵盤、滑鼠、觸控面板等。使用者可按壓鍵盤上的硬鍵來輸入字元,藉由操作滑鼠來控制鼠標,或者是在觸控面板製造手勢來控制執行中的應用程式。手勢可包含單擊、雙擊、單指拖曳、多指拖曳等,但不限定於此。系統架構可選擇性的包含顯示單元320,而顯示單元320可包含顯示面板(例如,薄膜液晶顯示面板、有機發光二極體面板或其他具顯示能力的面板),用以顯示輸入的字元、數字、符號、拖曳鼠標的移動軌跡、繪製的圖案或應用程式所提供的畫面,提供給使用者觀看。FIG. 3 is a system architecture diagram of a computing device according to an embodiment of the present invention. This system architecture may be implemented in any of application servers 212 , 214 and 216 , database server 230 , including at least processing unit 310 . The processing unit 310 may be implemented in a variety of ways, such as in dedicated hardware circuits or general-purpose hardware (eg, a single processor, a multiprocessor with parallel processing capabilities, a graphics processor, or other processor capable of computing), and in When the code or software is executed, the functions described later are provided. The system architecture further includes a memory 350 and a storage unit 340. The memory 350 stores data required during the execution of the code, such as variables, data tables, etc., and the storage unit 340 stores various electronic files, such as , web pages, documents, audio files, video files, databases, etc. The system architecture further includes a communication interface 360 for the processing unit 310 to communicate with other electronic devices. The communication interface 360 may be a wireless telecommunications module (Wireless Telecommunications Module), a local area network (LAN) communication module or a wireless local area network communication module (WLAN). The Wireless Telecommunications Module may include any combination of modems (Modem) supporting 2G, 3G, 4G or above technology generations. The input device 330 may include a keyboard, a mouse, a touch panel, and the like. The user can press hard keys on the keyboard to input characters, control the mouse by operating the mouse, or control the running application by making gestures on the touch panel. The gestures may include single-click, double-click, single-finger drag, multi-finger drag, etc., but are not limited thereto. The system architecture may optionally include a display unit 320, and the display unit 320 may include a display panel (eg, a thin film liquid crystal display panel, an organic light-emitting diode panel, or other panels with display capability) for displaying input characters, Numbers, symbols, moving traces of dragging the mouse, drawn patterns or pictures provided by the application are provided to the user for viewing.

為了協調多個應用程式伺服器以執行進入排程的工作,資料庫伺服器230的儲存裝置340儲存關聯性資料庫,包含工作資料表“Jobs”。工作資料表可儲存多筆紀錄,每筆紀錄包含一個進入排程的工作的資訊。進入排程的工作是一種不能馬上執行的工作,而是要在指定時間到達後才能開始執行的工作。工作資料表可包含如表1所示的欄位範例: 表1 欄位名稱 描述 id 工作代碼 fromId 重新執行的工作代碼 jobName 工作名稱 startDateTime 排程開始時間 status 狀態(Wait/Running/Done/Error) step 長時工作狀態進度 owner 執行者 parameters 參數 version 樂觀鎖版號 其中,欄位“id”是工作紀錄的主鍵,並且欄位“jobName”、“startDateTime”和“paramters”分別儲存排程工作的名稱、開始執行時間和工作內容的參數。參數中可包含群組識別碼(Group ID),用以區分多個排程工作是否實質上是相同的。如果多個工作的參數裡包含了相同的群組識別碼,代表這些工作實質上是相同的。舉例來說,如果使用者在使用者介面上輸入或匯入帳務資料,並指定完成排程時間後反覆按了“月結算”按鈕數次,則會在記憶清單資料表新增多筆包含相同的群組識別碼的紀錄。當建立一個新的排程工作時,新增加紀錄的欄位“status”的初始狀態是“等待(Wait)”,欄位“owner”的初始值是空值,欄位“step”的初始值是“0”,而欄位“version”的初始值是“1”。 欄位“version”用來控制是由哪個應用程式伺服器來執行此排程工作,之後的段落將詳細描述如何使用此欄位來決定執行應用程式伺服器的細節。當一個應用程式伺服器執行工作時,應用程式伺服器修改相應紀錄的欄位“status”為“執行中(Running)”,並且在執行的過程中,可不斷更新欄位“step”的內容來反應目前的執行進度。當一個工作執行成功時,應用程式伺服器修改相應紀錄的欄位“status”為“完成(Done)”。當一個工作執行失敗時,應用程式伺服器修改相應紀錄的欄位“status”為“錯誤(Error)”。當一個工作因為某些原因而需要重新執行時,應用程式伺服器會修改相應紀錄的欄位“status”為“錯誤(Error)”,並且在記憶清單資料表新增一筆紀錄,在欄位“id” 賦予新的工作代碼,而欄位“jobName”、“startDateTime”和“paramters”則儲存原來紀錄的值,並且欄位“fromId”儲存原來紀錄的工作代碼,代表這是特定工作的再執行工作。In order to coordinate a plurality of application servers to execute incoming scheduled jobs, the storage device 340 of the database server 230 stores a relational database, including a job data table "Jobs". A job data table can store multiple records, each record containing information about an incoming scheduled job. A job that is scheduled is a job that cannot be executed immediately, but cannot be executed until a specified time has elapsed. A work data sheet can contain sample fields as shown in Table 1: Table 1 field name describe id working code fromId Re-executed working code jobName job title startDateTime Schedule start time status Status (Wait/Running/Done/Error) step long-term work status progress owner Executor parameters parameter version Optimistic lock version number Among them, the field "id" is the primary key of the job record, and the fields "jobName", "startDateTime" and "paramters" respectively store the name of the scheduled job, the start execution time and the parameters of the job content. The parameter can include a Group ID to distinguish whether multiple scheduled jobs are substantially the same. If the parameters of multiple jobs contain the same group ID, it means that these jobs are substantially the same. For example, if a user enters or imports billing data on the user interface, and then clicks the "Monthly Billing" button several times after specifying a schedule completion time, multiple entries will be added to the memory list data table that include: A record of the same group ID. When creating a new schedule job, the initial state of the field "status" of the newly added record is "Wait", the initial value of the field "owner" is null, and the initial value of the field "step" is "0", and the initial value of the field "version" is "1". The field "version" is used to control which application server executes the scheduling job. The following paragraphs describe in detail how to use this field to determine the details of the execution application server. When an application server executes work, the application server modifies the field "status" of the corresponding record to "Running", and during the execution process, the content of the field "step" can be continuously updated to Reflects the current execution progress. When a job is executed successfully, the application server modifies the field "status" of the corresponding record to "Done". When a job fails, the application server modifies the field "status" of the corresponding record to "Error". When a job needs to be re-executed for some reason, the application server will modify the field "status" of the corresponding record to "Error", and add a record in the memory list data table, in the field "id" is assigned to the new job code, while the fields "jobName", "startDateTime" and "paramters" store the value of the original record, and the field "fromId" stores the job code of the original record, indicating that this is a re-execution of a specific job Work.

應用程式伺服器212、214或216可週期性地請求資料庫伺服器230提供i個最接近的等待執行工作的內容,以便將來在到達排程時間時,能夠執行這些工作。圖4是根據本發明實施例的更新工作項目清單的方法流程圖,由應用程式伺服器212、214或216的處理單元310(以下稱處理單元310以求簡明)於載入並執行特定軟體模組時實施。具體說明如下:The application server 212, 214 or 216 may periodically request the database server 230 to provide the content of the i closest jobs waiting to be performed so that the jobs can be performed when the scheduled time is reached in the future. 4 is a flowchart of a method for updating a work item list according to an embodiment of the present invention. The processing unit 310 of the application server 212, 214 or 216 (hereinafter referred to as the processing unit 310 for brevity) loads and executes a specific software phantom. Implemented in groups. The specific instructions are as follows:

步驟S410:接收工作項目異動指令。操作人員可通過人機介面(Man-Machine Interface,MMI)來發出工作項目異動指令,啟動應用程式伺服器。Step S410: Receive a work item change instruction. The operator can issue a work item change command through the Man-Machine Interface (MMI) to start the application server.

步驟S420:請求資料庫伺服器230提供i筆最接近的等待執行的工作,i可設為從4到6的任意整數。處理單元310可發出如下的結構化查詢語言(Structured Query Language,SQL)指令給資料庫伺服器230來進行請求: select Top i * from Jobs where status=’Wait’ order by startDateTimeStep S420 : requesting the database server 230 to provide i closest jobs to be executed, where i can be set to any integer from 4 to 6. The processing unit 310 may issue the following Structured Query Language (SQL) command to the database server 230 for requesting: select Top i * from Jobs where status='Wait' order by startDateTime

步驟S430:儲存從資料庫伺服器230獲得的工作項目清單。處理單元310可直接儲存從資料庫伺服器230獲得的結果集(Result Set),作為工作項目清單,並且儲存於此應用程式伺服器的記憶體350。Step S430 : Store the work item list obtained from the database server 230 . The processing unit 310 can directly store the Result Set obtained from the database server 230 as a work item list, and store it in the memory 350 of the application server.

步驟S440:啟動計時器數一段預設的時間。例如,處理單元310可將預設的時間設為30分鐘到1小時中的任意時間,用於每隔一段預設的時間後就向資料庫伺服器230請求更新工作項目清單。Step S440: Start the timer to count a preset time. For example, the processing unit 310 may set the preset time as any time from 30 minutes to 1 hour, so as to request the database server 230 to update the work item list after a preset time interval.

圖5是依據本發明實施例的提取並執行工作的方法流程圖,由應用程式伺服器212、214或216的處理單元310(以下簡稱處理單元310以求簡明)於載入並執行特定軟體模組時實施,反覆執行一個迴圈(包含步驟S510至S560的操作),用於不斷地從工作項目清單取出可執行的工作,並儲存到佇列來執行。詳細說明如下:5 is a flowchart of a method for extracting and executing work according to an embodiment of the present invention. The processing unit 310 (hereinafter referred to as the processing unit 310 for brevity) of the application server 212, 214 or 216 loads and executes a specific software phantom. It is implemented during group time, and a loop (including the operations of steps S510 to S560 ) is repeatedly executed, for continuously fetching executable work from the work item list, and storing it in a queue for execution. Details are as follows:

步驟S510:判斷工作項目清單中是否有可執行的工作。如果是,則進行步驟S530的處理;否則,進行步驟S520的處理。處理單元310可搜索工作項目清單中是否存在一個工作,其狀態為“等待(Wait)”並且期排程開始時間“startDateTime”早於目前時間。如果是,則此工作為可執行的工作。Step S510: Determine whether there is executable work in the work item list. If yes, go to step S530; otherwise, go to step S520. The processing unit 310 may search whether there is a work in the work item list, the status of which is "Wait" and the scheduled start time "startDateTime" is earlier than the current time. If so, the job is executable.

步驟S520:等待1秒。此步驟可讓步驟S510的檢查每隔至少1秒就執行一次。Step S520: Wait for 1 second. In this step, the check in step S510 can be performed every at least one second.

步驟S530:請求資料庫伺服器230更新工作資料表中的相應於可執行工作的紀錄,用於獲得執行的權利。處理單元310可提供可執行工作的工作識別碼和樂觀鎖版號給資料庫伺服器230,並且請求資料庫伺服器230更新工作資料表中相應於可執行工作的紀錄,用於將此紀錄的樂觀鎖版號加一,將此紀錄的執行者變更為此伺服器的識別碼,以及將此紀錄的狀態變更為執行中,其中此紀錄在更新前需要包含可執行工作的工作識別碼以及可執行工作的樂觀鎖版號。詳細來說,處理單元310可發出如下的SQL指令給資料庫伺服器230來進行更新: Update Jobs set owner=myName, version=this.version+1, status=’Run’ where id=this.id & version=this.version 在這個SQL指令中,成功更新的條件有二個,一是工作代碼“id”要相符,二是樂觀鎖版號“version”也要相符,才會進行更新。如果工作資料表中不存在任何符合此更新條件的紀錄時,資料庫伺服器230會回覆更新失敗的訊息給處理單元310。舉例來說,當工作資料表中相應於可執行工作的紀錄被刪除時(也就是此工作被移出排程),資料庫伺服器230會找不到任何符合此更新條件的紀錄。或者,當工作資料表中相應於可執行工作的紀錄中的樂觀鎖版號被其他的應用程式伺服器更新過時(也就是其他應用程式伺服器已經先一步取得這個可執行工作的執行權),資料庫伺服器230會找不到任何符合此更新條件的紀錄。一旦滿足更新條件,資料庫伺服器230會將相應於此可執行工作的紀錄中的執行者“owner”更新為此應用程式伺服器的識別碼“myName”,將樂觀鎖版號“version”加1,並且將狀態“status”更新為“執行中(Run)”。需要注意的是,將相應紀錄的樂觀鎖版號“version”加1後,其他應用程式伺服器如果想用如上所述的SQL指令來更新相同紀錄就會失敗,因而確保了此工作只能被一個應用伺服器執行。如果更新成功,處理單元310會從資料庫伺服器230接收到更新成功的訊息。Step S530 : requesting the database server 230 to update the record corresponding to the executable work in the work data table, so as to obtain the execution right. The processing unit 310 can provide the work identifier and the optimistic lock version number of the executable work to the database server 230, and request the database server 230 to update the record corresponding to the executable work in the work data table, so that the record of the record can be updated. Add one to the optimistic lock version number, change the executor of this record to the identifier of this server, and change the state of this record to executing, where this record needs to contain the job identifier of the executable work and the available work before updating. Optimistic lock version number of the execution work. Specifically, the processing unit 310 can issue the following SQL commands to the database server 230 for updating: Update Jobs set owner=myName, version=this.version+1, status='Run' where id=this.id & version=this.version In this SQL command, there are two conditions for a successful update, one is that the work code "id" must match, and the other is that the optimistic lock version number "version" must match before the update is performed. If there is no record meeting the update condition in the work data table, the database server 230 will reply the update failure message to the processing unit 310 . For example, when the record corresponding to the executable job in the job data table is deleted (that is, the job is removed from the schedule), the database server 230 cannot find any record that meets the update condition. Or, when the optimistic lock version number in the record corresponding to the executable work in the work data table is updated by other application servers (that is, other application servers have obtained the execution right of the executable work first), Database server 230 will not find any records that meet this update criteria. Once the update condition is satisfied, the database server 230 will update the executor "owner" in the record corresponding to the executable work to the identifier "myName" of the application server, and add the optimistic lock version number "version" to 1, and update the status "status" to "Run". It should be noted that after adding 1 to the optimistic lock version number "version" of the corresponding record, other application servers will fail if they try to update the same record with the above SQL command, thus ensuring that this work can only be performed by An application server implementation. If the update is successful, the processing unit 310 will receive the update success message from the database server 230 .

步驟S540:根據資料庫伺服器230回覆的訊息來判斷是否更新成功。如果是,則進行步驟S560的處理;否則,進行步驟S550的處理。Step S540 : Determine whether the update is successful according to the message returned by the database server 230 . If yes, go to step S560; otherwise, go to step S550.

步驟S550:將可執行的工作從工作項目清單刪除。Step S550: Delete the executable work from the work item list.

步驟S560:將可執行的工作入列到佇列。圖6是依據本發明實施例的佇列配置示意圖。舉例來說,此應用程式伺服器(如應用程式伺服器212、214或216)的記憶體350(以下稱記憶體350以求簡明)可配置空間給佇列600,用於依照排程開始時間的時間順序儲存工作項目清單中的可執行工作。佇列600包含多筆項目(Entry)形成的集合(Collection),每一筆項目可儲存一個工作的內容。佇列600的操作基本原則是由結束位置(如指標T所指的位置)新增工作(可稱為入列),並且由開始位置(如指標H所指的位置)移除工作(可稱為出列)。也就是說,第一個新增至佇列600的工作,也將會是第一個被移出的,符合先進先出(First-In First-Out,FIFO)的原則。舉例來說,在16:00:00的時間點,佇列600儲存了5個工作,指定分別要在15:59:05、15:59:05、15:59:05、15:59:10和15:59:15開始執行。其中,前三個工作“X”的參數欄位中包含了相同的群組識別碼,代表實質相同的工作。工作“X”、“Y”和“Z”則是代表不同的工作。Step S560: List the executable work in the queue. FIG. 6 is a schematic diagram of a queue configuration according to an embodiment of the present invention. For example, the memory 350 (hereinafter referred to as the memory 350 for brevity) of the application server (such as the application server 212, 214 or 216) may allocate space for the queue 600 to be used according to the scheduled start time Stores executable work in a list of work items in chronological order. The queue 600 includes a collection (Collection) formed by multiple items (Entry), and each item (Entry) can store the content of one job. The basic principle of the operation of the queue 600 is to add work (which can be called enqueuing) from the end position (such as the position indicated by the index T), and remove the work from the starting position (such as the position indicated by the index H) (which can be called the position). to dequeue). That is to say, the first job added to queue 600 will also be the first to be removed, which conforms to the First-In First-Out (FIFO) principle. For example, at the time point of 16:00:00, queue 600 has stored 5 jobs, which are specified to be at 15:59:05, 15:59:05, 15:59:05, and 15:59:10 respectively. and 15:59:15 start execution. Among them, the parameter fields of the first three jobs "X" contain the same group ID, representing substantially the same job. Jobs "X", "Y" and "Z" represent different jobs.

應用程式伺服器212、214或216的處理單元310(以下簡稱處理單元310以求簡明)於載入並執行特定軟體模組時會依序從佇列600的頂端提取工作並執行。在每個工作執行前,處理單元310會先判斷佇列600中是否存在相同於取出工作的任何其他工作。如果是,則捨棄這個工作不執行。詳細來說,處理單元310可判斷佇列600中是否存在任何一個工作,其參數中包含相同於取出工作的群組識別碼。如果是,則代表主要佇列600中存在相同的工作。圖7是依據本發明實施例的執行佇列600中的工作的示意圖。在時間點16:00:01時,由於佇列600中包含了三個實質相同的工作“X”,處理單元310直接從佇列600取出前兩個工作“X”並丟棄而不執行,只執行第三個工作“X”。 如果不是,則執行取出的工作。When the processing unit 310 of the application server 212, 214 or 216 (hereinafter referred to as the processing unit 310 for brevity) loads and executes a specific software module, work is sequentially extracted from the top of the queue 600 and executed. Before each job is executed, the processing unit 310 will first determine whether there is any other job in the queue 600 that is the same as the fetch job. If so, discard the job and not execute it. Specifically, the processing unit 310 can determine whether there is any job in the queue 600 , and the parameter of which includes the same group identification code as the fetched job. If so, it means that the same job exists in the main queue 600. FIG. 7 is a schematic diagram of work in the execution queue 600 according to an embodiment of the present invention. At the time point of 16:00:01, since the queue 600 contains three substantially identical jobs "X", the processing unit 310 directly takes out the first two jobs "X" from the queue 600 and discards them without executing them. Execute the third job "X". If not, perform the fetched work.

排程的工作通常需要執行一段時間,可能長達數小時,處理單元310可在執行的期間不斷請求資料庫伺服器230更新相應於此工作的紀錄中欄位“step”的內容來反應目前的執行進度。當執行完畢時,處理單元310可請求資料庫伺服器230更新相應於此工作的紀錄中欄位“status”為“完成(Done)”。當執行失敗時,處理單元310可請求資料庫伺服器230更新相應於此工作的紀錄中欄位“status”為“錯誤(Error)”。The scheduled work usually needs to be executed for a period of time, which may be as long as several hours. During the execution, the processing unit 310 can continuously request the database server 230 to update the content of the field “step” in the record corresponding to the work to reflect the current execution progress. When the execution is completed, the processing unit 310 may request the database server 230 to update the field "status" in the record corresponding to the job to "Done". When the execution fails, the processing unit 310 may request the database server 230 to update the field "status" in the record corresponding to the job to be "Error".

本發明所述的方法中的全部或部分步驟可以電腦程式實現,例如電腦的作業系統、電腦中特定硬體的驅動程式、或軟體應用程式。此外,也可實現於如上所示的其他類型程式。所屬技術領域具有通常知識者可將本發明實施例的方法撰寫成電腦程式,為求簡潔不再加以描述。依據本發明實施例方法實施的電腦程式,可儲存於適當的電腦可讀取資料載具,例如DVD、CD-ROM、USB碟、硬碟,亦可置於可通過網路(例如,網際網路,或其他適當載具)存取的網路伺服器。All or part of the steps in the method of the present invention can be implemented by a computer program, such as a computer's operating system, a specific hardware driver in the computer, or a software application. In addition, it can also be implemented in other types of programs as shown above. Those skilled in the art can write the methods of the embodiments of the present invention into computer programs, which are not described for brevity. The computer program implemented by the method according to the embodiment of the present invention can be stored in a suitable computer-readable data carrier, such as DVD, CD-ROM, USB disk, hard disk, or can be stored in a computer that can be accessed through a network (for example, the Internet route, or other suitable vehicle) to access the web server.

雖然圖3中包含了以上描述的元件,但不排除在不違反發明的精神下,使用更多其他的附加元件,已達成更佳的技術效果。此外,雖然圖4至圖5的步驟採用指定的順序來執行,但是在不違反發明精神的情況下,熟習此技藝人士可以在達到相同效果的前提下,修改這些步驟間的順序,所以,本發明並不侷限於僅使用如上所述的順序。此外,熟習此技藝人士亦可以將若干步驟整合為一個步驟,或者是除了這些步驟外,循序或平行地執行更多步驟,本發明亦不因此而侷限。Although the above-described elements are included in FIG. 3 , it is not excluded that more other additional elements can be used to achieve better technical effects without departing from the spirit of the invention. In addition, although the steps in FIG. 4 to FIG. 5 are performed in the specified order, those skilled in the art can modify the order of these steps on the premise of achieving the same effect without violating the spirit of the invention. Therefore, this The invention is not limited to using only the sequence described above. In addition, those skilled in the art can also integrate several steps into one step, or in addition to these steps, perform more steps sequentially or in parallel, and the present invention is not limited thereby.

雖然本發明使用以上實施例進行說明,但需要注意的是,這些描述並非用以限縮本發明。相反地,此發明涵蓋了熟習此技藝人士顯而易見的修改與相似設置。所以,申請權利要求範圍須以最寬廣的方式解釋來包含所有顯而易見的修改與相似設置。Although the present invention is described using the above embodiments, it should be noted that these descriptions are not intended to limit the present invention. On the contrary, this invention covers modifications and similar arrangements obvious to those skilled in the art. Therefore, the scope of the appended claims is to be construed in the broadest manner so as to encompass all obvious modifications and similar arrangements.

100:網路 110:伺服器叢集 112,114,116:應用程式伺服器 113,115,117:計時器 130:資料庫伺服器 20:網路系統 200:網路 210:伺服器叢集 212,214,216:應用程式伺服器 230:資料庫伺服器 310:處理單元 320:顯示單元 330:輸入裝置 340:儲存裝置 350:記憶體 360:通訊介面 S410~S440:方法步驟 S510~S560:方法步驟 600:佇列 X,Y,Z:工作100: Internet 110: Server Cluster 112, 114, 116: Application Servers 113, 115, 117: Timer 130:Database server 20: Network System 200: Internet 210: Server Cluster 212, 214, 216: Application Servers 230:Database Server 310: Processing Unit 320: Display unit 330: Input Device 340: Storage Device 350: Memory 360: Communication Interface S410~S440: Method steps S510~S560: method steps 600: Queue X,Y,Z: work

圖1是依據一些實施方式的多個應用程式伺服器請求資料庫伺服器提供可執行工作的示意圖。 圖2係依據本發明實施例的網路系統架構圖。 圖3係依據本發明實施例的運算裝置的系統架構圖。 圖4是根據本發明實施例的更新工作項目清單的方法流程圖。 圖5是依據本發明實施例的提取並執行工作的方法流程圖。 圖6是依據本發明實施例的佇列配置示意圖。 圖7是依據本發明實施例的執行佇列中的工作的示意圖。FIG. 1 is a schematic diagram of multiple application servers requesting a database server to provide executable work, according to some embodiments. FIG. 2 is an architecture diagram of a network system according to an embodiment of the present invention. FIG. 3 is a system architecture diagram of a computing device according to an embodiment of the present invention. FIG. 4 is a flowchart of a method for updating a work item list according to an embodiment of the present invention. FIG. 5 is a flowchart of a method for extracting and executing work according to an embodiment of the present invention. FIG. 6 is a schematic diagram of a queue configuration according to an embodiment of the present invention. FIG. 7 is a schematic diagram of work in an execution queue according to an embodiment of the present invention.

S510~S560:方法步驟S510~S560: method steps

Claims (10)

一種電腦程式產品,應用在一資料庫伺服器統籌管理多個應用程式伺服器的一並行處理環境的工作排程與執行,包含能夠被一應用程式伺服器的一處理單元載入並執行的程式碼:從一工作項目清單中取得一工作,其中,該工作項目清單是該應用程式伺服器從該資料庫伺服器定期獲得,上述工作的一狀態為等待,並且上述工作的一排程開始時間早於目前時間;提供上述工作的一工作識別碼和一樂觀鎖版號給該資料庫伺服器;請求上述資料庫伺服器更新一工作資料表的一紀錄,用於將上述紀錄的一樂觀鎖版號加一,將上述紀錄的一執行者變更為上述應用程式伺服器的識別碼,以及將上述紀錄的一狀態變更為執行中,其中上述紀錄在更新前必須包含上述工作的一工作識別碼以及上述工作的上述樂觀鎖版號;以及當從上述資料庫伺服器接收到更新成功的訊息時,將上述工作入列到一佇列來執行。 A computer program product, applied to a database server to coordinate and manage the work scheduling and execution of a parallel processing environment of multiple application servers, including programs that can be loaded and executed by a processing unit of an application server Code: Get a job from a work item list, where the work item list is periodically obtained by the application server from the database server, a status of the job is waiting, and a scheduled start time of the job earlier than the current time; providing a job identification code and an optimistic lock version number of the above-mentioned job to the database server; requesting the above-mentioned database server to update a record of a job data table for an optimistic lock of the above record Add one to the version number, change an executor of the above record to the identifier of the above application server, and change a state of the above record to running, wherein the above record must contain a job identifier of the above job before updating and the optimistic locking version number of the above-mentioned work; and when receiving the update success message from the above-mentioned database server, the above-mentioned work is listed in a queue for execution. 如請求項1所述的電腦程式產品,包含程式碼:當從上述資料庫伺服器接收到更新失敗的訊息時,將上述工作從上述工作項目清單刪除。 The computer program product of claim 1, comprising program code: when receiving the update failure message from the database server, deleting the above-mentioned work from the above-mentioned work item list. 如請求項1所述的電腦程式產品,包含程式碼:從上述佇列提取上述工作;判斷上述佇列中是否存在相同於上述工作的任何其他工作;如果上述佇列中存在相同於上述工作的任何其他工作,則捨棄上述工作而不執行;以及 如果上述佇列中不存在相同於上述工作的任何其他工作,則執行上述工作。 The computer program product of claim 1, comprising code: extracting the above-mentioned job from the above-mentioned queue; determining whether there is any other job identical to the above-mentioned job in the above-mentioned queue; if there is any other job identical to the above-mentioned job in the above-mentioned queue for any other work, the said work shall be discarded and not performed; and If no other job identical to the above job exists in the above queue, the above job is executed. 如請求項3所述的電腦程式產品,包含程式碼:在上述工作的執行期間,不斷請求上述資料庫伺服器更新上述工作資料表的上述紀錄中的一進度的內容,用於反應目前的執行進度。 The computer program product according to claim 3, comprising code: during the execution of the above-mentioned work, continuously requesting the above-mentioned database server to update the content of a progress in the above-mentioned record of the above-mentioned work data table, which is used to reflect the current execution schedule. 如請求項3所述的電腦程式產品,包含程式碼:當上述工作執行完畢時,請求上述資料庫伺服器更新上述工作資料表的上述紀錄中的上述狀態為完成;以及當上述工作執行失敗時,請求上述資料庫伺服器更新上述工作資料表的上述紀錄中的上述狀態為錯誤。 The computer program product according to claim 3, comprising program code: when the execution of the above-mentioned work is completed, the above-mentioned status in the above-mentioned record of the above-mentioned work data table is requested to be updated by the above-mentioned database server to be completed; and when the above-mentioned work execution fails , requesting the database server to update the above record in the above work data table with the above status as error. 一種應用在連接一資料庫伺服器的一並行處理環境的工作排程與執行的裝置,包含:一記憶體,用於配置空間給一佇列及儲存一工作項目清單,其中該工作項目清單是該裝置從該資料庫伺服器定期獲得;以及一處理單元,耦接上述記憶體,用於從上述工作項目清單中取得一工作,其中,上述工作的一狀態為等待,並且上述工作的一排程開始時間早於目前時間;提供上述工作的一工作識別碼和一樂觀鎖版號給上述資料庫伺服器;請求上述資料庫伺服器更新一工作資料表的一紀錄,用於將上述紀錄的一樂觀鎖版號加一,將上述紀錄的一執行者變更為上述處理單元執行的一應用程式伺服器的識別碼,以及將上述紀錄的一狀態變更為執行中,其中上述紀錄在更新前必須包含上述工作的一工作識別碼以及上述工作的上述樂觀鎖版號;以及當從上述資料庫伺服器 接收到更新成功的訊息時,將上述工作入列到上述佇列來執行。 A device for work scheduling and execution applied in a parallel processing environment connected to a database server, comprising: a memory for allocating space to a queue and storing a work item list, wherein the work item list is The device periodically obtains from the database server; and a processing unit, coupled to the memory, for obtaining a job from the work item list, wherein a state of the job is waiting, and a row of the job The start time of the process is earlier than the current time; provide a job identification code and an optimistic lock version number of the above-mentioned job to the above-mentioned database server; An optimistic lock version number is incremented by one, an executor of the above-mentioned record is changed to the identifier of an application server executed by the above-mentioned processing unit, and a state of the above-mentioned record is changed to executing, wherein the above-mentioned record must be updated before updating. A job identifier including the above job and the above optimistic lock version number of the above job; and when the above database server is downloaded from the above When receiving a message that the update is successful, the above tasks are listed in the above queue for execution. 如請求項6所述的應用在並行處理環境的工作排程與執行的裝置,其中,當上述處理單元從上述資料庫伺服器接收到更新失敗的訊息時,將上述工作從上述工作項目清單刪除。 The apparatus for job scheduling and execution in a parallel processing environment according to claim 6, wherein when the processing unit receives a message of update failure from the database server, the job is deleted from the work item list . 如請求項6所述的應用在並行處理環境的工作排程與執行的裝置,其中,上述處理單元從上述佇列提取上述工作;判斷上述佇列中是否存在相同於上述工作的任何其他工作;如果上述佇列中存在相同於上述工作的任何其他工作,則捨棄上述工作而不執行;以及如果上述佇列中不存在相同於上述工作的任何其他工作,則執行上述工作。 The apparatus for job scheduling and execution in a parallel processing environment according to claim 6, wherein the processing unit extracts the job from the queue; determines whether there is any other job identical to the job in the queue; If any other job identical to the above job exists in the above queue, the above job is discarded and not executed; and if there is no other job identical to the above job in the above queue, the above job is executed. 如請求項8所述的應用在並行處理環境的工作排程與執行的裝置,其中,上述處理單元在上述工作的執行期間,不斷請求上述資料庫伺服器更新上述工作資料表的上述紀錄中的一進度的內容,用於反應目前的執行進度。 The apparatus for scheduling and executing jobs in a parallel processing environment according to claim 8, wherein the processing unit continuously requests the database server to update the records in the job data table during the execution of the job. A progress content, used to reflect the current execution progress. 如請求項8所述的應用在並行處理環境的工作排程與執行的裝置,其中,當上述工作執行完畢時,上述處理單元請求上述資料庫伺服器更新上述工作資料表的上述紀錄中的上述狀態為完成;以及當上述工作執行失敗時,上述處理單元請求上述資料庫伺服器更新上述工作資料表的上述紀錄中的上述狀態為錯誤。 The apparatus for scheduling and executing jobs in a parallel processing environment according to claim 8, wherein when the job is completed, the processing unit requests the database server to update the above records in the job data table The status is completed; and when the execution of the job fails, the processing unit requests the database server to update the record in the job data table and the status is error.
TW109117550A 2020-05-26 2020-05-26 Computer program product and apparatus for scheduling and executing jobs employed in parallel-processing environment TWI758736B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW109117550A TWI758736B (en) 2020-05-26 2020-05-26 Computer program product and apparatus for scheduling and executing jobs employed in parallel-processing environment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW109117550A TWI758736B (en) 2020-05-26 2020-05-26 Computer program product and apparatus for scheduling and executing jobs employed in parallel-processing environment

Publications (2)

Publication Number Publication Date
TW202145002A TW202145002A (en) 2021-12-01
TWI758736B true TWI758736B (en) 2022-03-21

Family

ID=80783650

Family Applications (1)

Application Number Title Priority Date Filing Date
TW109117550A TWI758736B (en) 2020-05-26 2020-05-26 Computer program product and apparatus for scheduling and executing jobs employed in parallel-processing environment

Country Status (1)

Country Link
TW (1) TWI758736B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW498282B (en) * 1999-08-31 2002-08-11 Andersen Consulting Llp System, method, and article of manufacture for a load balancer in environment services patterns
US20190325055A1 (en) * 2018-04-19 2019-10-24 Sap Se Parallel Replication Across Formats
AU2018202871B2 (en) * 2012-04-13 2020-02-06 Goldman Sachs & Co. LLC Systems and methods for scalable structured data distribution
CN110855708A (en) * 2019-11-26 2020-02-28 上海莉莉丝科技股份有限公司 Game server architecture

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW498282B (en) * 1999-08-31 2002-08-11 Andersen Consulting Llp System, method, and article of manufacture for a load balancer in environment services patterns
AU2018202871B2 (en) * 2012-04-13 2020-02-06 Goldman Sachs & Co. LLC Systems and methods for scalable structured data distribution
US20190325055A1 (en) * 2018-04-19 2019-10-24 Sap Se Parallel Replication Across Formats
CN110855708A (en) * 2019-11-26 2020-02-28 上海莉莉丝科技股份有限公司 Game server architecture

Also Published As

Publication number Publication date
TW202145002A (en) 2021-12-01

Similar Documents

Publication Publication Date Title
US20220327125A1 (en) Query scheduling based on a query-resource allocation and resource availability
US11321321B2 (en) Record expansion and reduction based on a processing task in a data intake and query system
US20200364223A1 (en) Search time estimate in a data intake and query system
US11494380B2 (en) Management of distributed computing framework components in a data fabric service system
US11921672B2 (en) Query execution at a remote heterogeneous data store of a data fabric service
US11442935B2 (en) Determining a record generation estimate of a processing task
US20200257691A1 (en) Executing untrusted commands from a distributed execution model
US20230031327A1 (en) Recommending Query Parameters Based on Tenant Information
US20190310977A1 (en) Bucket data distribution for exporting data to worker nodes
US20190258637A1 (en) Partitioning and reducing records at ingest of a worker node
US20190272271A1 (en) Assigning processing tasks in a data intake and query system
CN112997167A (en) Task scheduling in a database system
US10824968B2 (en) Transformation of logical data object instances and updates to same between hierarchical node schemas
US9148329B1 (en) Resource constraints for request processing
US7925619B2 (en) Addressing query scheduling and system resource requirements
US9672231B2 (en) Concurrent access for hierarchical data storage
CN116894069A (en) Cross-organization and cross-cloud automated data pipeline
CN112948467B (en) Data processing method and device, computer equipment and storage medium
TWI758736B (en) Computer program product and apparatus for scheduling and executing jobs employed in parallel-processing environment
CN117149849A (en) Method and device for processing multiple query requests and electronic equipment
US8832176B1 (en) Method and system for processing a large collection of documents
TWM602238U (en) Computer program product and apparatus for scheduling and executing jobs employed in parallel-processing environment
TWM600871U (en) Computer program product and apparatus for arranging and executing jobs
US11113302B2 (en) Updating one or more databases based on dataflow events
TWI745966B (en) Computer program product and apparatus for managing data caches