首页 > 其他分享 >Pulsar 入门实战(6)--Rest API

Pulsar 入门实战(6)--Rest API

时间:2024-11-24 19:22:34浏览次数:6  
标签:8080 -- persistent Rest topic admin v2 API 10.49

Rest API 是 broker 提供的关联 API,Java admin API 和 pulsar-admin CLI 底层都是使用的 Rest API;本文主要介绍其基本使用,文中所使用到的软件版本:Pulsar 3.3.0。

1、Admin

1.1、BOOKIES

1.1.1、列出所有 bookie

curl http://10.49.196.30:8080/admin/v2/bookies/all

1.2、BROKERS

1.2.1、列出本集群的所有 broker

curl http://10.49.196.30:8080/admin/v2/brokers

1.2.2、列出所有可动态修改配置项名称

curl http://10.49.196.30:8080/admin/v2/brokers/configuration

1.2.3、列出所有运行时配置

curl http://10.49.196.30:8080/admin/v2/brokers/configuration/runtime

1.2.4、列出已经更新过的动态配置

curl http://10.49.196.30:8080/admin/v2/brokers/configuration/values

1.2.5、更新动态配置

POST /admin/v2/brokers/configuration/{configName}/{configValue}

如:

curl -X POST http://10.49.196.30:8080/admin/v2/brokers/configuration/allowAutoTopicCreation/true

1.2.6、健康检查

curl http://10.49.196.30:8080/admin/v2/brokers/health

1.2.7、获取内部配置信息

curl http://10.49.196.30:8080/admin/v2/brokers/internal-configuration

1.2.8、获取 leader broker

curl http://10.49.196.30:8080/admin/v2/brokers/leaderBroker

1.2.9、检查 broker 是否完全初始化了

curl http://10.49.196.30:8080/admin/v2/brokers/ready

1.2.10、获取当前 broker 的版本

curl http://10.49.196.30:8080/admin/v2/brokers/version

1.2.11、列出 broker 的命名空间

GET /admin/v2/brokers/{clusterName}/{brokerId}/ownedNamespaces

如:

curl http://10.49.196.30:8080/admin/v2/brokers/pulsar-cluster-1/app1:8080/ownedNamespaces

1.2.12、列出指定集群的所有 broker

GET /admin/v2/brokers/{cluster}

如:

curl http://10.49.196.30:8080/admin/v2/brokers/pulsar-cluster-1

1.3、BROKER-STATS

1.3.1、获取 broker 的主题状态和系统资源使用信息

curl http://10.49.196.30:8080/admin/v2/broker-stats/load-report

1.3.2、获取主题的状态信息

curl http://10.49.196.30:8080/admin/v2/broker-stats/topics

1.4、CLUSTERS

1.4.1、列出集群

curl http://10.49.196.30:8080/admin/v2/clusters

1.4.2、获取集群配置信息

GET /admin/v2/clusters/{cluster}

如:

curl http://10.49.196.30:8080/admin/v2/clusters/pulsar-cluster-1

1.5、TENANTS

1.5.1、列出租户的命名空间

curl http://10.49.196.30:8080/admin/v2/tenants

1.5.2、删除租户

DELETE /admin/v2/tenants/{tenant}

如:

curl -X DELETE http://10.49.196.30:8080/admin/v2/tenants/test-tenant

1.5.3、获取租户的管理配置

GET /admin/v2/tenants/{tenant}

如:

curl  http://10.49.196.30:8080/admin/v2/tenants/public

1.5.4、更新租户管理配置

POST /admin/v2/tenants/{tenant}
{
  "adminRoles": [
    "string"
  ],
  "allowedClusters": [
    "string"
  ]
}

如:

curl -X POST -H 'content-type:application/json' http://10.49.196.30:8080/admin/v2/tenants/test-tenant -d '
{
  "adminRoles": [
    "string"
  ],
  "allowedClusters": [
    "pulsar-cluster-1"
  ]
}'

1.5.5、创建租户

PUT /admin/v2/tenants/{tenant}

如:

curl -X PUT -H 'content-type:application/json' http://10.49.196.30:8080/admin/v2/tenants/test-tenant -d '
{
  "adminRoles": [
    "string"
  ],
  "allowedClusters": [
    "pulsar-cluster-1"
  ]
}'

1.6、NAMESPACES

1.6.1、列出租户的命名空间

GET /admin/v2/namespaces/{tenant}

如:

curl http://10.49.196.30:8080/admin/v2/namespaces/public

1.6.2、获取命名空间策略

GET /admin/v2/namespaces/{tenant}/{namespace}

如:

curl http://10.49.196.30:8080/admin/v2/namespaces/public/default

1.6.3、删除命名空间(同时删除命名空间包含的主题)

DELETE /admin/v2/namespaces/{tenant}/{namespace}

如:

curl -X DELETE http://10.49.196.30:8080/admin/v2/namespaces/public/test-ns

1.6.4、创建命名空间

PUT /admin/v2/namespaces/{tenant}/{namespace}

如:

curl -X PUT http://10.49.196.30:8080/admin/v2/namespaces/public/test-ns

1.7、NON-PERSISTENT TOPIC

1.7.1、列出命名空间下的非分区主题

GET /admin/v2/non-persistent/{tenant}/{namespace}

如:

curl http://10.49.196.30:8080/admin/v2/non-persistent/public/default

1.7.2、列出命名空间下的分区主题

GET /admin/v2/non-persistent/{tenant}/{namespace}/partitioned

如:

curl http://10.49.196.30:8080/admin/v2/non-persistent/public/default/partitioned

1.7.3、创建非分区主题

PUT /admin/v2/non-persistent/{tenant}/{namespace}/{topic}

如:

curl -X PUT -L http://10.49.196.30:8080/admin/v2/non-persistent/public/default/test-topic

1.7.4、创建分区主题

PUT /admin/v2/non-persistent/{tenant}/{namespace}/{topic}/partitions

如:

curl -X PUT -H 'content-type:application/json' http://10.49.196.30:8080/admin/v2/non-persistent/public/default/test-topic-p/partitions -d 2

1.7.5、删除非分区主题

DELETE /admin/v2/non-persistent/{tenant}/{namespace}/{topic}

如:

curl -X DELETE -L http://10.49.196.30:8080/admin/v2/non-persistent/public/default/test-topic

1.7.6、删除分区主题

DELETE /admin/v2/non-persistent/{tenant}/{namespace}/{topic}/partitions

如:

curl -X DELETE  http://10.49.196.30:8080/admin/v2/non-persistent/public/default/test-topic-p/partitions

1.7.7、获取非分区主题的状态

GET /admin/v2/non-persistent/{tenant}/{namespace}/{topic}/stats

如:

curl -L http://10.49.196.30:8080/admin/v2/non-persistent/public/default/test-topic/stats

1.7.8、获取分区主题的状态

GET /admin/v2/non-persistent/{tenant}/{namespace}/{topic}/partitioned-stats

如:

curl -L http://10.49.196.30:8080/admin/v2/non-persistent/public/default/test-topic-p/partitioned-stats

1.7.9、获取非分区主题的内部状态

GET /admin/v2/non-persistent/{tenant}/{namespace}/{topic}/internalStats

如:

curl -L http://10.49.196.30:8080/admin/v2/non-persistent/public/default/test-topic/internalStats

1.7.10、获取分区主题的内部状态

GET /admin/v2/non-persistent/{tenant}/{namespace}/{topic}/partitioned-internalStats

如:

curl -L http://10.49.196.30:8080/admin/v2/non-persistent/public/default/test-topic-p/partitioned-internalStats

1.7.11、获取分区主题的元数据信息

GET /admin/v2/non-persistent/{tenant}/{namespace}/{topic}/partitions

如:

curl -L http://10.49.196.30:8080/admin/v2/non-persistent/public/default/test-topic-p/partitions

1.7.12、设置分区主题的分区数

POST /admin/v2/non-persistent/{tenant}/{namespace}/{topic}/partitions

如:

curl -X POST -H 'Content-Type:application/json' http://10.49.196.30:8080/admin/v2/non-persistent/public/default/test-topic-p/partitions -d '3'

1.8、PERSISTENT TOPIC

1.8.1、列出命名空间下的非分区主题

GET /admin/v2/persistent/{tenant}/{namespace}

如:

curl http://10.49.196.30:8080/admin/v2/persistent/public/default

1.8.2、列出命名空间下的分区主题

GET /admin/v2/persistent/{tenant}/{namespace}/partitioned

如:

curl -L http://10.49.196.30:8080/admin/v2/persistent/public/default/partitioned

1.8.3、创建非分区主题

PUT /admin/v2/non-persistent/{tenant}/{namespace}/{topic}

如:

curl -X PUT -L http://10.49.196.30:8080/admin/v2/persistent/public/default/test-topic

1.8.4、创建分区主题

PUT /admin/v2/persistent/{tenant}/{namespace}/{topic}/partitions

如:

curl -X PUT -H 'content-type:application/json' http://10.49.196.30:8080/admin/v2/persistent/public/default/test-topic-p/partitions -d 2

1.8.5、删除非分区主题

DELETE /admin/v2/persistent/{tenant}/{namespace}/{topic}

如:

curl -X DELETE -L http://10.49.196.30:8080/admin/v2/persistent/public/default/test-topic

1.8.6、删除分区主题

DELETE /admin/v2/persistent/{tenant}/{namespace}/{topic}/partitions

如:

curl -X DELETE  http://10.49.196.30:8080/admin/v2/persistent/public/default/test-topic-p/partitions

1.8.7、获取非分区主题的状态

GET /admin/v2/persistent/{tenant}/{namespace}/{topic}/stats

如:

curl -L http://10.49.196.30:8080/admin/v2/persistent/public/default/test-topic/stats

1.8.8、获取分区主题的状态

GET /admin/v2/persistent/{tenant}/{namespace}/{topic}/partitioned-stats

如:

curl -L http://10.49.196.30:8080/admin/v2/persistent/public/default/test-topic-p/partitioned-stats

1.7.9、获取非分区主题的内部状态

GET /admin/v2/persistent/{tenant}/{namespace}/{topic}/internalStats

如:

curl -L http://10.49.196.30:8080/admin/v2/persistent/public/default/test-topic/internalStats

1.7.10、获取分区主题的内部状态

GET /admin/v2/persistent/{tenant}/{namespace}/{topic}/partitioned-internalStats

如:

curl http://10.49.196.30:8080/admin/v2/persistent/public/default/test-topic-p/partitioned-internalStats

1.7.11、获取分区主题的元数据信息

GET /admin/v2/persistent/{tenant}/{namespace}/{topic}/partitions

或:

curl -L http://10.49.196.30:8080/admin/v2/persistent/public/default/test-topic-p/partitions

1.7.12、设置分区主题的分区数(只能比原来大)

POST /admin/v2/persistent/{tenant}/{namespace}/{topic}/partitions

或:

curl -X POST -H 'Content-Type:application/json' http://10.49.196.30:8080/admin/v2/persistent/public/default/test-topic-p/partitions -d '3'

1.7.13、获取最新消息的 ID

GET /admin/v2/persistent/{tenant}/{namespace}/{topic}/lastMessageId

如:

curl -L http://10.49.196.30:8080/admin/v2/persistent/public/default/my-topic/lastMessageId

1.7.14、通过消息 ID 获取消息

GET /admin/v2/persistent/{tenant}/{namespace}/{topic}/ledger/{ledgerId}/entry/{entryId}

如:

curl -L http://10.49.196.30:8080/admin/v2/persistent/public/default/my-topic/ledger/272/entry/1

1.7.15、通过时间获取消息的 ID

GET /admin/v2/persistent/{tenant}/{namespace}/{topic}/messageid/{timestamp}

如:

curl -L http://10.49.196.30:8080/admin/v2/persistent/public/default/my-topic/messageid/1723517025876

1.7.16、查看订阅的待消费消息(不会消费消息)

GET /admin/v2/persistent/{tenant}/{namespace}/{topic}/subscription/{subName}/position/{messagePosition}

如:

curl -L http://10.49.196.30:8080/admin/v2/persistent/public/default/my-topic/subscription/my-subscription/position/3

1.7.17、跳过特定主题的某个订阅中的若干条未消费消息

POST /admin/v2/persistent/{tenant}/{namespace}/{topic}/subscription/{subName}/skip/{numMessages}

如:

curl -X POST -L http://10.49.196.30:8080/admin/v2/persistent/public/default/my-topic/subscription/my-subscription/skip/2

1.7.18、跳过特定主题的某个订阅中的所有未消费消息

POST /persistent/{tenant}/{namespace}/{topic}/subscription/{subName}/skip_all

如:

curl -X POST -L http://10.49.196.30:8080/admin/v2/persistent/public/default/my-topic/subscription/my-subscription/skip_all

1.7.19、创建订阅

PUT /persistent/{tenant}/{namespace}/{topic}/subscription/{subscriptionName}

如:

curl -X PUT -L http://10.49.196.30:8080/admin/v2/persistent/public/default/test-topic/subscription/test-subscription

1.7.20、获取订阅信息

GET /admin/v2/persistent/{tenant}/{namespace}/{topic}/subscriptions

如:

curl -L http://10.49.196.30:8080/admin/v2/persistent/public/default/test-topic/subscriptions

1.7.21、删除订阅

DELETE /admin/v2/persistent/{tenant}/{namespace}/{topic}/subscription/{subName}

如:

curl -X DELETE -L http://10.49.196.30:8080/admin/v2/persistent/public/default/test-topic/subscription/test-subscription

2、Lookup

2.2.1、获取主题所属的 broker

GET /lookup/v2/topic/{topic-domain}/{tenant}/{namespace}/{topic}

如:

curl -L http://10.49.196.30:8080/lookup/v2/topic/persistent/public/default/test-topic

 

 

 

参考:https://pulsar.apache.org/docs/3.3.x/reference-rest-api-overview/

标签:8080,--,persistent,Rest,topic,admin,v2,API,10.49
From: https://www.cnblogs.com/wuyongyin/p/18347216

相关文章

  • 记一次数据同步方案的选择处理
    系统的数据来源是其他系统,要么通过第三方接口拿数据,要么把数据同步过来进行处理查询两种方案选择因为需要的数据源在其他系统里面,所以最大的阻碍其实是数据,要么和其他系统合作,两边对接api接口拿数据,要么从其他系统同步数据过来,自己去处理逻辑,两者互有利弊。综合考虑各种因素,最......
  • Font-awesome失效恢复
    Font-awesome失效恢复策略可能的原因有:1.用了收费pro的版本,没充钱。FontAwesome6字体分为Free和Pro两个版本。FontAwesome6Free字体是免费版,可以自由使用;FontAwesome6Pro字体是收费版,需要付费才能使用。2.链接失效,需要更新。比方说你原来库引用的是4.7版本的(......
  • 华为技术岗位笔试&面试题汇总-第二篇
    说在前面本篇文章是华为技术岗位笔试&面试题,第二篇。后续将持续推出互联网大厂,如阿里,腾讯,百度,美团,头条等技术面试题目,以及答案,专家出题人分析汇总。欢迎大家点赞关注转发。题目1:冒泡排序算法的时间复杂度是什么?参考答案:时间复杂度是O(n^2)。题目2:Internet采用哪种网络协议......
  • 实验四
    任务一:代码:#include<iostream>#include<string>usingstd::cout;usingstd::endl;usingstd::string;//定义类模板template<typenameT>classX{public:X(Tx0,Ty0);voiddisplay();private:Tx,y;};template<typenameT......
  • Android Studio 介绍
    AndroidStudio是Android应用的开发工具,由谷歌公司在2013年5月推出,AndroidStudio基于IntelliJIDEA演变而来,比Eclipse更加方便易用,运行速度也较快.AndroidStudio出现之前,使用Eclipse开发Android应用.虽然Android基于Linux内核,但是Android手......
  • ubuntu切换python默认版本
    1.检查当前Python版本首先,查看系统中已安装的Python版本:python--versionpython3--versionls/usr/bin/python*你应该会看到多个Python版本,如python2.x或python3.x。2.使用update-alternatives工具Ubuntu推荐使用update-alternatives来管理和切换默......
  • newstar2024 reverse
    Newstar2024--Reversebase64无壳shiftf12查找字符串换表的base64加密Simple_encryption打开主函数直接查看buffer,逆向破解enc=[0x47,0x95,0x34,0x48,0xA4,0x1C,0x35,0x88,0x64,0x16,0x88,0x07,0x14,0x6A,0x39,0x12,0xA2,0x0A,0x37,0x5C,0......
  • wp
    2024极客大挑战Hello_re脱壳die打开发现有upx壳一键不能去除,用010打开发现魔改了,将SYC0改为UPX0即可是个很简单的加密编写解密脚本key=[0x53,0x59,0x43,0x4C,0x4F,0x56,0x45,0x52]enc=[0,1,2,52,3,96,47,28,107,15,9,24,45,62,60,2,17,12......
  • shell脚本
    提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档文章目录前言shell脚本的创建和执行变量的使用前言声明学习视频来自B站UP主泷羽sec,如涉及侵权马上删除文章笔记的只是方便各位师傅学习知识,以下网站只涉及学习内容,其他的都与本人无关,切莫逾......
  • oracle ogg学习和ogg常见变更操作
    oracleogg学习和ogg常见变更操作OGG(OracleGoldenGate)OGG是一种基于日志的结构化数据复制软件,它通过解析源数据库在线日志或归档日志获得数据的增删改变化(数据量只有日志的四分之一左右)OGG能够实现大量交易数据的实时捕捉,变换和投递,实现源数据库与目标数据库的数据同......