Skip to content

JAVA: Move COPY command with database ID from standalone to base client#4804

Merged
affonsov merged 6 commits intorelease-2.1from
java/affonsov-add-database-id-for-copy-command-on-cluster-mode
Oct 1, 2025
Merged

JAVA: Move COPY command with database ID from standalone to base client#4804
affonsov merged 6 commits intorelease-2.1from
java/affonsov-add-database-id-for-copy-command-on-cluster-mode

Conversation

@affonsov
Copy link
Copy Markdown
Collaborator

@affonsov affonsov commented Sep 23, 2025

Refactor COPY Command with Database ID Support

Overview

This PR refactors the COPY command implementation to support database ID parameter across both standalone and cluster clients by moving the functionality from the standalone-specific GenericCommands interface to the shared GenericBaseCommands interface.

Changes Made

Core Implementation Changes

  • Moved COPY command methods from GenericCommands to GenericBaseCommands interface
  • Relocated implementation from GlideClient to BaseClient class
  • Updated constant location: Moved DB_VALKEY_API constant from GenericCommands to GenericBaseCommands

Batch Support

  • Enhanced BaseBatch: Added COPY with database ID support to BaseBatch class
  • Simplified Batch: Removed duplicate COPY implementation from Batch class (now inherits from BaseBatch)

Test Coverage

  • Added comprehensive tests for COPY with database ID functionality
  • String and GlideString support: Tests cover both string types
  • Version-specific testing: Proper version checks for standalone (6.2.0+) and cluster (9.0.0+) clients
  • Batch testing: Updated batch test utilities to include COPY with database ID operations

API Compatibility

  • Method signatures preserved: All existing COPY method signatures remain unchanged
  • Backward compatibility: No breaking changes to existing client code
  • Enhanced functionality: COPY with database ID now available for both client types

Version Requirements

  • Standalone clients: Valkey 6.2.0 and above
  • Cluster clients: Valkey 9.0.0 and above

Testing

  • Added copy_with_database_id() test method for String parameters
  • Added copy_binary_with_database_id() test method for GlideString parameters
  • Updated batch test utilities with COPY database ID operations
  • All tests include proper version checks and client type handling

This refactoring improves code organization by consolidating COPY functionality in the base classes while maintaining full backward compatibility and extending support to cluster clients.

Issue link

This Pull Request is linked to issue (URL): [#4766]

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one issue.
  • Commit message has a detailed description of what changed and why.
  • Tests are added or updated.
  • CHANGELOG.md and documentation files are updated.
  • Destination branch is correct - main or release
  • Create merge commit if merging release branch into main, squash otherwise.

- Move COPY command with destinationDB parameter from GenericCommands to GenericBaseCommands
- Move implementation from GlideClient to BaseClient to support both standalone and cluster clients
- Add COPY with database ID support to BaseBatch class
- Update Batch class to inherit COPY functionality from BaseBatch
- Add comprehensive tests for COPY with database ID for both String and GlideString types
- Update version requirements: Valkey 6.2.0+ for standalone, 9.0.0+ for cluster

Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
@affonsov affonsov requested a review from a team as a code owner September 23, 2025 23:47
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Copy link
Copy Markdown
Collaborator

@yipin-chen yipin-chen left a comment

Choose a reason for hiding this comment

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

LGTM, minor update on changelog is needed.
Please also check CIs.

…add-database-id-for-copy-command-on-cluster-mode

Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
@affonsov affonsov merged commit 9ade1a4 into release-2.1 Oct 1, 2025
21 of 22 checks passed
@affonsov affonsov deleted the java/affonsov-add-database-id-for-copy-command-on-cluster-mode branch October 1, 2025 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants