public ServiceManager(AppConfig config)
            {
                _dataTransfer  = DataTransferManager.New(Context, "File_Coordination");
                _repositoryApi = RepositoryApi.CreateProxy(Context.System);

                Receive <Init>(_ =>
                {
                    try
                    {
                        if (string.IsNullOrWhiteSpace(config.CurrentConfig))
                        {
                            return;
                        }

                        var hConfig          = ConfigurationFactory.ParseString(config.CurrentConfig);
                        var connectionString = hConfig.GetString("akka.persistence.journal.mongodb.connection-string");

                        if (string.IsNullOrWhiteSpace(connectionString))
                        {
                            return;
                        }

                        var stream = Context.System.EventStream;

                        Cluster.Get(Context.System).RegisterOnMemberUp(() =>
                        {
                            InitClient(connectionString);
                            stream.Publish(new DeploymentServicesChanged(_repository?.IsOk == true && _deploymentServer?.IsOk == true));
                        });
                    }
                    catch (Exception e)
                    {
                        Log.Warning(e, "Error on Parsing Current Configuration");
                    }
                });
                Receive <NewConnectionString>(s =>
                {
                    try
                    {
                        var hConfig          = ConfigurationFactory.ParseString(s.Config);
                        var connectionString = hConfig.GetString("akka.persistence.journal.mongodb.connection-string");

                        InitClient(connectionString);
                    }
                    catch (Exception e)
                    {
                        Log.Error(e, "Error on Init new Connection String");
                    }

                    Context.System.EventStream.Publish(new DeploymentServicesChanged(_repository?.IsOk == true && _deploymentServer?.IsOk == true));
                });
                Receive <GetCurrentState>(_ => Sender.Tell(new DeploymentServicesChanged(_repository?.IsOk == true && _deploymentServer?.IsOk == true)));
            }
Exemplo n.º 2
0
        static async Task Main(string[] args)
        {
            await Bootstrap.StartNode(args, KillRecpientType.Service)
            .ConfigurateAkkaSystem((context, system) =>
            {
                var repoManager = RepositoryApi.CreateProxy(system);
                var fileManager = DataTransferManager.New(system, "FileTransferManager");

                DeploymentManager.InitDeploymentManager(
                    system,
                    system.Settings.Config.GetString("akka.persistence.journal.mongodb.connection-string"), fileManager, repoManager);
            })
            .Build().Run();
        }
Exemplo n.º 3
0
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterSettingsManager(c => c.WithProvider <LocalConfigurationProvider>());
            builder.RegisterType <LocalConfiguration>().As <ILocalConfiguration>().SingleInstance();

            builder.Register(c => c.Resolve <IEventAggregator>().GetEvent <ConfigEventDispatcher, IConfigEvent>()).SingleInstance();

            builder.RegisterType <ClusterConnectionTracker>().As <IClusterConnectionTracker>().SingleInstance();
            builder.RegisterType <DatabaseConfig>().As <IDatabaseConfig>().SingleInstance();
            builder.RegisterType <ServerConfigurationApi>().As <IServerConfigurationApi>().SingleInstance();
            builder.RegisterType <PropertyChangedNotifer>().As <IPropertyChangedNotifer>().SingleInstance();

            builder.RegisterFeature <ClusterNodeManagerRef, IClusterNodeManager>(ClusterHostManagerActor.New());
            builder.RegisterFeature <ApiEventDispatcherRef, IApiEventDispatcher>(ApiEventDispatcherActor.New());
            builder.RegisterFeature <ProcessServiceHostRef, IProcessServiceHost>(ProcessServiceHostActor.New());

            builder.Register(c => DeploymentApi.CreateProxy(c.Resolve <ActorSystem>())).SingleInstance();
            builder.Register(c => RepositoryApi.CreateProxy(c.Resolve <ActorSystem>())).SingleInstance();
            builder.Register(c => ConfigurationApi.CreateProxy(c.Resolve <ActorSystem>())).SingleInstance();

            builder.RegisterStartUpAction <ActorStartUp>();

            base.Load(builder);
        }
        //TODO Refactor for StateManager

        public SetupBuilderViewModel(ILifetimeScope lifetimeScope, Dispatcher dispatcher, AppConfig config, DeploymentServices deploymentServices, IActionInvoker actionInvoker)
            : base(lifetimeScope, dispatcher, actionInvoker)
        {
            _config        = config;
            _server        = new SetupServer(s => UICall(() => TerminalLines !.Add(s)), Context.System.Settings.Config);
            _deploymentApi = DeploymentApi.CreateProxy(Context.System, "SetupBuilder_DeploymentApi");
            _repositoryApi = RepositoryApi.CreateProxy(Context.System, "SetupBuilder_RepositoryApi");

            AddShortcut   = RegisterProperty <bool>(nameof(AddShortcut));
            CurrentError  = RegisterProperty <string>(nameof(CurrentError));
            AddSeed       = RegisterProperty <bool>(nameof(AddSeed));
            TerminalLines = this.RegisterUiCollection <string>(nameof(TerminalLines)).AndAsync();

            var hostEntrys = new HashSet <string>();

            _api = HostApi.CreateOrGet(Context.System);
            Receive <HostEntryChanged>(e =>
            {
                if (string.IsNullOrWhiteSpace(e.Name))
                {
                    return;
                }

                if (e.Removed)
                {
                    hostEntrys.Remove(e.Name);
                }
                else
                {
                    hostEntrys.Add(e.Name);
                }
            });

            Func <string, string?> HostNameValidator(Func <UIProperty <string> > counterPart)
            {
                return(s =>
                {
                    if (string.IsNullOrWhiteSpace(s))
                    {
                        return LocLocalizer.Inst.SetupBuilderView.ErrorEmptyHostName;
                    }
                    return hostEntrys.Contains(s) || s == counterPart().Value ? LocLocalizer.Inst.SetupBuilderView.ErrorDuplicateHostName : null;
                });
            }

            HostName = RegisterProperty <string>(nameof(HostName))
                       .WithValidator(SetError(HostNameValidator(() => SeedHostName !)))
                       .OnChange(s => SeedHostName += s + "_Seed");

            SeedHostName = RegisterProperty <string>(nameof(SeedHostName))
                           .WithValidator(SetError(HostNameValidator(() => HostName)));

            NewCommad
            .WithCanExecute(b =>
                            b.And(
                                deploymentServices.IsReadyQuery(b),
                                b.FromProperty(_buildRunning, i => i == 0),
                                b.FromProperty(HostName.IsValid),
                                b.Or(
                                    b.FromProperty(AddSeed, s => !s),
                                    b.FromProperty(SeedHostName.IsValid))))
            .WithExecute(ExecuteBuild)
            .ThenRegister("CreateSeupCommand");
        }
Exemplo n.º 5
0
        public static async Task Main(string[] args)
        {
            await Bootstrap.StartNode(args, KillRecpientType.Service, IpcApplicationType.Client,
                                      ab =>
            {
                ab.OnMemberUp((context, system, cluster) =>
                {
                    string ApplyMongoUrl(string baseUrl, string repoKey, SharpRepositoryConfiguration configuration)
                    {
                        var builder = new MongoUrlBuilder(baseUrl)
                        {
                            DatabaseName = repoKey, ApplicationName = context.HostingEnvironment.ApplicationName
                        };
                        var mongoUrl = builder.ToString();

                        configuration.AddRepository(new MongoDbRepositoryConfiguration(repoKey, mongoUrl)
                        {
                            Factory = typeof(MongoDbConfigRepositoryFactory)
                        });

                        return(mongoUrl);
                    }

                    ServiceRegistry.Get(system)
                    .RegisterService(new RegisterService(
                                         context.HostingEnvironment.ApplicationName,
                                         cluster.SelfUniqueAddress,
                                         ServiceTypes.Infrastructure));

                    var connectionstring = system.Settings.Config.GetString("akka.persistence.snapshot-store.mongodb.connection-string");
                    if (string.IsNullOrWhiteSpace(connectionstring))
                    {
                        LogManager.GetCurrentClassLogger().Error("No Mongo DB Connection provided: Shutdown");
                        system.Terminate();
                        return;
                    }

                    var config            = new SharpRepositoryConfiguration();
                    var fileSystemBuilder = new VirtualFileFactory();

                    ApplyMongoUrl(connectionstring, CleanUpManager.RepositoryKey, config);

                    var url = ApplyMongoUrl(connectionstring, RepositoryManager.RepositoryKey, config);
                    RepositoryManager.InitRepositoryManager(system,
                                                            new RepositoryManagerConfiguration(config, fileSystemBuilder.CreateMongoDb(url),
                                                                                               DataTransferManager.New(system, "Repository-DataTransfer")));

                    url = ApplyMongoUrl(connectionstring, DeploymentManager.RepositoryKey, config);
                    DeploymentManager.InitDeploymentManager(system,
                                                            new DeploymentConfiguration(config,
                                                                                        fileSystemBuilder.CreateMongoDb(url),
                                                                                        DataTransferManager.New(system, "Deployment-DataTransfer"),
                                                                                        RepositoryApi.CreateProxy(system)));

                    ApplyMongoUrl(connectionstring, ServiceManagerDeamon.RepositoryKey, config);
                    ServiceManagerDeamon.Init(system, config);
                })
                .OnMemberRemoved((_, system, _) => system.Terminate());
            }, true)