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 2010/08/06 08:15:14 UTC
svn commit: r982881 [2/2] - in /hbase/branches/0.90_master_rewrite/src:
main/java/org/apache/hadoop/hbase/ main/java/org/apache/hadoop/hbase/client/
main/java/org/apache/hadoop/hbase/executor/
main/java/org/apache/hadoop/hbase/master/ main/java/org/apa...
Added: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/util/HMerge.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/util/HMerge.java?rev=982881&view=auto
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/util/HMerge.java (added)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/util/HMerge.java Fri Aug 6 06:15:12 2010
@@ -0,0 +1,410 @@
+/**
+ * Copyright 2009 The Apache Software Foundation
+ *
+ * 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.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.RemoteExceptionHandler;
+import org.apache.hadoop.hbase.TableNotDisabledException;
+import org.apache.hadoop.hbase.client.Delete;
+import org.apache.hadoop.hbase.client.HConnection;
+import org.apache.hadoop.hbase.client.HConnectionManager;
+import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.ResultScanner;
+import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.regionserver.HRegion;
+import org.apache.hadoop.hbase.regionserver.InternalScanner;
+import org.apache.hadoop.hbase.regionserver.wal.HLog;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Random;
+
+/**
+ * A non-instantiable class that has a static method capable of compacting
+ * a table by merging adjacent regions.
+ */
+class HMerge {
+ static final Log LOG = LogFactory.getLog(HMerge.class);
+ static final Random rand = new Random();
+
+ /*
+ * Not instantiable
+ */
+ private HMerge() {
+ super();
+ }
+
+ /**
+ * Scans the table and merges two adjacent regions if they are small. This
+ * only happens when a lot of rows are deleted.
+ *
+ * When merging the META region, the HBase instance must be offline.
+ * When merging a normal table, the HBase instance must be online, but the
+ * table must be disabled.
+ *
+ * @param conf - configuration object for HBase
+ * @param fs - FileSystem where regions reside
+ * @param tableName - Table to be compacted
+ * @throws IOException
+ */
+ public static void merge(Configuration conf, FileSystem fs,
+ final byte [] tableName)
+ throws IOException {
+ HConnection connection = HConnectionManager.getConnection(conf);
+ boolean masterIsRunning = connection.isMasterRunning();
+ HConnectionManager.deleteConnectionInfo(conf, false);
+ if (Bytes.equals(tableName, HConstants.META_TABLE_NAME)) {
+ if (masterIsRunning) {
+ throw new IllegalStateException(
+ "Can not compact META table if instance is on-line");
+ }
+ new OfflineMerger(conf, fs).process();
+ } else {
+ if(!masterIsRunning) {
+ throw new IllegalStateException(
+ "HBase instance must be running to merge a normal table");
+ }
+ new OnlineMerger(conf, fs, tableName).process();
+ }
+ }
+
+ private static abstract class Merger {
+ protected final Configuration conf;
+ protected final FileSystem fs;
+ protected final Path tabledir;
+ protected final HLog hlog;
+ private final long maxFilesize;
+
+
+ protected Merger(Configuration conf, FileSystem fs,
+ final byte [] tableName)
+ throws IOException {
+ this.conf = conf;
+ this.fs = fs;
+ this.maxFilesize = conf.getLong("hbase.hregion.max.filesize",
+ HConstants.DEFAULT_MAX_FILE_SIZE);
+
+ this.tabledir = new Path(
+ fs.makeQualified(new Path(conf.get(HConstants.HBASE_DIR))),
+ Bytes.toString(tableName)
+ );
+ Path logdir = new Path(tabledir, "merge_" + System.currentTimeMillis() +
+ HConstants.HREGION_LOGDIR_NAME);
+ Path oldLogDir = new Path(tabledir, HConstants.HREGION_OLDLOGDIR_NAME);
+ this.hlog =
+ new HLog(fs, logdir, oldLogDir, conf, null);
+ }
+
+ void process() throws IOException {
+ try {
+ for(HRegionInfo[] regionsToMerge = next();
+ regionsToMerge != null;
+ regionsToMerge = next()) {
+ if (!merge(regionsToMerge)) {
+ return;
+ }
+ }
+ } finally {
+ try {
+ hlog.closeAndDelete();
+
+ } catch(IOException e) {
+ LOG.error(e);
+ }
+ }
+ }
+
+ protected boolean merge(final HRegionInfo[] info) throws IOException {
+ if(info.length < 2) {
+ LOG.info("only one region - nothing to merge");
+ return false;
+ }
+
+ HRegion currentRegion = null;
+ long currentSize = 0;
+ HRegion nextRegion = null;
+ long nextSize = 0;
+ for (int i = 0; i < info.length - 1; i++) {
+ if (currentRegion == null) {
+ currentRegion =
+ HRegion.newHRegion(tabledir, hlog, fs, conf, info[i], null);
+ currentRegion.initialize();
+ currentSize = currentRegion.getLargestHStoreSize();
+ }
+ nextRegion =
+ HRegion.newHRegion(tabledir, hlog, fs, conf, info[i + 1], null);
+ nextRegion.initialize();
+ nextSize = nextRegion.getLargestHStoreSize();
+
+ if ((currentSize + nextSize) <= (maxFilesize / 2)) {
+ // We merge two adjacent regions if their total size is less than
+ // one half of the desired maximum size
+ LOG.info("merging regions " + Bytes.toString(currentRegion.getRegionName())
+ + " and " + Bytes.toString(nextRegion.getRegionName()));
+ HRegion mergedRegion =
+ HRegion.mergeAdjacent(currentRegion, nextRegion);
+ updateMeta(currentRegion.getRegionName(), nextRegion.getRegionName(),
+ mergedRegion);
+ break;
+ }
+ LOG.info("not merging regions " + Bytes.toString(currentRegion.getRegionName())
+ + " and " + Bytes.toString(nextRegion.getRegionName()));
+ currentRegion.close();
+ currentRegion = nextRegion;
+ currentSize = nextSize;
+ }
+ if(currentRegion != null) {
+ currentRegion.close();
+ }
+ return true;
+ }
+
+ protected abstract HRegionInfo[] next() throws IOException;
+
+ protected abstract void updateMeta(final byte [] oldRegion1,
+ final byte [] oldRegion2, HRegion newRegion)
+ throws IOException;
+
+ }
+
+ /** Instantiated to compact a normal user table */
+ private static class OnlineMerger extends Merger {
+ private final byte [] tableName;
+ private final HTable table;
+ private final ResultScanner metaScanner;
+ private HRegionInfo latestRegion;
+
+ OnlineMerger(Configuration conf, FileSystem fs,
+ final byte [] tableName)
+ throws IOException {
+ super(conf, fs, tableName);
+ this.tableName = tableName;
+ this.table = new HTable(conf, HConstants.META_TABLE_NAME);
+ this.metaScanner = table.getScanner(HConstants.CATALOG_FAMILY,
+ HConstants.REGIONINFO_QUALIFIER);
+ this.latestRegion = null;
+ }
+
+ private HRegionInfo nextRegion() throws IOException {
+ try {
+ Result results = getMetaRow();
+ if (results == null) {
+ return null;
+ }
+ byte[] regionInfoValue = results.getValue(HConstants.CATALOG_FAMILY,
+ HConstants.REGIONINFO_QUALIFIER);
+ if (regionInfoValue == null || regionInfoValue.length == 0) {
+ throw new NoSuchElementException("meta region entry missing " +
+ Bytes.toString(HConstants.CATALOG_FAMILY) + ":" +
+ Bytes.toString(HConstants.REGIONINFO_QUALIFIER));
+ }
+ HRegionInfo region = Writables.getHRegionInfo(regionInfoValue);
+ if (!Bytes.equals(region.getTableDesc().getName(), this.tableName)) {
+ return null;
+ }
+ checkOfflined(region);
+ return region;
+ } catch (IOException e) {
+ e = RemoteExceptionHandler.checkIOException(e);
+ LOG.error("meta scanner error", e);
+ metaScanner.close();
+ throw e;
+ }
+ }
+
+ protected void checkOfflined(final HRegionInfo hri)
+ throws TableNotDisabledException {
+ if (!hri.isOffline()) {
+ throw new TableNotDisabledException("Region " +
+ hri.getRegionNameAsString() + " is not disabled");
+ }
+ }
+
+ /*
+ * Check current row has a HRegionInfo. Skip to next row if HRI is empty.
+ * @return A Map of the row content else null if we are off the end.
+ * @throws IOException
+ */
+ private Result getMetaRow() throws IOException {
+ Result currentRow = metaScanner.next();
+ boolean foundResult = false;
+ while (currentRow != null) {
+ LOG.info("Row: <" + Bytes.toString(currentRow.getRow()) + ">");
+ byte[] regionInfoValue = currentRow.getValue(HConstants.CATALOG_FAMILY,
+ HConstants.REGIONINFO_QUALIFIER);
+ if (regionInfoValue == null || regionInfoValue.length == 0) {
+ currentRow = metaScanner.next();
+ continue;
+ }
+ foundResult = true;
+ break;
+ }
+ return foundResult ? currentRow : null;
+ }
+
+ @Override
+ protected HRegionInfo[] next() throws IOException {
+ List<HRegionInfo> regions = new ArrayList<HRegionInfo>();
+ if(latestRegion == null) {
+ latestRegion = nextRegion();
+ }
+ if(latestRegion != null) {
+ regions.add(latestRegion);
+ }
+ latestRegion = nextRegion();
+ if(latestRegion != null) {
+ regions.add(latestRegion);
+ }
+ return regions.toArray(new HRegionInfo[regions.size()]);
+ }
+
+ @Override
+ protected void updateMeta(final byte [] oldRegion1,
+ final byte [] oldRegion2,
+ HRegion newRegion)
+ throws IOException {
+ byte[][] regionsToDelete = {oldRegion1, oldRegion2};
+ for (int r = 0; r < regionsToDelete.length; r++) {
+ if(Bytes.equals(regionsToDelete[r], latestRegion.getRegionName())) {
+ latestRegion = null;
+ }
+ Delete delete = new Delete(regionsToDelete[r]);
+ table.delete(delete);
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("updated columns in row: " + Bytes.toString(regionsToDelete[r]));
+ }
+ }
+ newRegion.getRegionInfo().setOffline(true);
+
+ Put put = new Put(newRegion.getRegionName());
+ put.add(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER,
+ Writables.getBytes(newRegion.getRegionInfo()));
+ table.put(put);
+
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("updated columns in row: "
+ + Bytes.toString(newRegion.getRegionName()));
+ }
+ }
+ }
+
+ /** Instantiated to compact the meta region */
+ private static class OfflineMerger extends Merger {
+ private final List<HRegionInfo> metaRegions = new ArrayList<HRegionInfo>();
+ private final HRegion root;
+
+ OfflineMerger(Configuration conf, FileSystem fs)
+ throws IOException {
+ super(conf, fs, HConstants.META_TABLE_NAME);
+
+ Path rootTableDir = HTableDescriptor.getTableDir(
+ fs.makeQualified(new Path(conf.get(HConstants.HBASE_DIR))),
+ HConstants.ROOT_TABLE_NAME);
+
+ // Scan root region to find all the meta regions
+
+ root = HRegion.newHRegion(rootTableDir, hlog, fs, conf,
+ HRegionInfo.ROOT_REGIONINFO, null);
+ root.initialize();
+
+ Scan scan = new Scan();
+ scan.addColumn(HConstants.CATALOG_FAMILY,
+ HConstants.REGIONINFO_QUALIFIER);
+ InternalScanner rootScanner =
+ root.getScanner(scan);
+
+ try {
+ List<KeyValue> results = new ArrayList<KeyValue>();
+ while(rootScanner.next(results)) {
+ for(KeyValue kv: results) {
+ HRegionInfo info = Writables.getHRegionInfoOrNull(kv.getValue());
+ if (info != null) {
+ metaRegions.add(info);
+ }
+ }
+ }
+ } finally {
+ rootScanner.close();
+ try {
+ root.close();
+
+ } catch(IOException e) {
+ LOG.error(e);
+ }
+ }
+ }
+
+ @Override
+ protected HRegionInfo[] next() {
+ HRegionInfo[] results = null;
+ if (metaRegions.size() > 0) {
+ results = metaRegions.toArray(new HRegionInfo[metaRegions.size()]);
+ metaRegions.clear();
+ }
+ return results;
+ }
+
+ @Override
+ protected void updateMeta(final byte [] oldRegion1,
+ final byte [] oldRegion2, HRegion newRegion)
+ throws IOException {
+ byte[][] regionsToDelete = {oldRegion1, oldRegion2};
+ for(int r = 0; r < regionsToDelete.length; r++) {
+ Delete delete = new Delete(regionsToDelete[r]);
+ delete.deleteColumns(HConstants.CATALOG_FAMILY,
+ HConstants.REGIONINFO_QUALIFIER);
+ delete.deleteColumns(HConstants.CATALOG_FAMILY,
+ HConstants.SERVER_QUALIFIER);
+ delete.deleteColumns(HConstants.CATALOG_FAMILY,
+ HConstants.STARTCODE_QUALIFIER);
+ delete.deleteColumns(HConstants.CATALOG_FAMILY,
+ HConstants.SPLITA_QUALIFIER);
+ delete.deleteColumns(HConstants.CATALOG_FAMILY,
+ HConstants.SPLITB_QUALIFIER);
+ root.delete(delete, null, true);
+
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("updated columns in row: " + Bytes.toString(regionsToDelete[r]));
+ }
+ }
+ HRegionInfo newInfo = newRegion.getRegionInfo();
+ newInfo.setOffline(true);
+ Put put = new Put(newRegion.getRegionName());
+ put.add(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER,
+ Writables.getBytes(newInfo));
+ root.put(put);
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("updated columns in row: " + Bytes.toString(newRegion.getRegionName()));
+ }
+ }
+ }
+}
Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/ClusterStatusTracker.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/ClusterStatusTracker.java?rev=982881&r1=982880&r2=982881&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/ClusterStatusTracker.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/ClusterStatusTracker.java Fri Aug 6 06:15:12 2010
@@ -76,9 +76,4 @@ public class ClusterStatusTracker extend
"state node (" + watcher.clusterStateZNode + ") not found");
}
}
-
- @Override
- protected Log getLog() {
- return LOG;
- }
}
Added: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/MiniZooKeeperCluster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/MiniZooKeeperCluster.java?rev=982881&view=auto
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/MiniZooKeeperCluster.java (added)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/MiniZooKeeperCluster.java Fri Aug 6 06:15:12 2010
@@ -0,0 +1,225 @@
+/*
+ * Copyright 2009 The Apache Software Foundation
+ *
+ * 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.zookeeper;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.net.BindException;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.fs.FileUtil;
+import org.apache.zookeeper.server.NIOServerCnxn;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.apache.zookeeper.server.persistence.FileTxnLog;
+
+/**
+ * TODO: Most of the code in this class is ripped from ZooKeeper tests. Instead
+ * of redoing it, we should contribute updates to their code which let us more
+ * easily access testing helper objects.
+ */
+public class MiniZooKeeperCluster {
+ private static final Log LOG = LogFactory.getLog(MiniZooKeeperCluster.class);
+
+ private static final int TICK_TIME = 2000;
+ private static final int CONNECTION_TIMEOUT = 30000;
+
+ private boolean started;
+ private int clientPort = 21810; // use non-standard port
+
+ private NIOServerCnxn.Factory standaloneServerFactory;
+ private int tickTime = 0;
+
+ /** Create mini ZooKeeper cluster. */
+ public MiniZooKeeperCluster() {
+ this.started = false;
+ }
+
+ public void setClientPort(int clientPort) {
+ this.clientPort = clientPort;
+ }
+
+ public int getClientPort() {
+ return clientPort;
+ }
+
+ public void setTickTime(int tickTime) {
+ this.tickTime = tickTime;
+ }
+
+ // / XXX: From o.a.zk.t.ClientBase
+ private static void setupTestEnv() {
+ // during the tests we run with 100K prealloc in the logs.
+ // on windows systems prealloc of 64M was seen to take ~15seconds
+ // resulting in test failure (client timeout on first session).
+ // set env and directly in order to handle static init/gc issues
+ System.setProperty("zookeeper.preAllocSize", "100");
+ FileTxnLog.setPreallocSize(100);
+ }
+
+ /**
+ * @param baseDir
+ * @return ClientPort server bound to.
+ * @throws IOException
+ * @throws InterruptedException
+ */
+ public int startup(File baseDir) throws IOException,
+ InterruptedException {
+
+ setupTestEnv();
+
+ shutdown();
+
+ File dir = new File(baseDir, "zookeeper").getAbsoluteFile();
+ recreateDir(dir);
+
+ int tickTimeToUse;
+ if (this.tickTime > 0) {
+ tickTimeToUse = this.tickTime;
+ } else {
+ tickTimeToUse = TICK_TIME;
+ }
+ ZooKeeperServer server = new ZooKeeperServer(dir, dir, tickTimeToUse);
+ while (true) {
+ try {
+ standaloneServerFactory =
+ new NIOServerCnxn.Factory(new InetSocketAddress(clientPort));
+ } catch (BindException e) {
+ LOG.info("Failed binding ZK Server to client port: " + clientPort);
+ //this port is already in use. try to use another
+ clientPort++;
+ continue;
+ }
+ break;
+ }
+ standaloneServerFactory.startup(server);
+
+ if (!waitForServerUp(clientPort, CONNECTION_TIMEOUT)) {
+ throw new IOException("Waiting for startup of standalone server");
+ }
+
+ started = true;
+ LOG.info("Started MiniZK Server on client port: " + clientPort);
+ return clientPort;
+ }
+
+ private void recreateDir(File dir) throws IOException {
+ if (dir.exists()) {
+ FileUtil.fullyDelete(dir);
+ }
+ try {
+ dir.mkdirs();
+ } catch (SecurityException e) {
+ throw new IOException("creating dir: " + dir, e);
+ }
+ }
+
+ /**
+ * @throws IOException
+ */
+ public void shutdown() throws IOException {
+ if (!started) {
+ return;
+ }
+
+ standaloneServerFactory.shutdown();
+ if (!waitForServerDown(clientPort, CONNECTION_TIMEOUT)) {
+ throw new IOException("Waiting for shutdown of standalone server");
+ }
+
+ started = false;
+ }
+
+ // XXX: From o.a.zk.t.ClientBase
+ private static boolean waitForServerDown(int port, long timeout) {
+ long start = System.currentTimeMillis();
+ while (true) {
+ try {
+ Socket sock = new Socket("localhost", port);
+ try {
+ OutputStream outstream = sock.getOutputStream();
+ outstream.write("stat".getBytes());
+ outstream.flush();
+ } finally {
+ sock.close();
+ }
+ } catch (IOException e) {
+ return true;
+ }
+
+ if (System.currentTimeMillis() > start + timeout) {
+ break;
+ }
+ try {
+ Thread.sleep(250);
+ } catch (InterruptedException e) {
+ // ignore
+ }
+ }
+ return false;
+ }
+
+ // XXX: From o.a.zk.t.ClientBase
+ private static boolean waitForServerUp(int port, long timeout) {
+ long start = System.currentTimeMillis();
+ while (true) {
+ try {
+ Socket sock = new Socket("localhost", port);
+ BufferedReader reader = null;
+ try {
+ OutputStream outstream = sock.getOutputStream();
+ outstream.write("stat".getBytes());
+ outstream.flush();
+
+ Reader isr = new InputStreamReader(sock.getInputStream());
+ reader = new BufferedReader(isr);
+ String line = reader.readLine();
+ if (line != null && line.startsWith("Zookeeper version:")) {
+ return true;
+ }
+ } finally {
+ sock.close();
+ if (reader != null) {
+ reader.close();
+ }
+ }
+ } catch (IOException e) {
+ // ignore as this is expected
+ LOG.info("server localhost:" + port + " not up " + e);
+ }
+
+ if (System.currentTimeMillis() > start + timeout) {
+ break;
+ }
+ try {
+ Thread.sleep(250);
+ } catch (InterruptedException e) {
+ // ignore
+ }
+ }
+ return false;
+ }
+}
Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/RegionServerTracker.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/RegionServerTracker.java?rev=982881&r1=982880&r2=982881&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/RegionServerTracker.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/RegionServerTracker.java Fri Aug 6 06:15:12 2010
@@ -84,8 +84,7 @@ public class RegionServerTracker extends
try {
ZKUtil.watchAndGetNewChildren(watcher, watcher.rsZNode);
} catch (KeeperException e) {
- LOG.error("Unexpected zk exception getting RS nodes", e);
- abortable.abort();
+ abortable.abort("Unexpected zk exception getting RS nodes", e);
}
}
}
Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/RootRegionTracker.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/RootRegionTracker.java?rev=982881&r1=982880&r2=982881&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/RootRegionTracker.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/RootRegionTracker.java Fri Aug 6 06:15:12 2010
@@ -19,8 +19,6 @@
*/
package org.apache.hadoop.hbase.zookeeper;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.Abortable;
import org.apache.hadoop.hbase.HServerAddress;
import org.apache.hadoop.hbase.util.Bytes;
@@ -29,8 +27,6 @@ import org.apache.hadoop.hbase.util.Byte
* Tracks the root region server location node in zookeeper.
*/
public class RootRegionTracker extends ZooKeeperNodeTracker {
- private static final Log LOG = LogFactory.getLog(RootRegionTracker.class);
-
/**
* Creates a root region location tracker.
*
@@ -73,9 +69,4 @@ public class RootRegionTracker extends Z
byte [] data = super.blockUntilAvailable(timeout);
return data == null ? null : new HServerAddress(Bytes.toString(data));
}
-
- @Override
- protected Log getLog() {
- return LOG;
- }
}
Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperNodeTracker.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperNodeTracker.java?rev=982881&r1=982880&r2=982881&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperNodeTracker.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperNodeTracker.java Fri Aug 6 06:15:12 2010
@@ -35,13 +35,13 @@ import org.apache.zookeeper.KeeperExcept
public abstract class ZooKeeperNodeTracker extends ZooKeeperListener {
/** Path of node being tracked */
- protected String node;
+ protected final String node;
/** Data of the node being tracked */
private byte [] data;
/** Used to abort if a fatal error occurs */
- protected Abortable abortable;
+ protected final Abortable abortable;
/**
* Constructs a new ZK node tracker.
@@ -78,8 +78,7 @@ public abstract class ZooKeeperNodeTrack
}
}
} catch (KeeperException e) {
- getLog().fatal("Unexpected exception during initialization, aborting", e);
- abortable.abort();
+ abortable.abort("Unexpected exception during initialization, aborting", e);
}
}
@@ -139,8 +138,7 @@ public abstract class ZooKeeperNodeTrack
nodeDeleted(path);
}
} catch(KeeperException e) {
- getLog().fatal("Unexpected exception handling nodeCreated event", e);
- abortable.abort();
+ abortable.abort("Unexpected exception handling nodeCreated event", e);
}
}
}
@@ -155,8 +153,7 @@ public abstract class ZooKeeperNodeTrack
this.data = null;
}
} catch(KeeperException e) {
- getLog().fatal("Unexpected exception handling nodeCreated event", e);
- abortable.abort();
+ abortable.abort("Unexpected exception handling nodeDeleted event", e);
}
}
}
@@ -167,10 +164,4 @@ public abstract class ZooKeeperNodeTrack
nodeCreated(path);
}
}
-
- /**
- * Gets the logger. Used to provide more clear log messages.
- * @return log instance of extending class
- */
- protected abstract Log getLog();
}
Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java?rev=982881&r1=982880&r2=982881&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java Fri Aug 6 06:15:12 2010
@@ -236,7 +236,7 @@ public class ZooKeeperWatcher implements
case Expired:
error("Received Expired from ZooKeeper, aborting server");
if(abortable != null) {
- abortable.abort();
+ abortable.abort("Received Expired from ZooKeeper, aborting server", null);
}
break;
}
Modified: hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/HBaseClusterTestCase.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/HBaseClusterTestCase.java?rev=982881&r1=982880&r2=982881&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/HBaseClusterTestCase.java (original)
+++ hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/HBaseClusterTestCase.java Fri Aug 6 06:15:12 2010
@@ -30,6 +30,7 @@ import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.client.HConnectionManager;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.util.FSUtils;
+import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.hadoop.util.ReflectionUtils;
Modified: hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java?rev=982881&r1=982880&r2=982881&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java (original)
+++ hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java Fri Aug 6 06:15:12 2010
@@ -52,6 +52,7 @@ import org.apache.hadoop.hbase.util.Byte
import org.apache.hadoop.hbase.util.FSUtils;
import org.apache.hadoop.hbase.util.Threads;
import org.apache.hadoop.hbase.util.Writables;
+import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster;
import org.apache.hadoop.hbase.zookeeper.ZKConfig;
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
import org.apache.hadoop.hdfs.DFSClient;
@@ -746,7 +747,7 @@ public class HBaseTestingUtility {
expireSession(rs.getZooKeeper(), rs);
}
- public void expireSession(ZooKeeperWatcher nodeZK, ServerController server)
+ public void expireSession(ZooKeeperWatcher nodeZK, Server server)
throws Exception {
String quorumServers = ZKConfig.getZKQuorumServersString(conf);
int sessionTimeout = 5 * 1000; // 5 seconds
Modified: hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java?rev=982881&r1=982880&r2=982881&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java (original)
+++ hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java Fri Aug 6 06:15:12 2010
@@ -62,6 +62,7 @@ import org.apache.hadoop.hbase.util.FSUt
import org.apache.hadoop.hbase.util.Hash;
import org.apache.hadoop.hbase.util.MurmurHash;
import org.apache.hadoop.hbase.util.Pair;
+import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
Modified: hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/master/TestActiveMasterManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/master/TestActiveMasterManager.java?rev=982881&r1=982880&r2=982881&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/master/TestActiveMasterManager.java (original)
+++ hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/master/TestActiveMasterManager.java Fri Aug 6 06:15:12 2010
@@ -243,7 +243,7 @@ public class TestActiveMasterManager {
public void startShutdown() {}
@Override
- public void abort() {}
+ public void abort(final String msg, final Throwable t) {}
@Override
public Configuration getConfiguration() {
Added: hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/util/TestMergeMeta.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/util/TestMergeMeta.java?rev=982881&view=auto
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/util/TestMergeMeta.java (added)
+++ hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/util/TestMergeMeta.java Fri Aug 6 06:15:12 2010
@@ -0,0 +1,48 @@
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * 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.util;
+
+import java.io.IOException;
+
+import org.apache.hadoop.hbase.AbstractMergeTestBase;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.util.HMerge;
+
+/** Tests region merging */
+public class TestMergeMeta extends AbstractMergeTestBase {
+
+ /** constructor
+ * @throws Exception
+ */
+ public TestMergeMeta() throws Exception {
+ super(false);
+ conf.setLong("hbase.client.pause", 1 * 1000);
+ conf.setInt("hbase.client.retries.number", 2);
+ }
+
+ /**
+ * test case
+ * @throws IOException
+ */
+ public void testMergeMeta() throws IOException {
+ assertNotNull(dfsCluster);
+ HMerge.merge(conf, dfsCluster.getFileSystem(), HConstants.META_TABLE_NAME);
+ }
+}
\ No newline at end of file
Added: hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/util/TestMergeTable.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/util/TestMergeTable.java?rev=982881&view=auto
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/util/TestMergeTable.java (added)
+++ hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/util/TestMergeTable.java Fri Aug 6 06:15:12 2010
@@ -0,0 +1,40 @@
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * 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.util;
+
+import java.io.IOException;
+
+import org.apache.hadoop.hbase.AbstractMergeTestBase;
+import org.apache.hadoop.hbase.util.HMerge;
+
+/**
+ * Tests merging a normal table's regions
+ */
+public class TestMergeTable extends AbstractMergeTestBase {
+
+ /**
+ * Test case
+ * @throws IOException
+ */
+ public void testMergeTable() throws IOException {
+ assertNotNull(dfsCluster);
+ HMerge.merge(conf, dfsCluster.getFileSystem(), desc.getName());
+ }
+}
\ No newline at end of file
Modified: hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperNodeTracker.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperNodeTracker.java?rev=982881&r1=982880&r2=982881&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperNodeTracker.java (original)
+++ hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZooKeeperNodeTracker.java Fri Aug 6 06:15:12 2010
@@ -216,12 +216,6 @@ public class TestZooKeeperNodeTracker {
Abortable abortable) {
super(watcher, node, abortable);
}
-
- @Override
- protected Log getLog() {
- return LOG;
- }
-
}
public static class TestingZKListener extends ZooKeeperListener {
@@ -279,7 +273,7 @@ public class TestZooKeeperNodeTracker {
public static class StubAbortable implements Abortable {
@Override
- public void abort() {}
+ public void abort(final String msg, final Throwable t) {}
}
public static class StubWatcher implements Watcher {