public SubringTransportAddress(AHAddress target, string node_ns) :
     base(string.Format("brunet.{0}://{1}.{2}", TATypeToString(TAType.Subring),
                        target.ToMemBlock().ToBase32String(), node_ns))
 {
     Target    = target;
     Namespace = node_ns;
 }
Exemplo n.º 2
0
 public SubringTransportAddress(AHAddress target, string node_ns) :
   base(string.Format("brunet.{0}://{1}.{2}", TATypeToString(TAType.Subring),
         target.ToMemBlock().ToBase32String(), node_ns))
 {
   Target = target;
   Namespace = node_ns;
 }
Exemplo n.º 3
0
        public void Send(ICopyable data)
        {
            ConnectionList cl = Node.ConnectionTable.GetConnections(ConnectionType.Structured);
            // We start with the node immediately after the starting index
            int start = cl.IndexOf(From);

            if (start < 0)
            {
                start = ~start;
            }

            // We end with the node immediately before the end index
            int end = cl.IndexOf(To);

            if (end < 0)
            {
                end = ~end;
            }

            // If start >= end, because From < To or because this is a terminal
            // node and there are no other entities to forward it to.  So the
            // second test ensures that the first entity is actually inside the
            // range to forward it to.
            AHAddress start_addr = cl[start].Address as AHAddress;

            if (start >= end && start_addr.IsBetweenFromLeft(From, To))
            {
                end += cl.Count;
            }

            List <Connection> cons = SortByDistance(cl, start, end, Forwarders);

            for (int i = 0; i < cons.Count; i++)
            {
                Connection con   = cons[i];
                int        next  = i + 1;
                AHAddress  nfrom = con.Address as AHAddress;
                Address    nto   = To;
                if (next < cons.Count)
                {
                    nto = GetLeftNearTarget(cons[next].Address as AHAddress);
                }
                con.Edge.Send(new CopyList(PType, Source.ToMemBlock(),
                                           nfrom.ToMemBlock(), nto.ToMemBlock(), _forwarders, _hops, data));
            }

            _sent_to = cons.Count;
        }
Exemplo n.º 4
0
 public void CacheTest()
 {
   RandomNumberGenerator rng = new RNGCryptoServiceProvider();
   Address a = new AHAddress(rng);
   Address a2 = new AHAddress(a.ToMemBlock());
   TransportAddress ta = TransportAddressFactory.CreateInstance("brunet.tcp://127.0.0.1:5000");
   TransportAddress ta2 = TransportAddressFactory.CreateInstance("brunet.tcp://127.0.0.1:5000");
   NodeInfo ni = NodeInfo.CreateInstance(a, ta);
   NodeInfo ni2 = NodeInfo.CreateInstance(a2, ta2);
   Assert.AreSame( ni, ni2, "Reference equality of NodeInfo objects");
 }