comnetwork commented on code in PR #5430:
URL: https://github.com/apache/hbase/pull/5430#discussion_r1335505511
##########
hbase-server/src/main/java/org/apache/hadoop/hbase/wal/AbstractWALProvider.java:
##########
@@ -189,83 +159,66 @@ private DualAsyncFSWAL getWAL(String peerId, String
remoteWALDir) throws IOExcep
}
@Override
- public WAL getWAL(RegionInfo region) throws IOException {
+ public final WAL getWAL(RegionInfo region) throws IOException {
if (region == null) {
- return provider.getWAL(null);
+ return getWAL0(null);
}
- WAL wal = null;
+ // deal with sync replication
Optional<Pair<String, String>> peerIdAndRemoteWALDir =
peerInfoProvider.getPeerIdAndRemoteWALDir(region.getTable());
if (peerIdAndRemoteWALDir.isPresent()) {
Pair<String, String> pair = peerIdAndRemoteWALDir.get();
- wal = getWAL(pair.getFirst(), pair.getSecond());
+ WAL wal = getRemoteWAL(region, pair.getFirst(), pair.getSecond());
+ if (wal != null) {
+ return wal;
+ }
}
- return wal != null ? wal : provider.getWAL(region);
- }
-
- private Stream<WAL> getWALStream() {
- return Streams.concat(
-
peerId2WAL.values().stream().filter(Optional::isPresent).map(Optional::get),
- provider.getWALs().stream());
+ // fallback to normal WALProvider logic
+ return getWAL0(region);
}
@Override
- public List<WAL> getWALs() {
- return getWALStream().collect(Collectors.toList());
+ public final List<WAL> getWALs() {
+ return Streams
+
.concat(peerId2WAL.values().stream().filter(Optional::isPresent).map(Optional::get),
+ getWALs0().stream())
+ .collect(Collectors.toList());
}
@Override
- public void shutdown() throws IOException {
- // save the last exception and rethrow
- IOException failure = null;
- for (Optional<DualAsyncFSWAL> wal : peerId2WAL.values()) {
- if (wal.isPresent()) {
- try {
- wal.get().shutdown();
- } catch (IOException e) {
- LOG.error("Shutdown WAL failed", e);
- failure = e;
- }
- }
- }
- provider.shutdown();
- if (failure != null) {
- throw failure;
- }
+ public PeerActionListener getPeerActionListener() {
+ return this;
}
@Override
- public void close() throws IOException {
- // save the last exception and rethrow
- IOException failure = null;
- for (Optional<DualAsyncFSWAL> wal : peerId2WAL.values()) {
- if (wal.isPresent()) {
+ public void peerSyncReplicationStateChange(String peerId,
SyncReplicationState from,
+ SyncReplicationState to, int stage) {
+ if (from == SyncReplicationState.ACTIVE) {
+ if (stage == 0) {
+ Lock lock = createLock.acquireLock(peerId);
try {
- wal.get().close();
- } catch (IOException e) {
- LOG.error("Close WAL failed", e);
- failure = e;
+ Optional<WAL> opt = peerId2WAL.get(peerId);
+ if (opt != null) {
+ opt.ifPresent(w -> w.skipRemoteWAL(to ==
SyncReplicationState.STANDBY));
+ } else {
+ // add a place holder to tell the getWAL caller do not use
DualAsyncFSWAL any more.
Review Comment:
Here we should also fix DualAsyncFSWAL in comments?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]