Quorum Generation Algorithm Based on the Longest-shortest Distance

Many algorithms on quorum generation have been proposed but those algorithms with cyclic quorum usually had a common defect that the nodes would congregate in a special area of the quorum at the end of the algorithm(Called this problem as CE). For resolving this problem, a new algorithm on quorum generation based on the longest-shortest distance has been proposed in this paper. This algorithm has the same quorum length and time complexity as Li’s algorithm[8],but the space complexity is O( N ), lower than Li’s algorithm[8]. And this algorithm has not the problem of CE. So based on the longest-shortest distance to chose a node to insert the quorum is an executive method on resolving the problem CE.


INTRODUCTION
Since the Makeawa's [1] algorithm has been proposed, researches on distributed mutual exclusion algorithm entered the competitive stage based on quorum. The applications based on quorum to decide had become more and more widely [2,3,4]. Especially the replica strategies based on quorum [5,6,7] in database gradually became one usually means. But designs of the symmetric quorum generation algorithm became more and more difficult because of the contradiction of the quorum length and the time complexity. For resolving this contradiction, LI proposed three quorum generation algorithms [8,9,10]. Firstly, he proposed a quorum generation algorithm based on cyclic coding, translating the quorum to a vector, quorums' interaction to if there are any common node. It's average quorum length is 2 N , the algorithm's time complexity is O( N ) and the space complexity is O( 2 N ). Secondly, he proposed a quorum generation algorithm base on cyclic subset set, translating the quorums' interaction to the cover of a distance vector by the distance of any two nodes in the quorum. It's average quorum length is 2 N , the time complexity is O(N) and the space complexity is O(N). Thirdly, an algorithm has been proposed by him based on quorum properties. This algorithm has the property of backtracking. So it's quorum length is O( N +1), it's time complexity is O(N!). All these algorithms as above had a common defect that the nodes would congregate in a special area of the quorum at the end of the algorithm running(Called this problem as Congregation at the End, CE). This property made the nodes in the quorum distribute non-uniform. For resolving this problem, a new quorum generation algorithm based on the longest-shortest distance (Called it as LSD algorithm) will be proposed in this paper. It keeps the quorum length and time complexity as same as the LI's algorithm [10] but not exist the situation of CE.

II. MODEL
Because it's difficult to search the symmetric quorum for any scale system if the quorum is not cyclic [10], we will design a quorum generation algorithm and it can generate cyclic quorum to any scale distributed system. Based on the properties of cyclic quorum proposed in LI's algorithm [10], if numbered every node in the system such as 0,1,…N-1, the quorum of node 0 should have common nodes with the quorum of every other node in the system, and the quorum of node 1 can generate by the quorum of node 0 and so on. Use a vector to denote the quorum of node 0, such as , and i a should be 0 or 1, 0 denotes that this node was not included in quorum and 1 denotes that this node was included in quorum. So the cyclic quorum of node i should be To ensure the value of this inner product is larger than 0, there must one or more items of this inner product be 1. Because the subtract of index of i a in every item is N-i or i, and the subtract of index of i a can be looked as the distance of two nodes in the quorum, if the distance of two nodes in the quorum can be ensured, the inner product must be larger than 0. To , if the distances of any two nodes in the quorum can cover distance i, the quorums' interaction one by one should be ensured. At the same time, because every inner product includes two distances, i and N-i, if the quorum of node 0 interacts the quorum of node i, the quorum of node 0 must interact the quorum of node N-i. So if the quorum of node 0 interacts the quorum of node , the quorum of node 0 must interact the quorum of node . So to search the cyclic quorum of node 0, only to need ensure the distances of any two nodes in the quorum can cover the area of So the quorum generation algorithm become the problem as fallow: in one N-nodes vector of 0 or 1, set some locations to 1 to ensure the distances of all the locations with 1 can cover the area of The reason of CE to the algorithms [8,9,10] is that one node included in quorum only can ensure the quorum of node 0 interacts one another quorum at the end running of the algorithm. For resolving this problem, to search a node with the longest distance to every node in the quorum and to insert it in the quorum, and this distance is the longest in all those shortest distance that the node to all those nodes in the quorum. That's to say, we should calculate the shortest distance of a node which can be included in the quorum to every nodes in the quorum firstly, then search the longest distance in all those shortest distance. This node with the longest-shortest distance should be included in the quorum. So design a quorum generation algorithm that chose a node which has the longest-shortest distance near to all those nodes in the quorum to insert in quorum become an able thing. The quorum generation algorithm in this paper should include the plans as fallow: 1. Search those nodes can be included in the quorum and include them in a backup vector ; 2. Calculating the shortest distance of every node in the backup vector to every node in the quorum; 3. Search the node with the longest-shortest distance, insert it in the quorum.

IV. ALGORITHM DESCRIPTION
A. Data Structures quorum. It's a changeable length actor, using to store the quorum nodes in the algorithm running process.
backup. It's a changeable length actor, too. Using to store the backup nodes that can be inserted in quorum.
shortest_distance. It's a changeable length actor. Using to store the shortest distance of every node in the backup vector to every node in quorum.
longest_shortest_distance_node. It's a number to use to store the node with the longest-shortest distance.
need_cover_distance. It's a changeable length actor, using to store those needed to cover but not be covered distance by quorum.
quorum_cover_distance. It's a changeable length actor, using to store those distance can be covered by quorum.

B. Algorithm Processes generation_backup(int[]quorum,int distance,int N).
Using it to generate the backup actor to quorum with the distance while the system nodes is N.

insert_node_in_quorum(int[]quorum,int[]backup,int N).
Using it to insert the node with the longest-shortest distance in backup to quorum while the system nodes is N.
quorum_generation_distance(int[]quorum).Using it to generate the distance by those nodes in the quorum.

del_node(int[]a,int[]distance).
Using it to delete the distance vector's distances from vector a.

C. Algorithm Description
The overflow of the algorithm proposed in this paper is as figure 1.

A. Quorum Length
When every new node was included in the quorum with n nodes, n new distances can be generated. And it can generate n(n-1)/2 different distances at most and n-1 different distances at least if there was n nodes in quorum. So the average different distances can be generated is (n(n-1)+n)/4 when there was n nodes in quorum. Lets the average different distances equate N-1, so n=2 That's to say, the average quorum length of the algorithm is 2 N in this paper. The comparison of quorum length of several algorithms is as table 1. among it the cyclic denotes the cyclic coding algorithm, N and 2 N denote the algorithms with N or 2 N quorum length, LSD denotes the longest-shortest distance algorithm proposed in this paper.
In table 1, LSD denotes the algorithm proposed in this paper. And from this table, one conclusion can be gotten such as fallow: the quorum length of LSD algorithm is lower when N<700 and maybe is little larger than algorithm with 2 N quorum length. But in summery, the quorum length of LSD algorithm is little larger than the cyclic coding algorithm.

B. Time Complexity
Bases on the process of LSD algorithm, it needs one time query in vector need_cover_distance, n times plus and n+n*n times subtraction, and 2n+n*n*N/2 times comparison when there were n nodes in the quorum.  [8].

C. Space Complexity
For every time running of this LSD algorithm, the space needed is several vectors with n elements and n is lower than N/2. So the space complexity of LSD algorithm is O(N). Because the cyclic coding algorithm needs an array with N*N elements, the space complexity of cyclic coding is O ) ( 2 N . So the space complexity of LSD algorithm is lower than the cyclic coding algorithm.

D. Property of Congregation
In this algorithm, every node selected must be the node with the longest-shortest distance, so many nodes congregates next to next. Assume N=22, the quorum of LSD is 1010001000100100010001, the quorum of cyclic coding is 1101000100001000000010. From the quorum vectors, in the quorum generated by LSD algorithm, all 1 are distributed more dispersal than the quorum generated by the cyclic coding algorithm.

VI. CONCLUSION
The LSD algorithm has shorter quorum length, the average quorum length is 2 N , is close to the cyclic coding algorithm's quorum length. And the time complexity of LSD algorithm is O ) ( 2 N , is close to the cyclic coding algorithm's time complexity, too. But the space complexity of LSD algorithm is O(N), the space complexity of cyclic coding algorithm is O ) ( 2 N , LSD algorithm is more excellent than cyclic coding algorithm. At the same time, LSD can resolve the CE problem of the other cyclic coding algorithms.