-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-27218 Support rolling upgrading #4808
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,12 +21,14 @@ | |
| import java.util.ArrayList; | ||
| import java.util.Collection; | ||
| import java.util.Collections; | ||
| import java.util.HashMap; | ||
| import java.util.HashSet; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.NavigableMap; | ||
| import java.util.Set; | ||
| import java.util.function.Supplier; | ||
| import java.util.stream.Collectors; | ||
| import org.apache.hadoop.fs.Path; | ||
| import org.apache.hadoop.hbase.Cell; | ||
| import org.apache.hadoop.hbase.CellScanner; | ||
|
|
@@ -46,6 +48,7 @@ | |
| import org.apache.hadoop.hbase.client.Scan.ReadType; | ||
| import org.apache.hadoop.hbase.client.Table; | ||
| import org.apache.hadoop.hbase.filter.KeyOnlyFilter; | ||
| import org.apache.hadoop.hbase.replication.ZKReplicationQueueStorageForMigration.ZkLastPushedSeqId; | ||
| import org.apache.hadoop.hbase.util.Bytes; | ||
| import org.apache.hadoop.hbase.util.FutureUtils; | ||
| import org.apache.hadoop.hbase.util.Pair; | ||
|
|
@@ -74,12 +77,6 @@ public class TableReplicationQueueStorage implements ReplicationQueueStorage { | |
|
|
||
| private final TableName tableName; | ||
|
|
||
| @FunctionalInterface | ||
| private interface TableCreator { | ||
|
|
||
| void create() throws IOException; | ||
| } | ||
|
|
||
| public TableReplicationQueueStorage(Connection conn, TableName tableName) { | ||
| this.conn = conn; | ||
| this.tableName = tableName; | ||
|
|
@@ -541,4 +538,60 @@ public boolean hasData() throws ReplicationException { | |
| throw new ReplicationException("failed to get replication queue table", e); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void batchUpdateQueues(ServerName serverName, List<ReplicationQueueData> datas) | ||
| throws ReplicationException { | ||
| List<Put> puts = new ArrayList<>(); | ||
| for (ReplicationQueueData data : datas) { | ||
| if (data.getOffsets().isEmpty()) { | ||
| continue; | ||
| } | ||
| Put put = new Put(Bytes.toBytes(data.getId().toString())); | ||
| data.getOffsets().forEach((walGroup, offset) -> { | ||
| put.addColumn(QUEUE_FAMILY, Bytes.toBytes(walGroup), Bytes.toBytes(offset.toString())); | ||
| }); | ||
| puts.add(put); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ‘puts.add(put)’ should be moved after ‘put.addColumn’?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a single put, where it contains a lot column, but for the same row. |
||
| } | ||
| try (Table table = conn.getTable(tableName)) { | ||
| table.put(puts); | ||
| } catch (IOException e) { | ||
| throw new ReplicationException("failed to batch update queues", e); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void batchUpdateLastSequenceIds(List<ZkLastPushedSeqId> lastPushedSeqIds) | ||
| throws ReplicationException { | ||
| Map<String, Put> peerId2Put = new HashMap<>(); | ||
| for (ZkLastPushedSeqId lastPushedSeqId : lastPushedSeqIds) { | ||
| peerId2Put | ||
| .computeIfAbsent(lastPushedSeqId.getPeerId(), peerId -> new Put(Bytes.toBytes(peerId))) | ||
| .addColumn(LAST_SEQUENCE_ID_FAMILY, Bytes.toBytes(lastPushedSeqId.getEncodedRegionName()), | ||
| Bytes.toBytes(lastPushedSeqId.getLastPushedSeqId())); | ||
| } | ||
| try (Table table = conn.getTable(tableName)) { | ||
| table | ||
| .put(peerId2Put.values().stream().filter(p -> !p.isEmpty()).collect(Collectors.toList())); | ||
| } catch (IOException e) { | ||
| throw new ReplicationException("failed to batch update last pushed sequence ids", e); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void batchUpdateHFileRefs(String peerId, List<String> hfileRefs) | ||
| throws ReplicationException { | ||
| if (hfileRefs.isEmpty()) { | ||
| return; | ||
| } | ||
| Put put = new Put(Bytes.toBytes(peerId)); | ||
| for (String ref : hfileRefs) { | ||
| put.addColumn(HFILE_REF_FAMILY, Bytes.toBytes(ref), HConstants.EMPTY_BYTE_ARRAY); | ||
| } | ||
| try (Table table = conn.getTable(tableName)) { | ||
| table.put(put); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ‘table.put(put)’ should be moved into the for loop?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a single put, where it contains a lot column, but for the same row. |
||
| } catch (IOException e) { | ||
| throw new ReplicationException("failed to batch update hfile references", e); | ||
carp84 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.