提问者:小点点

Apache Ignite REST API


我正在使用Apache Ignite 2.8.0。我开发了一个用于监控Ignite性能的小型仪表板。现在我的问题是找到服务器的数量。首先我找到了节点的总数(在节点变量中),然后

    total_servers = 0
    port = 8080

    for j in range(0,node + 1):   
      if(persistence == True):
        url_cache = "http://localhost:" + str(port) + "/ignite?cmd=top&sessionToken=" +sessionToken

      else:
        url_cache = "http://localhost:" + str(port) + "/ignite?cmd=top"            
      try:
                    print(j)
                    try:
                        res = requests.get(url = url_cache)
                        print(res.status_code)
                        if(res.status_code == 200):
                             total_servers = total_servers + 1
                    except:
                        pass
      except:
             pass

      port = port + 1  

但这需要很多时间,我不想这样。有没有任何简单的方法可以通过使用REST API http请求来查找Apache Ignite中运行的服务器数量?


共2个答案

匿名用户

从REST中,您可以运行SQL命令< code>SELECT * FROM SYS。节点;确定:

~/Downloads/apache-ignite-2.8.1-bin% wget -q -O- http://localhost:8080/ignite\?cmd=qryfldexe\&pageSize\=10\&cacheName\=default\&qry=select\ \*\ from\ sys.nodes | jq .response.items
[
  [
    "3304155a-bc83-402f-a884-59d39f074d3a",
    "0:0:0:0:0:0:0:1%lo,127.0.0.1,172.17.0.1,192.168.1.7:47500",
    "2.8.1#20200521-sha1:86422096",
    false,
    false,
    1,
    "[0:0:0:0:0:0:0:1%lo, 127.0.0.1, 172.17.0.1, 192.168.1.7]",
    "[192.168.1.7, 172.17.0.1]",
    true
  ]
]

(假设您出于 API 目的将缓存命名为默认值

匿名用户

终于找到了一个答案。如果错了,请建议我,

http://localhost:8080/ignite?cmd=node&id=a427-a04631d64c98&attr=true

响应[“属性”][“org.apache.inite.cache.client”]=