public IsisNodeCoordinator()
        {
            IsisSystem.Start();

            _queryHandlersByMessageId.Add((uint)MessageId.ConnectionRequest, OnConnectRequest);

            _broadcastsHandlersByMessageId.Add((uint)MessageId.Empty, message => Log.Info("Received empty message"));
        }
Esempio n. 2
0
        protected void Application_Start(Object sender, EventArgs e)
        {
            Semaphore sem = new Semaphore(0, 1);
            Thread lbFileServerGroupThread = new Thread(delegate()
            {
                //Start the ISIS System
                IsisSystem.Start();

                string groupName        = "FS1";
                string logicalGroupName = "lbalancer-" + groupName;

                fileServerGroupList.TryAdd(logicalGroupName, new FileServerGroupObject());

                Group lbfsgroup = new Group(logicalGroupName);

                lbfsgroup.ViewHandlers += (ViewHandler) delegate(View v)
                {
                    Console.WriteLine("myGroup got a new view event: " + v);

                    Address [] addList = v.GetLiveMembers();
                    for (Int32 index = 0; index < addList.Length; index++)
                    {
                        Isis.WriteLine("The Add List Address " + addList[index].ToStringVerboseFormat());
                        fileServerGroupList[logicalGroupName].addToFileServerList(addList[index]);
                    }

                    Address [] removeList = v.GetFailedMembers();
                    for (Int32 index = 0; index < removeList.Length; index++)
                    {
                        fileServerGroupList[logicalGroupName].removeFromFileServerList(removeList[index]);
                    }
                };

                lbfsgroup.Join();
                sem.Release();
                IsisSystem.WaitForever();
            });

            lbFileServerGroupThread.Start();
            sem.WaitOne();
            Isis.WriteLine("Starting Web Service on the LoadBalancer");

            new AppHost().Init();
        }
        static void Main(string[] args)
        {
            try
            {
                if (args.Length == 3)
                {
                    int setlocal  = int.Parse(args[0]);
                    int setlocal_ = int.Parse(args[1]);
                    local.Port  = setlocal;
                    local_.Port = setlocal_;
                    Console.WriteLine("Local port has been set to " + setlocal + " and " + setlocal_);
                    bootstrap = args[2];
                }
                else if (args.Length == 1)
                {
                    bootstrap = args[0];
                }

                // Set up local UDP communication with web front
                string ip = NetSetup();

                // TODO: add logic to retrieve oracle information from bootstrap server

                // Set up runtime environments
                Environment.SetEnvironmentVariable("ISIS_TCP_ONLY", "true");


                IsisSystem.Start();
                Console.WriteLine("IsisSystem started");
                smallGroup = new SmallGroup("Azure Group");
                smallGroup.Join();
                Console.WriteLine("Azure group joined");
                Thread.Sleep(15 * 1000);

                IsisSystem.WaitForever();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Esempio n. 4
0
            public override void Configure(Funq.Container container)
            {
                Plugins.Add(new RequestLogsFeature());
                this.Config.DefaultContentType = "Json";
                //container.RegisterAutoWired<InMemoryFileSystem>();

                InMemoryFileSystem fileSystem = new InMemoryFileSystem();

                container.Register <InMemoryFileSystem> (fileSystem);

                Console.WriteLine("Application_Start ---->. Begin");

                //Start the ISIS System
                IsisSystem.Start();

                Console.WriteLine("ISIS Started :)");

                FileServerComm.fileServerGroupName = "FileServer";
                FileServerComm fileSrvComm = FileServerComm.getInstance();

                fileSrvComm.getFileHandler().filesystem = fileSystem;

                System.IO.StreamReader file = new System.IO.StreamReader("bootstrap.txt");
                string line = file.ReadLine();

                Console.WriteLine(line);

                bool isBootStrap = false;

                if (line.Equals("1"))
                {
                    isBootStrap = true;
                }

                fileSrvComm.ApplicationStartup(isBootStrap, FileServerComm.fileServerGroupName);

                Console.WriteLine("Application_Start. End");
            }
Esempio n. 5
0
        //public Dictionary<string, Dictionary<string, string>> entity = new Dictionary<string, Dictionary<string, string>>();

        public static void Isis_Start()
        {
            IsisSystem.Start();
            g = new Group("pb476_cs5412");
            int myRank = 0;


            g.ViewHandlers += (ViewHandler) delegate(View v)
            {
                IsisSystem.WriteLine("New View: " + v);
                myRank = v.GetMyRank();

                if (v.members.Length == 5)
                {
                    go.Release(1);
                }
            };
            g.Handlers[UPDATE] += (Action <string, string, string>) delegate(string key, string value, string attkey)
            {
                Dictionary <string, string> attr = new Dictionary <string, string>();
                if (value == "null")
                {
                    entity.Remove(key);
                }
                else if (entity.ContainsKey(key))
                {
                    entity[key] = attr;
                    attr[key]   = attkey;
                }
                else
                {
                    entity.Add(key, attr);
                }
                //collection cp = new collection();
                CS5412_Service cp = new CS5412_Service();
                cp.Set(key, value, attkey);
                IsisSystem.WriteLine("New collection: " + key + "/" + value + "/" + attkey);
            };
            g.Handlers[LOOKUP] += (Action <string>) delegate(string key)
            {
                Dictionary <string, string> attr = new Dictionary <string, string>();
                string result = null;
                //attr = entity;

                if (entity.ContainsKey(key))
                {
                    result = attr[key];
                }


                IsisSystem.WriteLine("=== Query for arg=" + key + "Result" + result);

                /*List<string> answer = new List<string>();
                 * //foreach (collection tp in database)
                 *  if (Get(key) == key)
                 *  {
                 *      IsisSystem.WriteLine("Including " + Get(key) + "/" + GetType());
                 *      answer.Add(Get(key));
                 *  }*/

                g.Reply(result);
            };
            g.Join();
            IsisSystem.WriteLine("Time elapsed is " + stopwatch.Elapsed);

            IsisSystem.WriteLine("Wait until database is full!");
            dbFull.WaitOne();
            IsisSystem.WriteLine("Database is fully populated!");
        }
Esempio n. 6
0
        public static int memPortNum = 9999;                 //memcached port number

        public static void createGroup(int nNum, int sSize, int mRank)
        {
            nodeNum   = nNum;
            shardSize = sSize;
            myRank    = mRank;

            timeout = new Isis.Timeout(15000, Isis.Timeout.TO_FAILURE);

            IsisSystem.Start();
            if (isVerbose)
            {
                Console.WriteLine("Isis system started!");
            }

//            shardSize = 1;
            shardGroup = new Isis.Group[shardSize];


            int groupNum = myRank;

//            groupNum /= sSize;

            for (int i = 0; i < shardSize; i++)
            {
                shardGroup[i] = new Isis.Group("group" + groupNum);
                groupNum--;
                if (groupNum < 0)
                {
                    groupNum += nodeNum;
                }
            }

            for (int i = 0; i < shardSize; i++)
            {
                int local = i;

                //Insert handler
                shardGroup[i].Handlers[INSERT] += (insert) delegate(string command, int rank) {
                    if (isVerbose)
                    {
                        Console.WriteLine("Got a command {0}", command);
                        Console.WriteLine("Rank is {0}", rank);
                    }

                    if (shardGroup[local].GetView().GetMyRank() == rank)
                    {
                        if (isVerbose)
                        {
                            Console.WriteLine("Got a message from myself!");
                        }
                        //shardGroup[local].Reply("Yes");
                    }
                    else
                    {
                        string ret = talkToMem(command, INSERT);
                        if (ret == "STORED")
                        {
                            //shardGroup[local].Reply("Yes");
                        }
                        else
                        {
                            //shardGroup[local].Reply("No");
                        }
                    }
                };

                //Get handler
                shardGroup[i].Handlers[GET] += (query) delegate(string command, int rank) {
                    if (isVerbose)
                    {
                        Console.WriteLine("Got a command {0}", command);
                    }
                    if (shardGroup[local].GetView().GetMyRank() == rank)
                    {
                        if (isVerbose)
                        {
                            Console.WriteLine("Got a message from myself!");
                        }
                        shardGroup[local].Reply("END\r\n");                         //Definitely not presented in local memcached!
                    }
                    else
                    {
                        string ret = talkToMem(command, GET);
                        shardGroup[local].Reply(ret);
                    }
                };

                //View handler
                shardGroup[i].ViewHandlers += (Isis.ViewHandler) delegate(View v) {
                    if (isVerbose)
                    {
                        Console.WriteLine("Got a new view {0}" + v);
                        Console.WriteLine("Group {0} has {1} members", local, shardGroup[local].GetView().GetSize());
                    }
                };
            }

            for (int i = 0; i < shardSize; i++)
            {
                shardGroup[i].Join();
            }

            is_Started = 1;
            IsisSystem.WaitForever();
        }