示例#1
0
        void ApplicationStartFileServerComm(bool isBootStrap, String fileServerGroupName)
        {
            Logger.Debug("ApplicationStartFileServerComm ---->. Begin " + isBootStrap);
            Thread fileServerCommThread = new Thread(delegate()
            {
                Logger.Debug("ApplicationStartFileServerComm. Begin");
                registerBootStrapHandlers();
                registerFileOperationHandlers();

                Msg.RegisterType(typeof(BootStrappingCheckPoint), BootStrapBegin);
                Msg.RegisterType(typeof(BootStrappingCheckPoint), BootStrapContinue);
                Msg.RegisterType(typeof(BootStrappingCheckPoint), BootStrapEnd);
                Msg.RegisterType(typeof(BootStrappingRequest), BootStrapRequest);
                Msg.RegisterType(typeof(BootStrappingResponse), BootStrapResponse);

                Msg.RegisterType(typeof(UserMetaDataSync), UpdateUserMetaData);
                Msg.RegisterType(typeof(FileMetaDataSync), UpdateFileMetaData);
                Msg.RegisterType(typeof(FileMetaDataSync), DeleteFileFromMemory);
                Msg.RegisterType(typeof(FileMetaDataSync), DeleteFile);
                Msg.RegisterType(typeof(OOBTransaction), SaveFileToMemory);
                Msg.RegisterType(typeof(OOBTransaction), UpdateUser);

                Msg.RegisterType(typeof(SyncSharedUser), ShareWithUser);
                Msg.RegisterType(typeof(SyncUnSharedUser), UnshareWithUser);


                fileServerGroup.ViewHandlers += (Isis.ViewHandler) delegate(View v)
                {
                    Logger.Debug("myGroup got a new view event: " + v);
                };

                fileServerGroup.Join();

                if (isBootStrap)
                {
                    Logger.Debug("Need to do BootStrapping :), So I'll do BootStrapping");
                    bootstrap.sendBootStrappingRequest(fileServerGroup, null);
                }
                else
                {
                    Logger.Debug("Do not Need to Do BootStrapping. Start the Application Server");
                    bootstrap.state.currState = eBootStrapState.BootStrappingComplete;
                    bootstrap.waitBootStrap.Release();
                }

                IsisSystem.WaitForever();
                Logger.Debug("ApplicationStartFileServerComm. End");
            });

            fileServerCommThread.Start();
        }
示例#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);
            }
        }
        static void Main(string[] args)
        {
            Logger Log = LogManager.GetLogger("ConsoleHost");


            Log.Info("Starting ISIS");
            var coordinator = new IsisNodeCoordinator();

            IPEndPoint externalEndpoint = null;
            IPEndPoint internalEndpoint = null;

            try
            {
                if (args.Length == 2)
                {
                    string[] addrPort = args[0].Split(':');
                    externalEndpoint = new IPEndPoint(IPAddress.Parse(addrPort[0]), int.Parse(addrPort[1]));
                    addrPort         = args[1].Split(':');
                    internalEndpoint = new IPEndPoint(IPAddress.Parse(addrPort[0]), int.Parse(addrPort[1]));
                }
                else
                {
                    externalEndpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 5055);
                    internalEndpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 5056);
                }
            }
            catch (Exception)
            {
                Log.Error("incorrect cmd params - expected:  externalIp:port internalIp:port");
            }

            var builder = new ContainerBuilder();

            //register core messages
            builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof(EmptyMessage)))
            .Where(x => x.IsAssignableTo <Message>() && x != typeof(Message))
            .As <Message>();

            //register domain messages
            builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof(IChatLogin)))
            .Where(x => x.IsAssignableTo <Message>() && x != typeof(Message))
            .As <Message>();

            //register domain service definitions and proxies
            builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof(IChatLogin)))
            .Where(x => x.IsAssignableTo <NetProxy>() && x != typeof(NetProxy))
            .As <NetProxy>();

            //register domain service implementations
            builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof(UserManager)))
            .Where(x => x.IsAssignableTo <Actor>() && x != typeof(Actor))
            .As <Actor>();

            builder.RegisterType <OperationDispatcher>().As <IOperationDispatcher>().SingleInstance();
            builder.RegisterType <ActorRepository>().As <IActorRepository>().SingleInstance();
            builder.RegisterType <MessageFactory>().As <IMessageFactory>().SingleInstance();

            var externalNetConf = new NetPeerConfiguration("ChatApp")
            {
                ConnectionTimeout = 30,
                Port         = externalEndpoint.Port,
                LocalAddress = externalEndpoint.Address
            };
            var internalNetConf = new NetPeerConfiguration("ChatApp")
            {
                ConnectionTimeout = 30,
                Port         = internalEndpoint.Port,
                LocalAddress = internalEndpoint.Address
            };

            builder.Register(c => new ServerNode(
                                 new LidgrenNetProvider(externalNetConf),
                                 new LidgrenNetProvider(internalNetConf),
                                 coordinator,
                                 c.Resolve <IMessageFactory>(), c.Resolve <IOperationDispatcher>(), c.Resolve <IActorRepository>(), () => new ChatClient()))
            .As <IServerNode>().SingleInstance();

            var container = builder.Build();

            var node = container.Resolve <IServerNode>();

            node.Start();

            IsisSystem.WaitForever();
        }
示例#5
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();
        }