当前位置: 首页>>代码示例>>Java>>正文


Java ClusterClientSettings类代码示例

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


ClusterClientSettings类属于akka.cluster.client包,在下文中一共展示了ClusterClientSettings类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startWorkersWithExecutors

import akka.cluster.client.ClusterClientSettings; //导入依赖的package包/类
public static ActorSystem startWorkersWithExecutors(AgentConfig agent) {
    Config conf = ConfigFactory.parseString("akka.cluster.roles=[" + agent.getActor().getRole() + "]")
            .withFallback(ConfigFactory.parseString("akka.remote.netty.tcp.port=" + agent.getActor().getPort()))
            .withFallback(ConfigFactory.parseString("akka.remote.netty.tcp.hostname=" + HostUtils.lookupIp()))
            .withFallback(ConfigFactory.load("application"));

    ActorSystem system = ActorSystem.create(Constants.PerformanceSystem, conf);

    Set<ActorPath> initialContacts = new HashSet<>(agent.getContactPoint()
                .map(p->ActorPaths.fromString(p))
                .collect(Collectors.toList()));

    ClusterClientSettings settings =  ClusterClientSettings.create(system).withInitialContacts(initialContacts);
    final ActorRef clusterClient = system.actorOf(ClusterClient.props(settings), "clusterClient");

    IntStream.range(1,agent.getActor().getNumberOfActors()+1).forEach(i->
        system.actorOf(Worker.props(clusterClient,
                        createWorkExecutor(agent),
                        agent.getActor().getRole()),
                        agent.getActor().getRole()+i)
    );
    return system;

}
 
开发者ID:Abiy,项目名称:distGatling,代码行数:25,代码来源:WorkerFactory.java

示例2: startCommandClient

import akka.cluster.client.ClusterClientSettings; //导入依赖的package包/类
public static ActorSystem startCommandClient(ClientConfig clientConfig) {
    Config conf = ConfigFactory.parseString("akka.cluster.roles=[" + clientConfig.getRole() + "]")
            .withFallback(ConfigFactory.parseString("akka.remote.netty.tcp.port=" + clientConfig.getPort()))
            .withFallback(ConfigFactory.parseString("akka.remote.netty.tcp.hostname=" + HostUtils.lookupIp()))
            .withFallback(ConfigFactory.load("application"));

    ActorSystem system = ActorSystem.create(Constants.PerformanceSystem, conf);

    Set<ActorPath> initialContacts = new HashSet<>(clientConfig.getContactPoint()
                .map(p->ActorPaths.fromString(p))
                .collect(Collectors.toList()));

    ClusterClientSettings settings =  ClusterClientSettings.create(system).withInitialContacts(initialContacts);
    final ActorRef clusterClient = system.actorOf(ClusterClient.props(settings), "clusterClient");

    system.actorOf(CommandClientActor.props(clusterClient, clientConfig), clientConfig.getRole() );

    return system;

}
 
开发者ID:Abiy,项目名称:distGatling,代码行数:21,代码来源:ClientFactory.java

示例3: startWorker

import akka.cluster.client.ClusterClientSettings; //导入依赖的package包/类
public static void startWorker(int port) {
  Config conf = ConfigFactory.parseString("akka.remote.netty.tcp.port=" + port).
      withFallback(ConfigFactory.load("worker"));

  ActorSystem system = ActorSystem.create("WorkerSystem", conf);

  ActorRef clusterClient = system.actorOf(
      ClusterClient.props(ClusterClientSettings.create(system)),
      "clusterClient");
  system.actorOf(Worker.props(clusterClient, Props.create(WorkExecutor.class)), "worker");
}
 
开发者ID:typesafehub,项目名称:activator-akka-distributed-workers-java,代码行数:12,代码来源:Main.java

示例4: testWorkers

import akka.cluster.client.ClusterClientSettings; //导入依赖的package包/类
@Test
public void testWorkers() throws Exception {
  new JavaTestKit(system) {{
    TestProbe clusterProbe = new TestProbe(system);
    Cluster.get(system).subscribe(clusterProbe.ref(), ClusterEvent.MemberUp.class);
    clusterProbe.expectMsgClass(ClusterEvent.CurrentClusterState.class);

    Address clusterAddress = Cluster.get(system).selfAddress();
    Cluster.get(system).join(clusterAddress);
    clusterProbe.expectMsgClass(ClusterEvent.MemberUp.class);

    system.actorOf(
        ClusterSingletonManager.props(
            Master.props(workTimeout),
            PoisonPill.getInstance(),
            ClusterSingletonManagerSettings.create(system).withRole("backend")
        ),
        "master");

    Set<ActorPath> initialContacts = new HashSet<>();
    initialContacts.add(ActorPaths.fromString(clusterAddress + "/system/receptionist"));

    ActorRef clusterClient = system.actorOf(
      ClusterClient.props(ClusterClientSettings.create(system).withInitialContacts(initialContacts)),
      "clusterClient");


    for (int n = 1; n <= 3; n += 1) {
      system.actorOf(Worker.props(clusterClient,
        Props.create(WorkExecutor.class), registerInterval), "worker-" + n);
    }

    ActorRef flakyWorker = system.actorOf(Worker.props(clusterClient,
      Props.create(FlakyWorkExecutor.class), registerInterval), "flaky-worker");

    final ActorRef frontend = system.actorOf(Props.create(Frontend.class), "frontend");

    final JavaTestKit results = new JavaTestKit(system);

    DistributedPubSub.get(system).mediator().tell(
      new DistributedPubSubMediator.Subscribe(Master.ResultsTopic, results.getRef()),
      getRef());
    expectMsgClass(DistributedPubSubMediator.SubscribeAck.class);




    // might take a while for things to get connected
    new AwaitAssert(duration("10 seconds")) {
      protected void check() {
        frontend.tell(new Master.Work("1", 1), getRef());
        expectMsgEquals(Frontend.Ok.getInstance());
      }
    };

    assertEquals(results.expectMsgClass(Master.WorkResult.class).workId, "1");

    for (int n = 2; n <= 100; n += 1) {
      frontend.tell(new Master.Work(Integer.toString(n), n), getRef());
      expectMsgEquals(Frontend.Ok.getInstance());
    }

    results.new Within(duration("10 seconds")) {
      public void run() {
        Object[] messages = results.receiveN(99);
        SortedSet<Integer> set = new TreeSet<Integer>();
        for (Object m: messages) {
          set.add(Integer.parseInt(((Master.WorkResult) m).workId));
        }
        // nothing lost, and no duplicates
        Iterator<Integer> iterator = set.iterator();
        for (int n = 2; n <= 100; n += 1) {
          assertEquals(n, iterator.next().intValue());
        }
      }
    };
  }};
}
 
开发者ID:typesafehub,项目名称:activator-akka-distributed-workers-java,代码行数:79,代码来源:DistributedWorkerTest.java

示例5: createClientActors

import akka.cluster.client.ClusterClientSettings; //导入依赖的package包/类
/**
 * Create ClientActor for each region.
 */
private void createClientActors( ActorSystem system ) {

    for ( String region : getSeedsByRegion().keySet() ) {

        if ( currentRegion.equals( region )) {

            logger.info( "Creating clientActor for region [{}]", region );

            // Each clientActor needs to know path to ClusterSingletonProxy and region
            clientActor = system.actorOf(
                Props.create( ClientActor.class, routersByMessageType ), "clientActor" );

            ClusterClientReceptionist.get(system).registerService( clientActor );

        } else {

            logger.info( "Creating clusterClient for region [{}]", region );

            Set<ActorPath> seedPaths = new HashSet<>(20);
            for ( String seed : getSeedsByRegion().get( region ) ) {
                seedPaths.add( ActorPaths.fromString( seed + "/system/receptionist") );
            }

            ActorRef clusterClient = system.actorOf( ClusterClient.props(
                ClusterClientSettings.create(system).withInitialContacts( seedPaths )), "client");

            clusterClientsByRegion.put( region, clusterClient );
        }
    }
}
 
开发者ID:apache,项目名称:usergrid,代码行数:34,代码来源:ActorSystemManagerImpl.java


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