[WIP][ISSUE #22]rocketmq-connect-redis adapt to the new connect api - #31
[WIP][ISSUE #22]rocketmq-connect-redis adapt to the new connect api#31doubleDimple wants to merge 5 commits into
Conversation
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
This PR modifies 23 file(s) with 752 lines of diff. Changes look reasonable.
Automated review by github-manager-bot
| @@ -1,4 +1,20 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
There was a problem hiding this comment.
Large diff (752 lines). Consider breaking into smaller, focused PRs for easier review.
|
This PR has conflicts with the base branch and cannot be merged. Please rebase or merge the base branch into your branch and resolve the conflicts: git fetch origin
git checkout support_redis_connent
git rebase origin/develop
# resolve conflicts, then:
git push --force-with-leaseThis is a one-time reminder. Feel free to @mention me for a re-review after conflicts are resolved. Automated notification by github-manager-bot |
|
This PR has been marked as [WIP] since March 2022 (over 4 years) and currently has merge conflicts. Status check: Is the Redis connector adaptation to the new Connect API still being worked on? The implementation looks substantial (source/sink connectors, event handlers, processors, and comprehensive tests), but needs to be rebased. If this is still relevant, please update the status and rebase. If the work has been abandoned or superseded by another effort, consider closing. Automated review by github-manager-bot |
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
PR received and logged for review. This PR requires detailed code review by a maintainer.
Diff size: 752 lines
Author: doubleDimple (CONTRIBUTOR)
Automated review by RockteMQ-AI
|
|
||
|
|
||
| public Boolean push(Map<Field, Object[]> fieldMap, EntryType entryType) { | ||
|
|
There was a problem hiding this comment.
RedisUpdater.push() is a stub that always returns null. RedisSinkTask.put() calls this method and checks the Boolean return value without null-safety, which will cause a NullPointerException at if (!isSuccess) on every invocation. The sink task is completely non-functional.
| Object[] value = JSONObject.parseArray((String)fieldValue).toArray(); | ||
| if (value.length == 2) { | ||
| fieldMap.put(field, value); | ||
| } else { |
There was a problem hiding this comment.
Unsafe cast: (String) fieldValue will throw ClassCastException if the payload value is not a String. There is no type check or null guard before the cast and the subsequent JSONObject.parseArray() call.
| List<Field> fields = schema.getFields(); | ||
| Boolean parseError = false; | ||
| if (!fields.isEmpty()) { | ||
| for (Field field : fields) { |
There was a problem hiding this comment.
updater field is never initialized — it is declared but no assignment appears in start() or anywhere else. Every call to put() will throw a NullPointerException when updater.push(...) is invoked.
| Schema schema = sinkDataEntry.getSchema(); | ||
| EntryType entryType = sinkDataEntry.getEntryType(); | ||
|
|
||
| List<Field> fields = schema.getFields(); |
There was a problem hiding this comment.
Boolean parseError is declared with boxed Boolean (object type) instead of primitive boolean. While initialized to false, using the boxed type is unnecessary here and could theoretically cause a NullPointerException if the variable were ever left uninitialized in a refactored code path.
| @Override | ||
| public void start(KeyValue keyValue) { | ||
| this.kvEntryConverter = new RedisEntryConverter(); | ||
|
|
There was a problem hiding this comment.
e.printStackTrace() is called in start() before the structured log statement. This sends the stack trace to stderr outside the logging framework, making it invisible in log aggregators. Use only LOGGER.error(...) with the exception as the last argument.
| } | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
The kvEntryConverter field is initialized in start() but never used anywhere in the class. The sink path bypasses the converter and directly parses JSON in put(), making the converter dead code and leaving the abstraction incomplete.
| return config; | ||
| } | ||
|
|
||
| @Override |
There was a problem hiding this comment.
The eventProcessor field and its associated RedisEventHandler are started in start(), but the sink task's put() method never reads from the processor — it only writes to Redis via updater. Starting a full replication event processor (which connects to Redis as a replica) in a sink task is architecturally wrong and will create a redundant Redis replication stream.
|
|
||
| @Override | ||
| public String verifyAndSetConfig(KeyValue config) { | ||
| this.keyValue = config; |
There was a problem hiding this comment.
taskConfigs() always returns a single-element list containing the full config regardless of the requested task count. The framework may call this with a parallelism hint; the connector ignores it and cannot scale to multiple tasks.
| this.eventProcessor = eventProcessor; | ||
| } | ||
|
|
||
| public Config getConfig() { |
There was a problem hiding this comment.
commit() is a no-op. For at-least-once delivery guarantees the framework relies on this callback to advance committed offsets. Leaving it empty means offsets are never acknowledged, which may cause the framework to redeliver all messages on restart.
| @@ -0,0 +1,15 @@ | |||
| package org.apache.rocketmq.connect.redis.sink; | |||
There was a problem hiding this comment.
Missing Apache License header. All other new/modified files in this PR have the ASF license header added, but RedisUpdater.java does not, which will fail the apache-rat license check added in pom.xml.
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
12 finding(s) to address.
Findings
- [CRITICAL]
connectors/rocketmq-connect-redis/src/main/java/org/apache/rocketmq/connect/redis/connector/RedisSinkTask.java:48—updateris never initialized —updater.push(...)on line 93 will always throw a NullPointerException. TheRedisUpdateris a stub that returnsnullanyway, making the entire sink path non-functional. - [CRITICAL]
connectors/rocketmq-connect-redis/src/main/java/org/apache/rocketmq/connect/redis/sink/RedisUpdater.java:12—push()always returnsnull(a stub). This makes the entire sink data path a no-op. The PR is marked WIP but this class should at minimum throwUnsupportedOperationExceptionor be clearly documented as unimplemented to avoid silent data loss. - [CRITICAL]
connectors/rocketmq-connect-redis/src/main/java/org/apache/rocketmq/connect/redis/connector/RedisSinkTask.java:89—JSONObject.parseArray((String)fieldValue)will throw an unchecked exception iffieldValueisnullor not valid JSON. No null-check or try-catch protects this call, so a single malformed record will crash the entireput()batch. - [WARNING]
connectors/rocketmq-connect-redis/src/main/java/org/apache/rocketmq/connect/redis/connector/RedisSinkTask.java:96— Whenupdater.push()fails orparseErroris true, the record is silently dropped after logging. There is no dead-letter routing, retry, or error-reporting mechanism, which risks silent data loss in production. - [WARNING]
connectors/rocketmq-connect-redis/src/main/java/org/apache/rocketmq/connect/redis/connector/RedisSinkTask.java:121—e.printStackTrace()is used instead of logging through SLF4J. This bypasses the configured logging infrastructure and is inappropriate for production connector code. - [WARNING]
connectors/rocketmq-connect-redis/src/main/java/org/apache/rocketmq/connect/redis/connector/RedisSinkTask.java:113— The sink task'sstart()creates aDefaultRedisEventProcessorandDefaultRedisEventHandler— these are source-side replication components (they listen to Redis replication stream). This is architecturally wrong for a sink task that should be writing data into Redis. - [WARNING]
connectors/rocketmq-connect-redis/src/main/java/org/apache/rocketmq/connect/redis/connector/RedisSinkConnector.java:40—configValidis set totrueinverifyAndSetConfigbut never read anywhere.adminStartedis declared but never used. These are dead fields that add confusion. - [WARNING]
connectors/rocketmq-connect-redis/src/main/java/org/apache/rocketmq/connect/redis/connector/RedisSinkConnector.java:73—taskConfigs()always returns exactly one config. For multi-partition or scaled deployments, this prevents parallelism. The connector should accept amaxTasksparameter and distribute configs accordingly. - [WARNING]
connectors/rocketmq-connect-redis/src/main/java/org/apache/rocketmq/connect/redis/connector/RedisSinkTask.java:103—commit()is empty — there is no offset tracking or acknowledgment logic. If the framework relies on the sink task to confirm processed offsets, this could lead to duplicate processing on restart. - [INFO]
connectors/rocketmq-connect-redis/src/main/java/org/apache/rocketmq/connect/redis/sink/RedisUpdater.java:1— Missing Apache License header. All other new files in this PR include the standard ASF license block. This will also causeapache-rat:checkto fail. - [INFO]
connectors/rocketmq-connect-redis/src/main/java/org/apache/rocketmq/connect/redis/connector/RedisSinkConnector.java:54—start()only logs a message and performs no initialization (no connection test, no admin client setup). A connectorstart()should validate connectivity or at least initialize shared resources. - [INFO]
connectors/rocketmq-connect-redis/src/main/java/org/apache/rocketmq/connect/redis/connector/RedisSinkTask.java:80—kvEntryConverteris initialized instart()but never used input()or anywhere else in this class. It appears to be leftover dead code.
Automated review by github-manager-bot
| * author doubleDimple | ||
| */ | ||
| public class RedisSinkTask extends SinkTask { | ||
|
|
There was a problem hiding this comment.
updater is never initialized — updater.push(...) on line 93 will always throw a NullPointerException. The RedisUpdater is a stub that returns null anyway, making the entire sink path non-functional.
|
|
||
|
|
||
| public Boolean push(Map<Field, Object[]> fieldMap, EntryType entryType) { | ||
|
|
There was a problem hiding this comment.
push() always returns null (a stub). This makes the entire sink data path a no-op. The PR is marked WIP but this class should at minimum throw UnsupportedOperationException or be clearly documented as unimplemented to avoid silent data loss.
| Boolean parseError = false; | ||
| if (!fields.isEmpty()) { | ||
| for (Field field : fields) { | ||
| Object fieldValue = payloads[field.getIndex()]; |
There was a problem hiding this comment.
JSONObject.parseArray((String)fieldValue) will throw an unchecked exception if fieldValue is null or not valid JSON. No null-check or try-catch protects this call, so a single malformed record will crash the entire put() batch.
| } else { | ||
| LOGGER.error("parseArray error, fieldValue:{}", fieldValue); | ||
| parseError = true; | ||
| } |
There was a problem hiding this comment.
When updater.push() fails or parseError is true, the record is silently dropped after logging. There is no dead-letter routing, retry, or error-reporting mechanism, which risks silent data loss in production.
| this.config.load(keyValue); | ||
| LOGGER.info("task config msg: {}", this.config.toString()); | ||
|
|
||
| this.eventProcessor = new DefaultRedisEventProcessor(config); |
There was a problem hiding this comment.
e.printStackTrace() is used instead of logging through SLF4J. This bypasses the configured logging infrastructure and is inappropriate for production connector code.
|
|
||
| @Override | ||
| public Class<? extends Task> taskClass() { | ||
| return RedisSinkTask.class; |
There was a problem hiding this comment.
taskConfigs() always returns exactly one config. For multi-partition or scaled deployments, this prevents parallelism. The connector should accept a maxTasks parameter and distribute configs accordingly.
| Boolean isSuccess = updater.push(fieldMap, entryType); | ||
| if (!isSuccess) { | ||
| LOGGER.error("push data error, entryType:{}, fieldMap:{}", fieldMap, entryType); | ||
| } |
There was a problem hiding this comment.
commit() is empty — there is no offset tracking or acknowledgment logic. If the framework relies on the sink task to confirm processed offsets, this could lead to duplicate processing on restart.
| @@ -0,0 +1,15 @@ | |||
| package org.apache.rocketmq.connect.redis.sink; | |||
There was a problem hiding this comment.
Missing Apache License header. All other new files in this PR include the standard ASF license block. This will also cause apache-rat:check to fail.
| @Override | ||
| public void start() { | ||
| LOGGER.info("the redisSinkConnector is start..."); | ||
| } |
There was a problem hiding this comment.
start() only logs a message and performs no initialization (no connection test, no admin client setup). A connector start() should validate connectivity or at least initialize shared resources.
| //save data from MQ to redis | ||
| for (SinkDataEntry sinkDataEntry : sinkDataEntries) { | ||
| Map<Field, Object[]> fieldMap = new HashMap<>(); | ||
| Object[] payloads = sinkDataEntry.getPayload(); |
There was a problem hiding this comment.
kvEntryConverter is initialized in start() but never used in put() or anywhere else in this class. It appears to be leftover dead code.
What is the purpose of the change
XXXXX
Brief changelog
XX
Verifying this change
XXXX
Follow this checklist to help us incorporate your contribution quickly and easily. Notice,
it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR.[ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyleto make sure basic checks pass. Runmvn clean install -DskipITsto make sure unit-test pass. Runmvn clean test-compile failsafe:integration-testto make sure integration-test pass.