예제 #1
0
        public ServerApiSmr(string id, string url, int minDelay, int maxDelay, List <string> serversUrls)
        {
            BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider();

            this.Id = id;
            Hashtable props = new Hashtable();
            int       port  = DU.ExtractPortFromUrl(url);

            props["port"]    = port;
            props["timeout"] = 1000;
            Channel          = new TcpChannel(props, null, provider);
            Nodes            = new List <Node>();

            ChannelServices.RegisterChannel(Channel, false);

            foreach (string serverUrl in serversUrls)
            {
                if (port != DU.ExtractPortFromUrl(serverUrl))
                {
                    Nodes.Add((Node)Activator.GetObject(typeof(Node), serverUrl));
                }
            }

            Node node = new Node(id, url, Nodes, minDelay, maxDelay);

            RemotingServices.Marshal(node, DU.ExtractObjectNameFromUrl(url));
        }
예제 #2
0
        //TODO: change this url. it should be the client's
        public ClientSmrApi(string id, string url, string scriptFile, List <string> serversUrls)
        {
            this.Id  = id;
            this.Seq = 0;
            int port = DU.ExtractPortFromUrl(url);

            Channel = new TcpChannel(port);
            Nodes   = new Dictionary <string, Node>();
            urls    = new List <string>();

            ChannelServices.RegisterChannel(Channel, false);
            Console.WriteLine(scriptFile);

            foreach (string serverUrl in serversUrls)
            {
                Nodes[serverUrl] = ((Node)Activator.GetObject(
                                        typeof(Node),
                                        serverUrl));
                //String.Format("tcp://{0}/Node", serverUrl)));
                urls.Add(serverUrl);
            }


            //System.Console.ReadLine();
        }
예제 #3
0
        //TODO: change this url. it should be the client's
        public ClientSmrApi(string id, string url, string scriptFile, List <string> serversUrls)
        {
            this.Id  = id;
            this.Seq = 0;
            int port = DU.ExtractPortFromUrl(url);

            Channel = new TcpChannel(port);
            Nodes   = new Dictionary <string, Node>();
            urls    = new List <string>();

            ChannelServices.RegisterChannel(Channel, false);
            Console.WriteLine(scriptFile);
            Dictionary <int, Pingable> ping = new Dictionary <int, Pingable>();
            int i = 0;

            foreach (string serverUrl in serversUrls)
            {
                Nodes[serverUrl] = ((Node)Activator.GetObject(
                                        typeof(Node),
                                        serverUrl));
                urls.Add(serverUrl);
                ping.Add(i, Nodes[serverUrl]);
                i++;
            }
            manager = new ViewManager(ping);
            manager.Start();
        }
예제 #4
0
        //TODO: change this url. it should be the client's
        public ClientApi(string id, string url, string scriptFile, List <string> serversUrls)
        {
            this.Id  = id;
            this.Seq = 0;
            //TODO: REMOVE Channel = new TcpChannel(Int32.Parse(url.Split(':')[1]));
            Channel = new TcpChannel(DU.ExtractPortFromUrl(url));

            ChannelServices.RegisterChannel(Channel, false);
            Console.WriteLine(scriptFile);

            for (int i = 0; i < serversUrls.Count; i++)
            {
                TupleSpaces.Add(serversUrls[i], (Pingable)Activator.GetObject(typeof(TupleSpace), serversUrls[i]));
            }
        }
예제 #5
0
        public List <string> RequestView()
        {
            CheckOnlyFreeze();
            List <string> view = viewManager.RequestView();

            foreach (string url in view)
            {
                if (DU.ExtractPortFromUrl(url) < DU.ExtractPortFromUrl(selfUrl))
                {
                    return(null);
                }
            }
            view.Add(selfUrl);
            return(view);
        }
예제 #6
0
        public ServerApi(string id, string url, int minDelay, int maxDelay, List <String> urls)
        {
            int        port    = DU.ExtractPortFromUrl(url);
            TcpChannel Channel = new TcpChannel(DU.ExtractPortFromUrl(url));

            ChannelServices.RegisterChannel(Channel, false);

            Dictionary <string, Pingable> TupleSpaces = new Dictionary <string, Pingable>();
            string selfURL = "";

            foreach (string serverUrl in urls)
            {
                if (port != DU.ExtractPortFromUrl(serverUrl))
                {
                    Console.WriteLine(serverUrl);
                    TupleSpaces.Add(serverUrl, (TupleSpace)Activator.GetObject(typeof(TupleSpace), serverUrl));
                }
                else
                {
                    selfURL = serverUrl;
                }
            }

            TupleSpace tupleSpace = new TupleSpace(selfURL, minDelay, maxDelay, TupleSpaces);

            RemotingServices.Marshal(tupleSpace, DU.ExtractObjectNameFromUrl(url));
            tupleSpace.Stopped = true;
            List <TupleSpace> tupleSpaces = new List <TupleSpace>();

            foreach (var entry in TupleSpaces)
            {
                tupleSpaces.Add((TupleSpace)entry.Value);
            }
            tupleSpace.Update();
            tupleSpace.Stopped = false;
            Console.WriteLine("Enter to exit");
            Console.ReadLine();
        }