Beispiel #1
0
        protected override void DoStart()
        {
            if (m_TargetName.IsNullOrWhiteSpace())
            {
                throw new MdbException(StringConsts.MDB_STORE_CONFIG_NO_TARGET_NAME_ERROR);
            }

            if (m_Areas.Count == 0)
            {
                throw new MdbException(StringConsts.MDB_STORE_CONFIG_NO_AREAS_ERROR);
            }


            try
            {
                GdidAuthorityService.CheckNameValidity(m_SchemaName);
                GdidAuthorityService.CheckNameValidity(m_BankName);

                var gdidScope = GetGdidScopePrefix(m_SchemaName, m_BankName);
                m_GdidGenerator = new GdidGenerator(this, "GdidGen({0})".Args(gdidScope), gdidScope, null);
                foreach (var ah in App.AsSky().Metabase.GDIDAuthorities)
                {
                    m_GdidGenerator.AuthorityHosts.Register(ah);
                    App.Log.Write(new Azos.Log.Message
                    {
                        Type  = Azos.Log.MessageType.InfoD,
                        Topic = SysConsts.LOG_TOPIC_MDB,
                        From  = GetType().FullName + ".makeGDIDGen()",
                        Text  = "Registered GDID authority host: " + ah.ToString()
                    });
                }
            }
            catch (Exception error)
            {
                throw new MdbException(StringConsts.MDB_STORE_CONFIG_GDID_ERROR + error.ToMessageWithType());
            }

            try
            {
                m_Cache      = new LocalCache(this, "MDBDataStore::" + Name);
                m_Cache.Pile = new DefaultPile(m_Cache, "MDBDataStore::Pile::" + Name);
                m_Cache.Configure(null);
                m_Cache.Start();
            }
            catch
            {
                try { DisposableObject.DisposeAndNull(ref m_GdidGenerator); } catch {}
                try { DisposableObject.DisposeAndNull(ref m_Cache); } catch {}
                throw;
            }
        }
Beispiel #2
0
        public void GD_ParallelGeneration_SameSequence()
        {
            prepdirs();

            var conf = LaconicConfiguration.CreateFromString(CONFIG);

            using (var app = new AzosApplication(null, conf.Root))
                using (var authority = new GdidAuthorityService(app))
                {
                    authority.Configure(null);
                    authority.Start();
                    _parallelGenerationSame();
                }
        }
Beispiel #3
0
        static void run(string[] args)
        {
            const string FROM = "AGDIDA.Program";

            using (var app = new SkyApplication(SystemApplicationType.GDIDAuthority, args, null))
            {
                try
                {
                    using (var authority = new GdidAuthorityService(app))
                    {
                        authority.Configure(null);
                        authority.Start();
                        try
                        {
                            // WARNING: Do not modify what this program reads/writes from/to standard IO streams because
                            //  AHGOV uses those particular string messages for its protocol
                            Console.WriteLine("OK."); //<-- AHGOV protocol, AHGOV waits for this token to assess startup situation
                            ConsoleUtils.WriteMarkupContent(typeof(ProgramBody).GetText("Welcome.txt"));
                            Console.WriteLine("Waiting for line to terminate...");

                            var abortableConsole = new TerminalUtils.AbortableLineReader();
                            try
                            {
                                while (app.Active)
                                {
                                    if (abortableConsole.Line != null)
                                    {
                                        app.Log.Write(new Message
                                        {
                                            Type  = MessageType.Info,
                                            Topic = SysConsts.LOG_TOPIC_ID_GEN,
                                            From  = FROM,
                                            Text  = "Main loop received CR|LF. Exiting..."
                                        });
                                        break; //<-- AHGOV protocol, AHGOV sends a <CRLF> when it is time to shut down
                                    }
                                    Thread.Sleep(250);
                                }
                            }
                            finally
                            {
                                abortableConsole.Abort();
                            }
                        }
                        finally
                        {
                            authority.WaitForCompleteStop();
                        }
                    }
                }
                catch (Exception error)
                {
                    app.Log.Write(new Message
                    {
                        Type      = MessageType.CatastrophicError,
                        Topic     = SysConsts.LOG_TOPIC_ID_GEN,
                        From      = FROM,
                        Text      = "Exception leaked in run(): " + error.ToMessageWithType(),
                        Exception = error
                    });

                    throw error;
                }
            }//using app
        }