Ejemplo n.º 1
0
        public Cluster(ActorSystemImpl system)
        {
            System   = system;
            Settings = new ClusterSettings(system.Settings.Config, system.Name);

            var provider = system.Provider as ClusterActorRefProvider;

            if (provider == null)
            {
                throw new ConfigurationException(
                          String.Format("ActorSystem {0} needs to have a 'ClusterActorRefProvider' enabled in the configuration, currently uses {1}",
                                        system,
                                        system.Provider.GetType().FullName));
            }
            SelfUniqueAddress = new UniqueAddress(provider.Transport.DefaultAddress, AddressUidExtension.Uid(system));

            _log = Logging.GetLogger(system, "Cluster");

            LogInfo("Starting up...");

            _failureDetector = new DefaultFailureDetectorRegistry <Address>(() => FailureDetectorLoader.Load(Settings.FailureDetectorImplementationClass, Settings.FailureDetectorConfig,
                                                                                                             system));

            _scheduler = CreateScheduler(system);

            // it has to be lazy - otherwise if downing provider will init a cluster itself, it will deadlock
            _downingProvider = new Lazy <IDowningProvider>(() => Akka.Cluster.DowningProvider.Load(Settings.DowningProviderType, system), LazyThreadSafetyMode.ExecutionAndPublication);

            //create supervisor for daemons under path "/system/cluster"
            _clusterDaemons = system.SystemActorOf(Props.Create(() => new ClusterDaemon(Settings)).WithDeploy(Deploy.Local), "cluster");

            _readView = new ClusterReadView(this);

            // force the underlying system to start
            _clusterCore = GetClusterCoreRef().Result;

            system.RegisterOnTermination(Shutdown);

            LogInfo("Started up successfully");
        }
Ejemplo n.º 2
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="system">TBD</param>
 public AutoDowning(ActorSystem system)
 {
     _clusterSettings = Cluster.Get(system).Settings;
 }
        public static IMetricsCollector Get(ExtendedActorSystem system, ClusterSettings settings)
        {
            var fqcn = settings.MetricsCollectorClass;
            if (fqcn == typeof (PerformanceCounterMetricsCollector).AssemblyQualifiedName) return new PerformanceCounterMetricsCollector(system);
            
            var metricsCollectorClass = Type.GetType(fqcn);
            if (metricsCollectorClass == null)
            {
                throw new ConfigurationException(string.Format("Could not create custom metrics collector {0}", fqcn));
            }

            try
            {
                var metricsCollector = (IMetricsCollector) Activator.CreateInstance(metricsCollectorClass, system);
                return metricsCollector;
            }
            catch (Exception ex)
            {
                throw new ConfigurationException(string.Format("Could not create custom metrics collector {0} because: {1}", fqcn, ex.Message));
            }
        }
Ejemplo n.º 4
0
 public InfoLogger(ILoggingAdapter log, ClusterSettings settings, Address selfAddress)
 {
     _log = log;
     _settings = settings;
     _selfAddress = selfAddress;
 }
Ejemplo n.º 5
0
        public ClusterDaemon(ClusterSettings settings)
        {
            // Important - don't use Cluster(context.system) here because that would
            // cause deadlock. The Cluster extension is currently being created and is waiting
            // for response from GetClusterCoreRef in its constructor.
            _coreSupervisor =
                Context.ActorOf(Props.Create<ClusterCoreSupervisor>().WithDispatcher(settings.UseDispatcher), "core");

            Context.ActorOf(Props.Create<ClusterHeartbeatReceiver>().WithDispatcher(settings.UseDispatcher), "heartbeatReceiver");

            _settings = settings;
        }
Ejemplo n.º 6
0
 public AutoDowning(ActorSystem system)
 {
     _clusterSettings = Cluster.Get(system).Settings;
 }