Exemple #1
0
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.Error.WriteLine("Usage: <program> <db address:port> <shard ID.");
                Environment.Exit(-1);
            }
            try
            {
                BaseDB.Connect(new Address(args[0]));
                ShardID id = ShardID.Decode(args[1]);

                var rs = BaseDB.TryGetAddress(id);
                while (rs.IsEmpty)
                {
                    Thread.Sleep(1000);
                    rs = BaseDB.TryGetAddress(id);
                }
                Console.WriteLine(rs.PeerAddress);
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex);
                Environment.Exit(-1);
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                throw new ArgumentException("Missing arguments. Usage: Executable <DBHost> <ShardID>");
            }
            int at     = 0;
            var dbHost = new Address(args[at++]);

            BaseDB.Connect(dbHost);            //,"admin","1234");
            ShardID addr = ShardID.Decode(args[at++]);

            BaseDB.BeginPullConfig(addr.XYZ);

            iface = new Consensus.Interface(addr, -1, 0, true, Consensus.Interface.ThreadOperations.CheckConfiguration, new Notify(error =>
            {
                Log.Error(error);
                iface.Dispose();
                Log.Message("Shutting down");
            }, () => iface));
            iface.Notify.OnConsensusChange(Consensus.Status.NotEstablished, null);

            iface.AwaitClosure();
        }
Exemple #3
0
        static void Main(string[] args)
        {
            //RunStupidModel();
            //return;



            if (args.Length < 2)
            {
                Console.Error.WriteLine("Usage: shard <db url> <my addr> | shard <db url> --setup");
                return;
            }

            try
            {
                int at     = 0;
                var dbHost = new Address(args[at++]);
                BaseDB.Connect(dbHost);                //,"admin","1234");
                ShardID addr = ShardID.Decode(args[at++]);


                bool haveConfig = BaseDB.BeginPullConfig(addr.XYZ);
                if (!haveConfig)
                {
                    Log.Error("Failed to establish connection to database");
                    Environment.Exit(-1);
                }

                Log.Message("Setting up clock");
                Clock.NTPHost = BaseDB.Config.ntp;

                while (Clock.NumQueries < 1)
                {
                    Thread.Sleep(100);
                }
                Log.Message("Starting up");



#if DRY_RUN
                if (addr == new ShardID())                  //root
                {
                    Log.Message("Resetting timer");
                    while (true)
                    {
                        Thread.Sleep(100);
                        var t = BaseDB.Timing;
                        if (t == null)
                        {
                            continue;
                        }

                        var n = Clock.Now + TimeSpan.FromSeconds(10);
                        t.startTime          = n.ToShortDateString() + " " + n.ToLongTimeString();
                        t.msGenerationBudget = 3000;                            //make sure we compute slowly
                        BaseDB.Timing        = t;
                        break;
                    }
                }
#endif


                if ((addr.XYZ >= BaseDB.Config.extent).Any)
                {
                    throw new ArgumentOutOfRangeException("addr", addr, "Exceeds extent: " + BaseDB.Config.extent);
                }
                if ((addr < ShardID.Zero).Any)
                {
                    throw new ArgumentOutOfRangeException("addr", addr, "Is (partially) negative");
                }

                Simulation.Run(addr);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }