Example #1
0
        public void Activate(IActivationLog log, IPerfTimer timer)
        {
            if (!_graph.HasChannels)
            {
                return;
            }

            log.Trace("Determining subscriptions for node " + _cache.NodeName);

            // assuming that there are no automaticly persistent tasks
            // upon startup
            _repository.Persist(new TransportNode(_graph));

            var requirements = determineStaticRequirements(log);


            if (requirements.Any())
            {
                log.Trace("Found static subscription requirements:");
                requirements.Each(x => log.Trace(x.ToString()));
            }
            else
            {
                log.Trace("No static subscriptions found from registry");
            }

            _repository.PersistSubscriptions(requirements);

            var subscriptions = _repository.LoadSubscriptions(SubscriptionRole.Publishes);

            _cache.LoadSubscriptions(subscriptions);

            sendSubscriptions();
        }
Example #2
0
 public void Activate(IActivationLog log, IPerfTimer timer)
 {
     _graph.ReadSettings(_services);
     OpenChannels();
     _graph.StartReceiving(_pipeline, _logger);
     ExecuteActivators();
 }
 public void Activate(IActivationLog log, IPerfTimer timer)
 {
     if (!_strategies.Any())
     {
         log.MarkFailure("There are no IAuthenticationStrategy services registered.  Either register an IAuthenticationStrategy or remove FubuMVC.Authentication from your application");
     }
 }
Example #4
0
 public DbUpgradeManager(Database database, IActivationLog log)
 {
     _database      = database;
     _log           = log;
     _app           = _database.DbModel.EntityApp;
     _dbInfoService = _app.GetService <IDbInfoService>(throwIfNotFound: false);
 }
 public virtual void CreateKey(IActivationLog log)
 {
     if (this.Key != null) //protect against multiple processing
     {
         return;
     }
     // we initially assign temp names
     this.Key = new EntityKeyInfo(HostEntity, KeyType, HostMember, this.Alias);
     // add members
     if (HostMember != null)
     {
         Key.KeyMembers.Add(new EntityKeyMemberInfo(HostMember, false));
     }
     else
     {
         // it will add errors if it fails
         HostEntity.TryParseKeySpec(this.MemberNames, log, out Key.KeyMembers, ordered: true);
     }
     // construct name
     Key.ExplicitDbKeyName = this.DbKeyName;
     // PK
     if (KeyType.IsSet(KeyType.PrimaryKey))
     {
         if (HostEntity.PrimaryKey == null)
         {
             HostEntity.PrimaryKey = Key;
             Key.KeyMembers.Each(km => km.Member.Flags |= EntityMemberFlags.PrimaryKey);
         }
         else
         {
             log.Error("Entity {0} has more than one Primary Key specified.", GetHostRef());
         }
     }
 }
Example #6
0
        public void BuildDbModelChanges(DbUpgradeInfo upgradeInfo, IDbObjectComparer comparer, IActivationLog log)
        {
            _upgradeInfo = upgradeInfo;
            _comparer    = comparer;
            _log         = log;
            _newModel    = upgradeInfo.NewDbModel;
            _oldModel    = upgradeInfo.OldDbModel;
            _options     = _upgradeInfo.Settings.UpgradeOptions;
            var driver = _newModel.Driver;

            _useRefIntegrity = driver.Supports(DbFeatures.ReferentialConstraints) && _newModel.Config.Options.IsSet(DbOptions.UseRefIntegrity);
            _compareTables   = _options.IsSet(DbUpgradeOptions.UpdateTables);
            _compareIndexes  = _options.IsSet(DbUpgradeOptions.UpdateIndexes);
            _compareViews    = driver.Supports(DbFeatures.Views) && _options.IsSet(DbUpgradeOptions.UpdateViews);
            _dropUnknown     = _options.IsSet(DbUpgradeOptions.DropUnknownObjects);
            _supportsSchemas = driver.Supports(DbFeatures.Schemas);

            // Nullify all obj.Peer fields to make sure we drop references to old model - mostly convenience in debugging
            // to allow multiple entry into this method in debugger
            _oldModel.ResetPeerRefs();
            MatchObjectsWithPeers();

            //new stuff
            BuildChangeList();

            // Do not do it here, refs to old objects might be need by Sql generators; we will reset refs after completing update
            // _newModel.ResetPeerRefs()
        }//class
 public bool UpdateDbInfo(DbModel dbModel, DbSettings settings, IActivationLog log, Exception exception = null)
 {
     try {
         var app     = dbModel.EntityApp;
         var session = App.OpenSystemSession();
         var ent     = session.EntitySet <IDbInfo>().FirstOrDefault(e => e.AppName == app.AppName);
         if (ent == null)
         {
             ent         = session.NewEntity <IDbInfo>();
             ent.Version = app.Version.ToString();
             ent.AppName = app.AppName;
         }
         if (exception == null)
         {
             ent.Version = app.Version.ToString();
             ent.LastModelUpdateFailed = false;
             ent.LastModelUpdateError  = null;
             ent.Values = SerializeValues(dbModel.VersionInfo);
             SaveModulesInfo(session, dbModel.VersionInfo);
         }
         else
         {
             ent.LastModelUpdateFailed = true;
             ent.LastModelUpdateError  = exception.ToLogString();
         }
         session.SaveChanges();
         return(true);
     } catch (Exception ex) {
         log.Error(ex.ToLogString());
         return(false);
     }
 }
 public void Activate(IActivationLog log, IPerfTimer timer)
 {
     _graph.ReadSettings(_services);
     OpenChannels();
     _graph.StartReceiving(_pipeline, _logger);
     ExecuteActivators();
 }
        public void Deactivate(IActivationLog log)
        {
            if(_settings.Enabled) return;

            log.Trace("Shutting down the scheduled jobs");
            _scheduledJobs.Deactivate();
        }
Example #10
0
        } //method

        public static EntityFilter ParseFilter(string listFilter, EntityInfo entity, IActivationLog log)
        {
            //Safely parse template - parse throws exc
            StringTemplate template;

            try {
                template = StringTemplate.Parse(listFilter);
            } catch (Exception ex) {
                log.Error(entity.Name + ", error in list filter: " + ex.Message);
                return(null);
            }
            // map names to members
            var members = new List <EntityMemberInfo>();

            foreach (var name in template.ArgNames)
            {
                var member = entity.FindMemberOrColumn(name);
                if (member == null)
                {
                    log.Error("Entity {0}, error in filter expression, member/column {1} not found. ", entity.Name, name);
                }
                else
                {
                    members.Add(member);
                }
            }
            return(new EntityFilter()
            {
                Template = template, Members = members
            });
        }
Example #11
0
 public void Activate(IActivationLog log, IPerfTimer timer)
 {
     if (!_strategies.Any())
     {
         log.MarkFailure("There are no IAuthenticationStrategy services registered.  Either register an IAuthenticationStrategy or remove FubuMVC.Authentication from your application");
     }
 }
        public void Activate(IActivationLog log, IPerfTimer timer)
        {
            if (!_graph.HasChannels) return;

            log.Trace("Determining subscriptions for node " + _cache.NodeName);

            // assuming that there are no automaticly persistent tasks
            // upon startup
            _repository.Persist(new TransportNode(_graph));

            var requirements = determineStaticRequirements(log);

            if (requirements.Any())
            {
                log.Trace("Found static subscription requirements:");
                requirements.Each(x => log.Trace(x.ToString()));
            }
            else
            {
                log.Trace("No static subscriptions found from registry");
            }

            _repository.PersistSubscriptions(requirements);

            var subscriptions = _repository.LoadSubscriptions(SubscriptionRole.Publishes);
            _cache.LoadSubscriptions(subscriptions);

            sendSubscriptions();
        }
Example #13
0
        private Subscription[] determineStaticRequirements(IActivationLog log)
        {
            var requirements = _requirements.SelectMany(x => x.DetermineRequirements()).ToArray();

            traceLoadedRequirements(log, requirements);
            return(requirements);
        }
Example #14
0
 public PgDbModelLoader(DbSettings settings, IActivationLog log) : base(settings, log)
 {
     // Value identifying tables in information_schema.Tables view; for Postgres it is 'BASE TABLE'
     base.TableTypeTag = "BASE TABLE";
     // Value identifying routines in information_schema.Routines view
     base.RoutineTypeTag = "FUNCTION";
 }
Example #15
0
 public DbModelBuilder(EntityModel entityModel, DbModelConfig config, IActivationLog log)
 {
     _entityModel   = entityModel;
     _dbModelConfig = config;
     _namingPolicy  = _dbModelConfig.NamingPolicy;
     _log           = log;
     _driver        = _dbModelConfig.Driver;
 }
Example #16
0
 public void Activate(IActivationLog log, IPerfTimer timer)
 {
     // Find the input models that have remote rules
     // "Bake" them into the remote graph
     _behaviorGraph
     .Actions()
     .Each(FillRules);
 }
 public override void CreateKey(IActivationLog log)
 {
     if (this.Key == null) //protect against multiple processing
     {
         base.CreateKey(log);
         ProcessIndexIncludesAndFilters(log);
     }
 }
 public void Activate(IActivationLog log, IPerfTimer timer)
 {
     // Find the input models that have remote rules
     // "Bake" them into the remote graph
     _behaviorGraph
         .Actions()
         .Each(FillRules);
 }
 public void Activate(IActivationLog log, IPerfTimer timer)
 {
     _registries.Each(r =>
     {
         log.Trace("Adding " + r);
         r.Configure(_stringifier);
     });
 }
 public override void Validate(IActivationLog log)
 {
     base.Validate(log);
     if (HostMember.Kind != EntityMemberKind.EntityList)
     {
         log.Error("Property {0}: OneToMany attribute can be used only on entity list properties.", GetHostRef());
     }
 }
Example #21
0
 public override void Validate(IActivationLog log)
 {
     base.Validate(log);
     if (string.IsNullOrWhiteSpace(this.GroupNames))
     {
         log.Error("Groups value may not be empty, entity {0}.", HostEntity.EntityType);
     }
 }
Example #22
0
 public override void Validate(IActivationLog log)
 {
     base.Validate(log);
     if (HostMember != null && HostMember.Kind != EntityMemberKind.EntityList)
     {
         log.Error("OrderBy attribute may be used only on entities or list properties. Property: {0}", this.GetHostRef());
     }
 }
 public void Activate(IActivationLog log, IPerfTimer timer)
 {
     _registries.Each(r =>
     {
         log.Trace("Adding " + r);
         r.Configure(_stringifier);
     });
 }
 public override void Validate(IActivationLog log)
 {
     base.Validate(log);
     if (this.HostMember == null && string.IsNullOrWhiteSpace(this.MemberNames))
     {
         log.Error("Entity {0}: Index/key attribute ({1}) on entity may not have empty member list.", GetHostRef(), this.GetAttributeName());
     }
 }
Example #25
0
 public override void Validate(IActivationLog log)
 {
     base.Validate(log);
     if (HostMember.Kind != EntityMemberKind.EntityList)
     {
         log.Error("PersistOrderIn attribute may be specified only on list members. Member: {0}.{1}.",
                   HostEntity.EntityType, HostMember.MemberName);
     }
 }
Example #26
0
 public override void Validate(IActivationLog log)
 {
     base.Validate(log);
     if (HostMember.Kind != EntityMemberKind.EntityRef)
     {
         log.Error("CascadeDelete attribute may be used only on properties that are references to other entities. Property: {0}.",
                   GetHostRef());
     }
 }
Example #27
0
 public static void CheckErrors(this IActivationLog log, string header = "Startup failed.")
 {
     if (log.HasErrors)
     {
         var errors = log.GetAllAsText();
         System.Diagnostics.Trace.WriteLine(header + Environment.NewLine + errors);
         throw new StartupFailureException(header, errors);
     }
 }
 public override void Validate(IActivationLog log)
 {
     base.Validate(log);
     KeyType = KeyType.SetFlag(KeyType.Clustered, this.Clustered).SetFlag(KeyType.Unique, this.Unique);
     if (HostMember != null && string.IsNullOrEmpty(this.MemberNames))
     {
         this.MemberNames = HostMember.MemberName;
     }
 }
 public override void Validate(IActivationLog log)
 {
     base.Validate(log);
     if (HostMember.Kind != EntityMemberKind.EntityRef)
     {
         log.Error("{0} may be used only on properties that are references to other entities. Property: {1}",
                   this.GetType().Name, this.GetHostRef());
     }
 }
Example #30
0
 public override void Validate(IActivationLog log)
 {
     base.Validate(log);
     if (string.IsNullOrEmpty(this.PropertyName))
     {
         log.Error("HashFor attribute - PropertyName must be specified. Entity/property: {0}.{1}.",
                   HostEntity.Name, HostMember.MemberName);
     }
 }
Example #31
0
 public override void Validate(IActivationLog log)
 {
     base.Validate(log);
     if (HostMember.ClrMemberInfo.HasSetter())
     {
         log.Error("Computed property {0}.{1} may not have a setter, it is readonly.",
                   HostEntity.EntityType, HostMember.MemberName);
     }
 }
Example #32
0
        public EntityModelBuilder(EntityApp app)
        {
            _app           = app;
            Log            = _app.ActivationLog;
            _customization = (EntityModelCustomizationService)_app.GetService <IEntityModelCustomizationService>();
            Model          = _app.Model = new EntityModel(_app);
#if DEBUG
            RandomizeAttributesOrder = true;
#endif
        }
Example #33
0
        public void Deactivate(IActivationLog log)
        {
            if (_settings.Enabled)
            {
                return;
            }

            log.Trace("Shutting down the scheduled jobs");
            _scheduledJobs.Deactivate();
        }
        public void Activate(IActivationLog log, IPerfTimer timer)
        {
            var repository = _services.VerifyRegistration<ISamlCertificateRepository>(log);
            _services.VerifyRegistration<IPrincipalBuilder>(log);
            _services.VerifyAnyRegistrations<ISamlResponseHandler>(log);

            if (repository != null)
            {
                checkCertificates(repository, log);
            }
        }
Example #35
0
        public override void Validate(IActivationLog log)
        {
            base.Validate(log);
            var dataType = HostMember.DataType;

            if (HostMember.DataType != typeof(DateTime) && HostMember.DataType != typeof(DateTime?))
            {
                log.Error("Property {0}.{1}: Utc attribute may be specified only on DataTime properties. ",
                          HostEntity.Name, HostMember.MemberName);
            }
        }
Example #36
0
 public void Check(IActivationLog log)
 {
     if (File.Exists(_file))
     {
         log.Trace(SuccessMessage, _file);
     }
     else
     {
         log.MarkFailure(FailureMessage, _file);
     }
 }
Example #37
0
 public void Check(IActivationLog log)
 {
     if (Directory.Exists(_folder))
     {
         log.Trace(SuccessMessage, _folder);
     }
     else
     {
         log.MarkFailure(FailureMessage, _folder);
     }
 }
Example #38
0
 public void Check(IActivationLog log)
 {
     if (File.Exists(_file))
     {
         log.Trace(SuccessMessage, _file);
     }
     else
     {
         log.MarkFailure(FailureMessage, _file);
     }
 }
Example #39
0
 public void Check(IActivationLog log)
 {
     if (Directory.Exists(_folder))
     {
         log.Trace(SuccessMessage, _folder);
     }
     else
     {
         log.MarkFailure(FailureMessage, _folder);
     }
 }
        public void Activate(IActivationLog log, IPerfTimer timer)
        {
            if (!_settings.Enabled)
            {
                log.Trace("Skipping activation because FubuTranportation is disabled.");
                return;
            }

            timer.Record("Activating Transports and Starting Listening", () => _transports.Activate(log, timer));
            timer.Record("Activating Subscriptions", () => _subscriptions.Activate(log, timer));
            timer.Record("Activating Polling Jobs", () => _pollingJobs.Activate(log, timer));
        }
 public void Activate(IActivationLog log, IPerfTimer timer)
 {
     _jobs.Where(x => x.ScheduledExecution != ScheduledExecution.Disabled).Each(x => {
         try
         {
             log.Trace("Starting " + x.JobType.GetFullName());
             x.Start();
         }
         catch (Exception ex)
         {
             log.MarkFailure(ex);
         }
     });
 }
        public void Deactivate(IActivationLog log)
        {
            _latch.Latched = true;

            _jobs.Each(x => {
                try
                {
                    x.Dispose();
                }
                catch (Exception ex)
                {
                    log.MarkFailure(ex);
                }
            });
        }
Example #43
0
        public void Activate(IActivationLog log, IPerfTimer timer)
        {
            _jobs.Where(x => x.ScheduledExecution != ScheduledExecution.Disabled).Each(x => {
                try
                {
                    log.Trace($"Starting {x.JobType.GetFullName()} on node {_channels.NodeId}");
                    Debug.WriteLine($"Starting {x.JobType.GetFullName()} on node {_channels.NodeId}");

                    x.Start();
                }
                catch (Exception ex)
                {
                    log.MarkFailure(ex);
                }
            });
        }
Example #44
0
 public static void WithLog(IActivationLog log, Action action)
 {
     _status.PushLog(log);
     try
     {
         log.Execute(action);
     }
     catch (Exception ex)
     {
         log.MarkFailure(ex);
     }
     finally
     {
         _status.PopLog();
     }
 }
Example #45
0
        public void Check(IActivationLog log)
        {
            var file = _folder.AppendPath(TracerFile);
            try
            {
                var system = new FileSystem();
                system.WriteStringToFile(file, "just a test of whether or not a process can write to a folder");
                system.DeleteFile(file);

                log.Trace(SuccessMessage.ToFormat(_folder));
            }
            catch (Exception)
            {
                log.MarkFailure(FailureMessage.ToFormat(_folder));
            }
        }
        private void checkCertificates(ISamlCertificateRepository repository, IActivationLog log)
        {
            var loader = _services.GetInstance<ICertificateLoader>();

            repository.AllKnownCertificates().Each(samlCertificate => {
                try
                {
                    var certificate = loader.Load(samlCertificate.Thumbprint);
                    if (certificate == null)
                    {
                        log.MarkFailure("Could not load Certificate for Issuer " + samlCertificate.Issuer);
                    }
                }
                catch (Exception ex)
                {
                    log.MarkFailure("Could not load Certificate for Issuer " + samlCertificate.Issuer);
                    log.MarkFailure(ex);
                }
            });
        }
Example #47
0
 public void Activate(IActivationLog log, IPerfTimer timer)
 {
     throw new System.NotImplementedException();
 }
 private Subscription[] determineStaticRequirements(IActivationLog log)
 {
     var requirements = _requirements.SelectMany(x => x.DetermineRequirements()).ToArray();
     traceLoadedRequirements(log, requirements);
     return requirements;
 }
 public void Activate(IActivationLog log, IPerfTimer timer)
 {
     log.Trace("Starting the in memory performance history tracking");
     _queue.Start();
 }
 public void Activate(IActivationLog log, IPerfTimer timer)
 {
     Thread.Sleep(_time);
 }
 private static void traceLoadedRequirements(IActivationLog log, Subscription[] requirements)
 {
     log.Trace("Found subscription requirements:");
     requirements.Each(x => log.Trace(x.ToString()));
 }
 public void Deactivate(IActivationLog log)
 {
     _settings.Middleware.OfType<IDisposable>().Each(x => x.Dispose());
 }
 public void Activate(IActivationLog log, IPerfTimer timer)
 {
     _factory.LoadAll(text => log.Trace(text));
     _factory.ApplyToLocalizationManager();
 }
 public void Deactivate(IActivationLog log)
 {
     throw new NotImplementedException();
 }
 public void Activate(IActivationLog log, IPerfTimer timer)
 {
     _watcher.Start();
 }
Example #56
0
 public void Activate(IActivationLog log, IPerfTimer timer)
 {
     _action();
 }
 public void Activate(IActivationLog log, IPerfTimer timer)
 {
     log.Trace("Adding TransportCleanup to the remote EventAggregator");
     Services.Messaging.EventAggregator.Messaging.AddListener(_cleanup);
 }
 public void Deactivate(IActivationLog log)
 {
     Messages.Add(_name);
 }
 public void Activate(IActivationLog log, IPerfTimer timer)
 {
     _controller.StartWatching(_context.SpecPath);
     _context.AddRemoteListener(_controller);
 }
Example #60
0
 public void PushLog(IActivationLog log)
 {
     _logs.Push(log);
 }