/** * Compute candidate scores for a shortcut connection. * @param start address computed by the SCO. * @param range nunber of candidate nodes. * @param cb callback function when candidate scores are available. * @param current current selection of the optimal in the provided range. */ public override void ComputeCandidates(Address start, int range, TargetSelectorDelegate cb, Address current) { Channel q = null; RequestState rs = null; lock (_sync) { #if VTS_DEBUG Console.Error.WriteLine("VTS local: {0}, start: {1}, range: {2}, count: {3}", _node.Address, start, range, _num_requests); #endif if (_num_requests == MAX_REQUESTS) { return; //do nothing and return; } _num_requests++; q = new Channel(); rs = new RequestState(start, range, cb, current); _channel_to_state[q] = rs; } //create a new request state ISender s = new ForwardingSender(_node, start, AHHeader.Options.Greedy, new DirectionalAddress(DirectionalAddress.Direction.Left), (short)range, AHHeader.Options.Path ); q.EnqueueEvent += new EventHandler(EnqueueHandler); q.CloseEvent += new EventHandler(CloseHandler); RpcManager rpc = _node.Rpc; rpc.Invoke(s, q, "ncserver.EchoVivaldiState", new object[] {}); }
public RequestState(Address start, int range, TargetSelectorDelegate cb, Address current) { Start = start; Range = range; Callback = cb; Current = current; ResultTable = new Hashtable(); }
/** * Selects an optimal target given a start address, the range starting at that address, and the current address (could be null). * If the current address is not null, it is returned as optimal, or else start address is returned. * @param start start address of the range. * @param range number of candidates * @param callback callback function into the caller * @param current currently selected optimal */ public override void ComputeCandidates(Address start, int range, TargetSelectorDelegate callback, Address current) { SortedList sorted = new SortedList(); if (current != null) { sorted[1.0] = (Address) current; } else { sorted[1.0] = start; } callback(start, sorted, current); }
/** * Selects an optimal target given a start address, the range starting at that address, and the current address (could be null). * If the current address is not null, it is returned as optimal, or else start address is returned. * @param start start address of the range. * @param range number of candidates * @param callback callback function into the caller * @param current currently selected optimal */ public override void ComputeCandidates(Address start, int range, TargetSelectorDelegate callback, Address current) { SortedList sorted = new SortedList(); if (current != null) { sorted[1.0] = (Address)current; } else { sorted[1.0] = start; } callback(start, sorted, current); }
/** * Compute candidate scores for a shortcut connection. * @param start address computed by the SCO. * @param range nunber of candidate nodes. * @param cb callback function when candidate scores are available. * @param current current selection of the optimal in the provided range. */ public override void ComputeCandidates(Address start, int range, TargetSelectorDelegate cb, Address current) { Channel q = null; RequestState rs = null; lock(_sync) { #if VTS_DEBUG Console.Error.WriteLine("VTS local: {0}, start: {1}, range: {2}, count: {3}", _node.Address, start, range, _num_requests); #endif if (_num_requests == MAX_REQUESTS) { return; //do nothing and return; } _num_requests++; q = new Channel(); rs = new RequestState(start, range, cb, current); _channel_to_state[q] = rs; } //create a new request state ISender s = new ForwardingSender(_node, start, AHHeader.Options.Greedy, new DirectionalAddress(DirectionalAddress.Direction.Left), (short) range, AHHeader.Options.Path ); q.EnqueueEvent += new EventHandler(EnqueueHandler); q.CloseEvent += new EventHandler(CloseHandler); RpcManager rpc = _node.Rpc; rpc.Invoke(s, q, "ncserver.EchoVivaldiState", new object[]{}); }
/** * Selects an optimal target given a start address, the range starting at that address, and the current address (could be null). * @param start start address of the range. * @param range number of candidates * @param callback callback function into the caller * @param current currently selected optimal */ public abstract void ComputeCandidates(Address start, int range, TargetSelectorDelegate callback, Address current);