-
Notifications
You must be signed in to change notification settings - Fork 1k
PHOENIX-7751 : [SyncTable Tool] Feature to validate table data using PhoenixSyncTable tool b/w source and target cluster #2379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rahulLiving
wants to merge
26
commits into
apache:master
Choose a base branch
from
rahulLiving:PHOENIX-7751
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+7,292
−38
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
3c54c86
connection creation time
c97f7e0
Revert "connection creation time"
53e9a3b
Revert "Revert "connection creation time""
6b75fec
Merge remote-tracking branch 'upstream/master'
6f40ab4
Merge remote-tracking branch 'upstream/master'
7328f93
Merge remote-tracking branch 'upstream/master'
fd46404
ITs changes
58ef6a9
Revert "ITs changes"
6f226f6
Merge remote-tracking branch 'upstream/master'
1ccf4b6
PHOENIX-7751 : [SyncTable Tool] Feature to validate table data using …
e75c6c1
revert other changes
a5060ab
checkstyle fix
cffd2e6
checkstyle fix
2ef30e6
checkstyle fix
dd18dae
adding more ITs
326e792
adding more ITs
b7127cc
misc fix
f588291
code comment
f81aa56
code comment formatting
d60104f
Adding all UT/ITs
359f345
Fix tests
1bcd693
Fix tests
7904c50
Merge remote-tracking branch 'upstream/master' into PHOENIX-7751
b9dfd3c
PhoenixConfigurationUtilTest
6c50f95
Fix build issues
b8c00e4
Some More UTs
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
phoenix-core-client/src/main/java/org/apache/phoenix/util/SHA256DigestUtil.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.phoenix.util; | ||
|
|
||
| import java.io.ByteArrayInputStream; | ||
| import java.io.DataInputStream; | ||
| import java.io.IOException; | ||
| import java.nio.ByteBuffer; | ||
| import org.apache.hadoop.hbase.util.Bytes; | ||
| import org.bouncycastle.crypto.digests.SHA256Digest; | ||
|
|
||
| /** | ||
| * Utility class for SHA-256 digest state serialization and deserialization. We are not using jdk | ||
| * bundled SHA, since their digest can't be serialized/deserialized which is needed for | ||
| * PhoenixSyncTableTool for cross-region hash continuation. | ||
| */ | ||
| public class SHA256DigestUtil { | ||
|
|
||
| /** | ||
| * Maximum allowed size for encoded SHA-256 digest state. SHA-256 state is ~96 bytes, we allow up | ||
| * to 128 bytes as buffer. | ||
| */ | ||
| public static final int MAX_SHA256_DIGEST_STATE_SIZE = 128; | ||
|
|
||
| /** | ||
| * Encodes a SHA256Digest state to a byte array with length prefix for validation. Format: [4-byte | ||
| * integer length][encoded digest state bytes] | ||
| * @param digest The digest whose state should be encoded | ||
| * @return Byte array containing integer length prefix + encoded state | ||
| */ | ||
| public static byte[] encodeDigestState(SHA256Digest digest) { | ||
| byte[] encoded = digest.getEncodedState(); | ||
| ByteBuffer buffer = ByteBuffer.allocate(Bytes.SIZEOF_INT + encoded.length); | ||
| buffer.putInt(encoded.length); | ||
| buffer.put(encoded); | ||
| return buffer.array(); | ||
| } | ||
|
|
||
| /** | ||
| * Decodes a SHA256Digest state from a byte array. | ||
| * @param encodedState Byte array containing 4-byte integer length prefix + encoded state | ||
| * @return SHA256Digest restored to the saved state | ||
| * @throws IOException if state is invalid, corrupted | ||
| */ | ||
| public static SHA256Digest decodeDigestState(byte[] encodedState) throws IOException { | ||
| if (encodedState == null) { | ||
| throw new IllegalArgumentException("Invalid encoded digest state: encodedState is null"); | ||
| } | ||
|
|
||
| DataInputStream dis = new DataInputStream(new ByteArrayInputStream(encodedState)); | ||
| int stateLength = dis.readInt(); | ||
| // Prevent malicious large allocations | ||
| if (stateLength > MAX_SHA256_DIGEST_STATE_SIZE) { | ||
| throw new IllegalArgumentException( | ||
| String.format("Invalid SHA256 state length: %d, expected <= %d", stateLength, | ||
| MAX_SHA256_DIGEST_STATE_SIZE)); | ||
| } | ||
|
|
||
| byte[] state = new byte[stateLength]; | ||
| dis.readFully(state); | ||
| return new SHA256Digest(state); | ||
| } | ||
|
|
||
| /** | ||
| * Decodes a digest state and finalizes it to produce the SHA-256 checksum. | ||
| * @param encodedState Serialized digest state (format: [4-byte length][state bytes]) | ||
| * @return 32-byte SHA-256 hash | ||
| * @throws IOException if state decoding fails | ||
| */ | ||
| public static byte[] finalizeDigestToChecksum(byte[] encodedState) throws IOException { | ||
| SHA256Digest digest = decodeDigestState(encodedState); | ||
| return finalizeDigestToChecksum(digest); | ||
| } | ||
|
|
||
| /** | ||
| * Finalizes a SHA256Digest to produce the final checksum. | ||
| * @param digest The digest to finalize | ||
| * @return 32-byte SHA-256 hash | ||
| */ | ||
| public static byte[] finalizeDigestToChecksum(SHA256Digest digest) { | ||
| byte[] hash = new byte[digest.getDigestSize()]; | ||
| digest.doFinal(hash, 0); | ||
| return hash; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo missing 'P'