Friday, November 4, 2016

Today we continue to review the mechanics of Active Directory replication:
We are referring to intrasite replication for the most often use cases of Active directory domain name-context item changes. Such AD replication takes place between DCs in pull operations, not pushes. AD controls and manages the transmission of AD Data.  We discussed what makes up the replication metadata and we saw how it is put to use.  We saw how it was used to address conflict resolution and usn rollbacks.
In order to override automatic replication of AD objects, we could do one of the following:
1) invoke repadmin command on the destination DC to pull the changes
2) invoke repadmin command on the souce DC to push changes to all other DC.
3) issue active directory powershell cmdlet to invoke sync on a per object basis.

If we have a Read-only domain controller
Then the propagation is one way. In such a case, we have some additional considerations.

#puzzle
Yesterday we were discussing a 'celebrity' problem.
In a party of N people, only one person is known to everyone. Such a person may be present in the party, if yes, she doesn’t know anyone in the party. We can only ask questions like "does A know B?". Find the stranger in minimum number of questions.
We used graph to solve this problem, however it had O(N^2) complexity.
Today we use a stack to improve it.
Using a stack to keep track of the celebrities, we exclude the possibilities until we are left with one or none. We do so as follows:
Push all the celebrities into a stack.
Pop two of them as A and B
    if A knows B then A is not a celebrity
    else B is not a celebrity
Push the remainder on the stack
Repeat the above until one or none remains on the stack.
Check the named person on the stack doesn't have acquaintance with anyone else. This last step is required because we may not have any celebrities in the stack.
int findCelebrity(List<int> persons)
{
var stk = persons.ToStack();
if (stk.size() == 0)  return -1;
if (stk.size() == 1) return 0;

A = stk.Peek();
stk.pop();
B = stk.Peek();
stk.pop();

while (stk.size() > 1)
{
   if (knows(A,B))
  {
    A = stk.peek();
    stk.pop();
  }else{
    B = stk.peek();
    stk.top();
  }
}
if (stk.size() == 0) {
    if (knows(A,B) && !knows(B,A))
        return B;
    if (knows(B,A) && !knows(A,B))
        return A;
    return -1;
}
C = s.peek();
C = stk.top();
if (knows (C,B)) C = B;
if (knows (C,A)) C = A;
for (int i = 0; i < n; i++)
{
if (i !== C && (knows(C,i) && !knows(i,C)))
    return -1;
}
return C;
}


No comments:

Post a Comment