상속: IReplyHandler, IDataHandler
예제 #1
0
    //Methods:

    protected PathELManager(EdgeListener el, bool thread) {
      _el = el;
      _sync = new object();
      _edges = new List<Edge>();
      _unannounced = new Dictionary<Edge, PathEdge>();
      _pel_map = new Dictionary<string, PathEdgeListener>();
      //Use the reqrep protocol with a special prefix:
      _rrm = new ReqrepManager("PathELManager:" + el.ToString(), PType.Protocol.Pathing);
      _rrm.Subscribe(this, null);
      Rpc = new RpcManager(_rrm);
      Rpc.AddHandler("sys:pathing", this);
      _el.EdgeEvent += HandleEdge;
      _running = true;

      if(thread) {
        _timer_thread = new Thread(
          delegate() {
            int counter = 0;
            int max_counter = EDGE_PERIOD / 1000;
            while(_running) {
              Thread.Sleep(1000);
              ReqrepTimeoutChecker();
              if(++counter == max_counter) {
                counter = 0;
                EdgeTimeoutChecker();
              }
            }
          }
        );

        _timer_thread.IsBackground = true;
        _timer_thread.Start();
      }
    }
예제 #2
0
 public LocalDiscovery(ITAHandler ta_handler, string realm, RpcManager rpc, IPHandler iphandler) :
   base(ta_handler)
 {
   _rpc = rpc;
   _iphandler = iphandler;
   _realm = realm;
   _rpc.AddHandler(RPC_CLASS, this);
 }
예제 #3
0
파일: RpcManager.cs 프로젝트: pcbing/brunet
 public ReflectionRpcHandler(RpcManager rpc, object handler, bool use_sender)
 {
     _rpc        = rpc;
     _handler    = handler;
     _type       = _handler.GetType();
     _use_sender = use_sender;
     _sync       = new object();
     //Cache the 10 most used methods:
     _method_cache = new Cache(10);
 }
예제 #4
0
 public BrunetRpc() {
   _rrm = new ReqrepManager("BrunetRpc");
   _rrm.Subscribe(this, null);
   Rpc = new RpcManager(_rrm);
   IPHandler = new IPHandler();
   IPHandler.Subscribe(this, null);
   _running = 1;
   _timer = new Thread(TimerThread);
   _timer.IsBackground = true;
   _timer.Start();
 }
예제 #5
0
 public BrunetRpc()
 {
     _rrm = new ReqrepManager("BrunetRpc");
     _rrm.Subscribe(this, null);
     Rpc       = new RpcManager(_rrm);
     IPHandler = new IPHandler();
     IPHandler.Subscribe(this, null);
     _running            = 1;
     _timer              = new Thread(TimerThread);
     _timer.IsBackground = true;
     _timer.Start();
 }
예제 #6
0
    public LocalConnectionOverlord(Node node) {
      _sync = new Object();
      _allow_localcons = false;
      _active = false;
      _local_addresses = new List<AHAddress>();
      _node = node;

      lock(_sync) {
        _rpc = node.Rpc;
        _rpc.AddHandler("LocalCO", this);

        _node.HeartBeatEvent += CheckConnection;
        _node.StateChangeEvent += StateChangeHandler;
        _node.ConnectionTable.ConnectionEvent += ConnectHandler;
        _node.ConnectionTable.DisconnectionEvent += DisconnectHandler;
        _last_announce_call = DateTime.MinValue;
        _last_activate_call = DateTime.MinValue;
      }
    }
예제 #7
0
 public ReflectionRpcHandler(RpcManager rpc, object handler, bool use_sender) {
   _rpc = rpc;
   _handler = handler;
   _type = _handler.GetType();
   _use_sender = use_sender;
   _sync = new object();
   //Cache the 10 most used methods:
   _method_cache = new Cache(10);
 }
예제 #8
0
 public XmlRpcManager(Node node, RpcManager rpc, string uri) {
   Uri = uri;
   _node = node;
   _rpc = rpc;
 }
예제 #9
0
 /**
  * @param url the URL of the XML-RPC service.
  * @param rpc The XmlRpcManager instance that the handler uses.
  */
 public XmlRpcHandler(string url, Node node) {
   _url = url;
   _node = node;
   _rpc = _node.Rpc;
 }
예제 #10
0
 public RpcSendResultAction(RpcManager rpc, object rs, object result) {
   _rpc = rpc; 
   _rs = rs;
   _result = result;
 }
예제 #11
0
 /** 
  * Constructor
  * @param node local node
  * @param state RPC related state.
  * @param task map-reduce task.
  * @param args arguments to the map reduce task.
  */
 public MapReduceComputation(Node node, object state, 
                             MapReduceTask task,
                             MapReduceArgs args)
 {
   _node = node;
   _rpc = node.Rpc;
   _mr_request_state = state;
   _mr_task = task;
   _mr_args = args;
   //Here is our state variable:
   _state = new State();
   _result = State.DEFAULT_OBJ;
 }
예제 #12
0
 /**
  * Constructor
  * @param n local node
  */
 public MapReduceHandler(Node n) {
   _node = n;
   _rpc = n.Rpc;
   _name_to_task = new Dictionary<string, MapReduceTask>();
   _sync = new object();
   //Set up some basic tasks:
   var basetasks = new MapReduceTask[]{
     new MapReduceBoundedBroadcast(_node),
     new MapReduceGreedy(_node),
     new MapReduceListConcat(_node),
   };
   foreach(MapReduceTask mrt in basetasks) {
     SubscribeTask(mrt);
   }
 }
예제 #13
0
 /*** Gracefully close this connection, if it is not already disconnected.
  * Idempotent (calling it twice is the same as once).
  * @return the old state, new state pair.
  */
 public Pair<ConnectionState,ConnectionState> Close(RpcManager rpc, string reason) {
   var old_new = Abort();
   if( old_new.First.Disconnected != true ) {
     //Now try to tell the other node:
     var close_info = new ListDictionary(); 
     if( reason != String.Empty ) {
       close_info["reason"] = reason;
     }
     Edge e = old_new.Second.Edge;
     var results = new Channel(1);
     //Either the RPC call times out, or we get a response.
     results.CloseEvent += delegate(object o, EventArgs args) {
       e.Close();
     };
     try { rpc.Invoke(e, results, "sys:link.Close", close_info); }
     catch { e.Close(); }
   }
   return old_new;
 }
예제 #14
0
 public EchoSendHandler(Node n, ISender dest, object req_state) {
   _rrman = n.Rrm;
   _rpc = n.Rpc;
   _req_state = req_state;
   _dest = dest;
 }
예제 #15
0
 /// <summary>
 /// The overloaded method for now is used to allow RpcManager to be replaced
 /// by MockRpcManager in unit tests.
 /// </summary>
 /// <param name="node"></param>
 /// <param name="rpc"></param>
 /// <param name="uri"></param>
 internal void Add(Node node, RpcManager rpc, string uri) {
   var xrm = new XmlRpcManager(node, rpc);
   lock (_sync_root) {
     // throw an exception if this mapping exists...
     _xrm_mappings.Add(node, xrm);
     RemotingServices.Marshal(xrm, uri);
     CheckAndSetDefaultManager();
   }
   rpc.AddHandler("xmlrpc", xrm);
 }
예제 #16
0
 /**
  * This constructor DOES NOT add the handler,
  * you have to do that.
  *
  * @param n the Node this Handler is for
  */
 public TraceRpcHandler(Node n) {
   _node = n;
   _rpc = n.Rpc;
 }
예제 #17
0
 public XmlRpcManager(Node node, RpcManager rpc) {
   _node = node;
   _rpc = rpc;
 }