CN109101340A - Dynamic distribution method, device, equipment and the storage medium of barrage message - Google Patents

Dynamic distribution method, device, equipment and the storage medium of barrage message Download PDF

Info

Publication number
CN109101340A
CN109101340A CN201811086359.XA CN201811086359A CN109101340A CN 109101340 A CN109101340 A CN 109101340A CN 201811086359 A CN201811086359 A CN 201811086359A CN 109101340 A CN109101340 A CN 109101340A
Authority
CN
China
Prior art keywords
distribution
message
value
secondary distribution
pressure
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.)
Granted
Application number
CN201811086359.XA
Other languages
Chinese (zh)
Other versions
CN109101340B (en
Inventor
张磊
陈少杰
张文明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan Douyu Network Technology Co Ltd
Original Assignee
Wuhan Douyu Network 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 Wuhan Douyu Network Technology Co Ltd filed Critical Wuhan Douyu Network Technology Co Ltd
Priority to CN201811086359.XA priority Critical patent/CN109101340B/en
Publication of CN109101340A publication Critical patent/CN109101340A/en
Application granted granted Critical
Publication of CN109101340B publication Critical patent/CN109101340B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/505Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the load

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the invention discloses dynamic distribution method, device, equipment and the storage mediums of a kind of barrage message.This method comprises: obtaining distribution pressure parameter value corresponding with each secondary distribution object, wherein distribution pressure parameter includes at least one of history message bearing capacity, current residual message bearing rate, current CPU idleness and current residual memory size;The message pressure-bearing value of the secondary distribution object is determined according to the distribution pressure parameter value of the secondary distribution object and the parameters weighting value of the distribution pressure parameter for each secondary distribution object;Targeted secondary distribution object is determined according to the corresponding each message pressure-bearing value of each secondary distribution object, and by barrage message distribution to the targeted secondary distribution object.Through the above technical solutions, realizing the efficient distribution of barrage message, and improve the fault-tolerance of barrage message distribution.

Description

Dynamic distribution method, device, equipment and the storage medium of barrage message
Technical field
The present embodiments relate to barrage technology more particularly to a kind of dynamic distribution methods of barrage message, device, equipment And storage medium.
Background technique
Barrage message can be largely used in audio and video playing/live streaming application software.In general, barrage message be by transmission and The server (i.e. barrage server) of processing barrage message is sent to application software, then by having distribution barrage to disappear in application software The barrage distribution module of function is ceased by received barrage message distribution to each barrage receiving module.
When the amount for the barrage message that barrage server is sent is very big, the distribution pressure of single barrage distribution module compared with Greatly, it may appear that barrage message distribution not in time, or even lose barrage message the problem of.It in this case, can be in application software The multistage barrage distribution module of inside setting, such as a top barrage distribution module and multiple secondary barrage distribution modules, top Grade barrage distribution module gives received barrage message distribution to each secondary barrage distribution module, then by secondary barrage distribution module By barrage message distribution to each barrage receiving module.
In the above process top barrage distribution module be randomly or sequentially by a barrage message distribution to some Secondary barrage distribution module.But the processing time of every barrage message is unequal, can make each secondary barrage distribution module Barrage message distribution speed it is unequal so that the distribution pressure of some secondary barrage distribution modules is larger, and other Secondary barrage distribution module is more idle, is unfavorable for the efficient distribution of barrage message.
Summary of the invention
The embodiment of the present invention provides dynamic distribution method, device, equipment and the storage medium of a kind of barrage message, to realize The efficient distribution of barrage message, and improve the fault-tolerance of barrage message distribution.
In a first aspect, the embodiment of the invention provides a kind of dynamic distribution methods of barrage message, comprising:
Obtain distribution pressure parameter value corresponding with each secondary distribution object, wherein distribution pressure parameter includes history At least one of message bearing amount, current residual message bearing rate, current CPU idleness and current residual memory size;
For each secondary distribution object, distribution pressure parameter value and the distribution according to the secondary distribution object The parameters weighting value of pressure parameter determines the message pressure-bearing value of the secondary distribution object;
Targeted secondary distribution object is determined according to the corresponding each message pressure-bearing value of each secondary distribution object, And by barrage message distribution to the targeted secondary distribution object.
Second aspect, the embodiment of the invention also provides a kind of dynamic diostribution device of barrage message, which includes:
Parameter value obtains module, for obtaining distribution pressure parameter value corresponding with each secondary distribution object, wherein point Hair pressure parameter includes that history message bearing capacity, current residual message bearing rate, current CPU idleness and current residual memory hold At least one of amount;
Message pressure-bearing value determining module, for being directed to each secondary distribution object, according to the secondary distribution object The parameters weighting value for distributing pressure parameter value and the distribution pressure parameter, determines the message pressure-bearing of the secondary distribution object Value;
Barrage message distribution module, for according to the corresponding each message pressure-bearing value of each secondary distribution object Determine targeted secondary distribution object, and by barrage message distribution to the targeted secondary distribution object.
The third aspect, the embodiment of the invention also provides a kind of equipment, which includes:
One or more processors;
Storage device, for storing one or more programs,
When one or more of programs are executed by one or more of processors, so that one or more of processing Device realizes the dynamic distribution method of barrage message provided by any embodiment of the invention.
Fourth aspect, the embodiment of the invention also provides a kind of computer readable storage mediums, are stored thereon with computer Program, the computer program realize the dynamic distribution of barrage message provided by any embodiment of the invention when being executed by processor Method.
The embodiment of the present invention between top distribution object and multiple secondary distribution objects by being arranged barrage message distribution Load-balancing mechanism realize barrage message efficient distribution.Particular by the corresponding distribution of each secondary distribution object of acquisition Pressure parameter value realizes that load-balancing mechanism improves necessary load and calculates data for top distribution object.By according to secondary The distribution pressure parameter value of grade distribution object and the parameters weighting value for distributing pressure parameter, determine each secondary distribution object Message pressure-bearing value has more reasonably determined the measurement standard value of equally loaded.By corresponding according to each secondary distribution object Each message pressure-bearing value determine targeted secondary distribution object, and by barrage message distribution to targeted secondary distribution object, realize Load balancing during barrage message distribution improves the distribution efficiency and distribution fault-tolerance of barrage message.
Detailed description of the invention
Fig. 1 is the flow chart of the dynamic distribution method of one of embodiment of the present invention one barrage message;
Fig. 2 is the flow chart of the dynamic distribution method of one of embodiment of the present invention two barrage message;
Fig. 3 is the structural schematic diagram of the dynamic diostribution device of one of embodiment of the present invention three barrage message;
Fig. 4 is the structural schematic diagram of one of the embodiment of the present invention four equipment.
Specific embodiment
The present invention is described in further detail with reference to the accompanying drawings and examples.It is understood that this place is retouched The specific embodiment stated is used only for explaining the present invention rather than limiting the invention.It also should be noted that in order to just Only the parts related to the present invention are shown in description, attached drawing rather than entire infrastructure.
Embodiment one
The dynamic distribution method of barrage message provided in this embodiment is applicable to the audio-video in Android client and broadcasts The barrage message distribution in application software is put/be broadcast live, the tandem type barrage when barrage message number is more is particularly suitable for and disappears Breath distribution.This method can be executed by the dynamic diostribution device of barrage message, which can be by the side of software and/or hardware Formula realizes that the device, which can integrate, is being equipped with the audio and video playing based on android system/live streaming application software equipment In, such as typically subscriber terminal equipment, such as mobile phone, tablet computer or smart television etc..Holding in the embodiment of the present invention Row main body is top distribution object, mainly illustrates the load balancing process of top distribution object.Referring to Fig. 1, the side of the present embodiment Method specifically comprises the following steps:
S110, distribution pressure parameter value corresponding with each secondary distribution object is obtained.
Wherein, secondary distribution object refers to the reality that the barrage distribution class of next level of processing is distributed to barrage message Exampleization object.What is be oppositely arranged with secondary distribution object is top distribution object, is to be distributed processing to barrage message A upper level barrage distribution class instance object.Distribution pressure parameter is the barrage for referring to characterization secondary distribution object Message distribution pressure/load parameter.Distribution pressure parameter value refers to the value of distribution pressure parameter.
Specifically, top distribution object will realize the load balancing during barrage message distribution, just first obtain each Need to receive the distribution pressure parameter value of the secondary distribution object of barrage message.Distribute the acquisition of pressure parameter value in practical application Process can be the communication channel established between top distribution object and each secondary distribution object, so as to each secondary distribution pair As reporting, it distributes pressure parameter value or top distribution object reads it from each secondary distribution object and distributes pressure parameter value; It is also possible to using the system communication channel in android system, such as system broadcasts channel or third party's open source event bus EventBus is distributed pressure parameter value for each secondary distribution object and is delivered to above system communication channel, and top Distribution object receives the distribution pressure parameter value of each secondary distribution object from the system communication channel.
Illustratively, distribution pressure parameter includes history message bearing capacity, current residual message bearing rate, current CPU sky At least one of not busy rate and current residual memory size.Message bearing amount refers to stored to be distributed of secondary distribution object The quantity of the barrage message (barrage message i.e. to be distributed) of object is received to each barrage.History message bearing capacity refers to time fraction Message bearing amount during barrage message distribution of the object before this operation is sent out, message in set period of time is can be and holds The maximum value or mean value of carrying capacity, preferably mean value, more reasonably to reflect the distribution capability of the secondary distribution object.Message bearing Rate refers to the message bearing amount and its maximum message bearing capacity (i.e. message bearing total amount) that can be carried of secondary distribution object Percent value.Current residual message bearing rate refers to that the surplus of the message bearing amount of current time secondary distribution object is held with message Carry the percent value of total amount.Current CPU idleness refers to the system CPU idleness of current time Android client.It is current surplus Remaining memory size refers to the residual capacity of the Installed System Memory of current time Android client.The advantages of this arrangement are as follows can To reflect the loading condition of secondary distribution object from least one angle.
S120, it is directed to each secondary distribution object, the distribution pressure parameter value and distribution pressure according to secondary distribution object The parameters weighting value of force parameter determines the message pressure-bearing value of secondary distribution object.
Wherein, parameters weighting value refers to the numerical value of distribution pressure parameter proportion when determining message pressure-bearing value, is One value less than or equal to 1.Message pressure-bearing value refers to the barrage message distribution pressure that secondary distribution object is currently able to undertake Assessed value, the value is bigger, shows that secondary distribution object current time remains to the quantity of received barrage message to be distributed and gets over It is more.
Specifically, after the distribution pressure parameter value of top distribution object acquisition secondary distribution object, distribution can be calculated The sum of products (i.e. product accumulation and) of the corresponding parameters weighting value of pressure parameter value, obtains corresponding message pressure-bearing value. For each secondary distribution object, top distribution object is performed both by the solution procedure of above-mentioned message pressure-bearing value, can obtain more Multiple message pressure-bearing values of a secondary distribution object.
It illustratively, include current residual message bearing rate, current CPU idleness and current residual in distribution pressure parameter When memory size, parameters weighting value includes load-carry duty weighted value, CPU weight value and memory weighted value;According to secondary distribution object Distribution pressure parameter value and distribute pressure parameter parameters weighting value, determine that the message pressure-bearing value of secondary distribution object includes: According in current residual message bearing rate and load-carry duty weighted value, current CPU idleness and CPU weight value and current residual Capacity and memory weighted value are deposited, determines product accumulation and the message pressure-bearing value as secondary distribution object.
Specifically, current residual message bearing rate, current CPU sky are set by the distribution pressure parameter of secondary distribution object Not busy rate and three kinds of current residual memory size, with it is more accurate, characterize the loading condition of secondary distribution object comprehensively and in real time. So parameters weighting value respectively corresponds as load-carry duty weighted value, CPU weight value and memory weighted value.In this case message pressure-bearing Value is: message pressure-bearing value=current residual message bearing rate * load-carry duty weighted value+current CPU idleness * CPU weight value+when Preceding free memory capacity * memory weighted value.Wherein, above-mentioned three classes parameters weighting value can be the fixed number of preparatory empirical setting Value is also possible to carry out dynamic setting according to the actual conditions of Android client.
Illustratively, when parameters weighting value be preset fixed numbers when, load-carry duty weighted value, CPU weight value and Memory weighted value is respectively that the first default weighted value, the second default weighted value and third preset weighted value.
It specifically, can be most due to the parameter value that current residual message bearing rate is individually for secondary distribution object Intuitively reflect the loading condition of secondary distribution object, therefore one can be set by the first default weighted value (load-carry duty weighted value) A biggish value, such as 1.Current CPU idleness and current residual memory size are the real-time system letters of entire Android client Breath can reflect the loading condition of secondary distribution object indirectly, and consider consumption of the different barrage message for CPU Demand and the consumption requirements of memory difference, therefore second can be statistically determined according to the consumption requirements of a plurality of barrage message Default weighted value (CPU weight value) and third preset weighted value (memory weighted value), are such as disposed as 0.5.In this way, message bearing Measure the calculating formula of result are as follows: result=1*danmuAllow+0.5*cpuAvai+0.5*memAvai, wherein DanmuAllow, cpuAvai and memAvai are respectively in current residual message bearing rate, current CPU idleness and current residual Deposit capacity.
Illustratively, when parameters weighting value is the numerical value of dynamic setting, CPU weight value and memory weighted value are according to barrage The type of message of message determines.
It specifically, can be according to barrage message to be distributed every time when parameters weighting value is the numerical value of dynamic setting Type of message determines CPU weight value and memory weighted value, and CPU weight value and memory weighted value and be 1.For example, for First barrage message is business logic processing class barrage message, then the first barrage message just needs the consumption of CPU Ask higher, and it is lower to the consumption requirements of memory, then CPU weight value and memory weighted value can be respectively set to 0.8 and 0.2; And for Article 2 barrage message, class barrage message is handled for display, then the Article 2 barrage message is just to the consumption of CPU Demand is lower, and higher to the consumption requirements of memory, then CPU weight value and memory weighted value can be respectively set to 0.3 He 0.7.And the setting of load-carry duty weighted value can still keep the fixed numbers of empirical setting.At this moment message bearing amount result Calculating formula are as follows: result=1*danmuAllow+x*cpuAvai+ (1-x) * memAvai, wherein x and (1-x) are respectively CPU weight value and memory weighted value, for first barrage message, x 0.8;For Article 2 barrage message, x is then 0.3. Setting, which can to calculate resulting message pressure-bearing value, so more has barrage message specific aim, to more reasonably screen Targeted secondary distribution object out.
S130, targeted secondary distribution object is determined according to the corresponding each message pressure-bearing value of each secondary distribution object, and By barrage message distribution to targeted secondary distribution object.
Wherein, targeted secondary distribution object refers to the target object that barrage message needs to distribute, and is top distribution object Resulting secondary distribution object after progress load balancing.
Specifically, top distribution object determines maximum message pressure-bearing value from each message pressure-bearing value, which is disappeared The corresponding secondary distribution object of breath pressure-bearing value is determined as targeted secondary distribution object.Later, top distribution object passes through itself and mesh The through formula communication channel established between mark secondary distribution object, by barrage message distribution to the targeted secondary distribution object.
Above-mentioned through formula communication channel is to pre-establish in the following way: pre-defined one is distributed function comprising barrage The barrage distribution protocol public interface of the interface type of public void OnMessage (Message) Imessage { }, and make the secondary distribution Similar integral barrage distribution protocol.Then, in each secondary distribution Object Creation, lead to It crosses and the constructed fuction instantiation of secondary distribution class is called to generate each secondary distribution object, which is also association simultaneously Distribution object is discussed, the interior barrage comprising as call back function distributes function OnMessage.In each secondary distribution Object Creation Later, it is registered to top distribution object, so that top distribution object holds the adduction relationship of each secondary distribution object, until This just constructs above-mentioned through formula communication channel.So, the process of top distribution object distribution barrage message is: top distribution Object is using barrage message as function input parameters, and the barrage distribution function in targeted secondary distribution object for calling it to hold will Barrage message is transmitted to targeted secondary distribution object.It should be noted that the input parameter Message of barrage distribution function is only One abstract representation can be specifically arranged according to the data format or application demand of barrage message.
Illustratively, targeted secondary distribution object is determined according to the corresponding each message pressure-bearing value of each secondary distribution object It include: to store each message pressure-bearing value to carrying according to the storage order of secondary distribution object each in distribution object array It is worth array;Maximum message pressure-bearing value and its array indexing in bearing value array are determined according to bearing value array;From distribution pair As determining the corresponding secondary distribution object of array indexing in array, as targeted secondary distribution object.By having between element Two arrays of one-to-one relationship safeguard secondary distribution object and its message pressure-bearing value respectively, can effectively save in system It deposits.
Illustratively, targeted secondary distribution object is determined according to the corresponding each message pressure-bearing value of each secondary distribution object It include:, according to the object identity and message pressure-bearing value of secondary distribution object, to call bearing value for any one secondary distribution object The element of map set is inserted into function put (object identity, message pressure-bearing value), and the message pressure-bearing value of secondary distribution object is stored Gather to bearing value map;According to each bearing value map value in bearing value map set, maximum message pressure-bearing value is determined;With most Big message pressure-bearing value is function input parameters, calls the key of bearing value map set to obtain function getKey (Value), obtains most Big message pressure-bearing is worth corresponding bearing value map key;Using bearing value map key as function input parameters, distribution object map set is called Value obtain function getValue (Key), obtain distribution object map set in secondary distribution pair corresponding with bearing value map key As, as targeted secondary distribution object, wherein using object identity as key in distribution object map set, and it is corresponding with object identity Secondary distribution object be value.Safeguard that secondary distribution object and its message are held respectively by the consistent map set of two map keys Pressure value can efficiently manage each secondary distribution object and its message pressure-bearing value, to improve top distribution object distribution barrage The load-balancing efficiency of message.
The technical solution of the present embodiment, by obtaining the corresponding distribution pressure parameter value of each secondary distribution object, for top Grade distribution object implementatio8 load-balancing mechanism improves necessary load and calculates data.Pass through the distribution according to secondary distribution object The parameters weighting value of pressure parameter value and distribution pressure parameter, determines the message pressure-bearing value of each secondary distribution object, more The measurement standard value of equally loaded is reasonably determined.By according to the corresponding each message pressure-bearing value of each secondary distribution object It determines targeted secondary distribution object, and by barrage message distribution to targeted secondary distribution object, realizes barrage message distribution mistake Load balancing in journey improves the distribution efficiency and distribution fault-tolerance of barrage message.
Embodiment two
The present embodiment on the basis of the above embodiment 1, to " obtaining corresponding with each secondary distribution object distribution pressure Force parameter value " is advanced optimized.Wherein the explanation of term identical or corresponding with the various embodiments described above is no longer superfluous herein It states.Referring to fig. 2, the dynamic distribution method of barrage message provided in this embodiment includes:
S210, serializing object corresponding with each secondary distribution object is obtained.
Wherein, serializing object refers to the object of storage serialized data.
Specifically, the distribution pressure parameter value of secondary distribution object transfer, this reality are obtained for the ease of top distribution object It applies secondary distribution object in example to encapsulate distribution pressure parameter value obtained into an object, and sequence is carried out to the object Change operation, to generate a serializing object mSecondResponseStr.In this way, top distribution object can pass through acquisition The serializing object of secondary distribution object distributes pressure parameter value to obtain it, improves top distribution object and obtains each secondary The efficiency of the distribution pressure parameter value of distribution object.
It should be noted that the acquisition modes and distribution pressure of distribution pressure parameter value of the secondary distribution object acquisition in it Relating to parameters.Such as distribution pressure parameter is history message bearing capacity and/or current residual message bearing rate, then can pass through reading The daily record data of system is taken to obtain;Such as distribution pressure parameter be current CPU idleness and/or current residual memory size, It can then be obtained by reading system running state parameter.
Illustratively, S210 includes: for any one secondary distribution object, when the data of the event object in event bus When type is consistent with the data type of function input parameters of event message reception function in top distribution object, by calling thing Part message sink function obtains the event object of secondary distribution object, as the corresponding serializing object of secondary distribution object;Its In, event object be secondary distribution object by first event bus object reference event message delivery function to be distributed to event total In line;Top distribution object is preparatory by second event bus object reference registration function in the constructed fuction of top distribution class It is registered in event bus.
Wherein, event bus object is the object generated by third party's open source event bus EventBus, is to realize thing Part message dilivery or received practical executor.First event bus object refers to be generated in module belonging to secondary distribution object Event bus object, second event bus object refers to the event bus pair generated in module belonging to top distribution object As.It is the function in first event bus object that event message, which delivers function, is used to event object being delivered to event bus In.
Specifically, it in order to simplify the communication mode between secondary distribution object and top distribution object, improves between the two Communication efficiency, and reduce coupling between the two, in the present embodiment using third party open source event bus EventBus come Realize acquisition of the top distribution object to distribution pressure parameter value.
Before executing this operation, each secondary distribution object will should encapsulate its object for distributing pressure parameter value Sequence turns to a serializing object, and the serializing object is stored into event object.In addition, each secondary distribution object The Object Creation function getDefualt that should be advanced in event bus EventBus pre-generates a first event bar Scholar's object mEvenBus1.Later, each secondary distribution object calls event to disappear by first event bus object mEvenBus1 Above-mentioned event object obtained is distributed in event bus by breath delivery function post ().
On the other hand, top distribution object will receive event message from event bus EventBus, then should in advance by Top distribution object is registered in event bus.Registration process are as follows: in the constructed fuction of top distribution class TopDanmnManager In, by calling the Object Creation function getDefualt in event bus class EventBus to generate a second event bus pair As mEvenBus2.Later, by calling the registration function register (this) in second event bus object mEvenBus2, The top distribution object mTopDanmnManager that instantiation generates is registered in event bus EventBus.By registration process Being arranged in the constructed fuction of top distribution class is advantageous in that the repeated registration for avoiding top distribution object.Similarly, top That distributes class TopDanmnManager destroys the note called in second event bus object mEvenBus2 in function onDestory It sells function unregister (this) and carrys out anti-registered events bus EventBus, work as top distribution class to realize TopDanmnManager no longer monitors the event message in event bus when destruction.In addition, need to also be at top point It sends out and pre-defines a publicly-owned public type in class, return value void, function name is the thing of onEventMainThread Part message sink function, and it is event object data type that the input parameter of the function, which is set as only one data type, The parameter of NotificationSecondResponseStr indicates that the top distribution object of the registration can receive data type For the message of NotificationSecondResponseStr.
Aforesaid operations are performed both by finish after, top distribution object mTopDanmnManager can be in event bus Event message monitored.When it is implemented, event bus can be by the number of the event object of each secondary distribution object publishing It is compared with the data type of the function input parameters of event message reception function in top distribution object according to type.When than When consistent compared with result, the event object of secondary distribution object publishing is just sent to event message reception function.And top distribution Object then passes through event message reception function onEventMainThread (mNotificationSecondResponseStr) To obtain above-mentioned event object mNotificationSecondResponseStr.Realization inside the event message reception function Process are as follows: by calling this.mNotificationSecondResponseStr= Function input parameters are assigned to one defined inside top distribution object by mNotificationSecondResponseStr A global variable mNotificationSecondResponseStr.Due to being stored with serializing object in event object, then push up Grade distribution object just obtains the serializing object of secondary distribution object.
S220, object is serialized for any one, to serialize object and the type of feedback category object that constructs is in advance Function input parameters call object unserializing function, obtain point of current secondary distribution object corresponding with serializing object Send out pressure parameter value.
It specifically, need to be to each serializing of above-mentioned acquisition in order to obtain the distribution pressure parameter value of secondary distribution object Object carries out hair serializing operation.Before unserializing operation, need to pre-define one can store each distribution pressure ginseng The information feedback sort SecondResponse of numerical value defines each distribution pressure parameter field in such, and is each distribution Pressure parameter is provided with corresponding field value storage function set* and field value function reading get*, and " * " here indicates corresponding Field.It is such as directed to current CPU idleness cpuAvai field, is provided with CPU field storage function setAvaiCpu () and CPU Field function reading getAvaiCpu () is similarly in history message bearing capacity, current residual message bearing rate and current residual It deposits capacity and corresponding field value storage function and field value function reading is set.
When it is implemented, top distribution object is with a serializing object mNotificationSecondResponseStr Type SecondResponse.class with feedback category object is function input parameters, is provided in calling Java language With static identifier static in JavaScript object numbered musical notation (JavaScript ObjectNotation, JSON) class Object unserializing function parseObject (mNotificationSecondResponseStr, SecondResponse.class), the unserializing result of a serializing object is obtained.The of the object unserializing function One function input parameters indicates that object to be resolved, second function input parameters indicate to need the type for the class being resolvable to, And field value storage function set* and field value function reading get* in feedback target can be called in function automatically.It is then above-mentioned anti- Serializing result is the feedback target mSecondResponse of a feedback category object SecondResponse type, and Corresponding distribution pressure parameter value has been had been filled in the feedback target, just obtains the serializing object pair as input parameter The distribution pressure parameter value for the current secondary distribution object answered.Above-mentioned object unserializing.It is equal for each serializing object Aforesaid operations are executed, then can get the distribution pressure parameter value of each secondary distribution object.
Object unserializing process in the present embodiment uses JSON format more general in Java language, works as use When the data format of other character string types, its corresponding object unserializing function need to be used.
Illustratively, if to serialize object and the Class Type of feedback target that constructs is adjusted as function input parameters in advance With object unserializing function, the knot of the distribution pressure parameter value of current secondary distribution object corresponding with serializing object is obtained Fruit is abnormal, then sets default parameter value for distribution pressure parameter value, or report to current secondary distribution object feedback data Message.
It specifically, is the fault-tolerance for improving program, by above-mentioned object unserializing operation setting fault-tolerant in the present embodiment It handles in the try structure in code block try-catch structure, when the results abnormity of above-mentioned object unserializing operation, such as object When unserializing function returns to the return value of an expression operation exception, the exception handling code section in catch structure is executed.It should Abnormality processing mode, which can be, sets default parameter value for the distribution pressure parameter value of currently processed serializing object, or By the through formula communication channel of barrage message distribution to current secondary distribution object feedback data reporting message, so that when previous Grade distribution object issues event object again.Later, the unserializing operation of next serializing object is executed.
S230, it is directed to each secondary distribution object, the distribution pressure parameter value and distribution pressure according to secondary distribution object The parameters weighting value of force parameter determines the message pressure-bearing value of secondary distribution object.
S240, targeted secondary distribution object is determined according to the corresponding each message pressure-bearing value of each secondary distribution object, and By barrage message distribution to targeted secondary distribution object.
The technical solution of the present embodiment carries secondary distribution object by using the serializing object of JSON data format Distribute pressure parameter, and carries out hair serializing processing, energy by using the corresponding object unserializing function of JSON data format The efficiency that top distribution object obtains the load data of each secondary distribution object is enough further increased, to further increase bullet The high efficiency of curtain message distribution.
It is the embodiment of the dynamic diostribution device of barrage message provided in an embodiment of the present invention below, the device and above-mentioned each The dynamic distribution method of the barrage message of embodiment belongs to the same inventive concept, in the reality of the dynamic diostribution device of barrage message The detail content of not detailed description in example is applied, it can be with reference to the embodiment of the dynamic distribution method of above-mentioned barrage message.
Embodiment three
The present embodiment provides a kind of dynamic diostribution devices of barrage message, and referring to Fig. 3, which is specifically included:
Parameter value obtains module 310, for obtaining distribution pressure parameter value corresponding with each secondary distribution object, In, distribution pressure parameter includes history message bearing capacity, current residual message bearing rate, current CPU idleness and current residual At least one of memory size;
Message pressure-bearing value determining module 320, point for being directed to each secondary distribution object, according to secondary distribution object It sends out pressure parameter value and distributes the parameters weighting value of pressure parameter, determine the message pressure-bearing value of secondary distribution object;
Barrage message distribution module 330, for being determined according to the corresponding each message pressure-bearing value of each secondary distribution object Targeted secondary distribution object, and by barrage message distribution to targeted secondary distribution object.
Optionally, parameter value acquisition module 310 includes:
Object acquisition submodule is serialized, for obtaining serializing object corresponding with each secondary distribution object;
Parameter value acquisition submodule, for for any one serialize object, with serialize object and in advance construct it is anti- The type for presenting object class is function input parameters, calls object unserializing function, is obtained corresponding with serializing object current The distribution pressure parameter value of secondary distribution object.
Further, serializing object acquisition submodule is specifically used for:
For any one secondary distribution object, when the data type and top distribution object of the event object in event bus When the data type of the function input parameters of middle event message reception function is consistent, by calling event message reception function to obtain The event object of secondary distribution object, as the corresponding serializing object of secondary distribution object;
Wherein, event object is that secondary distribution object passes through first event bus object reference event message delivery function hair Cloth is into event bus;Top distribution object is infused in the constructed fuction of top distribution class by second event bus object reference Volume function is registered in advance into event bus.
Optionally, on the basis of above-mentioned apparatus, further include exception processing module, be used for:
If to serialize object and the Class Type of feedback target that constructs calls object inverted sequence as function input parameters in advance Columnization function obtains the results abnormity of the distribution pressure parameter value of current secondary distribution object corresponding with serializing object, then Default parameter value is set by distribution pressure parameter value, or to current secondary distribution object feedback data reporting message.
It optionally, include in current residual message bearing rate, current CPU idleness and current residual in distribution pressure parameter When depositing capacity, parameters weighting value includes load-carry duty weighted value, CPU weight value and memory weighted value;
Correspondingly, message pressure-bearing value determining module 320 is specifically used for:
According to current residual message bearing rate and load-carry duty weighted value, current CPU idleness and CPU weight value, and work as Preceding free memory capacity and memory weighted value determine product accumulation and the message pressure-bearing value as secondary distribution object.
Wherein, when parameters weighting value is preset fixed numbers, load-carry duty weighted value, CPU weight value and memory Weighted value is respectively that the first default weighted value, the second default weighted value and third preset weighted value.
Alternatively, when parameters weighting value is the numerical value of dynamic setting, CPU weight value and memory weighted value are according to barrage The type of message of message determines.
The dynamic diostribution device of three a kind of barrage message through the embodiment of the present invention realizes efficiently dividing for barrage message Hair, and improve the fault-tolerance of barrage message distribution.
The dynamic diostribution device of barrage message provided by the embodiment of the present invention can be performed any embodiment of that present invention and be mentioned The dynamic distribution method of the barrage message of confession has the corresponding functional module of execution method and beneficial effect.
It is worth noting that, in the embodiment of the dynamic diostribution device of above-mentioned barrage message, included each unit and Module is only divided according to the functional logic, but is not limited to the above division, as long as corresponding functions can be realized ?;In addition, the specific name of each functional unit is also only for convenience of distinguishing each other, the protection being not intended to restrict the invention Range.
Example IV
Referring to fig. 4, a kind of equipment 400 is present embodiments provided comprising: one or more processors 420;Storage device 410, for storing one or more programs, when one or more programs are executed by one or more processors 420, so that one Or multiple processors 420 realize the dynamic distribution method of barrage message provided by the embodiment of the present invention, comprising:
Obtain distribution pressure parameter value corresponding with each secondary distribution object, wherein distribution pressure parameter includes history At least one of message bearing amount, current residual message bearing rate, current CPU idleness and current residual memory size;
For each secondary distribution object, distribution pressure parameter value and distribution pressure parameter according to secondary distribution object Parameters weighting value, determine the message pressure-bearing value of secondary distribution object;
Targeted secondary distribution object is determined according to the corresponding each message pressure-bearing value of each secondary distribution object, and by barrage Message distribution is to targeted secondary distribution object.
Certainly, it will be understood by those skilled in the art that processor 420 can also realize that any embodiment of that present invention is provided Barrage message dynamic distribution method technical solution.
The equipment 400 that Fig. 4 is shown is only an example, should not function to the embodiment of the present invention and use scope bring Any restrictions.As shown in figure 4, the equipment 400 includes processor 420, storage device 410, input unit 430 and output device 440;The quantity of processor 420 can be one or more in equipment, in Fig. 4 by taking a processor 420 as an example;Place in equipment Reason device 420, storage device 410, input unit 430 can be connected with output device 440 by bus or other modes, in Fig. 4 For being connected by bus 450.
Storage device 410 is used as a kind of computer readable storage medium, and it is executable to can be used for storing software program, computer Program and module, such as the corresponding program instruction of the dynamic distribution method of the barrage message in the embodiment of the present invention/module (example Such as, the parameter value in the dynamic diostribution device of barrage message obtains module, message pressure-bearing value determining module and barrage message distribution Module).
Storage device 410 can mainly include storing program area and storage data area, wherein storing program area can store operation Application program needed for system, at least one function;Storage data area, which can be stored, uses created data etc. according to terminal. In addition, storage device 410 may include high-speed random access memory, it can also include nonvolatile memory, for example, at least One disk memory, flush memory device or other non-volatile solid state memory parts.In some instances, storage device 410 It can further comprise the memory remotely located relative to processor 420, these remote memories can be by being connected to the network extremely Equipment.The example of above-mentioned network includes but is not limited to internet, intranet, local area network, mobile radio communication and combinations thereof.
Input unit 430 can be used for receiving the number or character information of input, and generate with the user setting of equipment with And the related key signals input of function control.Output device 440 may include that display screen etc. shows equipment.
Embodiment five
The present embodiment provides a kind of storage mediums comprising computer executable instructions, and computer executable instructions are by counting For executing a kind of dynamic distribution method of barrage message when calculation machine processor executes, this method comprises:
Obtain distribution pressure parameter value corresponding with each secondary distribution object, wherein distribution pressure parameter includes history At least one of message bearing amount, current residual message bearing rate, current CPU idleness and current residual memory size;
For each secondary distribution object, distribution pressure parameter value and distribution pressure parameter according to secondary distribution object Parameters weighting value, determine the message pressure-bearing value of secondary distribution object;
Targeted secondary distribution object is determined according to the corresponding each message pressure-bearing value of each secondary distribution object, and by barrage Message distribution is to targeted secondary distribution object.
Certainly, a kind of storage medium comprising computer executable instructions, computer provided by the embodiment of the present invention The method operation that executable instruction is not limited to the described above, can also be performed barrage message provided by any embodiment of the invention Dynamic distribution method in relevant operation.
By the description above with respect to embodiment, it is apparent to those skilled in the art that, the present invention It can be realized by software and required common hardware, naturally it is also possible to which by hardware realization, but in many cases, the former is more Good embodiment.Based on this understanding, technical solution of the present invention substantially in other words contributes to the prior art Part can be embodied in the form of software products, which can store in computer readable storage medium In, floppy disk, read-only memory (Read-Only Memory, ROM), random access memory (Random such as computer Access Memory, RAM), flash memory (FLASH), hard disk or CD etc., including some instructions are with so that a computer is set Standby (can be personal computer, server or the network equipment etc.) executes barrage provided by each embodiment of the present invention and disappears The dynamic distribution method of breath.
Note that the above is only a better embodiment of the present invention and the applied technical principle.It will be appreciated by those skilled in the art that The invention is not limited to the specific embodiments described herein, be able to carry out for a person skilled in the art it is various it is apparent variation, It readjusts and substitutes without departing from protection scope of the present invention.Therefore, although being carried out by above embodiments to the present invention It is described in further detail, but the present invention is not limited to the above embodiments only, without departing from the inventive concept, also It may include more other equivalent embodiments, and the scope of the invention is determined by the scope of the appended claims.

Claims (10)

1. a kind of dynamic distribution method of barrage message characterized by comprising
Obtain distribution pressure parameter value corresponding with each secondary distribution object, wherein distribution pressure parameter includes history message At least one of bearing capacity, current residual message bearing rate, current CPU idleness and current residual memory size;
For each secondary distribution object, distribution pressure parameter value and the distribution pressure according to the secondary distribution object The parameters weighting value of parameter determines the message pressure-bearing value of the secondary distribution object;
Targeted secondary distribution object is determined according to the corresponding each message pressure-bearing value of each secondary distribution object, and will Barrage message distribution is to the targeted secondary distribution object.
2. the method according to claim 1, wherein described obtain distribution corresponding with each secondary distribution object Pressure parameter value includes:
Obtain serializing object corresponding with each secondary distribution object;
Object is serialized for any one, it is defeated as function using the type of the feedback category object for serializing object and constructing in advance Enter parameter, call object unserializing function, obtains the distribution of current secondary distribution object corresponding with the serializing object Pressure parameter value.
3. according to the method described in claim 2, it is characterized in that, described obtain sequence corresponding with each secondary distribution object Changing object includes:
For any one secondary distribution object, when thing in the data type and top distribution object of the event object in event bus When the data type of the function input parameters of part message sink function is consistent, by calling the event message reception function to obtain The event object of the secondary distribution object, as the corresponding serializing object of the secondary distribution object;
Wherein, the event object is that the secondary distribution object passes through first event bus object reference event message delivery letter Number is distributed in the event bus;The top distribution object passes through second event bar in the constructed fuction of top distribution class In scholar's object reference registration function event bus.
4. according to the method described in claim 2, it is characterized by further comprising:
If described using the Class Type of the feedback target for serializing object and constructing in advance as function input parameters, object is called Unserializing function obtains the result of the distribution pressure parameter value of current secondary distribution object corresponding with the serializing object It is abnormal, then default parameter value is set by the distribution pressure parameter value, or to the current secondary distribution object feedback coefficient According to reporting message.
5. the method according to claim 1, wherein including that the current residual disappears in the distribution pressure parameter When ceasing load-carry duty, the current CPU idleness and the current residual memory size, the parameters weighting value includes load-carry duty power Weight values, CPU weight value and memory weighted value;
The distribution pressure parameter value according to the secondary distribution object and the parameters weighting value for distributing pressure parameter, determine institute The message pressure-bearing value for stating secondary distribution object includes:
According to the current residual message bearing rate and the load-carry duty weighted value, the current CPU idleness and CPU power Weight values and the current residual memory size and the memory weighted value, determine product accumulation and, as the secondary distribution The message pressure-bearing value of object.
6. according to the method described in claim 5, it is characterized in that, when the parameters weighting value is preset fixed numbers When, the load-carry duty weighted value, the CPU weight value and the memory weighted value be respectively the first default weighted value, second pre- If weighted value and third preset weighted value.
7. according to the method described in claim 5, it is characterized in that, when the parameters weighting value be dynamic setting numerical value when, The CPU weight value and the memory weighted value are determined according to the type of message of the barrage message.
8. a kind of dynamic diostribution device of barrage message characterized by comprising
Parameter value obtains module, for obtaining distribution pressure parameter value corresponding with each secondary distribution object, wherein distribution pressure Force parameter includes in history message bearing capacity, current residual message bearing rate, current CPU idleness and current residual memory size At least one;
Message pressure-bearing value determining module, for being directed to each secondary distribution object, the distribution according to the secondary distribution object The parameters weighting value of pressure parameter value and the distribution pressure parameter, determines the message pressure-bearing value of the secondary distribution object;
Barrage message distribution module, for being determined according to the corresponding each message pressure-bearing value of each secondary distribution object Targeted secondary distribution object, and by barrage message distribution to the targeted secondary distribution object.
9. a kind of equipment, which is characterized in that the equipment includes:
One or more processors;
Storage device, for storing one or more programs,
When one or more of programs are executed by one or more of processors, so that one or more of processors are real The now dynamic distribution method of the barrage message as described in any in claim 1-7.
10. a kind of computer readable storage medium, is stored thereon with computer program, which is characterized in that the computer program The dynamic distribution method of the barrage message as described in any in claim 1-7 is realized when being executed by processor.
CN201811086359.XA 2018-09-18 2018-09-18 Dynamic distribution method, device, equipment and storage medium of barrage message Active CN109101340B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811086359.XA CN109101340B (en) 2018-09-18 2018-09-18 Dynamic distribution method, device, equipment and storage medium of barrage message

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811086359.XA CN109101340B (en) 2018-09-18 2018-09-18 Dynamic distribution method, device, equipment and storage medium of barrage message

Publications (2)

Publication Number Publication Date
CN109101340A true CN109101340A (en) 2018-12-28
CN109101340B CN109101340B (en) 2021-11-26

Family

ID=64866582

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811086359.XA Active CN109101340B (en) 2018-09-18 2018-09-18 Dynamic distribution method, device, equipment and storage medium of barrage message

Country Status (1)

Country Link
CN (1) CN109101340B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113254838A (en) * 2021-06-18 2021-08-13 每日互动股份有限公司 Message distribution method based on mesh cascade, electronic equipment and medium
US11436653B1 (en) * 2019-09-26 2022-09-06 Amazon Technologies, Inc. Hybrid system event processing

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101465796A (en) * 2007-12-19 2009-06-24 ***通信集团公司 Method, device and system for collecting and distributing P2P system metadata
CN102902587A (en) * 2011-07-28 2013-01-30 ***通信集团四川有限公司 Distribution type task scheduling method, distribution type task scheduling system and distribution type task scheduling device
CN103605568A (en) * 2013-10-29 2014-02-26 北京奇虎科技有限公司 Multithread management method and device
CN103856353A (en) * 2014-03-06 2014-06-11 上海爱数软件有限公司 Service log data access and statistic analysis method and device
CN104360904A (en) * 2014-10-16 2015-02-18 四川长虹电器股份有限公司 Intermodular message transmission mechanism based on event bus
CN105912399A (en) * 2016-04-05 2016-08-31 杭州嘉楠耘智信息科技有限公司 Task processing method, device and system
CN106993234A (en) * 2017-03-22 2017-07-28 北京潘达互娱科技有限公司 Barrage display methods and device
US20180183866A1 (en) * 2016-12-22 2018-06-28 Nicira, Inc. Performing context-rich attribute-based load balancing on a host

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101465796A (en) * 2007-12-19 2009-06-24 ***通信集团公司 Method, device and system for collecting and distributing P2P system metadata
CN102902587A (en) * 2011-07-28 2013-01-30 ***通信集团四川有限公司 Distribution type task scheduling method, distribution type task scheduling system and distribution type task scheduling device
CN103605568A (en) * 2013-10-29 2014-02-26 北京奇虎科技有限公司 Multithread management method and device
CN103856353A (en) * 2014-03-06 2014-06-11 上海爱数软件有限公司 Service log data access and statistic analysis method and device
CN104360904A (en) * 2014-10-16 2015-02-18 四川长虹电器股份有限公司 Intermodular message transmission mechanism based on event bus
CN105912399A (en) * 2016-04-05 2016-08-31 杭州嘉楠耘智信息科技有限公司 Task processing method, device and system
US20180183866A1 (en) * 2016-12-22 2018-06-28 Nicira, Inc. Performing context-rich attribute-based load balancing on a host
CN106993234A (en) * 2017-03-22 2017-07-28 北京潘达互娱科技有限公司 Barrage display methods and device

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
天津滨海迅腾科技集团有限公司: "《Android模块化项目实战》", 31 July 2018 *
李晨: "《智能终端跨平台开发》", 31 May 2017 *
黑马程序员: "《Android面试宝典》", 31 January 2017 *
黑马程序员: "Android面试宝典", 《ANDROID面试宝典》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11436653B1 (en) * 2019-09-26 2022-09-06 Amazon Technologies, Inc. Hybrid system event processing
CN113254838A (en) * 2021-06-18 2021-08-13 每日互动股份有限公司 Message distribution method based on mesh cascade, electronic equipment and medium

Also Published As

Publication number Publication date
CN109101340B (en) 2021-11-26

Similar Documents

Publication Publication Date Title
CN104935622B (en) A kind of method and device for message distribution, consumption, the system for Message Processing
CN102916953A (en) Method and device for realizing concurrent service on basis of TCP (transmission control protocol) connection
CN106598735B (en) A kind of distributed computing method, main controlled node and computing system
CN113127192B (en) Method, system, device and medium for sharing same GPU by multiple services
CN103577251A (en) Event based Internet computing processing system and method
CN109101340A (en) Dynamic distribution method, device, equipment and the storage medium of barrage message
CN111694663A (en) Load balancing method, device and system for server cluster
CN105979294A (en) Data processing method and device based on users
CN106331783B (en) A kind of resource allocation methods, device and intelligent television system
CN110351311A (en) Load-balancing method and computer storage medium
CN111625353B (en) Virtual resource distribution processing method, device, server and storage medium
CN109584105A (en) A kind of method and system of service response
CN106713388A (en) Emergent business processing method and device
CN104301241B (en) A kind of SOA dynamic load distributing methods and system
CN106385375B (en) Load-balancing method and device for message queue
CN110233840A (en) A kind of method for processing business, device, equipment and storage medium
CN105591790B (en) Data communication connection pool management device
CN116012067A (en) Resource allocation method, apparatus, computer, readable storage medium, and program product
CN113763043A (en) Advertisement landing page display method and device, storage medium and computer equipment
CN109600402A (en) Server load balancing method and device, storage medium, server, service system
CN108810645B (en) Bullet screen message distribution method, device, equipment and storage medium
CN111475315A (en) Server and subscription notification push control and execution method
CN116647599A (en) Micro-service scheduling method, device, equipment and storage medium
CN115471121A (en) User matching method, device and medium for task
CN109089163A (en) Barrage message distributing method, device, equipment and storage medium

Legal Events

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