Ejemplo n.º 1
0
    FederationRoutingTokenHeader RoutingToken::SplitSuccToken(PartnerNodeSPtr const & succ, uint64 targetVersion, 
        NodeId const & ownerId)
    {
        if (succ->Id == ownerId)
        {
            return FederationRoutingTokenHeader();
        }

        // This is the boundary that should still belong to the current node.
        NodeId splitId = ownerId.GetSuccMidPoint(succ->Id);

        // This is the bounary that should belong to the neighbor.
        NodeId transferId = splitId.SuccWalk(LargeInteger::One);

        // Split is possible only when the transfer point is within the range.
        if (ownerId.SuccDist(transferId) > ownerId.SuccDist(range_.End))
        {
            return FederationRoutingTokenHeader();
        }

        // Split current token.
        NodeId oldEnd = range_.End;
        Update(NodeIdRange(range_.Begin, splitId));

        return FederationRoutingTokenHeader(NodeIdRange(transferId, oldEnd), version_, targetVersion);
    }
Ejemplo n.º 2
0
    FederationRoutingTokenHeader RoutingToken::SplitFullToken(PartnerNodeSPtr const & neighbor, uint64 targetVersion, 
        NodeId const & ownerId)
    {
        NodeId succMid = ownerId.GetSuccMidPoint(neighbor->Id);
        NodeId predMid = ownerId.GetPredMidPoint(neighbor->Id);

        Update(NodeIdRange(predMid, succMid));

        return FederationRoutingTokenHeader(
            NodeIdRange(succMid.SuccWalk(LargeInteger::One), predMid.PredWalk(LargeInteger::One)), 
            version_, targetVersion);
    }