/////////////// /// /// Here is the constructor /// //////////////// /** * @param local the local Node to connect to the remote node * @param target the address of the node you are trying to connect * to. Set to null if you don't know * @param target_list an enumerable list of TransportAddress of the * Host we want to connect to * @param t ConnectionType string of the new connection * @token unique token to associate the different connection setup messages */ public Linker(Node local, Address target, ICollection target_list, string ct, string token) { _task = new LinkerTask(local.Address, target, ct); _local_n = local; _active_lps_count = 0; //this TaskQueue starts new tasks in the announce thread of the node. _task_queue = new NodeTaskQueue(local); _task_queue.EmptyEvent += this.FinishCheckHandler; _ta_queue = new BC.LockFreeQueue<TransportAddress>(); if( target_list != null ) { int count = 0; Hashtable tas_in_queue = new Hashtable( _MAX_REMOTETAS ); foreach(TransportAddress ta in target_list ) { if(tas_in_queue.ContainsKey(ta) ) { // Console.Error.WriteLine("TA: {0} appeared in list twice", ta); } else { _ta_queue.Enqueue(ta); tas_in_queue[ta] = null; //Remember that we've seen this one if( target != null ) { /* * Make sure we don't go insane with TAs * we know who we want to try to connect to, * if it doesn't work after some number of * attempts, give up. Don't go arbitrarily * long */ count++; if( count >= _MAX_REMOTETAS ) { break; } } } } } _added_cons = 0; //We have not added a connection yet _contype = ct; _maintype = Connection.StringToMainType( _contype ); _target = target; _token = token; _ta_to_restart_state = new Hashtable( _MAX_REMOTETAS ); _started = 0; _hold_fire = 1; _cph_transfer_requests = 0; #if LINK_DEBUG _lid = Interlocked.Increment(ref _last_lid); if(BU.ProtocolLog.LinkDebug.Enabled) { BU.ProtocolLog.Write(BU.ProtocolLog.LinkDebug, String.Format("{0}: Making {1}", _local_n.Address, this)); if( target_list != null ) { BU.ProtocolLog.Write(BU.ProtocolLog.LinkDebug, String.Format("TAs:")); foreach(TransportAddress ta in target_list) { BU.ProtocolLog.Write(BU.ProtocolLog.LinkDebug, String.Format("{0}", ta)); } } } #endif }
/////////////// /// /// Here is the constructor /// //////////////// /** * @param local the local Node to connect to the remote node * @param target the address of the node you are trying to connect * to. Set to null if you don't know * @param target_list an enumerable list of TransportAddress of the * Host we want to connect to * @param t ConnectionType string of the new connection * @token unique token to associate the different connection setup messages */ public Linker(Node local, Address target, ICollection target_list, string ct, string token) { _task = new LinkerTask(local.Address, target, ct); _local_n = local; _active_lps_count = 0; //this TaskQueue starts new tasks in the announce thread of the node. _task_queue = new NodeTaskQueue(local); _task_queue.EmptyEvent += this.FinishCheckHandler; _ta_queue = new BC.LockFreeQueue <TransportAddress>(); if (target_list != null) { int count = 0; Hashtable tas_in_queue = new Hashtable(_MAX_REMOTETAS); foreach (TransportAddress ta in target_list) { if (tas_in_queue.ContainsKey(ta)) { // Console.Error.WriteLine("TA: {0} appeared in list twice", ta); } else { _ta_queue.Enqueue(ta); tas_in_queue[ta] = null; //Remember that we've seen this one if (target != null) { /* * Make sure we don't go insane with TAs * we know who we want to try to connect to, * if it doesn't work after some number of * attempts, give up. Don't go arbitrarily * long */ count++; if (count >= _MAX_REMOTETAS) { break; } } } } } _added_cons = 0; //We have not added a connection yet _contype = ct; _maintype = Connection.StringToMainType(_contype); _target = target; _token = token; _ta_to_restart_state = new Hashtable(_MAX_REMOTETAS); _started = 0; _hold_fire = 1; _cph_transfer_requests = 0; #if LINK_DEBUG _lid = Interlocked.Increment(ref _last_lid); if (BU.ProtocolLog.LinkDebug.Enabled) { BU.ProtocolLog.Write(BU.ProtocolLog.LinkDebug, String.Format("{0}: Making {1}", _local_n.Address, this)); if (target_list != null) { BU.ProtocolLog.Write(BU.ProtocolLog.LinkDebug, String.Format("TAs:")); foreach (TransportAddress ta in target_list) { BU.ProtocolLog.Write(BU.ProtocolLog.LinkDebug, String.Format("{0}", ta)); } } } #endif }