Detailed description of the invention
Embodiments herein proposes the heartbeat detecting method of a kind of distributed platform, and not only detection terminal sets
Standby presence, and whether terminal unit is had perform distributed task scheduling ability detect,
To solve the problem that prior art exists.
A kind of network environment that the embodiment of the present application is applied is as it is shown in figure 1, access device 10, access and set
It is the node of distributed platform for 30 and host node 20, passes through network-accessible each other;Access device
Terminal unit 11,12 and 13 is linked into distributed platform by 10, and to terminal unit 11,12 and 13
Carry out heartbeat detection;Terminal unit 31 and 32 is accessed distributed platform by access device 30;And to terminal
Equipment 11,12 and 13 carries out heartbeat detection.Access device can be PC, notebook computer, physics or
Virtual servers etc., terminal unit can be mobile phone, panel computer, PC, notebook computer, virtual machine
Or simulator etc., terminal unit can pass through cable network, wireless network, USB (Universal Serial
Bus, USB (universal serial bus)) etc. mode be connected with access device.Embodiments herein is to access device
And it is connected mode between the kind of terminal unit, terminal unit and access device and communication protocol, distributed
Implementing of platform does not the most limit.
In the present embodiment, apply the flow process of the distributed platform heartbeat detecting method on access device as schemed
Shown in 2, the flow process of application distributed platform heartbeat detecting method on the terminal device is as shown in Figure 3.
On access device, step 210, the terminal unit that detection accesses is the most online.
On the terminal device, step 310, the presence detection of response access device.
Presence detection is initiated by access device, can use in the order of operating system, communication protocol
Order, the self-defined request being specifically designed to presence detection and the mode such as answering.When terminal sets
When the standby presence sense command receiving access device or request, respond thereto.Access device is received
After the response of terminal unit, according to response itself (receive response i.e. explanation terminal unit online) or
The status information carried in response can learn that terminal unit is the most online.
Access device various can interpolate that terminal unit carries out terminal and sets in the way of the most online to use
Standby presence detection, such as in prior art, distributed platform is used when carrying out heartbeat detection
Mode, does not limits in the present embodiment.
On access device, step 220, instruct online installing terminal equipment and testing results program,
Obtain the execution result of instruction.
On the terminal device, step 320, receive the instruction of the installation and operation test program of access device,
To the execution result of access device return instruction, determine this terminal unit for access device according to performing result
Whether pass through heartbeat detection.
If terminal unit is not online, then this terminal unit does not passes through heartbeat detection.
To online terminal unit, access device instructs the test program that its installation and operation is specified.Test
It is local that the installation kit of program can be saved in terminal unit, it is also possible to is obtained from access device by terminal unit,
Can also be obtained from access device in the case of this locality does not preserves installation kit by terminal unit and preserve, this
Embodiment does not limits.
Terminal unit performs instruction, installs the test program specified, and installs backward access device feedback
The execution result installed.The execution result installed includes that test program is installed successfully or failure, also may be used
To include other information relevant with installation process and test program.
After the success of installing terminal equipment test program, continue executing with instruction, testing results program, run
Terminate the execution result of backward access device back-to-back running.The execution result run includes that test program is transported
Go successfully or failure, additionally, according to the realization of test program itself, it is also possible to include that test program exists
The data of output in running.
The installation and operation of test program is used for detecting whether the current state of terminal unit can perform distribution
The task of formula platform, in other words, if being in can service state.Therefore, select or what kind of is write
The specific requirement of terminal unit current state can be determined by test program according to distributed platform.Absolutely
In most cases, it is possible to successfully installation and operation test program at least shows the operation system of terminal unit
System state is normal and there is not the problems such as memory space is full, meets execution distributed platform and appoints
The basic demand of business.
If the state of terminal unit is had the further requirement that by distributed platform, can be existed by test program
In running, the SOT state of termination parameter of acquisition terminal equipment, according to the realization of test program, is gathered
SOT state of termination parameter can feed back to the access device (terminal that such as will gather as the execution result run
State parameter write daily record is read by access device), it is also possible in test program, utilize these terminal shapes
State parameter judge terminal unit whether be in can service state, if be in can service state; testing results
The execution result of program is successfully, and the execution result otherwise run is unsuccessfully, and the execution result that will run
Feed back to access device.
Can determine by the resource requirement according to the feature of task performed by distributed platform, to terminal unit
The SOT state of termination parameter that test program is to be gathered, the hardware-software configuration of terminal unit, currently used shape
Any information that can be obtained by test program such as state can serve as SOT state of termination parameter, such as, processes
Device frequency, processor utilization, residual memory space, free memory size, the network bandwidth, bandwidth profit
With rate, terminal unit, whether there is certain type of sensor etc., the present embodiment does not limits.
Heartbeat detection generally repeats with some cycles, use the most as far as possible small grain size, run quickly,
Take the test program that resource is few, to reduce the impact on terminal unit performance, therefore test program as far as possible
In typically do not include UI (User Interface, user interface) and other be helpless to taking terminal
The extra realization that business state makes a determination.
It should be noted that send the finger of installation and operation test program to terminal unit according to access device
Make, that terminal unit performs the concrete mode of instruction is different, may not include running in the execution result of instruction
The execution result of test program.Such as, access device can first send installation test program to terminal unit
Instruction, and the execution result receiving installing terminal equipment be successfully time, then send fortune to terminal unit
The instruction of row test program;If it is unsuccessfully that the installation of terminal unit performs result, the most no longer command terminal
Equipment testing results program, does not include the execution result run in the execution result now instructed.
On access device, step 230, determine whether terminal unit passes through according to the execution result of instruction
Heartbeat detection.
The concrete mode of the instruction of installation and operation test program, test program is sent according to access device
The difference implemented, content and representative implication thereof that the execution result of instruction includes may be different,
Corresponding, it is determined that whether terminal unit can be according to performing in result by the specific standards of heartbeat detection
Content and implication, the task feature of distributed platform and requirement determine.For example, it may be it is following several
Kind situation:
The first: terminal unit includes installing test program to the instruction execution result that access device feeds back
Whether success and/or testing results program whether success, as install failure, install successfully and run failure,
Install success and run successfully (or only back-to-back running success, it is meant that install successfully).Access sets
Standby when performing result for installing success and running successful, it is determined that terminal unit passes through heartbeat detection;Its
He performs result for not pass through.
The second: terminal unit includes installing test program to the instruction execution result that access device feeds back
Whether success and/or testing results program whether success, as install failure, install successfully and run failure,
Install success and run successfully (or only back-to-back running success, it is meant that install successfully), additionally
SOT state of termination parameter including the terminal unit that test program gathers in running.Access device is being held
Row result for installing successfully, run successfully, and perform the SOT state of termination parameter in result and meet and can service
During condition, it is determined that terminal unit passes through heartbeat detection;Otherwise do not pass through heartbeat detection.
It should be noted that the first situation includes implemented as described below: test program is adopted in running
Collected the SOT state of termination parameter of terminal unit, and test program at test program properly functioning and institute
Gather SOT state of termination parameter meet can conditions of service time feedback execution result for run successfully, the most instead
The execution result of feedback is for run unsuccessfully.
After the heartbeat detection that access device completes terminal unit, according to the type of organization of distributed platform,
Other nodes of at least one in distributed platform send the heartbeat detection result of terminal unit.Such as,
To the one of distributed platform to multiple control nodes (such as the host node) heartbeat detection sending terminal unit
As a result, control node can according to this information, carry out distributed platform topology update and task divide
Join.
Visible, the presence of terminal unit is not only detected by embodiments herein, and leads to
Cross installation and operation test program on the terminal device, can service state detect terminal unit,
It is in and the terminal unit of service state can could pass through heartbeat detection.So, distributed platform can be avoided
Assign the task to be in can not the terminal unit of service state, improve the operational efficiency of distributed platform.
It addition, by by the SOT state of termination parameter of acquisition terminal equipment be used as judging can the foundation of service state,
Distributed platform can select the terminal unit more conforming to task feature to perform task, thus further
The processing speed of lifting task.
In an application example of the application, Android terminal (includes mobile phone, flat board, Intelligent electric
Depending on, simulator etc.) connected by modes such as USB, WiFi (WIreless FIdelity, Wireless Fidelity)
To a PC, this PC is the node of distributed platform, is also that Android terminal accesses distributed putting down
The access device of platform, hereinafter referred to as PC node.Android terminal refers to be provided with Android operation system
Terminal.
PC node runs a finger daemon (assuming its entitled Worker), is responsible for access
Android terminal carry out heartbeat detection, and the task of distributed platform is got, tasks carrying, appoint
Business result is returned and is put.After Android terminal is connected with PC node, PC node is with some cycles pair
Android terminal carries out heartbeat detection, and its interaction is as shown in Figure 4.
Specifically, the cycle then, on PC node, Worker process encapsulation adb order, execution
Adb devices order.Can obtain being connected on PC node by adb devices, Worker process
The serial number (serial number) of Android terminal and Android terminal state (device,
offline).Wherein, device represents that Android terminal is online, and offline represents that Android terminal is not
Connect or without response.
Even if Android terminal is online, it is also possible to because loading problem can not perform the task of distributed platform.
In order to detect Android terminal can service state, use a small grain size Android program ping
As test program (ping.apk is the installation kit of ping), by PC node instruction Android terminal
Install and run this test program.Ping utility itself is in addition to the network connectivty of test Android terminal
Do not do other to realize.
Worker process sends two adb orders to Android terminal:
adb-s<serialNumber>install ping.apk;This order is used for instructing Serial No.
The Android terminal of serialNumber installs ping utility;
adb shell am start-n ping/PingActivity;This order is used for instructing above-mentioned being mounted with ping
The Android terminal of program runs ping utility.
Android terminal performs above-mentioned two adb orders, and after being finished on PC node
Worker progress feedback every orders the result of whether successful execution.
Worker process receives the execution result of instruction, if Android terminal installs ping utility success
And run ping utility success, then this Android terminal passes through heartbeat detection.
Worker process reports the heartbeat detection result of Android terminal to the host node of distributed platform.
Realizing corresponding with above-mentioned flow process, embodiments herein additionally provides one and applies on access device
The heartbeat detection device of distributed platform, and the heart of the distributed platform that a kind of application is on the terminal device
Jump detection device.Both devices all can be realized by software, it is also possible to by hardware or software and hardware
In conjunction with mode realize.As a example by implemented in software, as the device on logical meaning, it is to be set by access
The CPU (Central Process Unit, central processing unit) of standby or terminal unit is by corresponding computer
Programmed instruction reads and runs formation in internal memory.For hardware view, except the CPU shown in Fig. 5,
Outside internal memory and nonvolatile memory, the terminal unit at the heartbeat detection device place of distributed platform
Could be included for carrying out other hardware such as chip of wireless signal transmitting-receiving, the heart beating inspection of distributed platform
Survey the access device at device place and could be included for realizing other hardware such as board of network communicating function.
Fig. 6 show the heartbeat detection device of a kind of distributed platform that the present embodiment provides, and applies and is inciting somebody to action
Terminal unit accesses on the access device of distributed platform, is included in line states unit, test program unit
With testing result unit, wherein: presence unit is the most online for detecting the terminal unit of access;
Test program unit, for instructing online installing terminal equipment and testing results program, obtains holding of instruction
Row result;According to the execution result of instruction, testing result unit is for determining whether described terminal unit passes through
Heartbeat detection.
In one example, the execution result of described instruction includes: installation test program is the most successful and/or transports
Row test program is the most successful;Described testing result unit specifically for: survey in described installing terminal equipment
When examination program success and testing results program success, pass through heartbeat detection;Otherwise do not pass through heartbeat detection.
In previous example, the execution result of described instruction also includes: the described terminal gathered by test program
The SOT state of termination parameter of equipment;Described testing result unit specifically for: survey in described installing terminal equipment
Examination program success, testing results program success and its SOT state of termination parameter meet can conditions of service time,
Pass through heartbeat detection;Otherwise do not pass through heartbeat detection.
Optionally, described device also includes that testing result circulates a notice of unit, is used in distributed platform extremely
Few other node sends the heartbeat detection result of institute's access terminal equipment.
Optionally, described terminal unit is android terminal;The terminal unit that described detection accesses whether online,
Installing terminal equipment that described instruction is online testing results program are all by the debugging bridge adb order of Android
Carry out.
Fig. 7 show the heartbeat detection device of a kind of distributed platform that the present embodiment provides, and applies logical
Cross access device to access on the terminal unit of distributed platform, be included in line states response unit and test journey
Sequence is installed and running unit, wherein: presence response unit is for responding the presence of access device
Detection;Test program is installed and running unit is for receiving the installation and operation test program of access device
Instruction, to the execution result of access device return instruction, determines this end for access device according to performing result
Whether end equipment passes through heartbeat detection.
In one example, the execution result of described instruction includes: installs test program whether success and/or holds
Row test program is the most successful.
In previous example, the execution result of described instruction also includes: this terminal gathered by test program sets
Standby SOT state of termination parameter.
Optionally, this terminal unit is android terminal;The detection of described presence, described installation and operation
The instruction of test program is the debugging bridge adb order of Android.
The foregoing is only the preferred embodiment of the application, not in order to limit the application, all at this
Within the spirit of application and principle, any modification, equivalent substitution and improvement etc. done, should be included in
Within the scope of the application protection.
In a typical configuration, calculating equipment includes one or more processor (CPU), input/output
Interface, network interface and internal memory.
Internal memory potentially includes the volatile memory in computer-readable medium, random access memory
(RAM) and/or the form such as Nonvolatile memory, such as read only memory (ROM) or flash memory (flash RAM).
Internal memory is the example of computer-readable medium.
Computer-readable medium includes that removable media permanent and non-permanent, removable and non-can be by appointing
Where method or technology realize information storage.Information can be computer-readable instruction, data structure, program
Module or other data.The example of the storage medium of computer include, but are not limited to phase transition internal memory (PRAM),
Static RAM (SRAM), dynamic random access memory (DRAM), other kinds of with
Machine access memorizer (RAM), read only memory (ROM), Electrically Erasable Read Only Memory
(EEPROM), fast flash memory bank or other memory techniques, read-only optical disc read only memory (CD-ROM),
Digital versatile disc (DVD) or other optical storage, magnetic cassette tape, tape magnetic rigid disk stores or it
His magnetic storage apparatus or any other non-transmission medium, can be used for the letter that storage can be accessed by a computing device
Breath.According to defining herein, computer-readable medium does not include temporary computer readable media (transitory
Media), such as data signal and the carrier wave of modulation.
Also, it should be noted term " includes ", " comprising " or its any other variant are intended to non-
Comprising of exclusiveness, so that include that the process of a series of key element, method, commodity or equipment not only wrap
Include those key elements, but also include other key elements being not expressly set out, or also include for this process,
The key element that method, commodity or equipment are intrinsic.In the case of there is no more restriction, statement " include
One ... " key element that limits, it is not excluded that including the process of described key element, method, commodity or setting
Other identical element is there is also in Bei.
It will be understood by those skilled in the art that embodiments herein can be provided as method, system or computer journey
Sequence product.Therefore, the application can use complete hardware embodiment, complete software implementation or combine software and
The form of the embodiment of hardware aspect.And, the application can use and wherein include calculating one or more
The computer-usable storage medium of machine usable program code (include but not limited to disk memory, CD-ROM,
Optical memory etc.) form of the upper computer program implemented.