CN111258810A - Method, system, terminal equipment and storage medium for realizing data source switching - Google Patents

Method, system, terminal equipment and storage medium for realizing data source switching Download PDF

Info

Publication number
CN111258810A
CN111258810A CN202010020808.1A CN202010020808A CN111258810A CN 111258810 A CN111258810 A CN 111258810A CN 202010020808 A CN202010020808 A CN 202010020808A CN 111258810 A CN111258810 A CN 111258810A
Authority
CN
China
Prior art keywords
data source
host
application program
short message
main data
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
CN202010020808.1A
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.)
Guangdong Genius Technology Co Ltd
Original Assignee
Guangdong Genius 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 Guangdong Genius Technology Co Ltd filed Critical Guangdong Genius Technology Co Ltd
Priority to CN202010020808.1A priority Critical patent/CN111258810A/en
Publication of CN111258810A publication Critical patent/CN111258810A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1415Saving, restoring, recovering or retrying at system level
    • G06F11/1438Restarting or rejuvenating

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention provides a method, a system, a terminal device and a storage medium for realizing data source switching, wherein the method comprises the following steps: detecting whether a host is down; when the host is down, the cold standby data source is upgraded to a temporary main data source and the application program is informed of the cold standby data source in a broadcast mode, so that the application program provides short message aggregation service according to the temporary main data source; and when the host is not down, the application program provides short message aggregation service according to the main data source. The invention provides the continuously available short message capability so as to replace the data source under the condition of not restarting, thereby providing reliable and stable short message aggregation service for users.

Description

Method, system, terminal equipment and storage medium for realizing data source switching
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a method, a system, a terminal device, and a storage medium for implementing data source switching.
Background
Common enterprises have the capability of sending short messages and rely on short message service of a third party or integrate the short message capability of the third party into short message aggregation service. The short message aggregation service is an important basic service for business services required by many users.
In order to improve the availability and stability of the short message aggregation service, the short message aggregation service is deployed under the two machine rooms. Under a general double-machine-room architecture, a machine room cold standby database is provided, when the machine room is switched, the cold standby database is upgraded to a main database, an application program needs to modify the configuration of a data source, and the cold standby database can be restarted to take effect after the modification of the configuration. Therefore, the short message aggregation service can load a new data source after being restarted, so that the unstable time of the short message aggregation service is increased, and the use experience of a user is influenced.
Therefore, how to provide a continuously available short message capability so as to replace a data source without restarting is an urgent problem to be solved.
Disclosure of Invention
The invention aims to provide a method, a system, a terminal device and a storage medium for realizing data source switching, which realize the capability of providing continuously available short messages so as to replace data sources under the condition of not restarting, thereby providing reliable and stable short message aggregation service for users.
The technical scheme provided by the invention is as follows:
the invention provides a method for realizing data source switching, which comprises the following steps:
detecting whether a host is down;
when a host is down, a cold standby data source is upgraded to a temporary main data source and an application program is informed of the update of the cold standby data source through broadcasting, so that the application program provides short message aggregation service according to the temporary main data source;
and when the host is not down, the application program provides short message aggregation service according to the main data source.
Further, the detecting whether the host is down includes the following steps:
acquiring data source configuration information every other preset time period;
the method comprises the following steps of upgrading a cold standby data source to a temporary main data source when a host is down, and broadcasting and informing an application program, so that the application program provides short message aggregation service according to the temporary main data source, wherein the short message aggregation service comprises the following steps:
when the host is down, the cold standby data source is upgraded to a temporary main data source;
initializing a main data source, and creating a first data source object according to newly acquired data source configuration information;
performing data source configuration according to the cold standby data source configuration information in the newly acquired data source configuration information;
and broadcasting and sending data source switching information after the configuration is completed, so that the application program can access the temporary main data source through switching of the first data source object, and the application program can provide short message aggregation service according to the temporary main data source.
Further, the detecting whether the host is down includes the following steps:
acquiring data source configuration information every other preset time period;
the application program provides short message aggregation service according to the main data source when the host is not down, and the method comprises the following steps:
initializing a main data source when the host is not down, and creating a second data source object according to newly acquired data source configuration information;
and broadcasting object creation information after creation is completed so that the application program can access the main data source through the second data source object and provide short message aggregation service according to the main data source.
Further, the detecting whether the host is down includes the steps of:
and when the heartbeat messages from the host are not received within the preset time, determining that the host is down.
The invention also provides a system for realizing data source switching, which comprises:
the detection module is used for detecting whether the host is down;
the processing module is used for upgrading the cold standby data source into a temporary main data source and broadcasting and informing an application program when the host is down, so that the application program provides short message aggregation service according to the temporary main data source;
and the processing module is also used for providing short message aggregation service for the application program according to the main data source when the host is not down.
Further, the method also comprises the following steps:
the acquisition module is used for acquiring data source configuration information every other preset time period;
the processing module comprises:
the first processing unit is used for upgrading the cold standby data source into a temporary main data source when the host is down;
the first creating unit is used for initializing the main data source and creating a first data source object according to the newly acquired data source configuration information;
the configuration unit is used for configuring the data source according to the cold standby data source configuration information in the newly acquired data source configuration information;
and the execution unit is used for broadcasting and sending data source switching information after the configuration is completed, so that the application program can access the temporary main data source through the switching of the first data source object, and the application program can provide short message aggregation service according to the temporary main data source.
Further, the processing module comprises:
the second creating unit is used for initializing the main data source when the host is not down and creating a second data source object according to the newly acquired data source configuration information;
and the second execution unit is used for broadcasting the object creation information after creation is completed so that the application program can access the main data source through the second data source object and provide short message aggregation service according to the main data source.
Further, the detection module is further configured to determine that the host is down when the heartbeat message from the host is not received within a preset time period.
The invention also provides a terminal device, which comprises a processor, a memory and a computer program stored in the memory and capable of running on the processor, wherein the processor is used for executing the computer program stored on the memory and realizing the operation executed by the implementation method for switching the data source.
The present invention also provides a storage medium, wherein the storage medium stores at least one instruction, and the instruction is loaded and executed by a processor to implement the operations performed by the implementation method for switching data sources.
The implementation method, the system, the terminal equipment and the storage medium for switching the data source can provide continuously available short message capability so as to replace the data source under the condition of not restarting, thereby providing reliable and stable short message aggregation service for users.
Drawings
The above features, technical features, advantages and implementations of a method, a system, a terminal device and a storage medium for switching data sources will be further described in the following preferred embodiments in a clearly understandable manner with reference to the accompanying drawings.
FIG. 1 is a flow chart of one embodiment of a method for implementing a handoff of a data source of the present invention;
FIG. 2 is a flow chart of another embodiment of a method for implementing switching data sources of the present invention;
FIG. 3 is a flow chart of another embodiment of a method for implementing switching data sources of the present invention;
FIG. 4 is a flow chart of another embodiment of a method for implementing a handoff of a data source of the present invention;
FIG. 5 is a flow chart of another embodiment of a method for implementing switching data sources of the present invention;
FIG. 6 is a flow chart of another embodiment of a method for implementing switching data sources of the present invention;
FIG. 7 is a block diagram illustrating an embodiment of a system for switching data sources according to the present invention;
FIG. 8 is a flow chart illustrating configuration of an apollo configuration center according to the present invention;
FIG. 9 is a flow chart illustrating configuration of an apollo configuration center according to the present invention;
FIG. 10 is a schematic diagram of a computer device according to an embodiment of the present invention.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. However, it will be apparent to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
It will be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
For the sake of simplicity, the drawings only schematically show the parts relevant to the present invention, and they do not represent the actual structure as a product. In addition, in order to make the drawings concise and understandable, components having the same structure or function in some of the drawings are only schematically illustrated or only labeled. In this document, "one" means not only "only one" but also a case of "more than one".
It should be further understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
In particular implementations, the terminal devices described in embodiments of the present application include, but are not limited to, other portable devices such as mobile phones, laptop computers, or tablet computers having touch sensitive surfaces (e.g., touch screen displays and/or touch pads).
The terminal device supports various applications, such as one or more of the following: a drawing application, a presentation application, a network creation application, a word processing application, a disc burning application, a spreadsheet application, a gaming application, a telephone application, a video conferencing application, an email application, an instant messaging application, an exercise support application, a photo management application, a digital camera application, a digital video camera application, a Web browsing application, a digital music player application, and/or a digital video player application.
In addition, in the description of the present application, the terms "first", "second", and the like are used only for distinguishing the description, and are not intended to indicate or imply relative importance.
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following description will be made with reference to the accompanying drawings. It is obvious that the drawings in the following description are only some examples of the invention, and that for a person skilled in the art, other drawings and embodiments can be derived from them without inventive effort.
An embodiment of the present invention, as shown in fig. 1, is an implementation method for switching data sources, including:
s100, detecting whether a host is down;
specifically, the sms aggregation service is a basic capability of a sms communication service provided for a user, and is generally referred to as a sms sending service. The short message aggregation service comprises communication services such as group sending short messages, short message verification codes, short message notification, promotion short messages, marketing short messages and member notification short messages. The short message notification supports the notification short message sending of various scenes. The popularization short message supports the short message notification sending of various service scenes, such as the communication services of industry short message group sending and the like, including the support of business ultra-short message group sending, real estate short message group sending, education short message group sending, telephone business short message group sending, credit card short message group sending, recruitment short message group sending and the like.
S200, when the host is down, the cold standby data source is upgraded to a temporary main data source and the application program is informed of the cold standby data source in a broadcast mode, so that the application program provides short message aggregation service according to the temporary main data source;
s300, when the host is not down, the application program provides short message aggregation service according to the main data source.
Specifically, in this embodiment, when the host is down, the cold standby data source is upgraded to the temporary main data source, and the application program is notified by broadcasting, so that the application program provides the short message aggregation service according to the temporary main data source, and the short message aggregation service does not need to be restarted when the data sources are switched, and a new data source is automatically loaded, thereby reducing the unstable time of the service, reducing the time for modifying the configuration, and being friendly to operation and maintenance.
In addition, when the host is down, the cold standby data source is upgraded to the temporary main data source and the application program is informed of the temporary main data source in a broadcasting mode, so that the application program provides short message aggregation service according to the temporary main data source, the data source switching efficiency is improved, the situation that the data source cannot be switched in time when the host is down actually is avoided, the stability of the short message aggregation service is further guaranteed, and the use experience of a user is improved.
An embodiment of the present invention, as shown in fig. 2, is an implementation method for switching data sources, including:
s010 acquires data source configuration information at intervals of a preset time period;
s100, detecting whether a host is down;
s210, when the host is down, the cold standby data source is upgraded to a temporary main data source;
s220, initializing a main data source, and creating a first data source object according to newly acquired data source configuration information;
s230, configuring a data source according to the cold standby data source configuration information in the newly acquired data source configuration information;
s240, after the configuration is completed, data source switching information is broadcast and sent, so that the application program can access the temporary main data source through switching of the first data source object, and the application program can provide short message aggregation service according to the temporary main data source;
s300, when the host is not down, the application program provides short message aggregation service according to the main data source.
Specifically, the parts of this embodiment that are the same as the parts of the above embodiment are not described in detail herein. In this embodiment, the data source configuration information is acquired every preset time period, and the acquired data source configuration information includes druidProperties (configuration of a main data source), namespace (name of an apollo space where the configuration of a standby data source is located), name (name of an attribute source), prefix (attribute prefix), and key (attribute key for switching a data source switch).
As shown in fig. 8 and 9, when the host is down, the data source configuration corresponding to the namespace in the apollo configuration center is modified, that is, the namespace (the name of the apollo space where the spare data source configuration is located) is written into the apollo configuration center,
And newly building a first data source object, specifically, initializing the Builder according to the data source configuration information and a corresponding method of the Builder, and calling a build () method to create the first data source object, so that the application program can use the newly-created first data source object as a common data source, wherein the first data source object is a cold-standby data source upgraded to a temporary main data source.
And modifying the key value to true, namely switching the main data source to a cold standby data source, monitoring the change of the key value by Apollo HotReclaceS WitchListener, and calling a handle method of Apollo DruidSourceHandler to perform data source switching operation. And broadcasting to inform the application program that the configuration is switched to a cold-standby database, wherein the New Builder initializes the Builder according to the information and the corresponding method of the Builder, calls the build () method to create a first data source object, and the application program can use the cold-standby data source like a common data source.
When the host is down, the cold standby data source is upgraded to the temporary main data source and the application program is informed of the update of the cold standby data source in a broadcasting mode, so that the application program provides short message aggregation service according to the temporary main data source, the short message aggregation service does not need to be restarted when the data sources are switched, the new data source is automatically loaded, the unstable service time is reduced, the configuration modification time is reduced, and the operation and maintenance are friendly.
In addition, when the host is down, the cold standby data source is upgraded to the temporary main data source and the application program is informed of the temporary main data source in a broadcasting mode, so that the application program provides short message aggregation service according to the temporary main data source, the data source switching efficiency is improved, the situation that the data source cannot be switched in time when the host is down actually is avoided, the stability of the short message aggregation service is further guaranteed, and the use experience of a user is improved.
An embodiment of the present invention, as shown in fig. 3, is an implementation method for switching data sources, including:
s010 acquires data source configuration information at intervals of a preset time period;
s100, detecting whether a host is down;
s200, when the host is down, the cold standby data source is upgraded to a temporary main data source and the application program is informed of the cold standby data source in a broadcast mode, so that the application program provides short message aggregation service according to the temporary main data source;
s310, initializing a main data source when a host is not down, and creating a second data source object according to newly acquired data source configuration information;
and S320, broadcasting the object creating information after creating is completed, so that the application program accesses the main data source through the second data source object, and the application program provides the short message aggregation service according to the main data source.
Specifically, the parts of this embodiment that are the same as the parts of the above embodiment are not described in detail herein. In this embodiment, the data source configuration information is acquired every preset time period, and the acquired data source configuration information includes druidProperties (configuration of a main data source), namespace (name of an apollo space where the configuration of a standby data source is located), name (name of an attribute source), prefix (attribute prefix), and key (attribute key for switching a data source switch).
As shown in fig. 8 and fig. 9, New build is to create a data source object, specifically, initialize the build according to the above data source configuration information and the corresponding method of the build, and invoke the build () method to create a second data source object, so that the application program can use the newly created second data source object as a common data source, where the second data source object is upgraded to a main data source.
Modify key-false, this step is to roll back the master data source, the apolllo hotracuseswitchlistener monitors the change in key, calls the rollback method of apolllo druidsourcehandler to roll back the master data source according to druidProperties.
Specifically, in this embodiment, when the host is down, the cold standby data source is upgraded to the temporary main data source, and the application program is notified by broadcasting, so that the application program provides the short message aggregation service according to the temporary main data source, and the short message aggregation service does not need to be restarted when the data sources are switched, and a new data source is automatically loaded, thereby reducing the unstable time of the service, reducing the time for modifying the configuration, and being friendly to operation and maintenance.
In addition, when the host is down, the cold standby data source is upgraded to the temporary main data source and the application program is informed of the temporary main data source in a broadcasting mode, so that the application program provides short message aggregation service according to the temporary main data source, the data source switching efficiency is improved, the situation that the data source cannot be switched in time when the host is down actually is avoided, the stability of the short message aggregation service is further guaranteed, and the use experience of a user is improved.
An embodiment of the present invention, as shown in fig. 4, is an implementation method for switching data sources, including:
s010 acquires data source configuration information at intervals of a preset time period;
s110, when the heartbeat messages from the host computer are not received within a preset time length, determining that the host computer is down;
s210, when the host is down, the cold standby data source is upgraded to a temporary main data source;
s220, initializing a main data source, and creating a first data source object according to newly acquired data source configuration information;
s230, configuring a data source according to the cold standby data source configuration information in the newly acquired data source configuration information;
s240, after the configuration is completed, data source switching information is broadcast and sent, so that the application program can access the temporary main data source through switching of the first data source object, and the application program can provide short message aggregation service according to the temporary main data source;
s300, when the host is not down, the application program provides short message aggregation service according to the main data source.
Specifically, the parts of this embodiment that are the same as the parts of the above embodiment are not described in detail herein. In the implementation scenario of the embodiment of the present invention, the server may perform heartbeat detection on the host. The server may be a node having a heartbeat detection mechanism and capable of receiving heartbeat messages, and the host may be a node having a heartbeat detection mechanism and capable of sending heartbeat messages.
In the implementation scenario of the embodiment of the present invention, the host may send the heartbeat message to the server at regular time intervals. The method comprises the steps that a heartbeat message from a host is received from a server as a starting moment, if the server receives the next heartbeat message from the host within a heartbeat timeout duration, the host is judged to be in a normal working state, if the server does not receive the next heartbeat message from the host within the heartbeat timeout duration, the host is judged to be down, wherein the down of the host can be considered that the host stops working, and the working efficiency of the host is obviously lower than the normal working efficiency, because the condition and the condition that the host stops working can be considered to be the same as the condition that the host stops working, the same treatment is carried out.
In the implementation scenario of the embodiment of the present invention, the server may also send the request message to the host, and the host may send the heartbeat message to the server after receiving the request message when the host is not down. The method comprises the steps that a request message sent by a slave server is used as a starting moment, if the server receives heartbeat messages from a host within a heartbeat timeout duration, the host is judged to be in a normal working state, and if the server does not receive the heartbeat messages from the host within the heartbeat timeout duration, the host is judged to be down.
Through this embodiment, carry out the host computer through the mode of heartbeat mechanism and detect that the machine is down, avoid artifical subjective judgement host computer whether down, because the automatic intelligent judgement in backstage detects whether the host computer is down, in case detect out when the host computer is down, just can switch the data source, promote the accuracy and the efficiency that the data source switched, can't in time switch the condition of data source when avoiding the host computer to actually be down, and then guaranteed SMS polymerization service's stability, promote user's use and experience.
An embodiment of the present invention, as shown in fig. 5, is an implementation method for switching data sources, including:
s010 acquires data source configuration information at intervals of a preset time period;
s110, when the heartbeat messages from the host computer are not received within a preset time length, determining that the host computer is down;
s200, when the host is down, the cold standby data source is upgraded to a temporary main data source and the application program is informed of the cold standby data source in a broadcast mode, so that the application program provides short message aggregation service according to the temporary main data source;
s310, initializing a main data source when a host is not down, and creating a second data source object according to newly acquired data source configuration information;
and S320, broadcasting the object creating information after creating is completed, so that the application program accesses the main data source through the second data source object, and the application program provides the short message aggregation service according to the main data source.
Specifically, the parts of this embodiment that are the same as the parts of the above embodiment are not described in detail herein.
An embodiment of the present invention, as shown in fig. 6, is an implementation method for switching data sources, including:
s010 acquires data source configuration information at intervals of a preset time period;
s110, when the heartbeat messages from the host computer are not received within a preset time length, determining that the host computer is down;
s210, when the host is down, the cold standby data source is upgraded to a temporary main data source;
s220, initializing a main data source, and creating a first data source object according to newly acquired data source configuration information;
s230, configuring a data source according to the cold standby data source configuration information in the newly acquired data source configuration information;
s240, after the configuration is completed, data source switching information is broadcast and sent, so that the application program can access the temporary main data source through switching of the first data source object, and the application program can provide short message aggregation service according to the temporary main data source;
s310, initializing a main data source when a host is not down, and creating a second data source object according to newly acquired data source configuration information;
and S320, broadcasting the object creating information after creating is completed, so that the application program accesses the main data source through the second data source object, and the application program provides the short message aggregation service according to the main data source.
Specifically, the parts of this embodiment that are the same as the parts of the above embodiment are not described in detail herein.
For example, as shown in fig. 8 and fig. 9, an Apollo (Apollo) configuration center is an open source configuration management center, and the Apollo configuration center is an open source configuration management center, and can centrally manage the configurations of different environments and different clusters, and can push the configurations to an application end in real time after configuration modification, and has characteristics of standard authority, process management, and the like.
The Apollo configuration center provides a unified interface for centrally managing the configuration of different environments (environment), different clusters (cluster) and different namespaces (namespace).
The same code is deployed in different clusters, and can have different configurations, such as addresses of zookeeper.
Sharing of the same configuration by multiple different applications can be conveniently supported through a namespace (namespace), while also allowing applications to override the shared configuration.
After the user modifies the configuration and releases the configuration in the Apollo configuration center, the client can receive the latest configuration in real time (1 second) and notify the application program.
All configuration releases have a version concept so that rollback of configurations can be conveniently supported.
Once the host is down, operation and maintenance personnel switch, configure and release the data source in the Apollo configuration center, the Apollo configuration center informs the host of configuration update, the host pulls the latest configuration from the Apollo configuration center, namely, updates and configures the data source information, then the Apollo configuration center updates the local configuration and informs the application program, and the short message aggregation service is realized without restarting and the effect of automatically loading a new data source through a data source heat replacement method. In this embodiment, because the Apollo configuration center monitors the attribute information for configuring the data source switching (i.e., the attribute key for switching the data source switch), the data source switching method can actively push the application program in the cluster scale, and the delay is low, so that the application program can acquire a new data source configuration during running, create a new data source to replace an old data source, enable the host to read the data information of the cold-standby data source switched to the temporary main data source without restarting the application program, and further provide the short message aggregation service according to the data information of the cold-standby data source. The accuracy and the efficiency of data source switching are improved, the situation that the data source cannot be switched in time when the host is in actual downtime is avoided, the stability of short message aggregation service is further ensured, and the use experience of users is improved.
The above embodiments only exemplify the Apollo configuration center, and the Apollo configuration center may be replaced by a Zookeeper configuration center or a redis configuration center, a nacos configuration center, as required.
One embodiment of the present invention, as shown in fig. 7, is an implementation system for switching data sources, including:
the detecting module 10 is used for detecting whether the host is down;
the processing module 20 is configured to upgrade the cold standby data source to a temporary main data source and broadcast and inform the application program when the host is down, so that the application program provides a short message aggregation service according to the temporary main data source;
the processing module 20 is further configured to provide a short message aggregation service according to the main data source by the application program when the host is not down.
Specifically, the sms aggregation service is a basic capability of a sms communication service provided for a user, and is generally referred to as a sms sending service. The short message aggregation service comprises communication services such as group sending short messages, short message verification codes, short message notification, promotion short messages, marketing short messages and member notification short messages. The short message notification supports the notification short message sending of various scenes. The popularization short message supports the short message notification sending of various service scenes, such as the communication services of industry short message group sending and the like, including the support of business ultra-short message group sending, real estate short message group sending, education short message group sending, telephone business short message group sending, credit card short message group sending, recruitment short message group sending and the like.
Specifically, in this embodiment, when the host is down, the cold standby data source is upgraded to the temporary main data source, and the application program is notified by broadcasting, so that the application program provides the short message aggregation service according to the temporary main data source, and the short message aggregation service does not need to be restarted when the data sources are switched, and a new data source is automatically loaded, thereby reducing the unstable time of the service, reducing the time for modifying the configuration, and being friendly to operation and maintenance.
In addition, when the host is down, the cold standby data source is upgraded to the temporary main data source and the application program is informed of the temporary main data source in a broadcasting mode, so that the application program provides short message aggregation service according to the temporary main data source, the data source switching efficiency is improved, the situation that the data source cannot be switched in time when the host is down actually is avoided, the stability of the short message aggregation service is further guaranteed, and the use experience of a user is improved.
Based on the foregoing embodiment, further comprising: the acquisition module is used for acquiring data source configuration information every other preset time period;
the processing module 20 includes:
the first processing unit is used for upgrading the cold standby data source into a temporary main data source when the host is down;
the first creating unit is used for initializing the main data source and creating a first data source object according to the newly acquired data source configuration information;
the configuration unit is used for configuring the data source according to the cold standby data source configuration information in the newly acquired data source configuration information;
the execution unit is used for broadcasting and sending data source switching information after the configuration is completed, so that the application program can access the temporary main data source through the switching of the first data source object, and the application program can provide short message aggregation service according to the temporary main data source;
specifically, the parts of this embodiment that are the same as the parts of the above embodiment are not described in detail herein. In this embodiment, the data source configuration information is acquired every preset time period, and the acquired data source configuration information includes druidProperties (configuration of a main data source), namespace (name of an apollo space where the configuration of a standby data source is located), name (name of an attribute source), prefix (attribute prefix), and key (attribute key for switching a data source switch).
As shown in fig. 8 and 9, when the host is down, the data source configuration corresponding to the namespace in the apollo configuration center is modified, that is, the namespace (the name of the apollo space where the spare data source configuration is located) is written into the apollo configuration center,
And newly building a first data source object, specifically, initializing the Builder according to the data source configuration information and a corresponding method of the Builder, and calling a build () method to create the first data source object, so that the application program can use the newly-created first data source object as a common data source, wherein the first data source object is a cold-standby data source upgraded to a temporary main data source.
And modifying the key value to true, namely switching the main data source to a cold standby data source, monitoring the change of the key value by Apollo HotReclaceS WitchListener, and calling a handle method of Apollo DruidSourceHandler to perform data source switching operation. And broadcasting to inform the application program that the configuration is switched to a cold-standby database, wherein the New Builder initializes the Builder according to the information and the corresponding method of the Builder, calls the build () method to create a first data source object, and the application program can use the cold-standby data source like a common data source.
When the host is down, the cold standby data source is upgraded to the temporary main data source and the application program is informed of the update of the cold standby data source in a broadcasting mode, so that the application program provides short message aggregation service according to the temporary main data source, the short message aggregation service does not need to be restarted when the data sources are switched, the new data source is automatically loaded, the unstable service time is reduced, the configuration modification time is reduced, and the operation and maintenance are friendly.
In addition, when the host is down, the cold standby data source is upgraded to the temporary main data source and the application program is informed of the temporary main data source in a broadcasting mode, so that the application program provides short message aggregation service according to the temporary main data source, the data source switching efficiency is improved, the situation that the data source cannot be switched in time when the host is down actually is avoided, the stability of the short message aggregation service is further guaranteed, and the use experience of a user is improved.
The processing module 20 includes:
the second creating unit is used for initializing the main data source when the host is not down and creating a second data source object according to the newly acquired data source configuration information;
and the second execution unit is used for broadcasting the object creation information after creation is completed, so that the application program can access the main data source through the second data source object, and the application program can provide the short message aggregation service according to the main data source.
Specifically, the parts of this embodiment that are the same as the parts of the above embodiment are not described in detail herein. In this embodiment, the data source configuration information is acquired every preset time period, and the acquired data source configuration information includes druidProperties (configuration of a main data source), namespace (name of an apollo space where the configuration of a standby data source is located), name (name of an attribute source), prefix (attribute prefix), and key (attribute key for switching a data source switch).
As shown in fig. 8 and 9, when the host is down, the data source configuration corresponding to the namespace in the apollo configuration center is modified, that is, the namespace (the name of the apollo space where the spare data source configuration is located) is written into the apollo configuration center,
And newly building a first data source object, specifically, initializing the Builder according to the data source configuration information and a corresponding method of the Builder, and calling a build () method to create the first data source object, so that the application program can use the newly-created first data source object as a common data source, wherein the first data source object is a cold-standby data source upgraded to a temporary main data source.
And modifying the key value to true, namely switching the main data source to a cold standby data source, monitoring the change of the key value by Apollo HotReclaceS WitchListener, and calling a handle method of Apollo DruidSourceHandler to perform data source switching operation. And broadcasting to inform the application program that the configuration is switched to a cold-standby database, wherein the New Builder initializes the Builder according to the information and the corresponding method of the Builder, calls the build () method to create a first data source object, and the application program can use the cold-standby data source like a common data source.
When the host is down, the cold standby data source is upgraded to the temporary main data source and the application program is informed of the update of the cold standby data source in a broadcasting mode, so that the application program provides short message aggregation service according to the temporary main data source, the short message aggregation service does not need to be restarted when the data sources are switched, the new data source is automatically loaded, the unstable service time is reduced, the configuration modification time is reduced, and the operation and maintenance are friendly.
In addition, when the host is down, the cold standby data source is upgraded to the temporary main data source and the application program is informed of the temporary main data source in a broadcasting mode, so that the application program provides short message aggregation service according to the temporary main data source, the data source switching efficiency is improved, the situation that the data source cannot be switched in time when the host is down actually is avoided, the stability of the short message aggregation service is further guaranteed, and the use experience of a user is improved.
Based on the foregoing embodiment, the detecting module 10 is further configured to determine that the host is down when the heartbeat message from the host is not received within a preset time period.
Specifically, the parts of this embodiment that are the same as the parts of the above embodiment are not described in detail herein. In the implementation scenario of the embodiment of the present invention, the server may perform heartbeat detection on the host. The server may be a node having a heartbeat detection mechanism and capable of receiving heartbeat messages, and the host may be a node having a heartbeat detection mechanism and capable of sending heartbeat messages.
In the implementation scenario of the embodiment of the present invention, the host may send the heartbeat message to the server at regular time intervals. The method comprises the steps that a heartbeat message from a host is received from a server as a starting moment, if the server receives the next heartbeat message from the host within a heartbeat timeout duration, the host is judged to be in a normal working state, if the server does not receive the next heartbeat message from the host within the heartbeat timeout duration, the host is judged to be down, wherein the down of the host can be considered that the host stops working, and the working efficiency of the host is obviously lower than the normal working efficiency, because the condition and the condition that the host stops working can be considered to be the same as the condition that the host stops working, the same treatment is carried out.
In the implementation scenario of the embodiment of the present invention, the server may also send the request message to the host, and the host may send the heartbeat message to the server after receiving the request message when the host is not down. The method comprises the steps that a request message sent by a slave server is used as a starting moment, if the server receives heartbeat messages from a host within a heartbeat timeout duration, the host is judged to be in a normal working state, and if the server does not receive the heartbeat messages from the host within the heartbeat timeout duration, the host is judged to be down.
Through this embodiment, carry out the host computer through the mode of heartbeat mechanism and detect that the machine is down, avoid artifical subjective judgement host computer whether down, because the automatic intelligent judgement in backstage detects whether the host computer is down, in case detect out when the host computer is down, just can switch the data source, promote the accuracy and the efficiency that the data source switched, can't in time switch the condition of data source when avoiding the host computer to actually be down, and then guaranteed SMS polymerization service's stability, promote user's use and experience.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of program modules is illustrated, and in practical applications, the above-described distribution of functions may be performed by different program modules, that is, the internal structure of the apparatus may be divided into different program units or modules to perform all or part of the above-described functions. Each program module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one processing unit, and the integrated unit may be implemented in a form of hardware, or may be implemented in a form of software program unit. In addition, the specific names of the program modules are only used for distinguishing the program modules from one another, and are not used for limiting the protection scope of the application.
One embodiment of the present invention, as shown in fig. 10, a terminal device 100, includes a processor 110, a memory 120, wherein the memory 120 is used for storing a computer program 121; the processor 110 is configured to execute the computer program 121 stored in the memory 120 to implement the method for switching data sources in any one of the corresponding method embodiments of fig. 1 to fig. 6.
The terminal device 100 may be a desktop computer, a notebook, a palm computer, a tablet computer, a mobile phone, a human-computer interaction screen, or the like. The terminal device 100 may include, but is not limited to, a processor 110, a memory 120. Those skilled in the art will appreciate that fig. 10 is merely an example of the terminal device 100, does not constitute a limitation of the terminal device 100, and may include more or less components than those shown, or combine certain components, or different components, such as: the terminal device 100 may also include input/output interfaces, display devices, network access devices, communication buses, communication interfaces, and the like. A communication interface and a communication bus, and may further include an input/output interface, wherein the processor 110, the memory 120, the input/output interface and the communication interface complete communication with each other through the communication bus. The memory 120 stores a computer program 121, and the processor 110 is configured to execute the computer program 121 stored in the memory 120 to implement the method for switching data sources in any one of the corresponding method embodiments of fig. 1 to 6.
The Processor 110 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 120 may be an internal storage unit of the terminal device 100, such as: hard disk or memory of the terminal device. The memory may also be an external storage device of the terminal device, such as: the terminal equipment is provided with a plug-in hard disk, an intelligent memory Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card) and the like. Further, the memory 120 may also include both an internal storage unit and an external storage device of the terminal device 100. The memory 120 is used for storing the computer program 121 and other programs and data required by the terminal device 100. The memory may also be used to temporarily store data that has been output or is to be output.
A communication bus is a circuit that connects the described elements and enables transmission between the elements. For example, the processor 110 receives commands from other elements through the communication bus, decrypts the received commands, and performs calculations or data processing according to the decrypted commands. The memory 120 may include program modules such as a kernel (kernel), middleware (middleware), an Application Programming Interface (API), and applications. The program modules may be comprised of software, firmware or hardware, or at least two of the same. The input/output interface forwards commands or data entered by a user via the input/output interface (e.g., sensor, keyboard, touch screen). The communication interface connects the terminal device 100 with other network devices, user equipment, networks. For example, the communication interface may be connected to a network by wire or wirelessly to connect to external other network devices or user devices. The wireless communication may include at least one of: wireless fidelity (WiFi), Bluetooth (BT), Near Field Communication (NFC), Global Positioning Satellite (GPS) and cellular communications, among others. The wired communication may include at least one of: universal Serial Bus (USB), high-definition multimedia interface (HDMI), asynchronous transfer standard interface (RS-232), and the like. The network may be a telecommunications network and a communications network. The communication network may be a computer network, the internet of things, a telephone network. The terminal device 100 may be connected to the network through a communication interface, and a protocol by which the terminal device 100 communicates with other network devices may be supported by at least one of an application, an Application Programming Interface (API), middleware, a kernel, and a communication interface.
In an embodiment of the present invention, a storage medium stores at least one instruction, and the instruction is loaded and executed by a processor to implement the operations performed by the corresponding embodiment of the method for implementing switching data sources in any one of fig. 1 to 6. For example, the storage medium may be a read-only memory (ROM), a Random Access Memory (RAM), a compact disc read-only memory (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, and the like.
They may be implemented in program code that is executable by a computing device such that it is executed by the computing device, or separately, or as individual integrated circuit modules, or as a plurality or steps of individual integrated circuit modules. Thus, the present invention is not limited to any specific combination of hardware and software.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or recited in detail in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/terminal device and method may be implemented in other ways. For example, the above-described embodiments of the apparatus/terminal device are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated modules/units may be stored in a storage medium if they are implemented in the form of software functional units and sold or used as separate products. Based on such understanding, all or part of the flow in the method according to the embodiments of the present invention may also be implemented by sending instructions to relevant hardware by the computer program 121, where the computer program 121 may be stored in a storage medium, and when the computer program 121 is executed by a processor, the steps of the above-described embodiments of the method may be implemented. The computer program 121 may be in a source code form, an object code form, an executable file or some intermediate form, etc. The storage medium may include: any entity or device capable of carrying the computer program 121, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signal, telecommunication signal, and software distribution medium, etc. It should be noted that the content of the storage medium may be increased or decreased as appropriate according to the requirements of legislation and patent practice in the jurisdiction, for example: in certain jurisdictions, in accordance with legislation and patent practice, computer-readable storage media do not include electrical carrier signals and telecommunications signals.
It should be noted that the above embodiments can be freely combined as necessary. The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

Claims (10)

1. An implementation method for switching data sources is characterized by comprising the following steps:
detecting whether a host is down;
when a host is down, a cold standby data source is upgraded to a temporary main data source and an application program is informed of the update of the cold standby data source through broadcasting, so that the application program provides short message aggregation service according to the temporary main data source;
and when the host is not down, the application program provides short message aggregation service according to the main data source.
2. The method for implementing switching data sources according to claim 1, wherein the detecting whether the host is down includes the steps of:
acquiring data source configuration information every other preset time period;
the method comprises the following steps of upgrading a cold standby data source to a temporary main data source when a host is down, and broadcasting and informing an application program, so that the application program provides short message aggregation service according to the temporary main data source, wherein the short message aggregation service comprises the following steps:
when the host is down, the cold standby data source is upgraded to a temporary main data source;
initializing a main data source, and creating a first data source object according to newly acquired data source configuration information;
performing data source configuration according to the cold standby data source configuration information in the newly acquired data source configuration information;
and broadcasting and sending data source switching information after the configuration is completed, so that the application program can access the temporary main data source through switching of the first data source object, and the application program can provide short message aggregation service according to the temporary main data source.
3. The method for implementing switching data sources according to claim 1, wherein the detecting whether the host is down includes the steps of:
acquiring data source configuration information every other preset time period;
the application program provides short message aggregation service according to the main data source when the host is not down, and the method comprises the following steps:
initializing a main data source when the host is not down, and creating a second data source object according to newly acquired data source configuration information;
and broadcasting object creation information after creation is completed so that the application program can access the main data source through the second data source object and provide short message aggregation service according to the main data source.
4. The method for implementing switching data sources according to any one of claims 1 to 3, wherein the detecting whether the host is down includes the steps of:
and when the heartbeat messages from the host are not received within the preset time, determining that the host is down.
5. An implementation system for switching data sources, comprising:
the detection module is used for detecting whether the host is down;
the processing module is used for upgrading the cold standby data source into a temporary main data source and broadcasting and informing an application program when the host is down, so that the application program provides short message aggregation service according to the temporary main data source;
and the processing module is also used for providing short message aggregation service for the application program according to the main data source when the host is not down.
6. The system for switching data sources according to claim 5, further comprising:
the acquisition module is used for acquiring data source configuration information every other preset time period;
the processing module comprises:
the first processing unit is used for upgrading the cold standby data source into a temporary main data source when the host is down;
the first creating unit is used for initializing the main data source and creating a first data source object according to the newly acquired data source configuration information;
the configuration unit is used for configuring the data source according to the cold standby data source configuration information in the newly acquired data source configuration information;
and the execution unit is used for broadcasting and sending data source switching information after the configuration is completed, so that the application program can access the temporary main data source through the switching of the first data source object, and the application program can provide short message aggregation service according to the temporary main data source.
7. The system according to claim 6, wherein the processing module comprises:
the second creating unit is used for initializing the main data source when the host is not down and creating a second data source object according to the newly acquired data source configuration information;
and the second execution unit is used for broadcasting the object creation information after creation is completed so that the application program can access the main data source through the second data source object and provide short message aggregation service according to the main data source.
8. An implementation system for switching data sources according to any one of claims 6 to 7, characterized in that:
the detection module is further configured to determine that the host is down when the heartbeat message from the host is not received within a preset time period.
9. A terminal device, comprising a processor, a memory and a computer program stored in the memory and operable on the processor, wherein the processor is configured to execute the computer program stored in the memory to implement the operations performed by the method for implementing switching data sources according to any one of claims 1 to 4.
10. A storage medium, wherein at least one instruction is stored in the storage medium, and the instruction is loaded and executed by a processor to implement the operation performed by the implementation method for switching a data source according to any one of claims 1 to 4.
CN202010020808.1A 2020-01-09 2020-01-09 Method, system, terminal equipment and storage medium for realizing data source switching Pending CN111258810A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010020808.1A CN111258810A (en) 2020-01-09 2020-01-09 Method, system, terminal equipment and storage medium for realizing data source switching

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010020808.1A CN111258810A (en) 2020-01-09 2020-01-09 Method, system, terminal equipment and storage medium for realizing data source switching

Publications (1)

Publication Number Publication Date
CN111258810A true CN111258810A (en) 2020-06-09

Family

ID=70948586

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010020808.1A Pending CN111258810A (en) 2020-01-09 2020-01-09 Method, system, terminal equipment and storage medium for realizing data source switching

Country Status (1)

Country Link
CN (1) CN111258810A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111988398A (en) * 2020-08-19 2020-11-24 政采云有限公司 Data acquisition method, API gateway and medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2005111788A2 (en) * 2004-05-07 2005-11-24 Asempra Technologies, Inc. Moving real-time data events across devices in a network
CN108667930A (en) * 2018-05-09 2018-10-16 聚龙股份有限公司 A kind of configuration of dynamic data source and automation switching method
CN109471896A (en) * 2018-11-01 2019-03-15 数贸科技(北京)有限公司 Data source information dynamic altering method and device
CN110321337A (en) * 2019-06-24 2019-10-11 南威互联网科技集团有限公司 A kind of method and computer readable storage medium for realizing Database Dynamic switching

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2005111788A2 (en) * 2004-05-07 2005-11-24 Asempra Technologies, Inc. Moving real-time data events across devices in a network
CN108667930A (en) * 2018-05-09 2018-10-16 聚龙股份有限公司 A kind of configuration of dynamic data source and automation switching method
CN109471896A (en) * 2018-11-01 2019-03-15 数贸科技(北京)有限公司 Data source information dynamic altering method and device
CN110321337A (en) * 2019-06-24 2019-10-11 南威互联网科技集团有限公司 A kind of method and computer readable storage medium for realizing Database Dynamic switching

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
XU LIANG: "A design method of dual cold sparing system of attitude and orbit control computer" *
周丽媛: "综合监控系统的冗余功能设计" *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111988398A (en) * 2020-08-19 2020-11-24 政采云有限公司 Data acquisition method, API gateway and medium

Similar Documents

Publication Publication Date Title
CN114629865B (en) Instant messaging system for interacting with dynamically expanding applications
US20180129511A1 (en) Application store and intelligence system for networked telephony and digital media services devices
EP3547715A1 (en) Method and apparatus for reducing continuous-wakeup delay of bluetooth loudspeaker, and bluetooth loudspeaker
CN112464095B (en) Message pushing method, device, terminal and storage medium
US20230164543A1 (en) Nomination of a primary cell phone from a pool of cell phones
CN110716945A (en) Data updating method, data updating system, server and storage medium
WO2024109786A1 (en) Instant messaging session information processing method and apparatus, and electronic device
CN112486733B (en) System restoration method, device, terminal and storage medium
CN111258810A (en) Method, system, terminal equipment and storage medium for realizing data source switching
CN105453518B (en) Synchronization of metering networks
WO2015176498A1 (en) Software upgrade method, mobile terminal and computer storage medium
CN106775835B (en) Method, server and terminal for acquiring upgrade file
JP2021010164A (en) Method and apparatus for processing notification using notification preset
CN102833279A (en) Method, device and server for updating information
WO2023066246A1 (en) Method and system for installing application on cloudphone, and client cloudphone
CN113721936B (en) Application management method, intelligent terminal, device and storage medium
US11144312B2 (en) Management method for preset third-party applications, intelligent terminal and storage medium
WO2022083483A1 (en) Display control method and apparatus, terminal and storage medium
CN114610366A (en) Difference package upgrading method and system, intelligent electronic equipment and storage medium
CN110795194B (en) Desktop display control method, device, terminal and storage medium
US10891017B1 (en) Rotating icon selection and interaction software development kit (SDK)
CN115004139A (en) System and method for changing representation of application based on application state
CN111309367A (en) Method, device, medium and electronic equipment for managing service discovery
CN111176679A (en) Application program updating method and device
CN113709710B (en) Interface management 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