-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
HBASE-29027 Introduce a new WALProvider to generate WAL files consumed by Replication #6532
Open
YutSean
wants to merge
11
commits into
apache:master
Choose a base branch
from
YutSean:HBASE-29027
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.
+270
−3
Open
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
449648b
HBASE-29027 Introduce a new WALProvider to generate WAL files consume…
bc25864
Rename variable
2b1b89f
Compile fix
59bb084
Fix UTs
bcf40ce
Refined code style
c7ca5da
UT fix
88f8546
Revert useless change
4b8a5e6
Apply spotless
42850cc
UT fix
33b7e88
Add null check
0477696
UT fix
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 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 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 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 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 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 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
43 changes: 43 additions & 0 deletions
43
...va/org/apache/hadoop/hbase/replication/regionserver/TestReplicatorWithReplicationWAL.java
This file contains 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,43 @@ | ||
/* | ||
* 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.hadoop.hbase.replication.regionserver; | ||
|
||
import static org.apache.hadoop.hbase.HConstants.REPLICATION_WAL_FILTER_BY_SCOPE_ENABLED; | ||
import org.apache.hadoop.hbase.HBaseClassTestRule; | ||
import org.apache.hadoop.hbase.ipc.RpcServer; | ||
import org.apache.hadoop.hbase.replication.TestReplicationBase; | ||
import org.apache.hadoop.hbase.testclassification.MediumTests; | ||
import org.junit.BeforeClass; | ||
import org.junit.ClassRule; | ||
import org.junit.experimental.categories.Category; | ||
|
||
@Category(MediumTests.class) | ||
public class TestReplicatorWithReplicationWAL extends TestReplicator { | ||
@ClassRule | ||
public static final HBaseClassTestRule CLASS_RULE = | ||
HBaseClassTestRule.forClass(TestReplicatorWithReplicationWAL.class); | ||
|
||
@BeforeClass | ||
public static void setUpBeforeClass() throws Exception { | ||
// Set RPC size limit to 10kb (will be applied to both source and sink clusters) | ||
CONF1.setInt(RpcServer.MAX_REQUEST_SIZE, 1024 * 10); | ||
CONF1.setBoolean(REPLICATION_WAL_FILTER_BY_SCOPE_ENABLED, true); | ||
TestReplicationBase.setUpBeforeClass(); | ||
} | ||
|
||
} |
116 changes: 116 additions & 0 deletions
116
hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestReplicationScopedWAL.java
This file contains 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,116 @@ | ||
/* | ||
* 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.hadoop.hbase.wal; | ||
|
||
import static org.apache.hadoop.hbase.HConstants.REPLICATION_SCOPE_GLOBAL; | ||
import org.apache.hadoop.fs.FileStatus; | ||
import org.apache.hadoop.fs.FileSystem; | ||
import org.apache.hadoop.fs.Path; | ||
import org.apache.hadoop.hbase.HBaseClassTestRule; | ||
import org.apache.hadoop.hbase.HBaseTestingUtil; | ||
import org.apache.hadoop.hbase.HConstants; | ||
import org.apache.hadoop.hbase.TableName; | ||
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor; | ||
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder; | ||
import org.apache.hadoop.hbase.client.Put; | ||
import org.apache.hadoop.hbase.client.Table; | ||
import org.apache.hadoop.hbase.client.TableDescriptor; | ||
import org.apache.hadoop.hbase.client.TableDescriptorBuilder; | ||
import org.apache.hadoop.hbase.testclassification.MediumTests; | ||
import org.apache.hadoop.hbase.testclassification.RegionServerTests; | ||
import org.apache.hadoop.hbase.util.Bytes; | ||
import org.apache.hadoop.hbase.util.CommonFSUtils; | ||
import org.junit.AfterClass; | ||
import org.junit.Assert; | ||
import org.junit.BeforeClass; | ||
import org.junit.ClassRule; | ||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
|
||
@Category({ RegionServerTests.class, MediumTests.class }) | ||
public class TestReplicationScopedWAL { | ||
@ClassRule public static final HBaseClassTestRule CLASS_RULE = | ||
HBaseClassTestRule.forClass(TestReplicationScopedWAL.class); | ||
|
||
static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil(); | ||
|
||
private final byte[] family1 = Bytes.toBytes("f1"); | ||
private final byte[] family2 = Bytes.toBytes("f2"); | ||
|
||
@BeforeClass | ||
public static void setUpBeforeClass() throws Exception { | ||
TEST_UTIL.getConfiguration() | ||
.setBoolean(HConstants.REPLICATION_WAL_FILTER_BY_SCOPE_ENABLED, true); | ||
TEST_UTIL.startMiniCluster(); | ||
} | ||
|
||
@AfterClass | ||
public static void tearDownAfterClass() throws Exception { | ||
TEST_UTIL.shutdownMiniCluster(); | ||
} | ||
|
||
@Test | ||
public void testReplicationScopedWAL() throws Exception { | ||
TableName tableName1 = TableName.valueOf("testReplicationScopedWAL1"); | ||
TableName tableName2 = TableName.valueOf("testReplicationScopedWAL2"); | ||
|
||
ColumnFamilyDescriptor column1 = | ||
ColumnFamilyDescriptorBuilder.newBuilder(family1).setScope(REPLICATION_SCOPE_GLOBAL).build(); | ||
|
||
ColumnFamilyDescriptor column2 = ColumnFamilyDescriptorBuilder.of(family2); | ||
|
||
TableDescriptor tableDescriptor1 = | ||
TableDescriptorBuilder.newBuilder(tableName1).setColumnFamily(column1).build(); | ||
TableDescriptor tableDescriptor2 = | ||
TableDescriptorBuilder.newBuilder(tableName2).setColumnFamily(column2).build(); | ||
|
||
Table table1 = TEST_UTIL.createTable(tableDescriptor1, null); | ||
Table table2 = TEST_UTIL.createTable(tableDescriptor2, null); | ||
|
||
Put put1 = new Put(Bytes.toBytes("row1")); | ||
put1.addColumn(family1, Bytes.toBytes("qualifier1"), Bytes.toBytes("value1")); | ||
|
||
Put put2 = new Put(Bytes.toBytes("row2")); | ||
put2.addColumn(family2, Bytes.toBytes("qulifier2"), Bytes.toBytes("value2")); | ||
|
||
table1.put(put1); | ||
table2.put(put2); | ||
|
||
TEST_UTIL.flush(); | ||
FileSystem fs = TEST_UTIL.getTestFileSystem(); | ||
Path walRootDir = CommonFSUtils.getWALRootDir(TEST_UTIL.getConfiguration()); | ||
FileStatus[] statusArray = fs.listStatus(walRootDir); | ||
Assert.assertTrue(statusArray.length >= 2); | ||
|
||
boolean hasReplicated = false; | ||
boolean hasNormal = false; | ||
for (FileStatus status : statusArray) { | ||
Path path = status.getPath(); | ||
if (AbstractFSWALProvider.isFileInReplicationScope(path)) { | ||
hasReplicated = true; | ||
} else if (!AbstractFSWALProvider.isMetaFile(path)) { | ||
hasNormal = true; | ||
} | ||
} | ||
Assert.assertTrue(hasReplicated); | ||
Assert.assertTrue(hasNormal); | ||
|
||
table1.close(); | ||
table2.close(); | ||
} | ||
} |
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.
why introduce it, and still use source 8?
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.
IDE miss import. Reverted the change