CN109120692B - Method and apparatus for processing requests - Google Patents

Method and apparatus for processing requests Download PDF

Info

Publication number
CN109120692B
CN109120692B CN201810933029.3A CN201810933029A CN109120692B CN 109120692 B CN109120692 B CN 109120692B CN 201810933029 A CN201810933029 A CN 201810933029A CN 109120692 B CN109120692 B CN 109120692B
Authority
CN
China
Prior art keywords
instance
information
request
state information
query
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810933029.3A
Other languages
Chinese (zh)
Other versions
CN109120692A (en
Inventor
韩丁
陆振飞
赵得润
王辉
周倜
宋利华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN201810933029.3A priority Critical patent/CN109120692B/en
Publication of CN109120692A publication Critical patent/CN109120692A/en
Application granted granted Critical
Publication of CN109120692B publication Critical patent/CN109120692B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/51Discovery or management thereof, e.g. service location protocol [SLP] or web services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/50Network service management, e.g. ensuring proper service fulfilment according to agreements
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/10Active monitoring, e.g. heartbeat, ping or trace-route

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Health & Medical Sciences (AREA)
  • Cardiology (AREA)
  • General Health & Medical Sciences (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the application discloses a method and a device for processing a request. One embodiment of the method comprises: receiving a first instance processing request, wherein the first instance processing request is used for requesting to modify instance positioning information in an instance positioning device; generating a query request according to the first instance processing request; sending the query request to query equipment in which instance state information is stored in advance, and receiving a query result returned by the query equipment, wherein the instance state information is a copy of an instance identifier and state indication information in the instance positioning equipment, and the query equipment generates the query result according to the instance state information; and determining whether the example positioning equipment is requested to modify the example positioning information according to the query result. This embodiment provides a new way of handling requests.

Description

Method and apparatus for processing requests
Technical Field
The embodiment of the application relates to the technical field of computers, in particular to a method and a device for processing a request.
Background
As the number of services increases, the invocation between services becomes complicated, a service may rely on external services, how to notify a relying party when a domain name or internet protocol address of a service changes, or how quickly a relying party discovers a change in the address of a service provider. A service may be embodied as one or more instances (service instances).
Thus, service registration and discovery has evolved. Service registration may be understood as maintaining a registry that manages all service addresses within the system. When a new service is started, it will hand over its own address information to the registry. A relying party to a service may request the service address from the registry.
Disclosure of Invention
The embodiment of the application provides a method and a device for processing a request.
In a first aspect, an embodiment of the present application provides a method for processing a request, where the method includes: receiving a first instance processing request, wherein the first instance processing request is used for requesting to modify instance location information in instance location equipment, and the instance location information comprises an instance identifier, state indication information and an instance address; generating a query request according to the first instance processing request; sending the query request to query equipment in which instance state information is stored in advance, and receiving a query result returned by the query equipment, wherein the instance state information is a copy of an instance identifier and state indication information in the instance positioning equipment, and the query equipment generates the query result according to the instance state information; and determining whether the example positioning equipment is requested to modify the example positioning information or not according to the query result.
In a second aspect, an embodiment of the present application provides an apparatus for processing a request, where the apparatus includes: the device comprises a receiving unit, a processing unit and a processing unit, wherein the receiving unit is configured to receive a first instance processing request, the first instance processing request is used for requesting to modify instance positioning information in instance positioning equipment, and the instance positioning information comprises instance identification, state indication information and an instance address; a first generating unit configured to generate a query request according to the first instance processing request; a first sending unit, configured to send the query request to a query device in which instance state information is stored in advance, and receive a query result returned by the query device, where the instance state information is a copy of an instance identifier and state indication information in instance location information in the instance location device, and the query device generates a query result according to the instance state information; and the first determining unit is configured to determine whether to request the example positioning equipment to modify the example positioning information according to the query result.
In a third aspect, an embodiment of the present application provides an electronic device, including: one or more processors; a storage device, on which one or more programs are stored, which, when executed by the one or more processors, cause the one or more processors to implement the method as described in any implementation manner of the first aspect.
In a fourth aspect, the present application provides a computer-readable medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the method as described in any implementation manner of the first aspect.
According to the method and the device for processing the request, a copy is stored to the query device according to the instance identification and the state indication information in the instance positioning device; the instance providing device does not directly send the instance processing request to the instance positioning device, but the execution main body queries the device to query the relevant information after receiving the first instance processing request, and determines whether to request the instance positioning device to modify the instance positioning information according to the query result. The technical effects may include at least: a new way of handling requests is provided.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 is an exemplary system architecture diagram in which the present application may be applied;
FIG. 2 is a flow diagram for one embodiment of a method for processing a request according to the present application;
FIG. 3 is a schematic diagram of an application scenario of a method for processing a request according to the present application;
FIG. 4 is a flow diagram of yet another embodiment of a method for processing a request according to the present application;
FIG. 5 is a flow chart of an alternative implementation of a method according to the present application;
FIG. 6 is a flow chart of an alternative implementation of a method according to the present application;
FIG. 7 is a block diagram illustrating one embodiment of an apparatus for processing requests in accordance with the present application;
FIG. 8 is a block diagram of a computer system suitable for use in implementing the electronic device of an embodiment of the present application.
Detailed Description
The present application will be described in further detail with reference to the following drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.
Fig. 1 shows an exemplary system architecture 100 to which embodiments of the method for processing a request or the apparatus for processing a request of the present application may be applied.
As shown in fig. 1, the system architecture 100 may include instance providing devices 101, 102, 103, an administration device 104, a querying device 105, an instance locating device 106, and a network 107.
The network 107 is used to provide a medium for communication links between the instance providing device and the managing device, between the managing device and the querying device, and between the managing device and the instance locating device. The network 107 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
Each of the instance providing device 101, 102, 103, the management device 104, the query device 105, and the instance positioning device 106 may be hardware or software. When the devices 101, 102, 103 are hardware, they may be various electronic devices with communication functions, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III, mpeg Audio Layer 3), MP4 players (Moving Picture Experts Group Audio Layer IV, mpeg Audio Layer 4), laptop portable computers, desktop computers, and the like. When the device is software, the software can be installed in the electronic devices listed above. It may be implemented as multiple pieces of software or software modules (e.g., to provide distributed services) or as a single piece of software or software module. And is not particularly limited herein.
The instance providing devices 101, 102, 103 may run instances. When the instance providing device needs to call an instance in other instance providing devices, the instance providing device can also serve as an instance calling device.
Example location device 106, roles may include the following: the method comprises the following steps that firstly, a service registration center is used for registering or deregistering a service or an instance in an instance providing device; and secondly, providing an instance address query service, namely receiving an instance query request sent by the instance calling device and returning an instance address (such as an internet protocol address and a port) to the instance calling device.
The querying device 105 may store a copy of the portion of the data in the instance locating device 106 and process the query request of the managing device based on the stored copy.
The management device 104 may receive the instance processing request of the instance providing device 101, 102, 103, query the querying device 105 for the required information, and determine whether to request the instance locating device 106 to perform the modification operation based on the matter requested by the instance processing request.
The management device 104 may be a server with respect to the instance providing devices 101, 102, 103, such as a background server that provides support for the instance providing devices 101, 102, 103 to send instance processing requests and the like. The background server may process the received instance processing request and the like, and feed back a processing result (e.g., processing success information) to the terminal device.
It should be noted that the method for processing the request provided by the embodiment of the present application is generally performed by the management device 104, and accordingly, the apparatus for processing the request is generally disposed in the management device 104.
The server may be hardware or software. When the server is hardware, it may be implemented as a distributed server cluster formed by multiple servers, or may be implemented as a single server. When the server is software, it may be implemented as multiple pieces of software or software modules (e.g., to provide distributed services), or as a single piece of software or software module. And is not particularly limited herein.
It should be understood that the number of instance providing devices, managing devices, querying devices, instance locating devices, and networks in fig. 1 is merely illustrative. There may be any number of instance providing devices, managing devices, querying devices, instance locating devices, and networks, as desired for an implementation.
Referring to FIG. 2, a flow 200 of one embodiment of a method for processing a request is shown. The embodiment is mainly exemplified by applying the method to an electronic device with certain computing capability, which may be the management device 104 shown in fig. 1. The method for processing the request comprises the following steps:
step 201, a first instance processing request is received.
In this embodiment, an execution subject (e.g., the management device 104 shown in fig. 1) of the method for processing a request may receive a first instance processing request from an instance providing device or a monitoring device monitoring the instance providing device in a wired connection manner or a wireless connection manner.
Here, the instance providing device or the monitoring device may send the first instance processing request to the execution main body when an instance in the instance providing device changes or when an instance status is agreed to be reported as needed.
In this embodiment, the first instance processing request may be used to request to modify instance location information in the instance location device.
In this embodiment, an instance may also be referred to as a service instance. The service instance may provide a predefined service. A service instance may be considered a process or a combination of processes. The service instance may provide an instance interface. Other processes can call the instance interface, send the data to be processed to the service instance, and then receive the calculation result of the service instance. For example, the other process may be a process that generates a payment amount page, and the service instance may be a process that calculates a payment amount.
It will be appreciated that the other processes described above invoke the service instance described above, requiring knowledge of the manner in which the service instance is invoked. The electronic device (caller) on which the other process runs needs to know the device information of the electronic device (callee) on which the service instance is located.
In this embodiment, the instance location information may include an instance identifier, status indication information, and an instance address.
In this embodiment, the instance identification may indicate an instance. The instance identification may be an instance name or number, etc.
In this embodiment, the status indication information may indicate whether the instance is in an available state. The status indication information may include status information indicating availability or unavailability. The availability status information may indicate that the instance is in an available state. The unavailability status information may indicate that the instance is in an unavailable state.
In this embodiment, the instance address may be used to indicate the way in which the instance was found. Example addresses may include, but are not limited to, at least one of: the internet protocol address, port number, etc. of the device where the instance is located.
In this embodiment, the example positioning device may store example positioning information. Here, the example location information stored in the example location information may be one or a plurality of. Typically, the stored example location information in the example location device is multiple, i.e., the example location device may maintain a large amount of example location information. The various instance calling devices can send instance positioning requests to the instance positioning devices and then receive instance addresses returned by the instance positioning information.
Optionally, the description information of the function of the instance may be referred to as instance function information, and may also be referred to as a service identifier. The instance location information may be associated with a service identification. The service identification may be associated with one or more instance location information.
For example, the instance requirement device a may send an instance location request a to the above instance location device, and the instance location request a may include the service identity a. The instance location device may query the instance location information associated with the service identifier a, and return an instance address in the queried one or more instance location information to the instance requirement device a.
In some optional implementations of this embodiment, the first instance processing request may be associated with a request type in a predefined set of request types. The set of request types may include, but is not limited to, at least one of: adding a service location information type, deleting a service location information type, adding an instance location information type, deleting an instance location information type, and modifying a status indication information type.
Optionally, the first instance processing request of the add service location information type may include a service identifier and instance location information, and is used to request the instance location device to add the service identifier and the instance location information associated with the service identifier.
Optionally, the first instance processing request for deleting the service location information type may include a service identifier for requesting the instance location device to delete the service identifier and the instance location information associated with the service identifier.
Optionally, the first instance processing request of the type of augmented instance location information may include a service identifier and instance location information for requesting the augmented instance location information and associating the augmented instance location information with the service identifier.
Optionally, the first instance processing request for deleting the instance location information type may include a service identifier and an instance identifier, and is used to request to delete the instance location information associated with the service identifier.
Optionally, the first instance processing request for modifying the type of the status indication information may include an instance identifier and target status indication information.
Step 202, a query request is generated according to the first instance processing request.
In this embodiment, an execution subject (e.g., the management device 104 shown in fig. 1) of the method for processing a request may generate a query request according to the first example processing request described above.
In this embodiment, the query request may be used to request to query the relevant information of the instance location information to which the first instance processing request is directed.
In this embodiment, the execution subject may refer to the parameter in the first instance processing request and the associated request type to generate the query request. For simplicity of illustration, please refer to the example in step 203.
Step 203, sending a query request to the query device which stores the instance state information in advance, and receiving a query result returned by the query device.
In this embodiment, an execution subject (for example, the management device 104 shown in fig. 1) of the method for processing a request may send the query request to a query device in which instance state information is stored in advance, and receive a query result returned by the query device.
In this embodiment, the instance status information may be a copy of the instance identifier and the status indication information in the instance location device. The instance identifier and the state indication information in each instance location information in the instance location device may be copied to obtain one copy, all copies obtained by copying are used as an instance state information set, and the instance state information set is stored in the query device.
It is understood that the querying device with the instance state information stored in advance can also be referred to as the querying device with the instance state information set stored in advance.
In this embodiment, the instance status information may include an instance identifier and status indication information.
In this embodiment, the query device may generate a query result according to the instance state information.
For example, if the associated request type is an add service location information type, the query request may include service identification a. The query request may be used to query whether the service identifier a already exists in the service identifiers associated with the instance identifiers in the instance status information. The query result may be presence indication information or absence indication information.
For example, if the determined request type is an add instance location information type, the query request may include an instance identification a in instance location information a. This query request may be used to query whether instance location information already exists. The query result may be presence indication information or absence indication information.
For example, if the associated request type is a modified status indication information type, the query request may include instance identification B and target status indication information. This query request may be used to query the status indication information of the instance status information B including the instance identification B. The query result may return status indication information for instance status information B.
Step 204, according to the query result, determining whether the example positioning device is requested to modify the example positioning information.
In this embodiment, an execution subject of the method for processing a request (e.g., the management device 104 shown in fig. 1) may determine whether to request the instance location device to modify the instance location information according to the query result.
For example, if the associated request type is an add service location information type, the query request may include service identification a. The query request may be used to query whether the service identifier a already exists in the service identifiers associated with the instance identifiers in the instance status information. The query result may be presence indication information or absence indication information. And if the query result indicates that the information exists, determining not to request the example positioning equipment to modify the example positioning information. And if the query result indicates that no information exists, determining to request the example positioning equipment to modify the example positioning information.
For example, if the associated request type is a modified status indication information type, the query request may include instance identification B and target status indication information. This query request may be used to query the status indication information of the instance status information B including the instance identification B. The query result may return status indication information for instance status information B. And if the state indication information in the query result is consistent with the target state indication information, determining not to request the example positioning equipment to modify the example positioning information. And if the state indication information in the query result is inconsistent with the target state indication information, determining to request the example positioning equipment to modify the example positioning information.
With continued reference to fig. 3, fig. 3 is a schematic diagram of an application scenario of the method for processing a request according to the present embodiment. In the application scenario of fig. 3:
the instance providing device 301 may send a first instance processing request 303 to the managing device 302. Here, the first instance processing request 303 is for requesting modification of instance location information in the instance location device 307.
The managing device 302 may generate a query request 304 based on the first instance process request 303.
The managing device 302 may send a query request 304 to the querying device 305.
The querying device 305 may return query results 306 based on the query request 304 to the managing device 302.
The management device 302 may determine whether to request the instance location device 307 to modify the instance location information based on the query results 306. In fig. 3, the dashed line between the management device 302 and the example positioning device 307, the management device 302 may or may not request the example positioning device 307 to modify the example positioning information.
In the method provided by the above embodiment of the present application, a copy is stored to the query device by referring to the instance identifier and the state indication information in the instance location device; the instance providing device does not directly send the instance processing request to the instance positioning device, but the execution main body queries the device to query the relevant information after receiving the first instance processing request, and determines whether to request the instance positioning device to modify the instance positioning information according to the query result. The technical effects may include at least:
first, a new way of handling requests is provided.
Second, first instance processing requests that do not need to be processed (or are otherwise invalid) are filtered out before being processed by the instance location device. Some first instance processing requests may be invalid, for example, due to untimely information exchange, the first instance processing request expects a target state to be reached by the instance location information, and the first instance processing request may be invalid if the instance location information is already in the target state.
Third, filtering out first instance processing requests that do not need to be processed can reduce the request throughput of the instance location device.
With further reference to FIG. 4, a flow 400 of yet another embodiment of a method for processing a request is shown. The flow 400 of the method for processing a request includes the steps of:
at step 401, a first instance processing request is received.
In this embodiment, an execution subject (e.g., the management device 104 shown in fig. 1) of the method for processing a request may receive a first instance processing request from an instance providing device or a monitoring device monitoring the instance providing device in a wired connection manner or a wireless connection manner.
Step 402, generating a query request according to the first instance processing request.
In this embodiment, an execution subject (e.g., the management device 104 shown in fig. 1) of the method for processing a request may generate a query request according to the first example processing request described above.
Step 403, sending a query request to the query device which stores the instance state information in advance, and receiving a query result returned by the query device.
In this embodiment, an execution subject (for example, the management device 104 shown in fig. 1) of the method for processing a request may send the query request to a query device in which instance state information is stored in advance, and receive a query result returned by the query device.
Step 404, determining whether to request the example positioning device to modify the example positioning information according to the query result.
In this embodiment, an execution subject of the method for processing a request (e.g., the management device 104 shown in fig. 1) may determine whether to request the instance location device to modify the instance location information according to the query result.
The specific operations of step 401, step 402, step 403, and step 404 in this embodiment are substantially the same as the operations of step 201, step 202, step 203, and step 204 in the embodiment shown in fig. 2, and are not described again here.
Step 405, in response to determining that the instance location device is requested to modify the instance location information, generates an instance processing file according to the first instance processing request.
In this embodiment, the execution subject may generate the instance processing file according to the first instance processing request in response to determining that the instance positioning device is requested to modify the instance positioning information.
An example process file is understood here to mean a task or a data packet to be processed. The instance processing file may be generated according to the first instance processing request, and the instance processing file may be generated by packaging parameters in the first instance processing request and adding some device information of the execution subject.
Step 406, add the instance process file to the pre-established request buffer queue.
In this embodiment, the execution body may add the instance process file to a pre-established request buffer queue.
The request buffer queue may include at least one instance process file.
Step 407, sending a second instance processing request to the instance positioning device based on the request buffer queue.
In this embodiment, the execution main body may send a second instance processing request to the instance location device based on the request buffer queue.
Here, the second example processing request includes an example processing file located at the head of the request buffer queue.
Here, the instance location device may modify the instance location information according to the received second instance processing request, and return a modification result to the execution subject.
It should be noted that the load pressure of the above example positioning device for processing the example positioning request is already large. Thus, the instance location device typically has a numerical limit on the instance processing requests that are processed, and if too many, may result in the instance processing requests being rejected by the instance location device. The technical effects of setting a request buffer queue at least comprise the following steps:
first, the frequency of sending instance processing requests to the instance location device may be controlled.
Second, the frequency of sending instance processing requests can be adjusted in time when the processing capability of the instance location device is perceived to change.
Third, when it is discovered that an instance processing request is rejected by an instance location device, the rejected instance processing request can be placed in the queue again, ensuring that the instance processing request is not lost until it is not processed.
Step 408, in response to receiving the modification result, generating and sending a third instance processing request to the querying device according to the modification result.
In this embodiment, the execution subject may generate and send a third instance processing request to the query device according to the modification result in response to receiving the modification result.
Here, the querying device may modify the instance state information according to the third instance processing request.
It should be noted that, after the instance location device modifies the instance location information, the querying device modifies the corresponding copy, which can ensure consistency between the instance state information in the querying device and the state indication information in the instance location device, and provide reliable querying basis for processing the first instance processing request and querying request later.
As can be seen from fig. 4, compared with the corresponding embodiment of fig. 2, the flow 400 of the method for processing a request in the present embodiment highlights the step of requesting modification of the instance location information and the instance state information based on the request buffer queue. Therefore, the technical effects of the solution described in this embodiment at least include:
first, a new way of handling requests is provided.
Second, the frequency of sending instance processing requests to the instance location device may be controlled.
Thirdly, the consistency of the instance state information in the query device and the state indication information in the instance positioning device is ensured.
In some embodiments, the method described herein may further include the flow 500 shown in fig. 5. The process 500 may include the following steps:
step 501, a request query device modifies state indication information in instance state information in an instance state information set into unavailable state information.
Here, the example state information set is a set of example state information stored in the querying device.
Step 502, requesting the query device to update the instance state information according to the instance heartbeat information received within the preset time length range.
Here, step 502 may include: within a preset time range, executing the following steps: and in response to receiving instance heartbeat information associated with the instance identifier, sending the instance identifier associated with the instance heartbeat information to the inquiring equipment, wherein the inquiring equipment modifies the state indication information corresponding to the received instance identifier into available state information.
Step 503, determining the instance state information indicating the unavailable instance according to the update result of the query device.
Here, the execution subject may determine, as the instance state information indicating the unavailable instance, instance state information including the unavailable state information in the querying device.
Step 504, according to the instance identifiers in the instance state information indicating the unavailable instances, an unavailable instance identifier set is generated.
Step 505, according to the set of unavailable instance identifiers, determining whether the instance location device is requested to modify the instance location information including the unavailable instance identifier.
Step 505 may include: determining the number of unavailable instance identifications in the set of unavailable instance identifications; and determining whether to delete the example positioning information comprising the unavailable example identifier in the unavailable example identifier set in the example positioning equipment according to the number and a preset number threshold.
Step 505 may include: generating a fourth instance processing request according to the unavailable instance identifier in the unavailable instance identifier set; and sending the fourth instance processing request to the instance positioning equipment, wherein the instance positioning equipment modifies instance positioning information comprising an unavailable instance identifier according to the fourth instance processing request.
It should be noted that the process 500 may be executed periodically. I.e., every predetermined length of time, the process 500 is executed.
It should be noted that, in some abnormal scenarios, such as a machine crash, the instance cannot normally send a logout heartbeat, so that the abnormal instance positioning information cannot be deleted by the instance positioning device. If such abnormal conditions cannot be quickly identified and repaired, abnormal instance location information is left in the instance location equipment, resulting in abnormal instance location services. By the method illustrated by flow 500, the instance status may be periodically scanned, and abnormal instances discovered and cleaned up.
In some embodiments, the method shown herein may further comprise: and requesting to modify the instance location information and/or the instance state information according to the instance identifier in the instance location information and the instance identifier in the instance state information.
In some embodiments, the request to modify the instance location information and/or the instance state information based on the instance identification in the instance location information and the instance identification in the instance state information may pass through flow 600 shown in fig. 6. The process 600 may include the following steps:
step 601, determining the instance identifier in the instance positioning information as a first instance identifier, and generating a first instance identifier set.
Here, the executing body may first obtain an instance identifier in the instance positioning information in the instance positioning device, and then generate the first instance identifier set. For example, for a plurality of pieces of instance location information, an instance identifier of each piece of instance location information may be acquired as the first instance identifier. The plurality of instance identifications in the plurality of instance location information may be a first set of instance identifications.
Step 602, determining the instance identifier in the instance state information as a second instance identifier, and generating a second instance identifier set.
Here, the executing entity may first obtain the instance identifier in the instance status information in the querying device, and then generate the first instance identifier set. For example, for a plurality of pieces of instance state information, the instance identifier in each piece of instance state information may be acquired as the first instance identifier. The plurality of instance identifications in the plurality of instance state information may be a second set of instance identifications.
Step 603, determine the intersection of the first instance identifier set and the second instance identifier set.
Step 604, requesting to modify the instance location information and/or the instance state information according to the intersection.
Optionally, step 604 may include: and searching a second instance identifier which belongs to the second instance set but not to the intersection, and requesting the query equipment to delete the instance state information comprising the searched second instance identifier. In this way, the instance state information in the querying device that is inconsistent with the instance location information is cleared based on the instance location information.
Optionally, step 604 may include: searching a first example identifier which belongs to the first example set but does not belong to the intersection, and sending a fifth example processing request comprising the searched first example identifier to example positioning equipment; and searching a second example identifier which belongs to the second example set but does not belong to the intersection, and sending a sixth example processing request comprising the searched second example identifier to the query equipment.
Here, the example location device may delete the example location information including the first example identification in the fifth example processing request in response to receiving the fifth example processing request. The querying device may delete the instance state information including the second instance identification in the second instance processing request in response to receiving the sixth instance processing request.
Therefore, the technical effects of the scheme provided by fig. 6 at least include: the data in the query device can be ensured to be consistent with the data in the example positioning device, and reliable query basis is provided. Due to frequent instance handling requests (requesting instance registration or deregistration), the following may occur: the instance state information in the query device is not a strict copy of the instance identification and state indication information in the instance location device. To cope with this situation, the data in the querying device and the instance location device may be managed to have consistency through the scheme shown in fig. 6.
With further reference to fig. 7, as an implementation of the methods shown in the above-mentioned figures, the present application provides an embodiment of an apparatus for processing a request, which corresponds to the method embodiment shown in fig. 2, and which is particularly applicable to various electronic devices.
As shown in fig. 7, the apparatus 700 for processing a request of the present embodiment includes: a receiving unit 701 configured to receive a first instance processing request, where the first instance processing request is used to request to modify instance location information in an instance location device, the instance location information includes an instance identifier, status indication information, and an instance address, and the instance identifier is associated with instance function information; a first generating unit 702, configured to generate an inquiry request according to the first instance processing request, where the inquiry request is used to request to inquire about information about instance location information to which the first instance processing request is directed; a first sending unit 703, configured to send the query request to a query device in which instance state information is stored in advance, and receive a query result returned by the query device, where the instance state information is a copy of an instance identifier and state indication information in instance location information in the instance location device, and the query device generates a query result according to the instance state information; a first determining unit 704 configured to determine whether to request the example positioning device to modify the example positioning information according to the query result.
In this embodiment, specific processing of the receiving unit 701, the first generating unit 702, the first sending unit 703 and the first determining unit 704 of the apparatus 700 for processing a request and technical effects brought by the specific processing can refer to relevant descriptions of step 201, step 202, step 203 and step 204 in the corresponding embodiment of fig. 2, which are not described herein again.
In some optional implementations of this embodiment, the apparatus further includes: a second generating unit configured to generate an instance processing file according to the first instance processing request in response to determining that the instance positioning device is requested to modify the instance positioning information; and the adding unit is configured to add the example processing file into a pre-established request buffer queue.
In some optional implementations of this embodiment, the apparatus further includes: and the second sending unit is configured to send a second instance processing request to the instance positioning device based on the request buffer queue, wherein the second instance processing request includes an instance processing file located at the head of the request buffer queue, and the instance positioning device modifies the instance positioning information according to the received second instance processing request and returns a modification result.
In some optional implementations of this embodiment, the apparatus further includes: and the third generating unit is configured to generate and send a third instance processing request to the inquiring device according to the modification result in response to receiving the modification result, wherein the inquiring device modifies instance state information according to the third instance processing request.
In some optional implementations of this embodiment, the instance status information includes available status information or unavailable status information; and the above apparatus further comprises: a first requesting unit, configured to request an inquiring device to modify state indication information in instance state information in an instance state information set into unavailable state information, where the instance state information set is a set of instance state information stored in the inquiring device; the second request unit is configured to request the query equipment to update the instance state information according to the instance heartbeat information received in the preset time length range; a second determination unit configured to determine instance state information indicating an unavailable instance according to an update result of the querying device.
In some optional implementations of this embodiment, the second requesting unit is further configured to: within a preset time range, executing the following steps: and in response to receiving instance heartbeat information associated with the instance identifier, sending the instance identifier associated with the instance heartbeat information to the inquiring equipment, wherein the inquiring equipment modifies the state indication information corresponding to the received instance identifier into available state information.
In some optional implementations of this embodiment, the second determining unit is further configured to: after the preset time range, searching the instance state information including the unavailable state information in the query device, and determining the searched instance state information as the instance state information indicating the unavailable instance.
In some optional implementations of this embodiment, the apparatus further includes: a fourth generating unit configured to generate an unavailable instance identification set according to an instance identification in the instance state information indicating an unavailable instance; a third determining unit, configured to determine whether to request the instance positioning device to modify the instance positioning information including the unavailable instance identifier according to the unavailable instance identifier set.
In some optional implementations of this embodiment, the third determining unit is further configured to: determining the number of unavailable instance identifications in the set of unavailable instance identifications; and determining whether to delete the example positioning information comprising the unavailable example identifier in the unavailable example identifier set in the example positioning equipment according to the number and a preset number threshold.
In some optional implementations of this embodiment, the third determining unit is further configured to: generating a fourth instance processing request according to the unavailable instance identifier in the unavailable instance identifier set; and sending the fourth instance processing request to the instance positioning equipment, wherein the instance positioning equipment modifies instance positioning information comprising an unavailable instance identifier according to the fourth instance processing request.
In some optional implementations of this embodiment, the apparatus further includes: and the third request unit is configured to request to modify the instance positioning information and/or the instance state information according to the instance identifier in the instance positioning information and the instance identifier in the instance state information.
In some optional implementations of this embodiment, the third requesting unit is further configured to determine the instance identifier in the instance positioning information as the first instance identifier, and generate the first instance identifier set; determining the instance identifier in the instance state information as a second instance identifier, and generating a second instance identifier set; determining an intersection of the first instance identifier set and the second instance identifier set; and requesting to modify the instance positioning information and/or the instance state information according to the intersection.
In some optional implementations of this embodiment, the third requesting unit is further configured to: searching a first example identifier which belongs to the first example set but does not belong to the intersection, and sending a fifth example processing request comprising the searched first example identifier to example positioning equipment; and searching a second example identifier which belongs to the second example set but does not belong to the intersection, and sending a sixth example processing request comprising the searched second example identifier to the query equipment.
It should be noted that details of implementation and technical effects of each unit in the apparatus for processing a request provided in the embodiment of the present application may refer to descriptions of other embodiments in the present application, and are not described herein again.
Referring now to FIG. 8, shown is a block diagram of a computer system 800 suitable for use in implementing the electronic device of an embodiment of the present application. The electronic device shown in fig. 8 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present application.
As shown in fig. 8, a computer system 800 includes a Central Processing Unit (CPU)801 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 802 or a program loaded from a storage section 808 into a Random Access Memory (RAM) 803. In the RAM 803, various programs and data necessary for the operation of the system 800 are also stored. The CPU 801, ROM 802, and RAM 803 are connected to each other via a bus 804. An Input/Output (I/O) interface 805 is also connected to bus 804.
The following components are connected to the I/O interface 805: an input portion 806 including a keyboard, a mouse, and the like; an output section 807 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and a speaker; a storage portion 808 including a hard disk and the like; and a communication section 809 including a Network interface card such as a LAN (Local Area Network) card, a modem, or the like. The communication section 809 performs communication processing via a network such as the internet. A drive 810 is also connected to the I/O interface 805 as necessary. A removable medium 811 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 810 as necessary, so that a computer program read out therefrom is mounted on the storage section 808 as necessary.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication section 809 and/or installed from the removable medium 811. The computer program performs the above-described functions defined in the method of the present application when executed by the Central Processing Unit (CPU) 801. It should be noted that the computer readable medium mentioned above in the present application may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present application, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In this application, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present application may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present application may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes a receiving unit, a first generating unit, a first transmitting unit, and a first determining unit. Where the names of these units do not in some cases constitute a limitation on the unit itself, for example, a receiving unit may also be described as a "unit that receives a first instance processing request".
As another aspect, the present application also provides a computer-readable medium, which may be contained in the apparatus described in the above embodiments; or may be present separately and not assembled into the device. The computer readable medium carries one or more programs which, when executed by the apparatus, cause the apparatus to: receiving a first instance processing request, wherein the first instance processing request is used for requesting to modify instance location information in instance location equipment, and the instance location information comprises an instance identifier, state indication information and an instance address; generating a query request according to the first instance processing request; sending the query request to query equipment in which instance state information is stored in advance, and receiving a query result returned by the query equipment, wherein the instance state information is a copy of an instance identifier and state indication information in the instance positioning equipment, and the query equipment generates the query result according to the instance state information; and determining whether the example positioning equipment is requested to modify the example positioning information or not according to the query result.
The above description is only a preferred embodiment of the application and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention herein disclosed is not limited to the particular combination of features described above, but also encompasses other arrangements formed by any combination of the above features or their equivalents without departing from the spirit of the invention. For example, the above features may be replaced with (but not limited to) features having similar functions disclosed in the present application.

Claims (15)

1. A method for processing a request, the method comprising:
receiving a first instance processing request, wherein the first instance processing request is used for requesting to modify instance location information in instance location equipment, and the instance location information comprises instance identification, state indication information and an instance address;
generating a query request according to the first instance processing request;
sending the query request to query equipment in which instance state information is stored in advance, and receiving a query result returned by the query equipment, wherein the instance state information is a copy of an instance identifier and state indication information in the instance positioning equipment, the query equipment generates the query result according to the instance state information, and the instance state information comprises available state information or unavailable state information;
determining whether the example positioning equipment is requested to modify the example positioning information or not according to the query result;
requesting query equipment to modify state indication information in instance state information in an instance state information set into unavailable state information, wherein the instance state information set is a set of instance state information stored in the query equipment;
requesting query equipment to update instance state information according to instance heartbeat information received within a preset time length range;
instance state information indicating unavailable instances is determined based on the updated results of the querying device.
2. The method of claim 1, wherein the method further comprises:
in response to determining that the instance location device is requested to modify the instance location information, generating an instance processing file according to the first instance processing request;
and adding the instance processing file into a pre-established request buffer queue.
3. The method of claim 2, wherein the method further comprises:
and sending a second instance processing request to the instance positioning equipment based on the request buffer queue, wherein the second instance processing request comprises an instance processing file positioned at the head of the request buffer queue, and the instance positioning equipment modifies instance positioning information according to the received second instance processing request and returns a modification result.
4. The method of claim 3, wherein the method further comprises:
and in response to receiving the modification result, generating and sending a third instance processing request to the query device according to the modification result, wherein the query device modifies instance state information according to the third instance processing request.
5. The method according to claim 1, wherein the requesting, according to the instance heartbeat information received within the preset time length range, the query device to update the instance state information includes:
within a preset time length range, executing the following steps: and in response to receiving instance heartbeat information associated with the instance identifier, sending the instance identifier associated with the instance heartbeat information to the inquiring equipment, wherein the inquiring equipment modifies the state indication information corresponding to the received instance identifier into available state information.
6. The method of claim 5, wherein the determining instance state information indicating unavailable instances according to the update results comprises:
after the preset duration range, searching the instance state information including the unavailable state information in the query device, and determining the searched instance state information as the instance state information indicating the unavailable instance.
7. The method of claim 1, wherein the method further comprises:
generating an unavailable instance identification set according to the instance identification in the instance state information indicating the unavailable instance;
determining whether to request the instance location device to modify instance location information including an unavailable instance identification according to the set of unavailable instance identifications.
8. The method of claim 7, wherein said determining whether to request the instance location device to modify instance location information including an unavailable instance identification from the set of unavailable instance identifications comprises:
determining a number of unavailable instance identifications in the set of unavailable instance identifications;
and determining whether to delete the example positioning information comprising the unavailable example identifier in the unavailable example identifier set in the example positioning equipment according to the number and a preset number threshold.
9. The method of claim 7, wherein said determining whether to request the instance location device to modify instance location information including an unavailable instance identification from the set of unavailable instance identifications comprises:
generating a fourth instance processing request according to the unavailable instance identifier in the unavailable instance identifier set;
and sending the fourth instance processing request to the instance positioning equipment, wherein the instance positioning equipment modifies instance positioning information comprising unavailable instance identification according to the fourth instance processing request.
10. The method according to any one of claims 1-9, wherein the method further comprises:
and requesting to modify the instance location information and/or the instance state information according to the instance identifier in the instance location information and the instance identifier in the instance state information.
11. The method of claim 10, wherein the requesting modification of the instance location information and/or the instance state information according to the instance identifier in the instance location information and the instance identifier in the instance state information comprises:
determining an instance identifier in the instance positioning information as a first instance identifier, and generating a first instance identifier set;
determining the instance identifier in the instance state information as a second instance identifier, and generating a second instance identifier set;
determining an intersection of the first set of instance identifications and the second set of instance identifications;
and requesting to modify the instance positioning information and/or the instance state information according to the intersection.
12. The method of claim 11, wherein the requesting modification of instance location information and/or instance state information based on the intersection comprises:
searching for a first instance identifier which belongs to the first instance identifier set but does not belong to the intersection, and sending a fifth instance processing request comprising the searched first instance identifier to instance positioning equipment;
searching for a second instance identifier that belongs to the second instance identifier set but not to the intersection, and sending a sixth instance processing request including the searched second instance identifier to the querying device.
13. An apparatus for processing a request, comprising:
the device comprises a receiving unit and a processing unit, wherein the receiving unit is configured to receive a first instance processing request, the first instance processing request is used for requesting to modify instance positioning information in an instance positioning device, and the instance positioning information comprises instance identification, state indication information and an instance address;
a first generating unit configured to generate a query request according to the first instance processing request;
the first sending unit is configured to send the query request to a query device which stores instance state information in advance, and receive a query result returned by the query device, wherein the instance state information is a copy of instance identification and state indication information in the instance positioning device, the query device generates the query result according to the instance state information, and the instance state information comprises available state information or unavailable state information;
a first determining unit configured to determine whether to request the instance positioning device to modify instance positioning information according to the query result;
a first requesting unit, configured to request an inquiring device to modify state indication information in instance state information in an instance state information set into unavailable state information, where the instance state information set is a set of instance state information stored in the inquiring device;
the second request unit is configured to request the query equipment to update the instance state information according to the instance heartbeat information received in the preset time length range;
a second determination unit configured to determine instance state information indicating an unavailable instance according to an update result of the querying device.
14. An electronic device, comprising:
one or more processors;
a storage device having one or more programs stored thereon,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-12.
15. A computer-readable medium, on which a computer program is stored, wherein the program, when executed by a processor, implements the method of any one of claims 1-12.
CN201810933029.3A 2018-08-16 2018-08-16 Method and apparatus for processing requests Active CN109120692B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810933029.3A CN109120692B (en) 2018-08-16 2018-08-16 Method and apparatus for processing requests

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810933029.3A CN109120692B (en) 2018-08-16 2018-08-16 Method and apparatus for processing requests

Publications (2)

Publication Number Publication Date
CN109120692A CN109120692A (en) 2019-01-01
CN109120692B true CN109120692B (en) 2021-09-28

Family

ID=64853306

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810933029.3A Active CN109120692B (en) 2018-08-16 2018-08-16 Method and apparatus for processing requests

Country Status (1)

Country Link
CN (1) CN109120692B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113591095B (en) * 2021-08-04 2023-08-29 百度在线网络技术(北京)有限公司 Identification information processing method and device and electronic equipment

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106161076A (en) * 2015-04-22 2016-11-23 华为技术有限公司 Virtual network function extended method and device

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8903782B2 (en) * 2010-07-27 2014-12-02 Microsoft Corporation Application instance and query stores
CN104331492B (en) * 2014-11-14 2017-11-21 北京国双科技有限公司 A kind of method and device for caching more instance datas

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106161076A (en) * 2015-04-22 2016-11-23 华为技术有限公司 Virtual network function extended method and device

Also Published As

Publication number Publication date
CN109120692A (en) 2019-01-01

Similar Documents

Publication Publication Date Title
US11146502B2 (en) Method and apparatus for allocating resource
CN108737270B (en) Resource management method and device for server cluster
CN110311983B (en) Service request processing method, device and system, electronic equipment and storage medium
CN108011949B (en) Method and apparatus for acquiring data
CN109388626B (en) Method and apparatus for assigning numbers to services
CN111045833A (en) Interface calling method and device
CN114189525B (en) Service request method and device and electronic equipment
CN111460129A (en) Method and device for generating identification, electronic equipment and storage medium
CN111126948A (en) Processing method and device for approval process
CN109828830B (en) Method and apparatus for managing containers
CN108958933B (en) Configuration parameter updating method, device and equipment of task executor
CN109120692B (en) Method and apparatus for processing requests
CN107818027B (en) Method and device for switching main name node and standby name node and distributed system
CN109471713B (en) Method and device for inquiring information
WO2018188607A1 (en) Stream processing method and device
CN113282589A (en) Data acquisition method and device
CN110740464A (en) NF service discovery method and device
CN111831503B (en) Monitoring method based on monitoring agent and monitoring agent device
CN113779412B (en) Message touch method, node and system based on blockchain network
CN110798358A (en) Distributed service identification method and device, computer readable medium and electronic equipment
CN109284177B (en) Data updating method and device
CN115934292A (en) Calling method, device and equipment of microservice application
CN113760487B (en) Service processing method and device
CN114374657A (en) Data processing method and device
CN113742617A (en) Cache updating method and device

Legal Events

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