public void status() { Console.WriteLine("----------Server status----------"); Console.WriteLine("--TupleSpace--"); foreach (TupleClass tuple in tupleSpace) { Console.WriteLine(tuple); } Console.WriteLine("--View--"); foreach (string s in fd.getView()) { Console.WriteLine(s); } Console.WriteLine("--Suspects--"); foreach (string str in fd.getSuspects()) { Console.WriteLine(str); } }
private void selfPrepare(int min_delay, int max_delay) { serverRemoteObjects = new Dictionary <string, IServerService>(); matchIndexMap = new Dictionary <string, int>(); channel = new TcpChannel(_port); Console.WriteLine(_port.ToString()); ChannelServices.RegisterChannel(channel, false); myRemoteObject = new ServerService(this, min_delay, max_delay); RemotingServices.Marshal(myRemoteObject, _name, typeof(ServerService)); //TODO remote object name fd = new FailureDetector(); Console.WriteLine("Hello! I'm a Server at port " + _port); foreach (string url in ConfigurationManager.AppSettings.AllKeys) { string[] urlSplit = url.Split(new Char[] { '/', ':' }, StringSplitOptions.RemoveEmptyEntries); int portOut; Int32.TryParse(urlSplit[2], out portOut); //not to connect to himself if (portOut != _port) { serverRemoteObjects.Add(url, (ServerService)Activator.GetObject(typeof(ServerService), url)); matchIndexMap.Add(url, 0); } } _numServers = serverRemoteObjects.Count; List <string> view = fd.getView(); while (view == null || view.Count == 0) { Thread.Sleep(100); view = fd.getView(); } _state = new FollowerState(this, 0);; Console.WriteLine("Finished constructing server " + _port + " with thread " + Thread.CurrentThread.ManagedThreadId); }
public List <string> viewRequest() { return(fd.getView()); }