CN116743837A - Communication control method, device, electronic equipment and storage medium - Google Patents

Communication control method, device, electronic equipment and storage medium Download PDF

Info

Publication number
CN116743837A
CN116743837A CN202210206375.8A CN202210206375A CN116743837A CN 116743837 A CN116743837 A CN 116743837A CN 202210206375 A CN202210206375 A CN 202210206375A CN 116743837 A CN116743837 A CN 116743837A
Authority
CN
China
Prior art keywords
instance
client identifier
client
operation time
distributed lock
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.)
Pending
Application number
CN202210206375.8A
Other languages
Chinese (zh)
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.)
Shanghai Qwik Smart Technology Co Ltd
Original Assignee
Shanghai Qwik Smart 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 Shanghai Qwik Smart Technology Co Ltd filed Critical Shanghai Qwik Smart Technology Co Ltd
Priority to CN202210206375.8A priority Critical patent/CN116743837A/en
Publication of CN116743837A publication Critical patent/CN116743837A/en
Pending legal-status Critical Current

Links

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/14Session management
    • H04L67/146Markers for unambiguous identification of a particular session, e.g. session cookie or URL-encoding
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/141Setup of application sessions
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/70Reducing energy consumption in communication networks in wireless communication networks

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)

Abstract

The invention discloses a communication control method, a communication control device, electronic equipment and a storage medium. The communication control method includes: in response to an execution request of the communication service, initiating a plurality of instances of the communication service to cause the instances to acquire the distributed lock; controlling to obtain a first instance of the distributed lock, and obtaining client identifiers from a plurality of client identifiers of the electronic equipment so that the first instance establishes communication connection with the external equipment by using the obtained client identifiers; wherein, the client identifiers are different from each other, and each client identifier is configured with an operation time; in the process that the client identifier is used, updating the operation time of the used client identifier to the current time of the electronic equipment according to a preset period; and controlling to obtain a second instance of the distributed lock, and obtaining a client identifier of which the difference between the operation time and the current time is larger than a preset period, so that the second instance establishes communication connection with external equipment by using the obtained client identifier. Thereby avoiding instances preempting client identifications from each other.

Description

Communication control method, device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a communication control method, a device, an electronic apparatus, and a storage medium.
Background
Distributed locks are one way to control the synchronous access of shared resources between different devices in a distributed system. In a cloud computing environment, a distributed lock has a very wide use scenario, and the most main application scenario is that in a distributed system, when different devices access a shared resource, the system often needs the distributed lock to support mutual exclusivity of accessing the shared resource so as to ensure consistency.
In a distributed concurrency environment, because the network environment is complex, the occupancy rate of machine resources is difficult to control, and how to ensure the correctness and efficiency of the distributed lock in the complex system environment becomes a problem to be solved urgently.
Disclosure of Invention
The invention aims to overcome the defect that client identifiers are preempted in a scene of adopting a distributed lock in the prior art, and provides a communication control method, a device, electronic equipment and a storage medium.
The invention solves the technical problems by the following technical scheme:
in a first aspect, a communication control method is provided, applied to an electronic device, and the communication control method includes:
in response to an execution request of a communication service, starting a plurality of instances of the communication service to enable the instances to acquire a distributed lock;
controlling to obtain a first instance of the distributed lock, and obtaining a client identifier from a plurality of client identifiers of the electronic equipment so that the first instance establishes communication connection with external equipment by using the obtained client identifier; wherein, the client identifiers are different from each other, and each client identifier is configured with an operation time;
updating the operation time of the used client identifier to the current time of the electronic equipment according to a preset period in the process that the client identifier is used;
and controlling to obtain a second instance of the distributed lock, and obtaining a client identifier of which the difference value between the operation time and the current time is larger than the preset period, so that the second instance establishes communication connection with the external equipment by using the obtained client identifier.
Optionally, the method further comprises:
determining a first set, wherein the first set contains all client identifiers;
determining a second set, wherein the second set comprises client identifiers of which the difference value between the operation time and the current time is not more than the preset period;
controlling the second instance to acquire the client identifier includes:
controlling the second instance to acquire the client identification which is not included in the second set from the first set.
Optionally, the method further comprises:
determining a third set, wherein the third set comprises client identifiers of which the difference value between the operation time and the current time of the electronic equipment is larger than a preset period;
controlling the second instance to acquire the client identifier includes:
and controlling the second instance to acquire the client identifier from the third set.
Optionally, the method further comprises:
writing a client identifier of which the difference value between the operation time and the current time of the electronic equipment is smaller than a preset period into a redis memory;
updating the operation time of the used client identifier to the current time of the electronic equipment, wherein the method comprises the following steps:
and updating the operation time of the client identifier in the redis memory to the current time of the electronic equipment.
Optionally, the instance using the client identifier updates the operation time of the used client identifier to the current time of the electronic device according to a preset period.
Optionally, the method further comprises:
controlling the first instance to release the distributed lock under the condition that the client identifier is obtained;
or releasing the distributed lock when the time length of the first instance for obtaining the distributed lock reaches a time length threshold value.
Optionally, the method further comprises:
controlling the second instance to release the distributed lock under the condition that the client identifier is obtained;
or releasing the distributed lock when the duration of the second instance for obtaining the distributed lock reaches a duration threshold.
In a second aspect, there is provided a communication control apparatus applied to an electronic device, the communication control apparatus including:
the starting module is used for responding to the execution request of the communication service and starting a plurality of instances of the communication service so as to enable the instances to acquire the distributed lock;
the control module is used for controlling to obtain a first instance of the distributed lock, and obtaining client identifiers from a plurality of client identifiers of the electronic equipment so that the first instance can establish communication connection with external equipment by using the obtained client identifiers; wherein, the client identifiers are different from each other, and each client identifier is configured with an operation time;
the updating module is used for updating the operation time of the used client identifier to the current time of the electronic equipment according to a preset period in the process of using the client identifier;
the control module is further configured to control to obtain a second instance of the distributed lock, and obtain a client identifier of which a difference between the operation time and the current time is greater than the preset period, so that the second instance uses the obtained client identifier to establish communication connection with the external device.
In a third aspect, there is provided an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the method of any of the preceding claims when executing the computer program.
In a fourth aspect, a computer readable storage medium is provided, on which a computer program is stored which, when executed by a processor, implements the method of any of the preceding claims.
The invention has the positive progress effects that: in the embodiment of the invention, in the process of using the client identifier, the operation time of the client identifier is updated based on the current time of the electronic equipment, so that the situation that the client identifier is mistakenly used by an instance and preempted by other instances due to overlong service time of the client identifier is avoided, and the situation that the instances preempt the client identifier mutually can be effectively avoided.
Drawings
Fig. 1 is a flowchart of a communication control method according to an exemplary embodiment of the present invention;
fig. 2 is a flowchart of another communication control method according to an exemplary embodiment of the present invention;
fig. 3 is a schematic block diagram of a communication control device according to an exemplary embodiment of the present invention;
fig. 4 is a schematic structural diagram of an electronic device according to an exemplary embodiment of the present invention.
Detailed Description
The invention is further illustrated by means of the following examples, which are not intended to limit the scope of the invention.
The distributed lock is used for guaranteeing the uniqueness and the security of the registration of the main service instance when a plurality of service instances are started simultaneously.
The redisson distributed lock can guarantee that only one instance can acquire the lock at a time. The service start initializes a certain number of clientIDs (client identifier) to store in redis (which is a memory), then each instance starts to remove the initialized clientIDs, and connects the mqtt server with the obtained clientIDs for receiving messages.
The service has a timed task to update the own occupied (used) clientID of each instance and store it in redis, identifying that this clientID is in use (used), and long-term non-updated clientIDs are considered unused by the instance.
In the prior art, the clientID is typically randomly generated, regularly generated, or a fixed clientID is employed. In either of the above ways, there is a problem that the clientIDs preempt each other, resulting in a multi-instance service start-up error, because the same clientID can only successfully connect to the mqtt server (interjacent, publishing the message) once.
For example, the service needs to start multiple instances, improving the mqtt data processing efficiency, 4 clientIDs, namely, clientID-1, clientID-2, clientID-3, and clientID-4 are initialized when the service starts to connect to the mqtt server, the clientIDs are stored in the redis, 2 instances A and B are started in total, the clientID is taken in the redis at A, B start, and if A takes the clientID-1 first and the mqtt server is successfully connected, and then B takes the clientID-1 again, but the instance A has succeeded in connecting to the mqtt by using the clientID-1, then the instance B always reports errors.
Based on the above problems, the embodiments of the present invention provide a communication control method, so as to avoid the problem of multi-instance service start-up error reporting caused by mutual preemption.
Fig. 1 is a flowchart of a communication control method according to an exemplary embodiment of the present invention, where the communication control method is applied to an electronic device, and the electronic device may include, but is not limited to, a computer, a server, a vehicle-mounted terminal, and the like. Referring to fig. 1, the communication control method includes the steps of:
step 101, in response to an execution request of the communication service, a plurality of instances of the communication service are started, so that the instances acquire the distributed lock.
The distributed lock may be, for example, a redisson distributed lock.
Step 102, controlling to obtain a first instance of the distributed lock, and obtaining a client identifier from a plurality of client identifiers of the electronic device, so that the first instance establishes communication connection with the external device by using the obtained client identifier.
The client identifiers are different from each other, and each client identifier is configured with an operation time for identifying whether the client identifier is used or not. The plurality of client identifiers may be randomly generated, regularly generated, or fixed client identifiers may be adopted.
In one embodiment, upon obtaining the client identification, the first instance releases the distributed lock to enable other instances than the first instance to obtain the distributed lock.
In one embodiment, the distributed lock is released if the duration of the first instance of obtaining the distributed lock reaches a duration threshold. By setting the duration threshold, it can be ensured that the first instance has acquired the client identity when releasing the distributed lock. The time length threshold can be set according to actual conditions.
Step 103, in the process of using the client identifier, updating the operation time of the used client identifier to the current time of the electronic device according to a preset period.
And updating the operation time of the used client identifier to the current time of the electronic equipment so as to identify whether the client identifier is used or not, and avoiding other instances from preempting the client identifier.
The preset period can be set according to actual requirements. The current time of day of the electronic device may be characterized by the current system time of day.
It will be appreciated that the smaller the preset period setting, the more frequently the operation time of the client identifier is updated, the more the client identifier can be characterized as being used. And in the process that the client identifier is used, the operation time of the client identifier is identified based on the current time of the electronic equipment, so that the situation that the client identifier is mistakenly not used by an instance and preempted by other instances due to overlong use time of the client identifier is avoided.
In one embodiment, a client identifier with a difference between the operation time and the current time of the electronic device being smaller than a preset period is written into the redis memory, and when the operation time is updated, the operation time of the client identifier in the redis memory is updated to the current time of the electronic device. The difference between the operation time and the current time of the electronic equipment is smaller than the client identifier of the preset period, which indicates that the client identifier is used by an instance, and the client identifier is written into the redis memory, so that the operation time of the client identifier is conveniently updated by the instance of the client identifier, and other instances are also convenient to distinguish whether the client identifier is used or not. And when the client identifier of which the difference between the operation time and the current time of the electronic equipment is not smaller than the preset period exists in the redis memory, removing the client identifier from the redis memory.
In one embodiment, the instance identified by the using client updates the operating time of the used client identification to the current time of the electronic device according to a preset period. The instance updates the operation time of the client identifier used by the instance, so that the timeliness and the accuracy of the update can be improved, and on the other hand, the instance or the script is not required to be additionally arranged, and the resource can be saved.
Step 104, controlling to obtain a second instance of the distributed lock, and obtaining a client identifier with a difference value between the operation time and the current time being greater than a preset period, so that the second instance establishes communication connection with external equipment by using the obtained client identifier.
If the difference between the operation time of the client identifier and the current time is larger than the preset period, the client identifier is not used by any instance, and the second instance can be controlled to acquire the client identifier, so that the preemption phenomenon with other instances can not occur.
In the embodiment of the invention, in the process of using the client identifier, the operation time of the client identifier is updated based on the current time of the electronic equipment, so that the situation that the client identifier is used for too long and is mistakenly not used by an instance is avoided, and the client identifier is preempted by other instances.
In one embodiment, in order to make the implementation logic simpler, the instance can conveniently obtain the unused client identifiers, the client identifiers can be divided, the client identifiers of the same type are divided into the same set, specifically, two sets are set, the first set contains all the client identifiers, and the second set contains the client identifiers with the difference between the operation time and the current time not greater than a preset period, namely the client identifiers used by the instance. When the second instance is controlled to acquire the client identifiers, the second instance is controlled to acquire the client identifiers which are not included in the second set from the first set, so that the second instance is prevented from comparing the operation time of each client identifier, unused and available client identifiers are determined, and the first instance only needs to find the used client identifiers in the first set and update the operation time of the used client identifiers, so that the operation is convenient.
In one embodiment, the first set is determined by acquiring a first instance of the distributed lock when the communication service is started, specifically, the acquired first instance of the distributed lock is responsible for initializing a preset number of client identifiers and putting the client identifiers into the first set, a key of the first set is the client identifier, a value is an operation time of the client identifier, the first set can be stored into a redis by using an hmset command, and other instances do not need the operation.
In one embodiment, the instance traverses the client identifier in the first set, extracts the value time (operation time) of the key and the value, compares the value time with the current time, considers the client identifier to be available when the difference between the operation time of the client identifier and the current time is larger than a preset period, puts the client identifier in the second set, and sets the distributed lock to be released within a certain time.
In one embodiment, a third set is set, the third set includes a client identifier having a difference between an operation time and a current time of the electronic device greater than a preset period, and when the second instance is controlled to acquire the client identifier, the second instance is controlled to acquire the client identifier from the third set.
In one embodiment, a first set, a second set and a third set are set at the same time, the first set contains all client identifiers, the second set contains the client identifiers of which the difference between the operation time and the current time is not greater than a preset period, the third set contains the client identifiers of which the difference between the operation time and the current time of the electronic device is greater than the preset period, the second instance is controlled to acquire the client identifiers which are not contained in the second set from the third set, and the first instance is controlled to update the operation time of the client identifiers in the second set.
Fig. 2 is a flowchart of another communication control method according to an exemplary embodiment of the present invention, in which an example a and an example B are taken as examples, and the example a performs client identifier initialization for illustration, and further illustrates communication control. Referring to fig. 2, the communication control method includes the steps of:
step 201, instance a acquires a redisson distributed lock.
Step 202, instance a determines whether a redisson distributed lock is acquired.
In step 202, if the determination result is yes, step 203 is executed; if the result is negative, return to step 201.
Step 203, the instance a initializes a predetermined number of client identifiers and puts them into the first set.
The key of the first set is the client identification, value is the time of operation, instance A uses the hmset command to store the first set into redis.
Step 204, the instance a obtains an operation time of the client identifier from the first set.
Step 205, the instance a determines whether the difference between the operation time of the client identifier and the current time of the electronic device is greater than a difference threshold.
In step 205, if the determination result is yes, it is indicated that the client identifier is available or not occupied by other instances, and step 206 is performed; if the result is no, the step 204 is returned to acquire the operation time of the client identifier again. The re-acquisition of the client identification may take the form of a loop traversal.
Step 206, instance a places the client identification into a second set and establishes a communication connection with an external device using the client identification.
The second set includes client identifiers having a difference between the operation time and the current time not greater than a preset period, i.e., client identifiers occupied by the instance.
In step 207, in the process that the client identifier is used, the instance a updates the operation time of the used client identifier to the current time of the electronic device according to the preset period.
The instance A updates the operation time of the client identifier in the second set according to the preset period, and updates the operation time of the client identifier in the second set to the first set, so that the operation time of the client identifier in the second set is synchronous with the operation time of the corresponding client identifier in the first set.
Step 208, instance a releases the redisson distributed lock to enable other instances to acquire the redisson distributed lock.
Step 201', instance B acquires a redisson distributed lock.
Step 202', instance B determines whether a redisson distributed lock was acquired.
In step 202', if the determination result is yes, step 203' is executed; if the determination is negative, the process returns to step 201'.
Step 203', instance B loops the first set to sequentially obtain the operation time of one client identifier.
Step 204', instance B determines whether the client identification exists in the second set.
In step 204', if the determination result is no, step 205' is performed; if the determination result is yes, the step 203' is returned to acquire the operation time of one client identifier again. The re-acquisition of the client identification may take the form of a loop traversal.
Step 205', instance B creates a third set, in which the key is the currently acquired client identifier and the value is the operation time of the client identifier.
Step 206', instance B loops over the first set, storing the third set use hmset command into redis.
The hmset command may update only the value of the change, which does not update.
It should be noted that, each instance may start a timing task, execute steps 203 'to 206', specifically, loop the first set, then determine that the circulated client identifier is not in the second set, create a third set if the circulated client identifier exists, where the key of the third set is the client identifier clientID, the value is the operation time of the client identifier, the first set is circulated, and store the command of using hmset by the third set into redis.
Through the steps, only one instance can be ensured to initialize and distribute the client identifiers at the same time, the situation that the client identifiers are preempted by each other can not occur when multiple instances are started, and the client identifiers can be accurately known.
If so, the instance B may also obtain a client identifier from the first set, which is not included in the second set, and use the client identifier to establish a communication connection with the external device.
The invention also provides an embodiment of the communication control device corresponding to the embodiment of the communication control method.
Fig. 3 is a schematic block diagram of a communication control device according to an exemplary embodiment of the present invention, where the communication control device is applied to an electronic apparatus, and the communication control device includes:
a starting module 31, configured to respond to an execution request of a communication service, and start multiple instances of the communication service, so that the instances acquire a distributed lock;
a control module 32, configured to control to obtain a first instance of the distributed lock, obtain a client identifier from a plurality of client identifiers of the electronic device, so that the first instance uses the obtained client identifier to establish a communication connection with an external device; wherein, the client identifiers are different from each other, and each client identifier is configured with an operation time;
an updating module 33, configured to update, during the process of using the client identifier, an operation time of the used client identifier to a current time of the electronic device according to a preset period;
the control module 32 is further configured to control obtaining a second instance of the distributed lock, and obtain a client identifier having a difference between the operation time and the current time greater than the preset period, so that the second instance uses the obtained client identifier to establish communication connection with the external device.
Optionally, the method further comprises:
a first determining module, configured to determine a first set, where the first set includes all client identifiers;
the second determining module is further configured to determine a second set, where the second set includes a client identifier that a difference between the operation time and the current time is not greater than the preset period;
when controlling the second instance to obtain the client identifier, the control module 32 is specifically configured to:
controlling the second instance to acquire the client identification which is not included in the second set from the first set.
Optionally, the method further comprises:
the second determining module is used for determining a third set, and the third set comprises client identifiers of which the difference value between the operation time and the current time of the electronic equipment is larger than a preset period;
when controlling the second instance to acquire the client identifier, the control module is configured to:
and controlling the second instance to acquire the client identifier from the third set.
Optionally, the method further comprises:
the writing module is used for writing the client identifier of which the difference value between the operation time and the current time of the electronic equipment is smaller than a preset period into a redis memory;
the update module 33 is specifically configured to:
and updating the operation time of the client identifier in the redis memory to the current time of the electronic equipment.
Optionally, the instance using the client identifier updates the operation time of the used client identifier to the current time of the electronic device according to a preset period.
Optionally, the method further comprises:
a release module, configured to control the first instance to release the distributed lock when the client identifier is obtained;
or a releasing module, configured to release the distributed lock when the duration of the first instance of obtaining the distributed lock reaches a duration threshold.
Optionally, the method further comprises:
a release module, configured to control the second instance to release the distributed lock if the client identifier is obtained;
or a releasing module, configured to release the distributed lock when the duration of the second instance of obtaining the distributed lock reaches a duration threshold.
For the device embodiments, reference is made to the description of the method embodiments for the relevant points, since they essentially correspond to the method embodiments. The apparatus embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purposes of the present invention. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
Fig. 4 is a schematic diagram of an electronic device, showing an exemplary embodiment of the invention, showing a block diagram of an exemplary electronic device 40 suitable for use in implementing embodiments of the invention. The electronic device 40 shown in fig. 4 is merely an example and should not be construed as limiting the functionality and scope of use of embodiments of the present invention.
As shown in fig. 4, the electronic device 40 may be embodied in the form of a general purpose computing device, which may be a server device, for example. Components of electronic device 40 may include, but are not limited to: the at least one processor 41, the at least one memory 42, a bus 43 connecting the different system components, including the memory 42 and the processor 41.
The bus 43 includes a data bus, an address bus, and a control bus.
Memory 42 may include volatile memory such as Random Access Memory (RAM) 421 and/or cache memory 422, and may further include Read Only Memory (ROM) 423.
Memory 42 may also include a program tool 425 (or utility) having a set (at least one) of program modules 424, such program modules 424 including, but not limited to: an operating system, one or more application programs, other program modules, and program data, each or some combination of which may include an implementation of a network environment.
The processor 41 executes various functional applications and data processing, such as the methods provided in any of the embodiments described above, by running a computer program stored in the memory 42.
The electronic device 40 may also communicate with one or more external devices 44 (e.g., keyboard, pointing device, etc.). Such communication may be through an input/output (I/O) interface 45. Also, model-generated electronic device 40 may also communicate with one or more networks such as a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network such as the internet via network adapter 46. As shown, the network adapter 46 communicates with the other modules of the model-generated electronic device 40 via the bus 43. It should be appreciated that although not shown, other hardware and/or software modules may be used in connection with model-generating electronic device 40, including, but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID (disk array) systems, tape drives, data backup storage systems, and the like.
It should be noted that although several units/modules or sub-units/modules of an electronic device are mentioned in the above detailed description, such a division is merely exemplary and not mandatory. Indeed, the features and functionality of two or more units/modules described above may be embodied in one unit/module in accordance with embodiments of the present invention. Conversely, the features and functions of one unit/module described above may be further divided into ones that are embodied by a plurality of units/modules.
While specific embodiments of the invention have been described above, it will be appreciated by those skilled in the art that this is by way of example only, and the scope of the invention is defined by the appended claims. Various changes and modifications to these embodiments may be made by those skilled in the art without departing from the principles and spirit of the invention, but such changes and modifications fall within the scope of the invention.

Claims (10)

1. A communication control method, characterized by being applied to an electronic device, comprising:
in response to an execution request of a communication service, starting a plurality of instances of the communication service to enable the instances to acquire a distributed lock;
controlling to obtain a first instance of the distributed lock, and obtaining a client identifier from a plurality of client identifiers of the electronic equipment so that the first instance establishes communication connection with external equipment by using the obtained client identifier; wherein, the client identifiers are different from each other, and each client identifier is configured with an operation time;
updating the operation time of the used client identifier to the current time of the electronic equipment according to a preset period in the process that the client identifier is used;
and controlling to obtain a second instance of the distributed lock, and obtaining a client identifier of which the difference value between the operation time and the current time is larger than the preset period, so that the second instance establishes communication connection with the external equipment by using the obtained client identifier.
2. The communication control method according to claim 1, further comprising:
determining a first set, wherein the first set contains all client identifiers;
determining a second set, wherein the second set comprises client identifiers of which the difference value between the operation time and the current time is not more than the preset period;
controlling the second instance to acquire the client identifier includes:
controlling the second instance to acquire the client identification which is not included in the second set from the first set.
3. The communication control method according to claim 1, further comprising:
determining a third set, wherein the third set comprises client identifiers of which the difference value between the operation time and the current time of the electronic equipment is larger than a preset period;
controlling the second instance to acquire the client identifier includes:
and controlling the second instance to acquire the client identifier from the third set.
4. The communication control method according to claim 1, further comprising:
writing a client identifier of which the difference value between the operation time and the current time of the electronic equipment is smaller than a preset period into a redis memory;
updating the operation time of the used client identifier to the current time of the electronic equipment, wherein the method comprises the following steps:
and updating the operation time of the client identifier in the redis memory to the current time of the electronic equipment.
5. The communication control method according to claim 1, wherein the operation time of the used client identifier is updated to the current time of the electronic device according to a preset period by the instance using the client identifier.
6. The communication control method according to claim 1, further comprising:
controlling the first instance to release the distributed lock under the condition that the client identifier is obtained;
or releasing the distributed lock when the time length of the first instance for obtaining the distributed lock reaches a time length threshold value.
7. The communication control method according to claim 1, further comprising:
controlling the second instance to release the distributed lock under the condition that the client identifier is obtained;
or releasing the distributed lock when the duration of the second instance for obtaining the distributed lock reaches a duration threshold.
8. A communication control apparatus, characterized by being applied to an electronic device, comprising:
the starting module is used for responding to the execution request of the communication service and starting a plurality of instances of the communication service so as to enable the instances to acquire the distributed lock;
the control module is used for controlling to obtain a first instance of the distributed lock, and obtaining client identifiers from a plurality of client identifiers of the electronic equipment so that the first instance can establish communication connection with external equipment by using the obtained client identifiers; wherein, the client identifiers are different from each other, and each client identifier is configured with an operation time;
the updating module is used for updating the operation time of the used client identifier to the current time of the electronic equipment according to a preset period in the process of using the client identifier;
the control module is further configured to control to obtain a second instance of the distributed lock, and obtain a client identifier of which a difference between the operation time and the current time is greater than the preset period, so that the second instance uses the obtained client identifier to establish communication connection with the external device.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method of any one of claims 1 to 7 when executing the computer program.
10. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the method of any of claims 1 to 7.
CN202210206375.8A 2022-03-01 2022-03-01 Communication control method, device, electronic equipment and storage medium Pending CN116743837A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210206375.8A CN116743837A (en) 2022-03-01 2022-03-01 Communication control method, device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210206375.8A CN116743837A (en) 2022-03-01 2022-03-01 Communication control method, device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116743837A true CN116743837A (en) 2023-09-12

Family

ID=87899879

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210206375.8A Pending CN116743837A (en) 2022-03-01 2022-03-01 Communication control method, device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116743837A (en)

Similar Documents

Publication Publication Date Title
CN108549580B (en) Method for automatically deploying Kubernets slave nodes and terminal equipment
US10509680B2 (en) Methods, systems and apparatus to perform a workflow in a software defined data center
CN109194538B (en) Testing method, device, server and storage medium based on distributed coordination
US9386079B2 (en) Method and system of virtual desktop infrastructure deployment studio
US20180373750A1 (en) Allocation method and device for a distributed lock
US10797952B1 (en) Intelligent rollback analysis of configuration changes
US20060259594A1 (en) Progressive deployment and maintenance of applications on a set of peer nodes
CN110309161B (en) Data synchronization method and device and server
US11888933B2 (en) Cloud service processing method and device, cloud server, cloud service system and storage medium
CN109862101B (en) Cross-platform application starting method and device, computer equipment and storage medium
CN109375933B (en) Method and equipment for upgrading client
CN106708608B (en) Distributed lock service method, acquisition method and corresponding device
CN113127133B (en) Cross-platform virtual machine hot migration method, device, equipment and medium
CN107666493B (en) Database configuration method and equipment thereof
CN104793981A (en) Online snapshot managing method and device for virtual machine cluster
CN113342507B (en) Distributed lock service realization method and device and computer equipment
CN113434283A (en) Service scheduling method and device, server and computer readable storage medium
CN111953809B (en) Method, device, equipment and system for managing resource address
CN115951845B (en) Disk management method, device, equipment and storage medium
US20220206836A1 (en) Method and Apparatus for Processing Virtual Machine Migration, Method and Apparatus for Generating Virtual Machine Migration Strategy, Device and Storage Medium
CN113268254A (en) Cluster system installation method and device, electronic equipment and storage medium
CN116743837A (en) Communication control method, device, electronic equipment and storage medium
CN115022307A (en) File downloading method and device, storage medium and electronic equipment
CN111431951B (en) Data processing method, node equipment, system and storage medium
CN109376135B (en) Cluster file system management method and system

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