Ignite实战之四 集群的管理

在之前的例子中, 我们的程序实现了分布式调用,这是一个最最基础的需求--能跑。随后我们的“野心”会更大,希望能精细化的控制我们的应用跑在哪里,某一个实例上或者某几个实例上。这就需要下层的分布式系统能对集群做精细化的管理,而在Ignite中,对集群的管理大致可以发分为两类

粗放化

  • 远程节点分组
IgniteCluster cluster = ignite.cluster();
// Cluster group with remote nodes, i.e. other than this node.
ClusterGroup remoteGroup = cluster.forRemotes();
  • client节点分组
IgniteCluster cluster = ignite.cluster();
// All client nodes.
ClusterGroup clientGroup = cluster.forClients();
  • server节点分组
IgniteCluster cluster = ignite.cluster();
// All server nodes.
ClusterGroup serverGroup = cluster.forServers();

精细化

  • 根据是否部署了特定cache分组
IgniteCluster cluster = ignite.cluster();
// All nodes on which cache with name "myCache" is deployed,
// either in client or server mode.
ClusterGroup cacheGroup = cluster.forCache("myCache");
  • 根据部署了特定cache的server节点分组
IgniteCluster cluster = ignite.cluster();
// All data nodes responsible for caching data for "myCache".
ClusterGroup dataGroup = cluster.forDataNodes("myCache");
  • 根据可访问特定cache的client节点分组
IgniteCluster cluster = ignite.cluster();
// All client nodes that access "myCache".
ClusterGroup clientGroup = cluster.forClientNodes("myCache");
  • 根据节点属性分组
    节点启动时可以配置特定的属性值
<bean class="org.apache.ignite.IgniteConfiguration">
    ...
    <property name="userAttributes">
        <map>
            <entry key="ROLE" value="worker"/>
        </map>
    </property>
    ...
</bean>

之后可以根据属性值进行分组

IgniteCluster cluster = ignite.cluster();
// All nodes with attribute "ROLE" equal to "worker".
ClusterGroup attrGroup = cluster.forAttribute("ROLE", "worker");

如此,我们就可以将应用精确的部署到所需要的分组中了

IgniteCompute compute = ignite.compute(xxxGroup);
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,771评论 19 139
  • 语言和文字的力量让人难以想象,丰富多彩的语言和文字才能赋予更加多的内容和想象,但是当数量减少,与之相对应的赋予的意...
    羊咩的内心拥有一头狼阅读 1,716评论 0 0
  • 之所以当你要给一个故事收尾的时候会遇到难题,正是因为你没有 制造出一个真正的开端,一个真正的冲突。结尾的秘诀在于:...
    predict图腾阅读 4,726评论 0 2
  • 03119-焦小红 《幸福的种子•丰富的语言体验》包括两个部分:一是语言深植心中;二是听觉的体验...
    胡焦阅读 1,501评论 0 0
  • 作为最常见的症状,每个人用得经历几场感冒,换季会感冒,着凉会感冒,流感肆虐的时候也有不少人中招,感冒发作就像毒瘾发...
    行走在路上呢阅读 1,768评论 0 0