Esempio n. 1
30
 /// <summary>
 ///     Initializes a new instance of the <see cref="RemoteDaemon" /> class.
 /// </summary>
 /// <param name="system">The system.</param>
 /// <param name="path">The path.</param>
 /// <param name="parent">The parent.</param>
 /// <param name="log"></param>
 public RemoteDaemon(ActorSystemImpl system, ActorPath path, InternalActorRef parent, LoggingAdapter log)
     : base(system.Provider, path, parent, log)
 {
     _system = system;
     AddressTerminatedTopic.Get(system).Subscribe(this);
 }
Esempio n. 2
17
        private TestKitBase(TestKitAssertions assertions, ActorSystem system, Config config, string actorSystemName, string testActorName)
        {
            if(assertions == null) throw new ArgumentNullException("assertions");
            if(system == null)
            {
                var configWithDefaultFallback = config.SafeWithFallback(_defaultConfig);
                system = ActorSystem.Create(actorSystemName ?? "test", configWithDefaultFallback);
            }

            _assertions = assertions;
            _system = system;
            system.RegisterExtension(new TestKitExtension());
            system.RegisterExtension(new TestKitAssertionsExtension(assertions));
            _testKitSettings = TestKitExtension.For(_system);
            _queue = new BlockingQueue<MessageEnvelope>();
            _log = Logging.GetLogger(system, GetType());
            _eventFilterFactory = new EventFilterFactory(this);
            if (string.IsNullOrEmpty(testActorName))
                testActorName = "testActor" + _testActorId.IncrementAndGet();

            var testActor = CreateTestActor(system, testActorName);
            //Wait for the testactor to start
            AwaitCondition(() =>
            {
                var repRef = testActor as RepointableRef;
                return repRef == null || repRef.IsStarted;
            }, TimeSpan.FromSeconds(5), TimeSpan.FromMilliseconds(10));

            if(!(this is NoImplicitSender))
            {
                InternalCurrentActorCellKeeper.Current = (ActorCell)((ActorRefWithCell)testActor).Underlying;
            }
            _testActor = testActor;

        }
Esempio n. 3
1
 public Remoting(ActorSystem system, RemoteActorRefProvider provider)
     : base(system, provider)
 {
     log = Logging.GetLogger(System, "remoting");
 }
Esempio n. 4
1
        protected MultiNodeSpec(
            RoleName myself,
            ActorSystem system,
            ImmutableList<RoleName> roles,
            Func<RoleName, ImmutableList<string>> deployments)
            : base(new XunitAssertions(), system)
        {
            _myself = myself;
            _log = Logging.GetLogger(Sys, this);
            _roles = roles;
            _deployments = deployments;
            var node = new Node()
            {
                Host = Dns.GetHostEntry(ServerName).AddressList.First(a => a.AddressFamily == AddressFamily.InterNetwork),
                Port = ServerPort
            };
            _controllerAddr = node;

            AttachConductor(new TestConductor(system));

            _replacements = _roles.ToImmutableDictionary(r => r, r => new Replacement("@" + r.Name + "@", r, this));

            InjectDeployments(system, myself);

            _myAddress = system.AsInstanceOf<ExtendedActorSystem>().Provider.DefaultAddress;

            Log.Info("Role [{0}] started with address [{1}]", myself.Name, _myAddress);
        }
Esempio n. 5
1
 public EndpointManager(RemoteSettings settings, LoggingAdapter log)
 {
     this.settings = settings;
     this.log = log;
 }
Esempio n. 6
0
 public Remoting(ActorSystem system, RemoteActorRefProvider provider)
     : base(system, provider)
 {
     log = Logging.GetLogger(system, "remoting");
     _eventPublisher = new EventPublisher(system, log, Logging.LogLevelFor(provider.RemoteSettings.RemoteLifecycleEventsLogLevel));
     _transportSupervisor = system.SystemActorOf(Props.Create<TransportSupervisor>(), "transports");
 }
 public RootGuardianSupervisor(RootActorPath root, ActorRefProvider provider, TaskCompletionSource<Status> terminationPromise, LoggingAdapter log)
 {
     _log = log;
     _terminationPromise = terminationPromise;
     _provider = provider;
     _path = root / "_Root-guardian-supervisor";   //In akka this is root / "bubble-walker" 
 }
Esempio n. 8
0
        private TestKitBase(TestKitAssertions assertions, ActorSystem system, Config config, string actorSystemName = null)
        {
            if(assertions == null) throw new ArgumentNullException("assertions");
            if(system == null)
            {
                var configWithDefaultFallback = config.SafeWithFallback(_defaultConfig);
                system = ActorSystem.Create(actorSystemName ?? "test", configWithDefaultFallback);
            }

            _assertions = assertions;
            _system = system;
            system.RegisterExtension(new TestKitExtension());
            system.RegisterExtension(new TestKitAssertionsExtension(assertions));
            _testKitSettings = TestKitExtension.For(_system);
            _queue = new BlockingQueue<MessageEnvelope>();
            _log = Logging.GetLogger(system, GetType());


            var testActor = CreateTestActor(system, "testActor" + _testActorId.IncrementAndGet());
            _testActor = testActor;
            //Wait for the testactor to start
            AwaitCondition(() =>
            {
                var repRef = _testActor as RepointableRef;
                return repRef == null || repRef.IsStarted;
            }, TimeSpan.FromSeconds(1), TimeSpan.FromMilliseconds(10));
        }
Esempio n. 9
0
 public TcpTransport(ActorSystem system, Config config) : base(system, config)
 {
     string protocol = "akka." + config.GetString("transport-protocol");
     SchemeIdentifier = protocol;
     string host = config.GetString("hostname");
     int port = config.GetInt("port");
     Address = new Address(protocol, system.Name, host, port);
     log = Logging.GetLogger(system, this);
     server = new TcpServer(system, Address);
 }
        public LocalActorRefProvider(string systemName, Settings settings, EventStream eventStream, Deployer deployer, Func<ActorPath, InternalActorRef> deadLettersFactory)
        {
            _settings = settings;
            _eventStream = eventStream;
            _deployer = deployer ?? new Deployer(settings);
            _rootPath = new RootActorPath(new Address("akka", systemName));
            _log = Logging.GetLogger(eventStream, "LocalActorRefProvider(" + _rootPath.Address + ")");
            if (deadLettersFactory == null)
                deadLettersFactory = p => new DeadLetterActorRef(this, p, _eventStream);
            _deadLetters = deadLettersFactory(_rootPath / "deadLetters");
            _tempNumber = new AtomicCounterLong(1);
            _tempNode = _rootPath / "temp";

            //TODO: _guardianSupervisorStrategyConfigurator = dynamicAccess.createInstanceFor[SupervisorStrategyConfigurator](settings.SupervisorStrategyClass, EmptyImmutableSeq).get
            _systemGuardianStrategy = SupervisorStrategy.DefaultStrategy;

        }
 public EventPublisher(ActorSystem system, LoggingAdapter log, LogLevel logLevel)
 {
     System = system;
     Log = log;
     LogLevel = logLevel;
 }
Esempio n. 12
0
 public EndpointManager(Config config, LoggingAdapter log)
 {
     conf = config;
     settings = new RemoteSettings(conf);
     this.log = log;
     eventPublisher = new EventPublisher(Context.System, log, Logging.LogLevelFor(settings.RemoteLifecycleEventsLogLevel));
 }
Esempio n. 13
0
 public RemoteActorRefProvider(ActorSystem system)
     : base(system)
 {
     config = system.Settings.Config.GetConfig("akka.remote");
     log = Logging.GetLogger(system, this);
 }
 private static void ConditionalLog(LoggingAdapter logger, string format, params object[] args)
 {
     if (logger != null)
         logger.Debug(format, args);
 }
        /// <summary>
        /// <para>Await until the given condition evaluates to <c>true</c> or the timeout
        /// expires, whichever comes first.</para>
        /// <para>If no timeout is given, take it from the innermost enclosing `within`
        /// block.</para>
        /// <para>Note that the timeout is <see cref="Dilated(TimeSpan)">dilated</see>, i.e. scaled by the factor 
        /// specified in config value "akka.test.timefactor".</para>
        /// <para>The parameter <paramref name="interval"/> specifies the time between calls to <paramref name="conditionIsFulfilled"/>
        /// Between calls the thread sleeps. If <paramref name="interval"/> is undefined the thread only sleeps 
        /// one time, using the <paramref name="max"/> as duration, and then rechecks the condition and ultimately 
        /// succeeds or fails.</para>
        /// <para>To make sure that tests run as fast as possible, make sure you do not leave this value as undefined,
        /// instead set it to a relatively small value.</para>
        /// </summary>
        /// <param name="conditionIsFulfilled">The condition that must be fulfilled within the duration.</param>
        /// <param name="max">The maximum duration. The value is <see cref="Dilated(TimeSpan)">dilated</see>, i.e. 
        /// scaled by the factor specified in config value "akka.test.timefactor".</param>
        /// <param name="interval">The time between calls to <paramref name="conditionIsFulfilled"/> to check
        /// if the condition is fulfilled. Between calls the thread sleeps. If undefined the thread only sleeps 
        /// one time, using the <paramref name="max"/>, and then rechecks the condition and ultimately 
        /// succeeds or fails.
        /// <para>To make sure that tests run as fast as possible, make sure you do not set this value as undefined,
        /// instead set it to a relatively small value.</para>
        /// </param>
        /// <param name="fail">Action that is called when the timeout expired. 
        /// The parameters conforms to <see cref="string.Format(string,object[])"/></param>
        /// <param name="logger">If a <see cref="LoggingAdapter"/> is specified, debug messages will be logged using it. If <c>null</c> nothing will be logged</param>
        protected static bool InternalAwaitCondition(Func<bool> conditionIsFulfilled, TimeSpan max, TimeSpan? interval, Action<string, object[]> fail, LoggingAdapter logger)
        {
            max.EnsureIsPositiveFinite("max");
            var start = Now;
            var stop = start + max;
            ConditionalLog(logger, "Awaiting condition for {0}.{1}", max, interval.HasValue ? " Will sleep " + interval.Value + " between checks" : "");

            while (!conditionIsFulfilled())
            {
                var now = Now;

                if (now > stop)
                {
                    const string message = "Timeout {0} expired while waiting for condition.";
                    ConditionalLog(logger, message, max);
                    fail(message, new object[] { max });
                    return false;
                }
                var sleepDuration = (stop - now).Min(interval);
                Thread.Sleep(sleepDuration);
            }
            ConditionalLog(logger, "Condition fulfilled after {0}", Now-start);
            return true;
        }
Esempio n. 16
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="RemoteDaemon" /> class.
 /// </summary>
 /// <param name="system">The system.</param>
 /// <param name="path">The path.</param>
 /// <param name="parent">The parent.</param>
 /// <param name="log"></param>
 public RemoteDaemon(ActorSystem system, ActorPath path, InternalActorRef parent, LoggingAdapter log)
     : base(system.Provider, path, parent, log)
 {
     System = system;
 }