• No results found

3.5 Replication Schemes in the Internet

4.1.1 Network Setup Phase

In this phase, the aim is to build a hierarchy of partitions and assign a DN for each partition to lookup for the placement within the partition’s member nodes. We assume that all nodes1are bootstrapped with Alg. 1. To trigger the network setup phase, an application process called the Content Manager (CM) Content Manager (CM)—which is a component of the ReplicaDaemon—starts this phase.

1In order to avoid confusion throughout this thesis, the terms MRs, nodes and N refer to the

To reduce the message overhead, the CM can be hosted by a centroid node. The CM plays a role in collecting statistical information about different objects’ requests, computing the number of replicas per object for the next τ period, and assigning the placement job to the corresponding DNs.

We define two graph structures gLeft and gRight in line 3 since each DN will

bipartite the received graph G into two partitions (sub-graphs) and selects one of the member nodes to act as a DN for each partition; hence, we define two node structures dnLeftand dnRightin line 3. The two string variables sLeftand sRight(line 4)

are used to keep track of the already selected DNs. Alg. 1 is triggered by the CM with G representing the whole graph and the string variable s initialized with the NULL string. The CM selects itself to act as a DN for the network graph G and initializes both sLeftand sRightto the value of s (line 6, which is a NULL string

when the instance is called by the CM. The CM bipartites G (line 20, selects a DN for each partition (lines 20 and 21) such that the selected DN was not assigned before to another partition. This is verified by making sure that the selected dnLeft

/

∈ sLeftand dnRight∈ dn/ Right. Afterwards, we append (concatenate) dnLeftand dnRight

to sLeftand sRightrespectively (lines 22 and 23).

The CM then forwards each partition (sub-graph) to its corresponding DN (lines 25 and 26) and waits (line 27) for its child DNs to return the string repre- sentation of the progenies of each branch. This process is recursively repeated until the partitions are fine-grained. When the base case is reached (line 6), the partition size is 2 the node running the algorithm instance selects itself as the left DN (the term this refers to the node itself (line 7)) and selects the remaining node (line 8) to be the right DN appearing as leaf nodes in the generated tree. Note that when the network size is a power of two, the case in line 11 will not be satisfied. Otherwise, at some stage, the partition size will eventually be 3. In this case, it selects one of the nodes to be dnLeft(line 12) to act as a leaf node. The

Algorithm 1:This function builds the DBT during the network setup phase.

Input: Network graph G.

Output: A string representation of the DBT returned to the CM.

1 Function BTree(Graph g, String s) 2 Graph gLeft, gRight

3 Node dnLeft, dnRight 4 String sLeft, sRight 5 sLeft← sRight← s 6 if |g| = 2 then 7 dnLeft← this 8 dnRight← {g} \ dnLeft 9 return dnLeft|| {g} 10 end 11 else if |g| = 3 then 12 dnLeft← rand(g) /∈ s 13 gRight← {g}\ dnLeft 14 dnRight← rand(gRight) /∈ s 15 forward (gRight, s) → dnRight 16 wait (dnRight)

17 return this || dnLeft|| dnRight

18 end

19 else

20 Bipartite (g, gLeft, gRight) 21 dnLeft← rand(gLeft) /∈ sLeft 22 dnRight← rand(gRight) /∈ sRight 23 sLeft← sLeft|| dnLeft

24 sRight← sRight|| dnRight 25 forward (gLeft, sLeft) → dnLeft 26 forward (gRight, sRight) → dnRight 27 wait(dnLeft, dnRight)

28 return this || dnLeft|| dnRight

remaining two nodes form the right partition (line 13) and then selects a dnRight

(line 13) to act as a DN for a partition of size 2.

The DNs in the lowest level partitions reply (line 9) to their callers (parent node) with a list representing the DN and its partition members. When the caller receives the lists from its child DNs, it merges the received lists (lines 17 and 28), appends its node ID and forwards the resulting list to its caller. Eventually, the CM (root node) will receive a list of DNs in the form of a balanced binary tree that we call the Delegates Binary Tree (DBT) as depicted in Fig. 4.1. Notice (Fig. 4.1b) that a node appears twice. Once as a parent node (i.e., partition- hosting) responsible for the descendant members (and itself) and another as a leaf node (i.e., self-hosting). We underline that this phase needs to be performed once. However, if the topology changes permanently (e.g., relocation of MRs), then we need to perform this phase again. We do not consider a temporary topology change due to temporary link variations, as content replication is required for long periods. Fig. 4.2 illustrates the generation of partitions for potential number of replicas and the assignment of a DN for each partition.

3 2 1 4 6 5 7 8 9

(a) Topology view.

1 7 2 3 6 9 8 4 4 1 4(4,1) 8(8,7) 9(9,3) 6(6,5) 7(8(8,7),4(4,1)) 2(3(2,9(9,3)), 6(6,5))! 1(2(3(2,9(9,3)), 6(6,5)), 7(8(8,7),4(4,1))) 7 8 2 3 9 6 5 3(2,9(9,3)) (b) Tree view.

Figure 4.1: This figure illustrates the conversion of the network graph G (a) into a balanced binary tree DBT (b), where each node represents a DN for the underlying partition.

3 2 1 4 6 5 7 8 9 (a) 3 2 1 4 6 5 7 8 9 (b) 3 2 1 4 6 5 7 8 9 (c) 3 2 1 4 6 5 7 8 9 (d)

Figure 4.2: This figure depicts the first 4 stages of the Network Setup Phase, where each stage represents the generation of (semi) equal partition sizes and assigning a DN for each partition.

Following the DBT creation, the CM maps the possible numbers of replicas to their DNs in the DBT, creating a Map-List by running Alg. 2. It recursively divides the possible number of replicas (p) by 2 starting from the root node. When the base case is reached (i.e., p = 1), it checks whether the node n is a leaf node in the DBT or not. If it is a leaf node, then it means that node n has to self-host the object for p replicas and returns the node ID concatenated with a flag (Shost) to indicate self-hosting. Otherwise, it returns the node ID along with a flag (Phost) to indicate partition-hosting (i.e., the DN will need to find the optimal location for the object within its partition). For every possible p, the CM creates an entry in the form of hp, set of DNsi and inserts it in the Map-List structure. Upon completion, the CM broadcasts the Map-List to all the nodes. This will facilitate for both the CM and the DNs to know textita priori that for a specific p, which DNs the CM shall communicate with to assign the placement job and the DN knows from the Map-List its role whether self-hosting or partition-hosting.

Algorithm 2:Function to map the possible number of replicas (p) to their DNs.

1 Function Map(N ode n, int p)

2 if p = 1 then 3 if n is leaf then 4 return n||Shost 5 else 6 return n||Phost 7 end 8 else

9 return map(n.lef t, bp2c) + map(n.right, dp2e)