Summary of the invention
The method and apparatus that the embodiment of the invention provides a kind of anti-zone state to determine, distributed definite anti-zone state reduces the service end load.
The method that the embodiment of the invention provides a kind of anti-zone state to determine is applied to comprise in the system in service end, client and defence area, comprising:
Described service end is selected the reckoner of a client as the state in described defence area from the client of the state of subscribing to described defence area, determined the state in described defence area according to the alarm in described defence area by described reckoner;
Described service end receives and writes down the state in the described defence area of described reckoner's transmission, and notifies the client of the state in the described defence area of subscription outside the described reckoner when the state in described defence area changes.
Described service end selects a client to comprise as the reckoner of the state in described defence area from the client of the state of subscribing to described defence area:
Described service end will be subscribed to the client of state in described defence area or the client of state of select subscribing to described defence area at random for the first time as the reckoner of the state in described defence area.
Described reckoner determines according to the alarm in described defence area also to comprise before the state in described defence area:
Described service end is the alarm that described reckoner subscribes to described defence area; Perhaps
Described reckoner periodically inquires about the alarm in described defence area to described service end.
Described service end selects a client to comprise as the reckoner of the state in described defence area from the client of the state of subscribing to described defence area:
When described service end receive any client to the state in described defence area obtain request the time, described service end is determined the state in current whether existing other described defence areas of client subscription;
If the current state that does not have other described defence areas of client subscription, described service end will send the reckoner of this client of obtaining request as the state in described defence area.
Described service end is selected also to comprise after the reckoner of client as the state in described defence area from the client of the state of subscribing to described defence area:
Described service end receives the obtain request of any client to the state in described defence area, judges whether send this client of obtaining request has subscribed to the state in described defence area;
If judged result is not, described service end is obtained the state in the described defence area of client subscription of request for sending this.
Subscribed to the state in described defence area or described service end for after the state that sends this described defence area of client subscription that obtains request if send this client of obtaining request, also comprised:
Described service end sends the state in the described defence area of current record to sending this client of obtaining request; And/or
When changing, the state of described service end in described defence area send the state in described defence area to this client of obtaining request of transmission.
When described reckoner can't operate as normal, select a client the client of the state in the described defence area of subscription of described service end outside described reckoner as new reckoner.
The equipment that the embodiment of the invention provides a kind of anti-zone state to determine is applied to comprise in the system in described service end, client and defence area as service end, comprising:
Selected cell is used for selecting the reckoner of a client as the state in described defence area from the client of the state of subscribing to described defence area;
Receiving element is used to receive and write down the state of described reckoner according to the described defence area of the alarm transmission in described defence area;
Notification unit is used for notifying the client of the state in the described defence area of subscription outside the described reckoner when the state in described defence area changes.
Described selected cell specifically is used for:
The client of state of the client or select at random of subscribing to for the first time the state in described defence area being subscribed to described defence area is as the reckoner of the state in described defence area.
Also comprise:
Subscriber units is connected with described selected cell, is used to described reckoner to subscribe to the alarm in described defence area; Perhaps
Transmitting element is used for the query requests to the alarm in described defence area according to described reckoner, sends the alarm in described defence area to described reckoner.
Described selected cell also is used for:
When described service end receive any client to the state in described defence area obtain request the time, determine the state in current whether existing other described defence areas of client subscription;
If the current state that does not have other described defence areas of client subscription obtains the reckoner of the client of request as the state in described defence area with sending this.
Described receiving element also is used for: receive the obtain request of any client to the state in described defence area;
This equipment also comprises judging unit, is connected with described receiving element, is used to judge whether send this client of obtaining request has subscribed to the state in described defence area;
This equipment also comprises subscriber units, is connected with described judging unit, does not subscribe to the state in described defence area as yet if be used for sending this client of obtaining request, then obtains the state in the described defence area of client subscription of request for sending this.
Described notification unit also is used for:
Subscribed to the state in described defence area or described service end for after the state that sends this described defence area of client subscription that obtains request if send this client of obtaining request, the state in the described defence area of current record has been sent to sending this client of obtaining request; And/or, when the state in described defence area changes to sending the state that this client of obtaining request sends described defence area.
Described selected cell also is used for:
When described reckoner can't operate as normal, select a client the client of the state in the described defence area of subscription outside described reckoner as new reckoner.
Compared with prior art, the present invention has the following advantages at least:
Among the present invention, calculate the state in defence area by client, service end does not need the calculating of the state in responsible all defence areas, has reduced the load of service end.
Embodiment
Core concept of the present invention is: calculate the state in defence area by the client of subscribing to anti-zone state, reduce the load that service end is calculated anti-zone state.
Introduce the method that anti-zone state provided by the invention is determined in detail below in conjunction with drawings and Examples.
Be the improvement that example is introduced service end at first with defence area shown in Figure 1 framework.With defence area A is example.
When not having client subscription or check the state of defence area A, service end is not calculated the state of defence area A.Concrete, service end can receive the alarm of the alarm source transmission of defence area A, if still there is not the state of client subscription defence area A, service end does not process the alarm of defence area A.
When the state of client subscription defence area A, service end need be selected the reckoner of a client as the state of defence area A, the alarm of subscribing to defence area A for this reckoner in advance.The reckoner is according to the state of the alarm calculating defence area A of defence area A, the state of the defence area A that storage computation obtains.When the state of defence area A changes or do not store the state of defence area A before, client sends the state of the current defence area A that calculates to service end.Service end writes down the state of defence area A, and sends to all clients of subscribing to the state of defence area A.If the reckoner of defence area A is not re-used as the reckoner of defence area A owing to network state or at other reasons, service end is reselected the client of the state of subscribing to defence area A as the reckoner.Usually, this reckoner is the client of subscribing to the state of defence area A at first.Certainly, this reckoner selects or the selection strategy of other settings at random.
When service end receive client to the state of defence area A obtain request the time, service end has at first been determined current whether existing other client subscriptions state of defence area A, if no, then this client is set to the reckoner of the state of defence area A, and is the alarm of client subscription defence area A.If existing other client subscriptions the state of defence area A and the state that this client has been subscribed to defence area A, then the state with the defence area A of record sends to this client, if existing other client subscriptions defence area A state but this client is not subscribed to the state of defence area A as yet, then be the state of this client subscription defence area A, and the state of the defence area A of current record is sent to this client.
Among the present invention, this service end is specifically as follows the network equipment of server or other similar service functions.
Concrete, in the embodiment of the invention, client obtain defence area A state process as shown in Figure 2, may further comprise the steps:
Step 201, client send the request of the state that obtains defence area A to service end.
Whether step 202, service end judge the number of references of defence area A greater than 1, if the number of references of defence area A less than 1, execution in step 203; Otherwise, execution in step 207.
Step 203, service end judge that defence area A is checked by client for the first time, needs to calculate the state of defence area A.
Step 204, service end sign client is the reckoner.
Step 205, service end are the alarm of client subscription defence area A alarm source.
Need explanation, this step is an optional step.For example, client also can periodically initiatively arrive the alarm of service end inquiry defence area A, and service end is returned the alarm of defence area A to client according to the query requests of client.
Step 206, client is calculated the state of defence area A according to the alarm of defence area A, and the state of the defence area A that calculates is sent to service end.
Concrete, client is sent to service end according to preset strategy with the state of the defence area A that calculates, for example, client is sent to service end at the state that for the first time calculates defence area A, and/or client is sent to service end with the state of the defence area A that calculates when calculating the state of finding defence area A and change.Client can also be periodically be sent to service end with the state of the defence area A that calculates, and the embodiment of the invention does not limit this.
Step 207, service end judge whether client has subscribed to the state of defence area A; If subscribed to, then execution in step 208; If do not subscribe to execution in step 209.
Step 208, the state of the defence area A of service end query note and to client feedback.
Need explanation, this step is optional.Because client has been subscribed to the state of defence area A, service end can be sent to client automatically with the Status Change message of defence area A.Certainly, service end also can be fed back the state of the defence area A of current record, and is sent to client in follow-up Status Change message with defence area A.
Step 209, service end increases the state number of references of defence area A.
Step 210, service end are the state of client subscription defence area A.
Step 211, the state of the defence area A of service end query note and to client feedback.
Need explanation, this step is optional.Because client has been subscribed to the state of defence area A, service end can be sent to client automatically with the Status Change message of defence area A.Certainly, client also can be set subscribe to for the first time when preventing the zone state success, service end will prevent that automatically zone state sends to client.
Corresponding with process shown in Figure 2, the reckoner of defence area A changes process as shown in Figure 3 in the embodiment of the invention, and assumed calculation person is a client 1, and this process comprises:
Step 301, service end is found client 1 off-line, cancellation.
Need explanation, service end can and the reckoner between set up communication mechanism, be used for determining whether the reckoner can operate as normal.For example, if do not receive reckoner's message within the Preset Time, service end can think that the reckoner can't operate as normal, need reset the reckoner.
Step 302, service end subtracts 1 with the number of references of defence area A, if the number of references of defence area A becomes 0, then no longer handles.
Step 303, service end select a client 2 as new reckoner from the residue person who quote of defence area A.
Selection strategy can be: select or remain the client of subscribing to defence area A condition among the person who quote at first at random.
Step 304, service end are the alarm that client 2 is subscribed to the alarm source of defence area A.
Step 305, client 2 is calculated the state of defence area A according to alarm, and when the state of defence area A changes, gives service end with the state feedback of new defence area A.
Step 306, service end is broadcast to other subscription clients with the state of defence area A.
Among the present invention, calculate the state in defence area by client, service end does not need the calculating of the state in responsible all defence areas, has reduced the load of service end.
Based on the same or analogous technical conceive of said method embodiment, the equipment that the embodiment of the invention provides a kind of anti-zone state to determine is applied to comprise in the system in described service end, client and defence area as service end, as shown in Figure 4, comprising:
Selected cell 10 is used for selecting the reckoner of a client as the state in described defence area from the client of the state of subscribing to described defence area;
Receiving element 20 is connected with described selected cell 10, is used to receive and write down the state of described reckoner according to the described defence area of the alarm transmission in described defence area;
Notification unit 30 is connected with described receiving element 20, is used for notifying when the state in described defence area changes the client of the state in the described defence area of subscription outside the described reckoner.
Described selected cell 10 specifically is used for:
The client of state of the client or select at random of subscribing to for the first time the state in described defence area being subscribed to described defence area is as the reckoner of the state in described defence area.
As shown in Figure 5, this equipment also comprises subscriber units 40, is connected with described selected cell 10, is used to described reckoner to subscribe to the alarm in described defence area; Perhaps
As shown in Figure 6, this equipment also comprises transmitting element 50, is used for the query requests to the alarm in described defence area according to described reckoner, sends the alarm in described defence area to described reckoner.
Described selected cell 10 also is used for:
When described service end receive any client to the state in described defence area obtain request the time, determine the state in current whether existing other described defence areas of client subscription;
If the current state that does not have other described defence areas of client subscription obtains the reckoner of the client of request as the state in described defence area with sending this.
Described receiving element 20 also is used for: receive the obtain request of any client to the state in described defence area; Accordingly, as shown in Figure 7, this equipment also comprises judging unit 60, is connected with described receiving element 20, is used to judge whether send this client of obtaining request has subscribed to the state in described defence area; Described subscriber units 40 can also be connected with described judging unit 60, does not subscribe to the state in described defence area as yet if be used for sending this client of obtaining request, then obtains the state in the described defence area of client subscription of request for sending this.
Described notification unit 30 also is used for:
Subscribed to the state in described defence area or described service end for after the state that sends this described defence area of client subscription that obtains request if send this client of obtaining request, the state in the described defence area of current record has been sent to sending this client of obtaining request; And/or, when the state in described defence area changes to sending the state that this client of obtaining request sends described defence area.
Described selected cell 10 also is used for: when described reckoner can't operate as normal, select a client as new reckoner the client of the state in the described defence area of subscription outside described reckoner.
Among the present invention, calculate the state in defence area by client, service end does not need the calculating of the state in responsible all defence areas, has reduced the load of service end.
Through the above description of the embodiments, those skilled in the art can be well understood to the present invention and can realize by the mode that software adds essential general hardware platform, can certainly pass through hardware, but the former is better execution mode under a lot of situation.Based on such understanding, the part that technical scheme of the present invention contributes to prior art in essence in other words can embody with the form of software product, this computer software product is stored in the storage medium, comprise that some instructions are with so that a computer equipment (can be a personal computer, server, the perhaps network equipment etc.) carry out the described method of each embodiment of the present invention.
It will be appreciated by those skilled in the art that accompanying drawing is the schematic diagram of a preferred embodiment, module in the accompanying drawing or flow process might not be that enforcement the present invention is necessary.
It will be appreciated by those skilled in the art that the module in the device among the embodiment can be distributed in the device of embodiment according to the embodiment description, also can carry out respective change and be arranged in the one or more devices that are different from present embodiment.The module of the foregoing description can be merged into a module, also can further split into a plurality of submodules.
More than disclosed only be several specific embodiment of the present invention, still, the present invention is not limited thereto, any those skilled in the art can think variation all should fall into protection scope of the present invention.