docker Delta Lake Sink Connector for Apache Pulsar with miniO throws(java.lang.IllegalArgumentException)

hgqdbh6s  于 2023-10-16  发布在  Docker
关注(0)|答案(2)|浏览(117)

我试图运行新的apache脉冲星Lakehouse Sink Connector,我得到java.lang.IllegalArgumentException
下面是我的设置。docker-compose.yaml文件:

version: '3.7'
volumes:
  mssql-data:
  minio-data:
networks:
  oentity:
    driver: bridge
services:
  pulsar:
    image: apachepulsar/pulsar:latest
    command: bin/pulsar standalone
    hostname: pulsar
    ports:
      - "8080:8080"
      - "6650:6650"
    restart: unless-stopped
    networks:
      oentity:
    volumes:
      - "./data/:/pulsar/data"
      - "./connectors/:/pulsar/connectors"
  dashboard:
    image: apachepulsar/pulsar-manager:latest
    ports:
      - "9528:9527"
      - "7750:7750"
    networks:
      oentity:
    depends_on:
      - pulsar
    links:
      - pulsar
    environment:
      SPRING_CONFIGURATION_FILE: /pulsar-manager/pulsar-manager/application.properties
  minio:
    image: 'minio/minio:latest'
    hostname: minio
    container_name: minio
    ports:
      - '9000:9000'
      - '9001:9001'
    volumes:
      - minio-data:/data
    environment:
      MINIO_ROOT_USER: minio
      MINIO_ROOT_PASSWORD: minio123
      MINIO_ACCESS_KEY: minio
      MINIO_SECRET_KEY: minio123
    command: server --console-address ":9001" /data
    networks:
      oentity:
  • 我下载了here的连接器,并将NAR包复制到容器中的Pulsar连接器目录$PULSAR_HOME/connectors
  • 我从http://localhost:9001/login登录到miniO,并创建了一个bucket调用lakehouse。
  • 我使用了类似于here的cconfiguration,并将tablePath值与我的miniO路径替换。我把这个文件命名为sink-connector-config.json
{
  "tenant":"public",
  "namespace":"default",
  "name":"delta_sink",
  "parallelism":1,
  "inputs": [
    "test-delta-pulsar"
  ],
  "archive": "connectors/pulsar-io-lakehouse-2.9.3.7-cloud.nar",
  "processingGuarantees":"EFFECTIVELY_ONCE",
  "configs":{
      "type":"delta",
      "maxCommitInterval":120,
      "maxRecordsPerCommit":10000000,
      "tablePath": "s3a://lakehouse/delta_sink",
      "hadoop.fs.s3a.aws.credentials.provider": "com.amazonaws.auth.DefaultAWSCredentialsProviderChain"
  }
}
  • 我查了湖边小屋Flume的连接器。docker exec -it <container name> bash

然后我处决了

PULSAR_HOME/bin/pulsar-admin sink localrun \
--sink-config-file sink-connector-config.json

我在下面的错误;

2022-09-06T16:53:08,396+0000 [main] INFO  org.apache.pulsar.functions.utils.io.ConnectorUtils - Found connector ConnectorDefinition(name=lakehouse, description=Lakehouse connectors, sourceClass=org.apache.pulsar.ecosystem.io.lakehouse.SourceConnector, sinkClass=org.apache.pulsar.ecosystem.io.lakehouse.SinkConnector, sourceConfigClass=org.apache.pulsar.ecosystem.io.lakehouse.SourceConnectorConfig, sinkConfigClass=org.apache.pulsar.ecosystem.io.lakehouse.SinkConnectorConfig) from /pulsar/connectors/pulsar-io-lakehouse-2.9.3.7-cloud.nar
2022-09-06T16:53:44,562+0000 [main] ERROR org.apache.pulsar.functions.LocalRunner - Encountered error starting localrunner
java.lang.IllegalArgumentException: Could not validate sink config: Cannot construct instance of `org.apache.pulsar.ecosystem.io.lakehouse.SinkConnectorConfig` (no Creators, like default constructor, exist): abstract types either need to be mapped 
to concrete types, have custom deserializer, or contain additional type information
 at [Source: UNKNOWN; byte offset: #UNKNOWN]
        at org.apache.pulsar.functions.utils.SinkConfigUtils.validateSinkConfig(SinkConfigUtils.java:594) ~[org.apache.pulsar-pulsar-functions-utils-2.9.3.jar:2.9.3]
        at org.apache.pulsar.functions.utils.SinkConfigUtils.validateAndExtractDetails(SinkConfigUtils.java:441) ~[org.apache.pulsar-pulsar-functions-utils-2.9.3.jar:2.9.3]
        at org.apache.pulsar.functions.LocalRunner.start(LocalRunner.java:439) ~[org.apache.pulsar-pulsar-functions-local-runner-original-2.9.3.jar:2.9.3]
        at org.apache.pulsar.functions.LocalRunner.main(LocalRunner.java:198) [org.apache.pulsar-pulsar-functions-local-runner-original-2.9.3.jar:2.9.3]
root@pulsar:/pulsar#

感谢@Tim Spann,他向我推荐了他的回购:https://github.com/tspannhw/FLiP-Pi-DeltaLake-Thermal

我做错了什么

  • 将消息从队列发送到队列
  • 无架构定义
    对我有效的是
  • 为队列创建架构
  • 使用yaml作为连接器属性,而不是json。例如
    miniO配置
tenant: public
namespace: default
name: delta_sink
parallelism: 1
inputs:
- raw.ro
archive: connectors/pulsar-io-lakehouse-2.9.3.7-cloud.nar
processingGuarantees: EFFECTIVELY_ONCE
configs:
  type: delta
  maxCommitInterval: 120
  maxRecordsPerCommit: 10000000
  tablePath: s3a://lakehouse/delta_sink
  processingGuarantees: "EXACTLY_ONCE"
  deltaFileType: "parquet"
  subscriptionType: "Failover"
  hadoop.fs.s3a.aws.credentials.provider: org.apache.hadoop.fs.s3a.SimpleAWSCredentialsProvider
  hadoop.fs.s3a.endpoint: http://minio:9000
  hadoop.fs.s3a.access.key: minio
  hadoop.fs.s3a.secret.key: minio123
  hadoop.fs.s3a.path.style.access: true

本地文件系统

tenant: public
namespace: default
name: delta_sink
parallelism: 1
inputs:
- raw.ro
archive: connectors/pulsar-io-lakehouse-2.9.3.7.nar
processingGuarantees: EFFECTIVELY_ONCE
configs:
 type: delta
 maxCommitInterval: 120
 maxRecordsPerCommit: 10000000
 tablePath: file:///opt/demo/lakehouse
 processingGuarantees: "EXACTLY_ONCE"
 deltaFileType: "parquet"
 subscriptionType: "Failover"

在python脚本中创建模式以将消息发送到pulsar

import pulsar
from pulsar.schema import *

class CciMessage(Record):
    message = String()
    id = Integer()

client = pulsar.Client('pulsar://pulsar:6650')
producer = client.create_producer(topic='raw.ro',
                            schema=JsonSchema(CciMessage))

producer.send(CciMessage(message="Sandbox", id=1))

剩下的步骤我可以在下面的bash脚本中总结。

SLEEP_TIME=2
SINK_NAME=delta_sink
NAME_SPACE=default
TENANT=public
TOPIC=raw.ro

sleep $SLEEP_TIME && echo "removing existing sink"
docker  exec -it solution_pulsar_1 bin/pulsar-admin sink stop --name $SINK_NAME --namespace $NAME_SPACE --tenant $TENANT

sleep $SLEEP_TIME && echo "copying connectors"
docker  exec -it solution_pulsar_1 bin/pulsar-admin sinks delete --tenant $TENANT --namespace $NAME_SPACE --name $SINK_NAME

sleep $SLEEP_TIME && echo "copying connectors"
docker cp connectors/pulsar-io-lakehouse-2.9.3.7-cloud.nar solution_pulsar_1:/pulsar/connectors
docker cp connectors/pulsar-io-lakehouse-2.9.3.7.nar solution_pulsar_1:/pulsar/connectors
docker cp l_conf/deltalake_sink.yaml solution_pulsar_1:/pulsar/connectors
docker cp l_conf/source-cloud-config.json solution_pulsar_1:/pulsar/connectors

sleep $SLEEP_TIME && echo "creating sink"
 sinks create --sink-config-file connectors/sink-cloud-config.json
docker  exec -it solution_pulsar_1 bin/pulsar-admin sinks create --sink-config-file connectors/deltalake_sink.yaml

sleep $SLEEP_TIME && echo "get sink properties"
docker  exec -it solution_pulsar_1 bin/pulsar-admin sinks get --tenant $TENANT --namespace $NAME_SPACE --name $SINK_NAME

sleep $SLEEP_TIME && echo "listing sink"
docker  exec -it solution_pulsar_1 bin/pulsar-admin sinks list

sleep $SLEEP_TIME && echo "get status of sink"
docker  exec -it solution_pulsar_1 bin/pulsar-admin sinks status --tenant $TENANT --namespace $NAME_SPACE --name $SINK_NAME

sleep $SLEEP_TIME && echo "sending test message to sink"
docker  exec -it solution_pulsar_1 python connectors/prducer_simple_schema.py

我希望它能帮助下一个尝试这个的人。是的,我可以看到我的三角洲湖条目,文件系统目标。
_delta_log part-0000-a7539e24-7eaa-4c43-9f4d-a8ebe24c8c7f-c000.snappy.parquet

icnyk63a

icnyk63a1#

看看我的例子
https://github.com/tspannhw/FLiP-Pi-DeltaLake-Thermal
您可能需要文件类型
型号:“delta”maxCommitInterval:120 maxRecordsPerCommit:10_000_000表路径:“file:/opt/demo/lakehouse”处理保证:“EXACTLY_ONCE”deltaFileType:“parquet”subscriptionType:“”
也不要执行localrun,执行create
bin/pulsar-admin sins create --archive ./connectors/pulsar-io-lakehouse-2.9.2.24.nar --tenant public --namespace default --name delta_sink --sink-config-file conf/deltalakesink.yml --inputs“persistent://public/default/pi-sensors”--parallelism 1 --subs-name pisensorwatch --processing-guarantees persistently_ONCE
也可以尝试YML配置而不是JSON

np8igboo

np8igboo2#

既然你是运行这个作为一个图片中的连接器,你是否确认,连接器是可用的,例如。$ pulsar-admin sinks available-sinks
你有没有试过将它作为非内置连接器运行,例如:

PULSAR_HOME/bin/pulsar-admin sinks create \
--sink-config-file <lakehouse-sink-config.yaml>

相关问题