zoukankan      html  css  js  c++  java
  • akka 的集群访问方式

    akka  中采用startProxy分区代理 访问 ,跟使用shardRegion 来访问的区别

    这两种访问方式是不是重了呢。

     而另外这是一个单例代理

    private fun startUniverseCwarManager() {
    val settings = ClusterSingletonManagerSettings.create(actorSystem).withRole(ClusterRole.universe_cwar.name)
    actorSystem.actorOf(
    ClusterSingletonManager.props(UniverseCwarManager.props(), Handoff, settings),
    UNIVERSE_CWAR_MANAGER
    )
    }

    以上创建的集群单例,通过以下方式进行访问
    protected fun startUniverseProxy(universeRole: UniverseRole) {
      val proxySettings = ClusterSingletonProxySettings.create(actorSystem).withRole(universeRole.clusterRole.name)
    val actorRef: ActorRef = actorSystem.actorOf(ClusterSingletonProxy.props(universeRole.proxyPath, proxySettings))
    universeProxies[universeRole] = actorRef
    }



    worldActor 中 又 创建了一个访问对象
    /**
    * actor分布在universe_cwar节点上
    */
    private fun startUniverseCwarShardRegion() {
    val settings = ClusterShardingSettings.create(actorSystem).withRole(ClusterRole.universe_cwar.name)
    val region = ClusterSharding.get(actorSystem).start(
    GameWorldShard.universe_cwar.name,
    UniverseCwarWorld.props(),
    settings,
    UCWorldMessageExtractor(),
    ShardCoordinator.LeastShardAllocationStrategy(5, 1),
    Handoff
    )
    logger.info("SharedRegion $region started.")

    ClusterClientReceptionist.get(actorSystem).registerService(region)
    }


    通过这种方式创建的集群分片 , 通过以下 代理进行访问


    /**
    * Retrieve the actor reference of the [[ShardRegion]] actor responsible for the named entity type.
    * The entity type must be registered with the [[#start]] or [[#startProxy]] method before it
    * can be used here. Messages to the entity is always sent via the `ShardRegion`.
    */
    就是只要  
    protected fun startUniverseCwarShardProxy() {
    ClusterSharding.get(actorSystem).startProxy(
    GameWorldShard.universe_cwar.name, Optional.of(ClusterRole.universe_cwar.name),
    UCWorldMessageExtractor()
    )
    .let { logger.info("UniverseCwar shard proxy $it started.") }
    }
    开始的方式, 就能以以下的方式获取到
    ClusterSharding.get(context.system()).let {
    ucWorldShardProxy = it.shardRegion(GameWorldShard.universe_cwar.name)
    }
  • 相关阅读:
    Rotate Image,N*N矩阵顺时针旋转90度
    JumpGame,JumpGame2
    WildcardMatching和Regex,通配符匹配和正则表达式匹配
    Multiply Strings,字符串相乘
    TrappingRainWater
    300万PV的ASP.NET网站使用阿里云的配置建议
    java 学习 安卓学习
    如何学习Yii
    Lemon开源OA
    JAVA-进行Java Web项目开发需要掌握的技术
  • 原文地址:https://www.cnblogs.com/vana/p/11005274.html
Copyright © 2011-2022 走看看