Exemple #1
1
 public EndpointManager(RemoteSettings settings, LoggingAdapter log)
 {
     this.settings = settings;
     this.log = log;
 }
Exemple #2
0
 public DefaultMessageDispatcher(ActorSystem system, RemoteActorRefProvider provider, ILoggingAdapter log)
 {
     this.system = system;
     this.provider = provider;
     this.log = log;
     remoteDaemon = provider.RemoteDaemon;
     settings = provider.RemoteSettings;
 }
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="system">TBD</param>
        /// <returns>TBD</returns>
        protected virtual IActorRef CreateRemoteWatcher(ActorSystemImpl system)
        {
            var failureDetector = CreateRemoteWatcherFailureDetector(system);

            return(system.SystemActorOf(RemoteSettings.ConfigureDispatcher(
                                            Akka.Remote.RemoteWatcher.Props(
                                                failureDetector,
                                                RemoteSettings.WatchHeartBeatInterval,
                                                RemoteSettings.WatchUnreachableReaperInterval,
                                                RemoteSettings.WatchHeartbeatExpectedResponseAfter)), "remote-watcher"));
        }
        public RemoteActorRefProvider(string systemName, Settings settings, EventStream eventStream)
        {
            var remoteDeployer = new RemoteDeployer(settings);
            Func <ActorPath, InternalActorRef> deadLettersFactory = null; //TODO:  path => new RemoteDeadLetterActorRef(this, path, eventStream);

            _local         = new LocalActorRefProvider(systemName, settings, eventStream, remoteDeployer, deadLettersFactory);
            Config         = settings.Config.WithFallback(RemoteConfigFactory.Default());
            RemoteSettings = new RemoteSettings(Config);
            Deployer       = remoteDeployer;
            _log           = _local.Log;
        }
Exemple #5
0
        public EndpointActor(Address localAddress, Address remoteAddress, Transport.Transport transport,
            RemoteSettings settings)
        {
            this.localAddress = localAddress;
            this.remoteAddress = remoteAddress;
            this.transport = transport;
            this.settings = settings;

            client = new TcpClient();
            client.Connect(remoteAddress.Host, remoteAddress.Port.Value);
            stream = client.GetStream();
        }
        /// <summary>
        /// Creates a new remote actor ref provider instance.
        /// </summary>
        /// <param name="systemName">Name of the actor system.</param>
        /// <param name="settings">The actor system settings.</param>
        /// <param name="eventStream">The <see cref="EventStream"/> instance used by this system.</param>
        public RemoteActorRefProvider(string systemName, Settings settings, EventStream eventStream)
        {
            settings.InjectTopLevelFallback(RemoteConfigFactory.Default());

            var remoteDeployer = new RemoteDeployer(settings);

            IInternalActorRef DeadLettersFactory(ActorPath path) => new RemoteDeadLetterActorRef(this, path, eventStream);

            _local         = new LocalActorRefProvider(systemName, settings, eventStream, remoteDeployer, DeadLettersFactory);
            RemoteSettings = new RemoteSettings(settings.Config);
            Deployer       = remoteDeployer;
            _log           = _local.Log;
        }
        public virtual void Init(ActorSystemImpl system)
        {
            _system = system;

            _local.Init(system);

            _remotingTerminator =
                _system.SystemActorOf(
                    RemoteSettings.ConfigureDispatcher(Props.Create(() => new RemotingTerminator(_local.SystemGuardian))),
                    "remoting-terminator");

            _remotingTerminator.Tell(RemoteInternals);

            Transport.Start();
            _remoteWatcher = CreateRemoteWatcher(system);
        }
Exemple #8
0
        private IActorRef CreateEndpoint(
            Address remoteAddress,
            Address localAddress,
            AkkaProtocolTransport transport,
            RemoteSettings endpointSettings,
            bool writing,
            AkkaProtocolHandle handleOption = null,
            int?refuseUid = null)
        {
            System.Diagnostics.Debug.Assert(_transportMapping.ContainsKey(localAddress));
            // refuseUid is ignored for read-only endpoints since the UID of the remote system is already known and has passed
            // quarantine checks

            IActorRef endpointActor;

            if (writing)
            {
                endpointActor =
                    Context.ActorOf(RARP.For(Context.System)
                                    .ConfigureDispatcher(
                                        ReliableDeliverySupervisor.ReliableDeliverySupervisorProps(handleOption, localAddress,
                                                                                                   remoteAddress, refuseUid, transport, endpointSettings, new AkkaPduProtobuffCodec(),
                                                                                                   _receiveBuffers, endpointSettings.Dispatcher)
                                        .WithDeploy(Deploy.Local)),
                                    string.Format("reliableEndpointWriter-{0}-{1}", AddressUrlEncoder.Encode(remoteAddress),
                                                  _endpointId.Next()));
            }
            else
            {
                endpointActor =
                    Context.ActorOf(RARP.For(Context.System)
                                    .ConfigureDispatcher(
                                        EndpointWriter.EndpointWriterProps(handleOption, localAddress, remoteAddress, refuseUid,
                                                                           transport, endpointSettings, new AkkaPduProtobuffCodec(), _receiveBuffers,
                                                                           reliableDeliverySupervisor: null)
                                        .WithDeploy(Deploy.Local)),
                                    string.Format("endpointWriter-{0}-{1}", AddressUrlEncoder.Encode(remoteAddress), _endpointId.Next()));
            }

            Context.Watch(endpointActor);
            return(endpointActor);
        }
        public override void Init()
        {
            //TODO: this should not be here
            Address = new Address("akka", System.Name); //TODO: this should not work this way...
            Deployer = new RemoteDeployer(System.Settings);
            base.Init();

            var daemonMsgCreateSerializer = new DaemonMsgCreateSerializer(System);
            var messageContainerSerializer = new MessageContainerSerializer(System);
            System.Serialization.AddSerializer(daemonMsgCreateSerializer);
            System.Serialization.AddSerializationMap(typeof (DaemonMsgCreate), daemonMsgCreateSerializer);
            System.Serialization.AddSerializer(messageContainerSerializer);
            System.Serialization.AddSerializationMap(typeof (ActorSelectionMessage), messageContainerSerializer);

            RemoteDaemon = new RemoteDaemon(System, RootPath/"remote", null);
            Transport = new Remoting(System, this);
            RemoteSettings = new RemoteSettings(System.Settings.Config);
            Transport.Start();
            //      RemoteHost.StartHost(System, port);
        }
        /// <inheritdoc/>
        public virtual void Init(ActorSystemImpl system)
        {
            _system = system;

            _local.Init(system);

            _actorRefResolveThreadLocalCache = ActorRefResolveThreadLocalCache.For(system);
            _actorPathThreadLocalCache       = ActorPathThreadLocalCache.For(system);

            _remotingTerminator =
                _system.SystemActorOf(
                    RemoteSettings.ConfigureDispatcher(Props.Create(() => new RemotingTerminator(_local.SystemGuardian))),
                    "remoting-terminator");

            _internals = CreateInternals();

            _remotingTerminator.Tell(RemoteInternals);

            Transport.Start();
            _remoteWatcher           = CreateRemoteWatcher(system);
            _remoteDeploymentWatcher = CreateRemoteDeploymentWatcher(system);
        }
Exemple #11
0
 public static Props ReliableDeliverySupervisorProps(
     AkkaProtocolHandle handleOrActive, 
     Address localAddress, 
     Address remoteAddress,
     int? refuseUid, 
     AkkaProtocolTransport transport, 
     RemoteSettings settings, 
     AkkaPduCodec codec, 
     ConcurrentDictionary<EndpointManager.Link, EndpointManager.ResendState> receiveBuffers,
     string dispatcher)
 {
     return
         Props.Create(
             () =>
                 new ReliableDeliverySupervisor(handleOrActive, localAddress, remoteAddress, refuseUid, transport,
                     settings, codec, receiveBuffers))
                     .WithDispatcher(dispatcher);
 }
Exemple #12
0
 public ReliableDeliverySupervisor(
     AkkaProtocolHandle handleOrActive, 
     Address localAddress, 
     Address remoteAddress,
     int? refuseUid, 
     AkkaProtocolTransport transport, 
     RemoteSettings settings, 
     AkkaPduCodec codec, 
     ConcurrentDictionary<EndpointManager.Link, EndpointManager.ResendState> receiveBuffers)
 {
     this.handleOrActive = handleOrActive;
     _localAddress = localAddress;
     _remoteAddress = remoteAddress;
     _refuseUid = refuseUid;
     _transport = transport;
     _settings = settings;
     this.codec = codec;
     _currentHandle = handleOrActive;
     _receiveBuffers = receiveBuffers;
     Reset();
     _writer = CreateWriter();
     Uid = handleOrActive != null ? (int?)handleOrActive.HandshakeInfo.Uid : null;
     UidConfirmed = Uid.HasValue;
 }
Exemple #13
0
 public ReliableDeliverySupervisor(
     AkkaProtocolHandle handleOrActive,
     Address localAddress,
     Address remoteAddress,
     int? refuseUid,
     AkkaProtocolTransport transport,
     RemoteSettings settings,
     AkkaPduCodec codec,
     ConcurrentDictionary<EndpointManager.Link, EndpointManager.ResendState> receiveBuffers)
 {
     _localAddress = localAddress;
     _remoteAddress = remoteAddress;
     _refuseUid = refuseUid;
     _transport = transport;
     _settings = settings;
     _codec = codec;
     _currentHandle = handleOrActive;
     _receiveBuffers = receiveBuffers;
     Reset(); // needs to be called at startup
     _writer = CreateWriter(); // need to create writer at startup
     Uid = handleOrActive != null ? (int?)handleOrActive.HandshakeInfo.Uid : null;
     UidConfirmed = Uid.HasValue;
     Receiving();
     _autoResendTimer = Context.System.Scheduler.ScheduleTellRepeatedlyCancelable(_settings.SysResendTimeout, _settings.SysResendTimeout, Self, new AttemptSysMsgRedelivery(),
             Self);
 }
Exemple #14
0
 public EndpointReader(
     Address localAddress, 
     Address remoteAddress, 
     AkkaProtocolTransport transport,
     RemoteSettings settings, 
     AkkaPduCodec codec, 
     IInboundMessageDispatcher msgDispatch, 
     bool inbound,
     int uid, 
     ConcurrentDictionary<EndpointManager.Link, EndpointManager.ResendState> receiveBuffers,
     IActorRef reliableDeliverySupervisor = null) :
     base(localAddress, remoteAddress, transport, settings)
 {
     _receiveBuffers = receiveBuffers;
     _msgDispatch = msgDispatch;
     Inbound = inbound;
     _uid = uid;
     _reliableDeliverySupervisor = reliableDeliverySupervisor;
     _codec = codec;
     _provider = RARP.For(Context.System).Provider;
 }
Exemple #15
0
 public static Props ReaderProps(
     Address localAddress, 
     Address remoteAddress, 
     AkkaProtocolTransport transport,
     RemoteSettings settings, 
     AkkaPduCodec codec, 
     IInboundMessageDispatcher dispatcher, 
     bool inbound, 
     int uid,
     ConcurrentDictionary<EndpointManager.Link, EndpointManager.ResendState> receiveBuffers,
     IActorRef reliableDeliverySupervisor = null)
 {
     return
         Props.Create(
             () =>
                 new EndpointReader(localAddress, remoteAddress, transport, settings, codec, dispatcher, inbound,
                     uid, receiveBuffers, reliableDeliverySupervisor))
                     .WithDispatcher(settings.Dispatcher);
 }
Exemple #16
0
 public static Props EndpointWriterProps(AkkaProtocolHandle handleOrActive, Address localAddress,
     Address remoteAddress, int? refuseUid, AkkaProtocolTransport transport, RemoteSettings settings,
     AkkaPduCodec codec, ConcurrentDictionary<EndpointManager.Link, EndpointManager.ResendState> receiveBuffers, IActorRef reliableDeliverySupervisor = null)
 {
     return Props.Create(
         () =>
             new EndpointWriter(handleOrActive, localAddress, remoteAddress, refuseUid, transport, settings,
                 codec, receiveBuffers, reliableDeliverySupervisor));
 }
        private IActorRef CreateEndpoint(
            Address remoteAddress,
            Address localAddress,
            AkkaProtocolTransport transport,
            RemoteSettings endpointSettings,
            bool writing,
            AkkaProtocolHandle handleOption = null,
            int? refuseUid = null)
        {
            System.Diagnostics.Debug.Assert(_transportMapping.ContainsKey(localAddress));
            System.Diagnostics.Debug.Assert(writing || refuseUid == null);

            IActorRef endpointActor;

            if (writing)
            {
                endpointActor =
                    Context.ActorOf(RARP.For(Context.System)
                    .ConfigureDispatcher(
                        ReliableDeliverySupervisor.ReliableDeliverySupervisorProps(handleOption, localAddress,
                            remoteAddress, refuseUid, transport, endpointSettings, new AkkaPduProtobuffCodec(),
                            _receiveBuffers, endpointSettings.Dispatcher)
                            .WithDeploy(Deploy.Local)),
                        string.Format("reliableEndpointWriter-{0}-{1}", AddressUrlEncoder.Encode(remoteAddress),
                            _endpointId.Next()));
            }
            else
            {
                endpointActor =
                    Context.ActorOf(RARP.For(Context.System)
                    .ConfigureDispatcher(
                        EndpointWriter.EndpointWriterProps(handleOption, localAddress, remoteAddress, refuseUid,
                            transport, endpointSettings, new AkkaPduProtobuffCodec(), _receiveBuffers,
                            reliableDeliverySupervisor: null)
                            .WithDeploy(Deploy.Local)),
                        string.Format("endpointWriter-{0}-{1}", AddressUrlEncoder.Encode(remoteAddress), _endpointId.Next()));
            }

            Context.Watch(endpointActor);
            return endpointActor;
        }
        public EndpointManager(Config config, ILoggingAdapter log)
        {
            _conf = config;
            _settings = new RemoteSettings(_conf);
            _log = log;
            _eventPublisher = new EventPublisher(Context.System, log, Logging.LogLevelFor(_settings.RemoteLifecycleEventsLogLevel));

            Receiving();
        }
Exemple #19
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));
 }
Exemple #20
0
 protected EndpointActor(Address localAddress, Address remoteAddress, AkkaProtocolTransport transport,
     RemoteSettings settings)
 {
     EventPublisher = new EventPublisher(Context.System, _log, Logging.LogLevelFor(settings.RemoteLifecycleEventsLogLevel));
     LocalAddress = localAddress;
     RemoteAddress = remoteAddress;
     Transport = transport;
     Settings = settings;
 }
Exemple #21
0
        public EndpointWriter(
            AkkaProtocolHandle handleOrActive, 
            Address localAddress, 
            Address remoteAddress,
            int? refuseUid, 
            AkkaProtocolTransport transport, 
            RemoteSettings settings,
            AkkaPduCodec codec, 
            ConcurrentDictionary<EndpointManager.Link, EndpointManager.ResendState> receiveBuffers,
            IActorRef reliableDeliverySupervisor = null) :
            base(localAddress, remoteAddress, transport, settings)
        {
            _handleOrActive = handleOrActive;
            _refuseUid = refuseUid;
            _codec = codec;
            _reliableDeliverySupervisor = reliableDeliverySupervisor;
            _system = Context.System;
            _provider = RARP.For(Context.System).Provider;
            _msgDispatcher = new DefaultMessageDispatcher(_system, _provider, _log);
            _receiveBuffers = receiveBuffers;
            Inbound = handleOrActive != null;
            _ackDeadline = NewAckDeadline();
            _handle = handleOrActive;

            if (_handle == null)
            {
                Context.Become(Initializing);
            }
            else
            {
                Context.Become(Writing);
            }
        }
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="system">TBD</param>
 /// <returns>TBD</returns>
 protected virtual IActorRef CreateRemoteDeploymentWatcher(ActorSystemImpl system)
 {
     return(system.SystemActorOf(RemoteSettings.ConfigureDispatcher(Props.Create <RemoteDeploymentWatcher>()),
                                 "remote-deployment-watcher"));
 }