You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2021/03/31 22:47:14 UTC

[hbase] branch HBASE-25713 updated: Make it compile again

This is an automated email from the ASF dual-hosted git repository.

stack pushed a commit to branch HBASE-25713
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/HBASE-25713 by this push:
     new 1c1d0a8  Make it compile again
1c1d0a8 is described below

commit 1c1d0a87f7fe5abb072bc135aed50bb8bb2e8da5
Author: stack <st...@apache.org>
AuthorDate: Wed Mar 31 15:43:16 2021 -0700

    Make it compile again
---
 .../regionserver/ReplicationSourceManager.java      |  6 ++----
 .../hadoop/hbase/wal/AbstractFSWALProvider.java     |  9 +++------
 .../hadoop/hbase/wal/DisabledWALProvider.java       |  4 ++--
 .../hadoop/hbase/wal/RegionGroupingProvider.java    | 19 ++++++++-----------
 .../org/apache/hadoop/hbase/wal/WALFactory.java     |  9 ++++-----
 .../org/apache/hadoop/hbase/wal/IOTestProvider.java | 21 +++++++--------------
 .../org/apache/hadoop/hbase/wal/TestWALSplit.java   |  2 +-
 .../org/apache/hadoop/hbase/wal/WALProvider.java    |  8 +++-----
 8 files changed, 30 insertions(+), 48 deletions(-)

diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java
index bfd4570..1daf00e 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java
@@ -41,7 +41,6 @@ import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.AtomicReference;
-import java.util.stream.Collectors;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
@@ -398,7 +397,6 @@ public class ReplicationSourceManager implements ReplicationListener {
    * replication state changes or new replication config changes. Here we don't need to change
    * replication queue storage and only to enqueue all logs to the new replication source
    * @param peerId the id of the replication peer
-   * @throws IOException
    */
   public void refreshSources(String peerId) throws IOException {
     String terminateMessage = "Peer " + peerId +
@@ -1008,7 +1006,7 @@ public class ReplicationSourceManager implements ReplicationListener {
    * This ReplicationSource is NOT created via {@link ReplicationSourceFactory}.
    * @see #addSource(String) This is a specialization of the addSource call.
    * @see #catalogReplicationSource for a note on this ReplicationSource's lifecycle (and more on
-   * why the special handling).
+   *    why the special handling).
    */
   private ReplicationSourceInterface createCatalogReplicationSource(RegionInfo regionInfo)
       throws IOException {
@@ -1041,7 +1039,7 @@ public class ReplicationSourceManager implements ReplicationListener {
       // instance too (listeners are passed by provider to WAL instance on creation but if provider
       // created already, our listener add above is missed). And add the current WAL file to the
       // Replication Source so it can start replicating it.
-      WAL wal = walProvider.getWAL(regionInfo);
+      WAL wal = walProvider.getWAL(regionInfo.getEncodedName());
       wal.registerWALActionsListener(listener);
       crs.enqueueLog(((AbstractFSWAL)wal).getCurrentFileName());
     }
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/AbstractFSWALProvider.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/AbstractFSWALProvider.java
index a7e3ef5..74e6d80 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/AbstractFSWALProvider.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/AbstractFSWALProvider.java
@@ -36,19 +36,18 @@ import org.apache.hadoop.hbase.Abortable;
 import org.apache.hadoop.hbase.FailedCloseWALAfterInitializedErrorException;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.ServerName;
-import org.apache.hadoop.hbase.client.RegionInfo;
 import org.apache.hadoop.hbase.regionserver.wal.AbstractFSWAL;
 import org.apache.hadoop.hbase.regionserver.wal.WALActionsListener;
 import org.apache.hadoop.hbase.util.CancelableProgressable;
 import org.apache.hadoop.hbase.util.CommonFSUtils;
 import org.apache.hadoop.hbase.util.LeaseNotRecoveredException;
 import org.apache.hadoop.hbase.util.RecoverLeaseFSUtils;
+import org.apache.hbase.thirdparty.com.google.common.collect.Lists;
 import org.apache.yetus.audience.InterfaceAudience;
 import org.apache.yetus.audience.InterfaceStability;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import org.apache.hbase.thirdparty.com.google.common.collect.Lists;
 
 /**
  * Base class of a WAL Provider that returns a single thread safe WAL that writes to Hadoop FS. By
@@ -98,14 +97,12 @@ public abstract class AbstractFSWALProvider<T extends AbstractFSWAL<?>> implemen
   private final ReadWriteLock walCreateLock = new ReentrantReadWriteLock();
 
   /**
-   * @param factory factory that made us, identity used for FS layout. may not be null
    * @param conf may not be null
    * @param providerId differentiate between providers from one factory, used for FS layout. may be
    *          null
    */
   @Override
-  public void init(WALFactory factory, Configuration conf, String providerId, Abortable abortable)
-      throws IOException {
+  public void init(Configuration conf, String providerId, Abortable abortable) throws IOException {
     if (!initialized.compareAndSet(false, true)) {
       throw new IllegalStateException("WALProvider.init should only be called once.");
     }
@@ -144,7 +141,7 @@ public abstract class AbstractFSWALProvider<T extends AbstractFSWAL<?>> implemen
   }
 
   @Override
-  public T getWAL(RegionInfo region) throws IOException {
+  public T getWAL(String encodedRegionName) throws IOException {
     T walCopy = wal;
     if (walCopy != null) {
       return walCopy;
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/DisabledWALProvider.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/DisabledWALProvider.java
index 5a9241e..7c5e4b7 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/DisabledWALProvider.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/DisabledWALProvider.java
@@ -56,7 +56,7 @@ class DisabledWALProvider implements WALProvider {
   WAL disabled;
 
   @Override
-  public void init(WALFactory factory, Configuration conf, String providerId, Abortable abortable)
+  public void init(Configuration conf, String providerId, Abortable abortable)
       throws IOException {
     if (null != disabled) {
       throw new IllegalStateException("WALProvider.init should only be called once.");
@@ -75,7 +75,7 @@ class DisabledWALProvider implements WALProvider {
   }
 
   @Override
-  public WAL getWAL(RegionInfo region) throws IOException {
+  public WAL getWAL(String encodedRegionName) throws IOException {
     return disabled;
   }
 
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/RegionGroupingProvider.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/RegionGroupingProvider.java
index 4a2c220..51de8ea 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/RegionGroupingProvider.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/RegionGroupingProvider.java
@@ -20,7 +20,6 @@ package org.apache.hadoop.hbase.wal;
 
 import static org.apache.hadoop.hbase.wal.AbstractFSWALProvider.META_WAL_PROVIDER_ID;
 import static org.apache.hadoop.hbase.wal.AbstractFSWALProvider.WAL_FILE_NAME_DELIMITER;
-
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
@@ -28,11 +27,9 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.locks.Lock;
 import java.util.stream.Collectors;
-
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.Abortable;
 import org.apache.hadoop.hbase.HConstants;
-import org.apache.hadoop.hbase.client.RegionInfo;
 // imports for classes still in regionserver.wal
 import org.apache.hadoop.hbase.regionserver.wal.WALActionsListener;
 import org.apache.hadoop.hbase.util.Bytes;
@@ -139,8 +136,7 @@ public class RegionGroupingProvider implements WALProvider {
   private Class<? extends WALProvider> providerClass;
 
   @Override
-  public void init(WALFactory factory, Configuration conf, String providerId, Abortable abortable)
-      throws IOException {
+  public void init(Configuration conf, String providerId, Abortable abortable) throws IOException {
     if (null != strategy) {
       throw new IllegalStateException("WALProvider.init should only be called once.");
     }
@@ -181,7 +177,7 @@ public class RegionGroupingProvider implements WALProvider {
     return cached.values().stream().flatMap(p -> p.getWALs().stream()).collect(Collectors.toList());
   }
 
-  private WAL getWAL(String group) throws IOException {
+  private WAL getWALFor(String group) throws IOException {
     WALProvider provider = cached.get(group);
     if (provider == null) {
       Lock lock = createLock.acquireLock(group);
@@ -200,23 +196,24 @@ public class RegionGroupingProvider implements WALProvider {
   }
 
   @Override
-  public WAL getWAL(RegionInfo region) throws IOException {
+  public WAL getWAL(String encodedRegionName) throws IOException {
     String group;
     if (META_WAL_PROVIDER_ID.equals(this.providerId)) {
       group = META_WAL_GROUP_NAME;
     } else {
       byte[] id;
       byte[] namespace;
-      if (region != null) {
-        id = region.getEncodedNameAsBytes();
-        namespace = region.getTable().getNamespace();
+      if (encodedRegionName != null) {
+        id = Bytes.toBytes(encodedRegionName);
+        // TODO: Used pass RegionInfo, now encoded Region name...region.getTable().getNamespace();
+        namespace = null;
       } else {
         id = HConstants.EMPTY_BYTE_ARRAY;
         namespace = null;
       }
       group = strategy.group(id, namespace);
     }
-    return getWAL(group);
+    return getWALFor(group);
   }
 
   @Override
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALFactory.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALFactory.java
index b84f1be..3230b32 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALFactory.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALFactory.java
@@ -21,7 +21,6 @@ import java.io.IOException;
 import java.io.InterruptedIOException;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicReference;
-
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
@@ -160,7 +159,7 @@ public class WALFactory {
     LOG.info("Instantiating WALProvider of type " + clazz);
     try {
       final WALProvider result = clazz.getDeclaredConstructor().newInstance();
-      result.init(this, conf, providerId, this.abortable);
+      result.init(conf, providerId, this.abortable);
       return result;
     } catch (Exception e) {
       LOG.error("couldn't set up WALProvider, the configured class is " + clazz);
@@ -206,7 +205,7 @@ public class WALFactory {
       // special handling of existing configuration behavior.
       LOG.warn("Running with WAL disabled.");
       provider = new DisabledWALProvider();
-      provider.init(this, conf, factoryId, null);
+      provider.init(conf, factoryId, null);
     }
   }
 
@@ -291,9 +290,9 @@ public class WALFactory {
     // Use different WAL for hbase:meta. Instantiates the meta WALProvider if not already up.
     if (region != null && region.isMetaRegion() &&
       region.getReplicaId() == RegionInfo.DEFAULT_REPLICA_ID) {
-      return getMetaProvider().getWAL(region);
+      return getMetaProvider().getWAL(region.getEncodedName());
     } else {
-      return provider.getWAL(region);
+      return provider.getWAL(region.getEncodedName());
     }
   }
 
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/IOTestProvider.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/IOTestProvider.java
index e624e6f..903c6c7 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/IOTestProvider.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/IOTestProvider.java
@@ -21,20 +21,18 @@ package org.apache.hadoop.hbase.wal;
 import static org.apache.hadoop.hbase.wal.AbstractFSWALProvider.DEFAULT_PROVIDER_ID;
 import static org.apache.hadoop.hbase.wal.AbstractFSWALProvider.META_WAL_PROVIDER_ID;
 import static org.apache.hadoop.hbase.wal.AbstractFSWALProvider.WAL_FILE_NAME_DELIMITER;
-
 import java.io.IOException;
+import java.time.Instant;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicBoolean;
-
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.Abortable;
 import org.apache.hadoop.hbase.HConstants;
-import org.apache.hadoop.hbase.client.RegionInfo;
 // imports for things that haven't moved from regionserver.wal yet.
 import org.apache.hadoop.hbase.regionserver.wal.FSHLog;
 import org.apache.hadoop.hbase.regionserver.wal.ProtobufLogWriter;
@@ -83,33 +81,28 @@ public class IOTestProvider implements WALProvider {
     none;
   }
 
-  private WALFactory factory;
-
   private Configuration conf;
 
   private volatile FSHLog log;
+  private Instant instant = Instant.now();
 
   private String providerId;
   protected AtomicBoolean initialized = new AtomicBoolean(false);
 
   private List<WALActionsListener> listeners = new ArrayList<>();
   /**
-   * @param factory factory that made us, identity used for FS layout. may not be null
    * @param conf may not be null
    * @param providerId differentiate between providers from one facotry, used for FS layout. may be
    *                   null
    */
   @Override
-  public void init(WALFactory factory, Configuration conf, String providerId, Abortable abortable)
+  public void init(Configuration conf, String providerId, Abortable abortable)
       throws IOException {
     if (!initialized.compareAndSet(false, true)) {
       throw new IllegalStateException("WALProvider.init should only be called once.");
     }
-    this.factory = factory;
     this.conf = conf;
     this.providerId = providerId != null ? providerId : DEFAULT_PROVIDER_ID;
-
-
   }
 
   @Override
@@ -118,15 +111,16 @@ public class IOTestProvider implements WALProvider {
   }
 
   private FSHLog createWAL() throws IOException {
-    String logPrefix = factory.factoryId + WAL_FILE_NAME_DELIMITER + providerId;
+    String now = this.instant.toString();
+    String logPrefix = now + WAL_FILE_NAME_DELIMITER + providerId;
     return new IOTestWAL(CommonFSUtils.getWALFileSystem(conf), CommonFSUtils.getWALRootDir(conf),
-        AbstractFSWALProvider.getWALDirectoryName(factory.factoryId),
+        AbstractFSWALProvider.getWALDirectoryName(now),
         HConstants.HREGION_OLDLOGDIR_NAME, conf, listeners, true, logPrefix,
         META_WAL_PROVIDER_ID.equals(providerId) ? META_WAL_PROVIDER_ID : null);
   }
 
   @Override
-  public WAL getWAL(RegionInfo region) throws IOException {
+  public WAL getWAL(String encodedRegionName) throws IOException {
     FSHLog log = this.log;
     if (log != null) {
       return log;
@@ -186,7 +180,6 @@ public class IOTestProvider implements WALProvider {
      *        If prefix is null, "wal" will be used
      * @param suffix will be url encoded. null is treated as empty. non-empty must start with
      *        {@link AbstractFSWALProvider#WAL_FILE_NAME_DELIMITER}
-     * @throws IOException
      */
     public IOTestWAL(final FileSystem fs, final Path rootDir, final String logDir,
         final String archiveDir, final Configuration conf,
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALSplit.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALSplit.java
index 62e7cbf..d873480 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALSplit.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALSplit.java
@@ -1357,7 +1357,7 @@ public class TestWALSplit {
         .addAllCompactionInput(Arrays.asList(inputs))
         .addCompactionOutput(output);
 
-    WALEdit edit = WALEdit.createCompaction(WALUtil.getRowForRegion(hri), desc.build());
+    WALEdit edit = WALEdit.createCompaction(hri.getNonEmptyStartKey(), desc.build());
     WALKeyImpl key = new WALKeyImpl(hri.getEncodedNameAsBytes(), TABLE_NAME, 1,
         EnvironmentEdgeManager.currentTime(), HConstants.DEFAULT_CLUSTER_ID);
     w.append(new Entry(key, edit));
diff --git a/hbase-wal/src/main/java/org/apache/hadoop/hbase/wal/WALProvider.java b/hbase-wal/src/main/java/org/apache/hadoop/hbase/wal/WALProvider.java
index b4fab32..895f9c5 100644
--- a/hbase-wal/src/main/java/org/apache/hadoop/hbase/wal/WALProvider.java
+++ b/hbase-wal/src/main/java/org/apache/hadoop/hbase/wal/WALProvider.java
@@ -40,17 +40,15 @@ public interface WALProvider {
 
   /**
    * Set up the provider to create wals. will only be called once per instance.
-   * @param factory factory that made us may not be null
    * @param conf may not be null
    * @param providerId differentiate between providers from one factory. may be null
    */
-  void init(WALFactory factory, Configuration conf, String providerId, Abortable abortable)
-      throws IOException;
+  void init(Configuration conf, String providerId, Abortable abortable) throws IOException;
 
   /**
    * @return a WAL for writing entries for the given region.
    */
-  WAL getWAL(byte [] encodedRegionName) throws IOException;
+  WAL getWAL(String encodedRegionName) throws IOException;
 
   /**
    * @return the List of WALs that are used by this server
@@ -118,7 +116,7 @@ public interface WALProvider {
   /**
    * Add a {@link WALActionsListener}.
    * <p>
-   * Notice that you must call this method before calling {@link #getWAL(byte[])} as this method
+   * Notice that you must call this method before calling {@link #getWAL(String)} as this method
    * will not effect the {@link WAL} which has already been created. And as long as we can only it
    * when initialization, it is not thread safe.
    */