From 1185c6c89c1990281dcf98ea02168d34287d49f6 Mon Sep 17 00:00:00 2001 From: Zhihong Yu Date: Tue, 9 Aug 2011 04:39:34 +0000 Subject: [PATCH] HBASE-4152 Rename o.a.h.h.regionserver.wal.WALObserver to o.a.h.h.regionserver.wal.WALActionsListener git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1155202 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 2 ++ .../hbase/regionserver/HRegionServer.java | 8 +++---- .../hadoop/hbase/regionserver/LogRoller.java | 4 ++-- .../hadoop/hbase/regionserver/wal/HLog.java | 22 +++++++++---------- ...LObserver.java => WALActionsListener.java} | 4 ++-- .../replication/regionserver/Replication.java | 4 ++-- .../hbase/regionserver/wal/TestHLog.java | 4 ++-- ...erver.java => TestWALActionsListener.java} | 16 +++++++------- .../TestReplicationSourceManager.java | 4 ++-- 9 files changed, 35 insertions(+), 33 deletions(-) rename src/main/java/org/apache/hadoop/hbase/regionserver/wal/{WALObserver.java => WALActionsListener.java} (95%) rename src/test/java/org/apache/hadoop/hbase/regionserver/wal/{TestWALObserver.java => TestWALActionsListener.java} (90%) diff --git a/CHANGES.txt b/CHANGES.txt index fee37553cc8..c2dba75b4d3 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -378,6 +378,8 @@ Release 0.91.0 - Unreleased HBASE-4025 Server startup fails during startup due to failure in loading all table descriptors. (Subbu Iyer via Ted Yu) HBASE-4017 BlockCache interface should be truly modular (Li Pi) + HBASE-4152 Rename o.a.h.h.regionserver.wal.WALObserver to + o.a.h.h.regionserver.wal.WALActionsListener NEW FEATURES HBASE-2001 Coprocessors: Colocate user code with regions (Mingjie Lai via diff --git a/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index 23225d72550..86652c08e05 100644 --- a/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ b/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -117,7 +117,7 @@ import org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler; import org.apache.hadoop.hbase.regionserver.handler.OpenRootHandler; import org.apache.hadoop.hbase.regionserver.metrics.RegionServerMetrics; import org.apache.hadoop.hbase.regionserver.wal.HLog; -import org.apache.hadoop.hbase.regionserver.wal.WALObserver; +import org.apache.hadoop.hbase.regionserver.wal.WALActionsListener; import org.apache.hadoop.hbase.regionserver.RegionOpeningState; import org.apache.hadoop.hbase.replication.regionserver.Replication; import org.apache.hadoop.hbase.security.User; @@ -1167,12 +1167,12 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler, /** * Called by {@link #instantiateHLog(Path, Path)} setting up WAL instance. - * Add any {@link WALObserver}s you want inserted before WAL startup. + * Add any {@link WALActionsListener}s you want inserted before WAL startup. * @return List of WALActionsListener that will be passed in to * {@link HLog} on construction. */ - protected List getWALActionListeners() { - List listeners = new ArrayList(); + protected List getWALActionListeners() { + List listeners = new ArrayList(); // Log roller. this.hlogRoller = new LogRoller(this, this); listeners.add(this.hlogRoller); diff --git a/src/main/java/org/apache/hadoop/hbase/regionserver/LogRoller.java b/src/main/java/org/apache/hadoop/hbase/regionserver/LogRoller.java index 9de4783ebb2..8e87c838ce0 100644 --- a/src/main/java/org/apache/hadoop/hbase/regionserver/LogRoller.java +++ b/src/main/java/org/apache/hadoop/hbase/regionserver/LogRoller.java @@ -26,7 +26,7 @@ import org.apache.hadoop.hbase.*; import org.apache.hadoop.hbase.regionserver.wal.FailedLogCloseException; import org.apache.hadoop.hbase.regionserver.wal.HLogKey; import org.apache.hadoop.hbase.regionserver.wal.WALEdit; -import org.apache.hadoop.hbase.regionserver.wal.WALObserver; +import org.apache.hadoop.hbase.regionserver.wal.WALActionsListener; import org.apache.hadoop.hbase.util.Bytes; import java.io.IOException; @@ -40,7 +40,7 @@ import java.util.concurrent.locks.ReentrantLock; * can be interrupted when there is something to do, rather than the Chore * sleep time which is invariant. */ -class LogRoller extends Thread implements WALObserver { +class LogRoller extends Thread implements WALActionsListener { static final Log LOG = LogFactory.getLog(LogRoller.class); private final ReentrantLock rollLock = new ReentrantLock(); private final AtomicBoolean rollLog = new AtomicBoolean(false); diff --git a/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java b/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java index ab19d5ae0e9..887f73694a6 100644 --- a/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java +++ b/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLog.java @@ -119,8 +119,8 @@ public class HLog implements Syncable { private final Path dir; private final Configuration conf; // Listeners that are called on WAL events. - private List listeners = - new CopyOnWriteArrayList(); + private List listeners = + new CopyOnWriteArrayList(); private final long optionalFlushInterval; private final long blocksize; private final String prefix; @@ -295,7 +295,7 @@ public class HLog implements Syncable { * @throws IOException */ public HLog(final FileSystem fs, final Path dir, final Path oldLogDir, - final Configuration conf, final List listeners, + final Configuration conf, final List listeners, final String prefix) throws IOException { this(fs, dir, oldLogDir, conf, listeners, true, prefix); } @@ -321,7 +321,7 @@ public class HLog implements Syncable { * @throws IOException */ public HLog(final FileSystem fs, final Path dir, final Path oldLogDir, - final Configuration conf, final List listeners, + final Configuration conf, final List listeners, final boolean failIfLogDirExists, final String prefix) throws IOException { super(); @@ -329,7 +329,7 @@ public class HLog implements Syncable { this.dir = dir; this.conf = conf; if (listeners != null) { - for (WALObserver i: listeners) { + for (WALActionsListener i: listeners) { registerWALActionsListener(i); } } @@ -404,11 +404,11 @@ public class HLog implements Syncable { return m; } - public void registerWALActionsListener (final WALObserver listener) { + public void registerWALActionsListener(final WALActionsListener listener) { this.listeners.add(listener); } - public boolean unregisterWALActionsListener(final WALObserver listener) { + public boolean unregisterWALActionsListener(final WALActionsListener listener) { return this.listeners.remove(listener); } @@ -501,7 +501,7 @@ public class HLog implements Syncable { } // Tell our listeners that a new log was created if (!this.listeners.isEmpty()) { - for (WALObserver i : this.listeners) { + for (WALActionsListener i : this.listeners) { i.logRolled(newPath); } } @@ -813,7 +813,7 @@ public class HLog implements Syncable { try { // Tell our listeners that the log is closing if (!this.listeners.isEmpty()) { - for (WALObserver i : this.listeners) { + for (WALActionsListener i : this.listeners) { i.logCloseRequested(); } } @@ -1053,7 +1053,7 @@ public class HLog implements Syncable { private void requestLogRoll() { if (!this.listeners.isEmpty()) { - for (WALObserver i: this.listeners) { + for (WALActionsListener i: this.listeners) { i.logRollRequested(); } } @@ -1066,7 +1066,7 @@ public class HLog implements Syncable { return; } if (!this.listeners.isEmpty()) { - for (WALObserver i: this.listeners) { + for (WALActionsListener i: this.listeners) { i.visitLogEntryBeforeWrite(htd, logKey, logEdit); } } diff --git a/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALObserver.java b/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALActionsListener.java similarity index 95% rename from src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALObserver.java rename to src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALActionsListener.java index bf6dba97cd9..151c90bc84c 100644 --- a/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALObserver.java +++ b/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALActionsListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2010 The Apache Software Foundation + * Copyright 2011 The Apache Software Foundation * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -27,7 +27,7 @@ import org.apache.hadoop.hbase.HTableDescriptor; * Get notification of {@link HLog}/WAL log events. The invocations are inline * so make sure your implementation is fast else you'll slow hbase. */ -public interface WALObserver { +public interface WALActionsListener { /** * The WAL was rolled. * @param newFile the path to the new hlog diff --git a/src/main/java/org/apache/hadoop/hbase/replication/regionserver/Replication.java b/src/main/java/org/apache/hadoop/hbase/replication/regionserver/Replication.java index 7314d097d1e..8e1f6e0c093 100644 --- a/src/main/java/org/apache/hadoop/hbase/replication/regionserver/Replication.java +++ b/src/main/java/org/apache/hadoop/hbase/replication/regionserver/Replication.java @@ -34,7 +34,7 @@ import org.apache.hadoop.hbase.Server; import org.apache.hadoop.hbase.regionserver.wal.HLog; import org.apache.hadoop.hbase.regionserver.wal.HLogKey; import org.apache.hadoop.hbase.regionserver.wal.WALEdit; -import org.apache.hadoop.hbase.regionserver.wal.WALObserver; +import org.apache.hadoop.hbase.regionserver.wal.WALActionsListener; import org.apache.hadoop.hbase.replication.ReplicationZookeeper; import org.apache.hadoop.hbase.replication.master.ReplicationLogCleaner; import org.apache.hadoop.hbase.util.Bytes; @@ -47,7 +47,7 @@ import static org.apache.hadoop.hbase.HConstants.REPLICATION_SCOPE_LOCAL; /** * Gateway to Replication. Used by {@link org.apache.hadoop.hbase.regionserver.HRegionServer}. */ -public class Replication implements WALObserver { +public class Replication implements WALActionsListener { private final boolean replication; private final ReplicationSourceManager replicationManager; private final AtomicBoolean replicating = new AtomicBoolean(true); diff --git a/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLog.java b/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLog.java index 6d89e66f083..b4c407baad9 100644 --- a/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLog.java +++ b/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestHLog.java @@ -594,7 +594,7 @@ public class TestHLog { final byte [] tableName = Bytes.toBytes("tablename"); final byte [] row = Bytes.toBytes("row"); HLog log = new HLog(fs, dir, oldLogDir, conf); - DumbWALObserver visitor = new DumbWALObserver(); + DumbWALActionsListener visitor = new DumbWALActionsListener(); log.registerWALActionsListener(visitor); long timestamp = System.currentTimeMillis(); HTableDescriptor htd = new HTableDescriptor(); @@ -692,7 +692,7 @@ public class TestHLog { } } - static class DumbWALObserver implements WALObserver { + static class DumbWALActionsListener implements WALActionsListener { int increments = 0; @Override diff --git a/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALObserver.java b/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALActionsListener.java similarity index 90% rename from src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALObserver.java rename to src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALActionsListener.java index 8632eb82aaf..dc43eb217e8 100644 --- a/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALObserver.java +++ b/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestWALActionsListener.java @@ -1,5 +1,5 @@ /** - * Copyright 2010 The Apache Software Foundation + * Copyright 2011 The Apache Software Foundation * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -38,8 +38,8 @@ import static org.junit.Assert.*; /** * Test that the actions are called while playing with an HLog */ -public class TestWALObserver { - protected static final Log LOG = LogFactory.getLog(TestWALObserver.class); +public class TestWALActionsListener { + protected static final Log LOG = LogFactory.getLog(TestWALActionsListener.class); private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); @@ -79,10 +79,10 @@ public class TestWALObserver { */ @Test public void testActionListener() throws Exception { - DummyWALObserver observer = new DummyWALObserver(); - List list = new ArrayList(); + DummyWALActionsListener observer = new DummyWALActionsListener(); + List list = new ArrayList(); list.add(observer); - DummyWALObserver laterobserver = new DummyWALObserver(); + DummyWALActionsListener laterobserver = new DummyWALActionsListener(); HLog hlog = new HLog(fs, logDir, oldLogDir, conf, list, null); HRegionInfo hri = new HRegionInfo(SOME_BYTES, SOME_BYTES, SOME_BYTES, false); @@ -117,7 +117,7 @@ public class TestWALObserver { /** * Just counts when methods are called */ - static class DummyWALObserver implements WALObserver { + static class DummyWALActionsListener implements WALActionsListener { public int logRollCounter = 0; public int closedCount = 0; @@ -135,7 +135,7 @@ public class TestWALObserver { public void visitLogEntryBeforeWrite(HRegionInfo info, HLogKey logKey, WALEdit logEdit) { // Not interested - + } @Override diff --git a/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSourceManager.java b/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSourceManager.java index dd5dc3e9d12..381ac904962 100644 --- a/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSourceManager.java +++ b/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSourceManager.java @@ -43,7 +43,7 @@ import org.apache.hadoop.hbase.catalog.CatalogTracker; import org.apache.hadoop.hbase.regionserver.wal.HLog; import org.apache.hadoop.hbase.regionserver.wal.HLogKey; import org.apache.hadoop.hbase.regionserver.wal.WALEdit; -import org.apache.hadoop.hbase.regionserver.wal.WALObserver; +import org.apache.hadoop.hbase.regionserver.wal.WALActionsListener; import org.apache.hadoop.hbase.replication.ReplicationSourceDummy; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.zookeeper.ZKUtil; @@ -156,7 +156,7 @@ public class TestReplicationSourceManager { WALEdit edit = new WALEdit(); edit.add(kv); - List listeners = new ArrayList(); + List listeners = new ArrayList(); listeners.add(replication); HLog hlog = new HLog(fs, logDir, oldLogDir, conf, listeners, URLEncoder.encode("regionserver:60020", "UTF8"));