Skip to content

[WIP][ISSUE #22]rocketmq-connect-redis adapt to the new connect api - #31

Open
doubleDimple wants to merge 5 commits into
apache:masterfrom
doubleDimple:support_redis_connent
Open

[WIP][ISSUE #22]rocketmq-connect-redis adapt to the new connect api#31
doubleDimple wants to merge 5 commits into
apache:masterfrom
doubleDimple:support_redis_connent

Conversation

@doubleDimple

Copy link
Copy Markdown
Contributor

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.

  • Make sure there is a Github issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test(over 80% coverage) to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in test module.
  • Run mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle to make sure basic checks pass. Run mvn clean install -DskipITs to make sure unit-test pass. Run mvn clean test-compile failsafe:integration-test to make sure integration-test pass.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

@odbozhou odbozhou added the enhancement New feature or request label Apr 1, 2022

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"?>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Large diff (752 lines). Consider breaking into smaller, focused PRs for easier review.

@RockteMQ-AI

Copy link
Copy Markdown

⚠️ Merge conflict detected

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-lease

This is a one-time reminder. Feel free to @mention me for a re-review after conflicts are resolved.


Automated notification by github-manager-bot

@RockteMQ-AI

Copy link
Copy Markdown

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 RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Review of PR #31: [WIP][ISSUE #22]rocketmq-connect-redis adapt to the new connect api

Findings: 10 issue(s) identified (3 critical).
CLA: unknown

Please address the inline comments above.


Automated review by github-manager-bot



public Boolean push(Map<Field, Object[]> fieldMap, EntryType entryType) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

}
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants