• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Actor.Address类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Akka.Actor.Address的典型用法代码示例。如果您正苦于以下问题:C# Address类的具体用法?C# Address怎么用?C# Address使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Address类属于Akka.Actor命名空间,在下文中一共展示了Address类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Watcher

            public Watcher(TestLatch exitingLatch, TestLatch removedLatch, Address secondAddress)
            {
                _exitingLatch = exitingLatch;
                _removedLatch = removedLatch;
                _secondAddress = secondAddress;

                Receive<ClusterEvent.CurrentClusterState>(state =>
                {
                    if (state.Members.Any(m => m.Address == _secondAddress && m.Status == MemberStatus.Exiting))
                        _exitingLatch.CountDown();
                });
                Receive<ClusterEvent.MemberExited>(m =>
                {
                    if (m.Member.Address == secondAddress)
                    {
                        exitingLatch.CountDown();
                    }
                });
                Receive<ClusterEvent.MemberRemoved>(m =>
                {
                    if (m.Member.Address == secondAddress)
                    {
                        _removedLatch.CountDown();
                    }
                });
            }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:26,代码来源:MembershipChangeListenerExitingSpec.cs


示例2: CreateCorrectToStringWithAddress

        public void CreateCorrectToStringWithAddress()
        {
            var local = new Address("akka.tcp", "mysys");
            var a = new Address("akka.tcp", "mysys", "aaa", 2552);
            var b = new Address("akka.tcp", "mysys", "bb", 2552);
            var c = new Address("akka.tcp", "mysys", "cccc" , 2552);
            var root = new RootActorPath(local);
            root.ToStringWithAddress(a).ShouldBe("akka.tcp://[email protected]:2552/");
            (root / "user").ToStringWithAddress(a).ShouldBe("akka.tcp://[email protected]:2552/user");
            (root / "user" / "foo").ToStringWithAddress(a).ShouldBe("akka.tcp://[email protected]:2552/user/foo");

            root.ToStringWithAddress(b).ShouldBe("akka.tcp://[email protected]:2552/");
            (root / "user").ToStringWithAddress(b).ShouldBe("akka.tcp://[email protected]:2552/user");
            (root / "user" / "foo").ToStringWithAddress(b).ShouldBe("akka.tcp://[email protected]:2552/user/foo");

            root.ToStringWithAddress(c).ShouldBe("akka.tcp://[email protected]:2552/");
            (root / "user").ToStringWithAddress(c).ShouldBe("akka.tcp://[email protected]:2552/user");
            (root / "user" / "foo").ToStringWithAddress(c).ShouldBe("akka.tcp://[email protected]:2552/user/foo");

            var rootA = new RootActorPath(a);
            rootA.ToStringWithAddress(b).ShouldBe("akka.tcp://[email protected]:2552/");
            (rootA / "user").ToStringWithAddress(b).ShouldBe("akka.tcp://[email protected]:2552/user");
            (rootA / "user" / "foo").ToStringWithAddress(b).ShouldBe("akka.tcp://[email protected]:2552/user/foo");

        }
开发者ID:Badmoonz,项目名称:akka.net,代码行数:25,代码来源:ActorPathSpec.cs


示例3: LocalAddressForRemote

        private Address LocalAddressForRemote(
            IDictionary<string, HashSet<ProtocolTransportAddressPair>> transportMapping, Address remote)
        {
            HashSet<ProtocolTransportAddressPair> transports;

            if (transportMapping.TryGetValue(remote.Protocol, out transports))
            {
                ProtocolTransportAddressPair[] responsibleTransports =
                    transports.Where(t => t.ProtocolTransport.Transport.IsResponsibleFor(remote)).ToArray();
                if (responsibleTransports.Length == 0)
                {
                    throw new RemoteTransportException(
                        "No transport is responsible for address:[" + remote + "] although protocol [" + remote.Protocol +
                        "] is available." +
                        " Make sure at least one transport is configured to be responsible for the address.",
                        null);
                }
                if (responsibleTransports.Length == 1)
                {
                    return responsibleTransports.First().Address;
                }
                throw new RemoteTransportException(
                    "Multiple transports are available for [" + remote + ": " +
                    string.Join(",", responsibleTransports.Select(t => t.ToString())) + "] " +
                    "Remoting cannot decide which transport to use to reach the remote system. Change your configuration " +
                    "so that only one transport is responsible for the address.",
                    null);
            }

            throw new RemoteTransportException(
                "No transport is loaded for protocol: [" + remote.Protocol + "], available protocols: [" +
                string.Join(",", transportMapping.Keys.Select(t => t.ToString())) + "]", null);
        }
开发者ID:Badmoonz,项目名称:akka.net,代码行数:33,代码来源:Remoting.cs


示例4: Serialize

        /// <summary>
        /// Serializes the specified message.
        /// </summary>
        /// <param name="system">The system.</param>
        /// <param name="address"></param>
        /// <param name="message">The message.</param>
        /// <returns>SerializedMessage.</returns>
        public static SerializedMessage Serialize(ActorSystem system, Address address, object message)
        {
            Serializer serializer = system.Serialization.FindSerializerFor(message);

            SerializedMessage.Builder messageBuilder = new SerializedMessage.Builder()
                .SetMessage(ByteString.Unsafe.FromBytes(serializer.ToBinaryWithAddress(address, message)))
                .SetSerializerId(serializer.Identifier);

            var serializer2 = serializer as SerializerWithStringManifest;
            if (serializer2 != null)
            {
                var manifest = serializer2.Manifest(message);
                if (!string.IsNullOrEmpty(manifest))
                {
                    messageBuilder.SetMessageManifest(ByteString.CopyFromUtf8(manifest));
                }
            }
            else
            {
                if (serializer.IncludeManifest)
                    messageBuilder.SetMessageManifest(ByteString.CopyFromUtf8(message.GetType().AssemblyQualifiedName));
            }

            return messageBuilder.Build();
        }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:32,代码来源:MessageSerializer.cs


示例5: RemoteMetricsSpec

        public RemoteMetricsSpec()
            : base(@"
            akka.actor.provider = ""Akka.Remote.RemoteActorRefProvider, Akka.Remote""
            akka.remote.log-frame-size-exceeding = 200 b
            akka.remote.helios.tcp = {
                port = 0
                hostname = localhost
            }
            akka.loglevel = DEBUG
            ")
        {
            _client = ActorSystem.Create("RemoteMetricsSpec-client", ConfigurationFactory.ParseString(@"
                akka.actor.provider =  ""Akka.Remote.RemoteActorRefProvider, Akka.Remote""
                 akka.remote.helios.tcp = {
                    port = 0
                    hostname = localhost
                }                
            ").WithFallback(Sys.Settings.Config));

            _address = Sys.AsInstanceOf<ExtendedActorSystem>().Provider.DefaultAddress;
            _subject = Sys.ActorOf(Props.Create(() => new Subject()).WithDeploy(Deploy.Local), "subject");
            var listener = Sys.ActorOf(Props.Create(() => new InfoEventListener(TestActor)).WithDeploy(Deploy.Local),
                "listener");
            Sys.EventStream.Subscribe(listener, typeof (Info));
        }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:25,代码来源:RemoteMetricsSpec.cs


示例6: ConnectionAssociationHandle

 public ConnectionAssociationHandle(IActorRef connection, Address localAddress, Address remoteAddress)
     : base(localAddress, remoteAddress)
 {
     _connection = connection;
     ReadHandlerSource = new TaskCompletionSource<IHandleEventListener>();
     ReadHandlerSource.Task.PipeTo(connection);
 }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:7,代码来源:ConnectionAssociation.cs


示例7: RemoteDeploySpec

        public RemoteDeploySpec()
            : base(@"
            akka {
                loglevel = INFO 
                log-dead-letters-during-shutdown = false
              //  actor.provider = ""Akka.Remote.RemoteActorRefProvider, Akka.Remote""
                remote.helios.tcp = {
                    hostname = localhost
                    port = 0
                }

                actor.deployment {
                  /router1 {
                    router = round-robin-pool
                    nr-of-instances = 3
                  }
                  /router2 {
                    router = round-robin-pool
                    nr-of-instances = 3
                  }
                  /router3 {
                    router = round-robin-pool
                    nr-of-instances = 0
                  }
                }
            }
")
        {
            _remoteSystem = ActorSystem.Create("RemoteSystem", Sys.Settings.Config);
            _remoteAddress = _remoteSystem.AsInstanceOf<ExtendedActorSystem>().Provider.DefaultAddress;
            var remoteAddressUid = AddressUidExtension.Uid(_remoteSystem);


        }
开发者ID:rodrigovidal,项目名称:akka.net,代码行数:34,代码来源:RemoteDeploySpec.cs


示例8: Ready

 private void Ready()
 {
     Receive<SendState>(msg =>
     {
         _cluster.SendCurrentClusterState(Self);
     });
     Receive<ClusterEvent.CurrentClusterState>(state =>
     {
         //_hub.ClusterState(state, _cluster.SelfAddress);
     });
     Receive<RemoveMe>(msg => {
         _logger.Warning("[l] Monitor stopping; Issuing a Cluster.Leave() command for following address: {0}", _cluster.SelfAddress);
         _cluster.Leave(_cluster.SelfAddress);
     });
     Receive<MemberLeave>(msg => {
         Address add = new Address(msg.Protocol, msg.System, msg.Host, msg.Port);
         _logger.Warning("[l] Forcing Member to leave cluster: {0}", add.ToString());
         _cluster.Leave(add);
     });
     Receive<MemberDown>(msg => {
         Address add = new Address(msg.Protocol, msg.System, msg.Host, msg.Port);
         _logger.Warning("[l] Forcing the Member down: {0}", add.ToString());
         _cluster.Down(add);
     });
 }
开发者ID:jurek333,项目名称:CoreWars,代码行数:25,代码来源:ClusterMonitor.cs


示例9: RemoteActorRefProvider_should_create_RemoteActorRef_for_nonlocaladdress

 public void RemoteActorRefProvider_should_create_RemoteActorRef_for_nonlocaladdress()
 {
     var nonLocalAddress = new Address("akka.trttl.gremlin.tcp", Sys.Name, "localhost", RARP.For(Sys).Provider.DefaultAddress.Port);
     var nonLocalActorPath = new RootActorPath(nonLocalAddress) / "user" / "foo";
     var resolved = RARP.For(Sys).Provider.ResolveActorRefWithLocalAddress(nonLocalActorPath.ToSerializationFormat(), nonLocalAddress);
     Assert.IsType<RemoteActorRef>(resolved); // should be a remote actorref
 }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:7,代码来源:RemoteMessageLocalDeliverySpec.cs


示例10: DisassociatedEvent

 public DisassociatedEvent(Address localAddress, Address remoteAddress, bool inbound)
 {
     LocalAddress = localAddress;
     RemoteAddress = remoteAddress;
     IsInbound = inbound;
     EventName = "Disassociated";
 }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:7,代码来源:RemotingLifecycleEvent.cs


示例11: Message

 public Message(IInternalActorRef recipient, Address recipientAddress, SerializedMessage serializedMessage, IActorRef senderOptional = null, SeqNo seq = null)
 {
     Seq = seq;
     SenderOptional = senderOptional;
     SerializedMessage = serializedMessage;
     RecipientAddress = recipientAddress;
     Recipient = recipient;
 }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:8,代码来源:AkkaPduCodec.cs


示例12: CreateCorrectToStringWithoutAddress

 public void CreateCorrectToStringWithoutAddress()
 {
     var a = new Address("akka.tcp", "mysys");
     //TODO: there must be a / after system name
     new RootActorPath(a).ToStringWithoutAddress().ShouldBe("/");
     (new RootActorPath(a) / "user").ToStringWithoutAddress().ShouldBe("/user");
     (new RootActorPath(a) / "user" / "foo").ToStringWithoutAddress().ShouldBe("/user/foo");
     (new RootActorPath(a) / "user" / "foo" / "bar").ToStringWithoutAddress().ShouldBe("/user/foo/bar");
 }
开发者ID:Badmoonz,项目名称:akka.net,代码行数:9,代码来源:ActorPathSpec.cs


示例13: ReadOnlyEndpointFor

 public IActorRef ReadOnlyEndpointFor(Address address)
 {
     IActorRef tmp;
     if (addressToReadonly.TryGetValue(address, out tmp))
     {
         return tmp;
     }
     return null;
 }
开发者ID:MaciekLesiczka,项目名称:akka.net,代码行数:9,代码来源:EndpointRegistry.cs


示例14: AssociationErrorEvent

 public AssociationErrorEvent(Exception cause, Address localAddress, Address remoteAddress, bool inbound, LogLevel level)
 {
     LocalAddress = localAddress;
     RemoteAddress = remoteAddress;
     IsInbound = inbound;
     EventName = "AssociationError";
     _level = level;
     Cause = cause;
 }
开发者ID:rodrigovidal,项目名称:akka.net,代码行数:9,代码来源:RemotingLifecycleEvent.cs


示例15: Setup

 public void Setup(BenchmarkContext context)
 {
     _actorSystem = ActorSystem.Create("MessageDispatcher" + Counter.GetAndIncrement(), RemoteHocon);
     _systemAddress = RARP.For(_actorSystem).Provider.DefaultAddress;
     _inboundMessageDispatcherCounter = context.GetCounter(MessageDispatcherThroughputCounterName);
     _message = SerializedMessage.CreateBuilder().SetSerializerId(0).SetMessage(ByteString.CopyFromUtf8("foo")).Build();
     _dispatcher = new DefaultMessageDispatcher(_actorSystem, RARP.For(_actorSystem).Provider, _actorSystem.Log);
     _targetActorRef = new BenchmarkActorRef(_inboundMessageDispatcherCounter, RARP.For(_actorSystem).Provider);
 }
开发者ID:,项目名称:,代码行数:9,代码来源:


示例16: RemoteActorRef

 /// <summary>
 /// Initializes a new instance of the <see cref="RemoteActorRef"/> class.
 /// </summary>
 /// <param name="remote">The remote.</param>
 /// <param name="localAddressToUse">The local address to use.</param>
 /// <param name="path">The path.</param>
 /// <param name="parent">The parent.</param>
 /// <param name="props">The props.</param>
 /// <param name="deploy">The deploy.</param>
 internal RemoteActorRef(RemoteTransport remote, Address localAddressToUse, ActorPath path, InternalActorRef parent,
     Props props, Deploy deploy)
 {
     Remote = remote;
     LocalAddressToUse = localAddressToUse;
     Path = path;
     _parent = parent;
     _props = props;
     _deploy = deploy;
 }
开发者ID:pdoh00,项目名称:akka.net,代码行数:19,代码来源:RemoteActorRef.cs


示例17: TcpTransport

 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);
 }
开发者ID:Badmoonz,项目名称:akka.net,代码行数:10,代码来源:TcpTransport.cs


示例18: ToData

 /// <summary>
 /// Converts a <see cref="ByteString"/> structure into a Helios <see cref="NetworkData"/> structure
 /// </summary>
 /// <param name="byteString">The data to send over the network</param>
 /// <param name="address">The address that we received data from / are sending data to</param>
 /// <returns>a new <see cref="NetworkData"/> struct</returns>
 public static NetworkData ToData(ByteString byteString, Address address)
 {
     var data = new NetworkData()
     {
         Buffer = byteString.ToByteArray(),
         RemoteHost = HeliosTransport.AddressToNode(address)
     };
     data.Length = data.Buffer.Length;
     return data;
 }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:16,代码来源:HeliosHelpers.cs


示例19: MemoryFootprint

 public void MemoryFootprint(BenchmarkContext context)
 {
     var actorPaths = new Address[100000];
     for (var i = 0; i < 100000;)
     {
         actorPaths[i] = new Address("akka", "foo", "localhost", 9091);
         ++i;
         _parseThroughput.Increment();
     }
 }
开发者ID:juergenhoetzel,项目名称:akka.net,代码行数:10,代码来源:AddressSpec.cs


示例20: Down

 public override void Down(Address node)
 {
     if (_leader)
     {
         _probe.Tell(new DownCalled(node));
     }
     else
     {
         _probe.Tell("down must only be done by leader");
     }
 }
开发者ID:rodrigovidal,项目名称:akka.net,代码行数:11,代码来源:AutoDownSpec.cs



注:本文中的Akka.Actor.Address类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Actor.Envelope类代码示例发布时间:2022-05-24
下一篇:
C# Actor.ActorRef类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap