欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Java使用pulsar-flink-connector讀取pulsar catalog元數(shù)據(jù)代碼剖析

 更新時(shí)間:2021年08月02日 16:02:20   作者:CNBLOG  
這篇文章主要介紹了Java使用pulsar-flink-connector讀取pulsar catalog元數(shù)據(jù)代碼剖析,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

簡(jiǎn)介

通過 pulsar-flink-connector 讀取到 Apache pulsar 中的namespaces、topics的元數(shù)據(jù)信息。
pulsar-flink-connector 的 github: https://github.com/streamnative/pulsar-flink

Maven

 <dependency>
   <groupId>io.streamnative.connectors</groupId>
   <artifactId>pulsar-flink-connector-2.11-1.12</artifactId>
   <version>2.7.3</version>
 </dependency>

   <!-- JAR repositories -->
   <repositories>
        <repository>
            <id>central</id>
            <layout>default</layout>
            <url>https://repo1.maven.org/maven2</url>
        </repository>
        <repository>
            <id>bintray-streamnative-maven</id>
            <name>bintray</name>
            <url>https://dl.bintray.com/streamnative/maven</url>
        </repository>
    </repositories>

CODE

使用PulsarMetadataReader獲取元數(shù)據(jù)

package com.levi.demo;

import org.apache.flink.streaming.connectors.pulsar.internal.PulsarMetadataReader;
import org.apache.pulsar.client.admin.PulsarAdminException;
import org.apache.pulsar.client.impl.auth.AuthenticationToken;
import org.apache.pulsar.client.impl.conf.ClientConfigurationData;
import org.apache.pulsar.common.schema.SchemaInfo;
import org.apache.pulsar.common.schema.SchemaType;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Test.
 *
 * @author levi
 * @version 1.0
 **/
public class Test {

    public static void main(String[] args)  {
        final ClientConfigurationData configurationData = new ClientConfigurationData();
        configurationData.setServiceUrl("pulsar://127.0.0.1:6650");
        //Your Pulsar Token
        final AuthenticationToken token =
                new AuthenticationToken(
                        "eyJxxxxxxxxxxx.eyxxxxxxxxxxxxx.xxxxxxxxxxx"); 
        configurationData.setAuthentication(token);
 
        try (final PulsarMetadataReader reader =
                     new PulsarMetadataReader("http://127.0.0.1:8443",
                             configurationData,
                             "",
                             new HashMap(),
                             -1,
                             -1)) {
            //獲取namespaces
            final List<String> namespaces = reader.listNamespaces();
            System.out.println("namespaces: " + namespaces.toString());
            
            for (final String namespace : namespaces) {
                //獲取Topics
                final List<String> topics = reader.getTopics(namespace);
                System.out.println("topic: " + topics.toString());
                
                for (String topic : topics) {
                    //獲取字段SchemaInfo
                    final SchemaInfo schemaInfo = reader.getPulsarSchema(topic);
                    final String name = schemaInfo.getName();
                    System.out.println("SchemaName:" + name); //topicName
                    final SchemaType type = schemaInfo.getType(); 
                    System.out.println("SchemaType:" + type.toString());// "JSON"...
                    final Map<String, String> properties = schemaInfo.getProperties();
                    System.out.println(properties); 
                    final String schemaDefinition = schemaInfo.getSchemaDefinition();
                    System.out.println(schemaDefinition); // Field info.
                }
            }

        } catch (IOException | PulsarAdminException e) {
            e.printStackTrace();
        }


    }


}

到此這篇關(guān)于Java使用pulsar-flink-connector讀取pulsar catalog元數(shù)據(jù)的文章就介紹到這了,更多相關(guān)Java讀取pulsar catalog元數(shù)據(jù)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • JAVA設(shè)計(jì)模式之建造者模式原理與用法詳解

    JAVA設(shè)計(jì)模式之建造者模式原理與用法詳解

    這篇文章主要介紹了JAVA設(shè)計(jì)模式之建造者模式,簡(jiǎn)單說(shuō)明了建造者模式的原理、組成,并結(jié)合實(shí)例形式分析了java建造者模式的定義與用法,需要的朋友可以參考下
    2017-08-08
  • 使用java代碼實(shí)現(xiàn)一個(gè)月內(nèi)不再提醒,通用到期的問題

    使用java代碼實(shí)現(xiàn)一個(gè)月內(nèi)不再提醒,通用到期的問題

    這篇文章主要介紹了使用java代碼實(shí)現(xiàn)一個(gè)月內(nèi)不再提醒,通用到期的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來(lái)看看吧
    2021-01-01
  • mybatis中 if-test 數(shù)字判斷的坑及解決

    mybatis中 if-test 數(shù)字判斷的坑及解決

    這篇文章主要介紹了mybatis中 if-test 數(shù)字判斷的坑及解決,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-06-06
  • Java?通過手寫分布式雪花SnowFlake生成ID方法詳解

    Java?通過手寫分布式雪花SnowFlake生成ID方法詳解

    SnowFlake是twitter公司內(nèi)部分布式項(xiàng)目采用的ID生成算法,開源后廣受國(guó)內(nèi)大廠的好評(píng)。由這種算法生成的ID,我們就叫做SnowFlakeID,下面我們來(lái)詳細(xì)看看
    2022-04-04
  • Vue結(jié)合Springboot實(shí)現(xiàn)用戶列表單頁(yè)面(前后端分離)

    Vue結(jié)合Springboot實(shí)現(xiàn)用戶列表單頁(yè)面(前后端分離)

    本文主要介紹了Vue結(jié)合Springboot實(shí)現(xiàn)用戶列表單頁(yè)面,可以實(shí)現(xiàn)簡(jiǎn)單的查詢,刪除,修改,和添加用戶信息功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-07-07
  • eclipse實(shí)現(xiàn)Schnorr數(shù)字簽名

    eclipse實(shí)現(xiàn)Schnorr數(shù)字簽名

    這篇文章主要為大家詳細(xì)介紹了eclipse實(shí)現(xiàn)Schnorr數(shù)字簽名,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-06-06
  • Java實(shí)現(xiàn)月餅的制作、下單和售賣功能

    Java實(shí)現(xiàn)月餅的制作、下單和售賣功能

    這篇文章主要介紹了Java實(shí)現(xiàn)月餅的制作、下單和售賣,借此機(jī)會(huì),我們用Lambda實(shí)現(xiàn)一遍月餅制作,下單,售賣的開發(fā)設(shè)計(jì)模式,主要有制作月餅的工廠模式,結(jié)合實(shí)例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下
    2022-09-09
  • Java并發(fā)編程之Semaphore詳解

    Java并發(fā)編程之Semaphore詳解

    這篇文章主要介紹了Java并發(fā)編程之Semaphore詳解,Semaphore信號(hào)量可以用來(lái)控制同時(shí)訪問特定資源的線程數(shù)量,常用于限流場(chǎng)景,Semaphore接收一個(gè)int整型值,表示 許可證數(shù)量,需要的朋友可以參考下
    2023-11-11
  • Springboot+echarts實(shí)現(xiàn)可視化

    Springboot+echarts實(shí)現(xiàn)可視化

    這篇文章主要為大家詳細(xì)介紹了Springboot+echarts實(shí)現(xiàn)可視化,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-12-12
  • springMVC+jersey實(shí)現(xiàn)跨服務(wù)器文件上傳

    springMVC+jersey實(shí)現(xiàn)跨服務(wù)器文件上傳

    這篇文章主要介紹了springMVC+jersey實(shí)現(xiàn)跨服務(wù)器文件上傳,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-08-08

最新評(píng)論