【问题标题】:Apache Ignite REST APIApache 点燃 REST API
【发布时间】:2020-09-27 07:45:28
【问题描述】:

我正在使用 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 中运行的服务器数量?

【问题讨论】:

  • 您尝试过#topology 方法吗? apacheignite.readme.io/docs/rest-api#topology
  • 监控可以使用WebConsole免费使用gridgain.com/docs/web-console/latest/…
  • 我也在使用它.. 但我需要历史记录。例如,我需要显示上周发生的记录。所以我开发了一个使用 MySQL 的工具。
  • 是的,我尝试过 top 命令。但是我没有找到服务器的数量。
  • 我有一个疑问 .. 对于客户端节点 tcpPort 始终为 '0' .. 对吗?

标签: caching ignite rest


【解决方案1】:

您可以通过 REST run SQL command SELECT * FROM SYS.NODES; 确定:

~/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
  ]
]

(假设您有名为 default 的缓存以供 API 使用)

【讨论】:

  • 我得到了以下响应 {"successStatus":1,"error":"Failed to find cache with name: default","re​​sponse":null,"sessionToken":null}
  • 是的,当我给出任何缓存名称(存在于集群中)时,我得到了正确的响应。但如果没有持久性,最初我没有任何缓存,那时我需要给什么名字?
  • 你需要创建一个缓存,你可以使用cmd=getorcreate
  • 谢谢alamar,我已经更新了我的答案..你能检查一下这是对还是错?
【解决方案2】:

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

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

响应["attributes"]["org.apache.ignite.cache.client"] => false,

【讨论】:

  • 是的,它应该通过结合topnode 命令的结果来工作。
  • @alamar 谢谢
猜你喜欢
  • 2015-09-07
  • 2022-01-19
  • 1970-01-01
  • 2020-05-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-04
相关资源
最近更新 更多