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 2012/11/30 18:50:47 UTC
svn commit: r1415766 - in /hbase/trunk/hbase-server/src:
main/java/org/apache/hadoop/hbase/ main/java/org/apache/hadoop/hbase/catalog/
main/java/org/apache/hadoop/hbase/client/
main/java/org/apache/hadoop/hbase/io/
main/java/org/apache/hadoop/hbase/map...
Author: stack
Date: Fri Nov 30 17:50:44 2012
New Revision: 1415766
URL: http://svn.apache.org/viewvc?rev=1415766&view=rev
Log:
HBASE-7234 Remove long-deprecated HServerAddress and HServerInfo Writables
Removed:
hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/HServerAddress.java
hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/HServerInfo.java
hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/TestHServerAddress.java
hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/TestHServerInfo.java
Modified:
hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/HRegionLocation.java
hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaReader.java
hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HConnection.java
hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HTable.java
hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/RetriesExhaustedWithDetailsException.java
hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/ScannerCallable.java
hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HbaseObjectWritable.java
hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableMapReduceUtil.java
hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableInputFormatBase.java
hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableMapReduceUtil.java
hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java
hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java
hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/io/TestHbaseObjectWritable.java
hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat.java
hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestEndToEndSplitTransaction.java
hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java
hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java
hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestRegionSplitter.java
hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/OfflineMetaRebuildTestCore.java
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/HRegionLocation.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/HRegionLocation.java?rev=1415766&r1=1415765&r2=1415766&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/HRegionLocation.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/HRegionLocation.java Fri Nov 30 17:50:44 2012
@@ -97,15 +97,6 @@ public class HRegionLocation implements
return regionInfo;
}
- /**
- * Do not use!!! Creates a HServerAddress instance which will do a resolve.
- * @return HServerAddress
- * @deprecated Use {@link #getHostnamePort}
- */
- public HServerAddress getServerAddress() {
- return new HServerAddress(this.hostname, this.port);
- }
-
public String getHostname() {
return this.hostname;
}
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaReader.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaReader.java?rev=1415766&r1=1415765&r2=1415766&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaReader.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaReader.java Fri Nov 30 17:50:44 2012
@@ -28,6 +28,7 @@ import java.util.TreeMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HTableDescriptor;
@@ -624,4 +625,20 @@ public class MetaReader {
this.results.add(r);
}
}
+
+ /**
+ * Count regions in <code>.META.</code> for passed table.
+ * @param c
+ * @param tableName
+ * @return Count or regions in table <code>tableName</code>
+ * @throws IOException
+ */
+ public static int getRegionCount(final Configuration c, final String tableName) throws IOException {
+ HTable t = new HTable(c, tableName);
+ try {
+ return t.getRegionLocations().size();
+ } finally {
+ t.close();
+ }
+ }
}
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HConnection.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HConnection.java?rev=1415766&r1=1415765&r2=1415766&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HConnection.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HConnection.java Fri Nov 30 17:50:44 2012
@@ -21,16 +21,13 @@ package org.apache.hadoop.hbase.client;
import java.io.Closeable;
import java.io.IOException;
import java.util.List;
-import java.util.Map;
import java.util.concurrent.ExecutorService;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Abortable;
-import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HRegionLocation;
-import org.apache.hadoop.hbase.HServerAddress;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.MasterAdminProtocol;
import org.apache.hadoop.hbase.MasterMonitorProtocol;
@@ -351,14 +348,6 @@ public interface HConnection extends Abo
public boolean getRegionCachePrefetch(final byte[] tableName);
/**
- * Load the region map and warm up the global region cache for the table.
- * @param tableName name of the table to perform region cache prewarm.
- * @param regions a region map.
- */
- public void prewarmRegionCache(final byte[] tableName,
- final Map<HRegionInfo, HServerAddress> regions);
-
- /**
* Scan zookeeper to get the number of region servers
* @return the number of region servers that are currently running
* @throws IOException if a remote or network exception occurs
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java?rev=1415766&r1=1415765&r2=1415766&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java Fri Nov 30 17:50:44 2012
@@ -58,7 +58,6 @@ import org.apache.hadoop.hbase.HBaseConf
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HRegionLocation;
-import org.apache.hadoop.hbase.HServerAddress;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.MasterAdminProtocol;
@@ -2242,17 +2241,6 @@ public class HConnectionManager {
}
@Override
- public void prewarmRegionCache(byte[] tableName,
- Map<HRegionInfo, HServerAddress> regions) {
- for (Map.Entry<HRegionInfo, HServerAddress> e : regions.entrySet()) {
- HServerAddress hsa = e.getValue();
- if (hsa == null || hsa.getInetSocketAddress() == null) continue;
- cacheLocation(tableName,
- new HRegionLocation(e.getKey(), hsa.getHostname(), hsa.getPort()));
- }
- }
-
- @Override
public void abort(final String msg, Throwable t) {
if (t instanceof KeeperException.SessionExpiredException
&& keepAliveZookeeper != null) {
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HTable.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HTable.java?rev=1415766&r1=1415765&r2=1415766&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HTable.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HTable.java Fri Nov 30 17:50:44 2012
@@ -19,9 +19,6 @@
package org.apache.hadoop.hbase.client;
import java.io.Closeable;
-import java.io.DataInput;
-import java.io.DataInputStream;
-import java.io.DataOutput;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.lang.reflect.Proxy;
@@ -40,9 +37,7 @@ import java.util.concurrent.Future;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-import com.google.protobuf.Service;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience;
@@ -52,14 +47,12 @@ import org.apache.hadoop.hbase.HBaseConf
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HRegionLocation;
-import org.apache.hadoop.hbase.HServerAddress;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.client.HConnectionManager.HConnectable;
import org.apache.hadoop.hbase.client.coprocessor.Batch;
import org.apache.hadoop.hbase.filter.BinaryComparator;
-import org.apache.hadoop.hbase.io.DataInputInputStream;
import org.apache.hadoop.hbase.ipc.CoprocessorProtocol;
import org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel;
import org.apache.hadoop.hbase.ipc.ExecRPCInvoker;
@@ -75,11 +68,11 @@ import org.apache.hadoop.hbase.protobuf.
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutateResponse;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.UnlockRowRequest;
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.CompareType;
-import org.apache.hadoop.hbase.util.Addressing;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.Pair;
import org.apache.hadoop.hbase.util.Threads;
+import com.google.protobuf.Service;
import com.google.protobuf.ServiceException;
/**
@@ -480,38 +473,13 @@ public class HTable implements HTableInt
/**
* Gets all the regions and their address for this table.
- * @return A map of HRegionInfo with it's server address
- * @throws IOException if a remote or network exception occurs
- * @deprecated Use {@link #getRegionLocations()} or {@link #getStartEndKeys()}
- */
- @Deprecated
- public Map<HRegionInfo, HServerAddress> getRegionsInfo() throws IOException {
- final Map<HRegionInfo, HServerAddress> regionMap =
- new TreeMap<HRegionInfo, HServerAddress>();
-
- final Map<HRegionInfo, ServerName> regionLocations = getRegionLocations();
-
- for (Map.Entry<HRegionInfo, ServerName> entry : regionLocations.entrySet()) {
- HServerAddress server = new HServerAddress();
- ServerName serverName = entry.getValue();
- if (serverName != null && serverName.getHostAndPort() != null) {
- server = new HServerAddress(Addressing.createInetSocketAddressFromHostAndPortStr(
- serverName.getHostAndPort()));
- }
- regionMap.put(entry.getKey(), server);
- }
-
- return regionMap;
- }
-
- /**
- * Gets all the regions and their address for this table.
* <p>
* This is mainly useful for the MapReduce integration.
* @return A map of HRegionInfo with it's server address
* @throws IOException if a remote or network exception occurs
*/
public NavigableMap<HRegionInfo, ServerName> getRegionLocations() throws IOException {
+ // TODO: Odd that this returns a Map of HRI to SN whereas getRegionLocation, singular, returns an HRegionLocation.
return MetaScanner.allTableRegions(getConfiguration(), getTableName(), false);
}
@@ -545,106 +513,6 @@ public class HTable implements HTableInt
}
/**
- * Save the passed region information and the table's regions
- * cache.
- * <p>
- * This is mainly useful for the MapReduce integration. You can call
- * {@link #deserializeRegionInfo deserializeRegionInfo}
- * to deserialize regions information from a
- * {@link DataInput}, then call this method to load them to cache.
- *
- * <pre>
- * {@code
- * HTable t1 = new HTable("foo");
- * FileInputStream fis = new FileInputStream("regions.dat");
- * DataInputStream dis = new DataInputStream(fis);
- *
- * Map<HRegionInfo, HServerAddress> hm = t1.deserializeRegionInfo(dis);
- * t1.prewarmRegionCache(hm);
- * }
- * </pre>
- * @param regionMap This piece of regions information will be loaded
- * to region cache.
- */
- public void prewarmRegionCache(Map<HRegionInfo, HServerAddress> regionMap) {
- this.connection.prewarmRegionCache(this.getTableName(), regionMap);
- }
-
- /**
- * Serialize the regions information of this table and output
- * to <code>out</code>.
- * <p>
- * This is mainly useful for the MapReduce integration. A client could
- * perform a large scan for all the regions for the table, serialize the
- * region info to a file. MR job can ship a copy of the meta for the table in
- * the DistributedCache.
- * <pre>
- * {@code
- * FileOutputStream fos = new FileOutputStream("regions.dat");
- * DataOutputStream dos = new DataOutputStream(fos);
- * table.serializeRegionInfo(dos);
- * dos.flush();
- * dos.close();
- * }
- * </pre>
- * @param out {@link DataOutput} to serialize this object into.
- * @throws IOException if a remote or network exception occurs
- * @deprecated serializing/deserializing regioninfo's are deprecated
- */
- @Deprecated
- public void serializeRegionInfo(DataOutput out) throws IOException {
- Map<HRegionInfo, HServerAddress> allRegions = this.getRegionsInfo();
- // first, write number of regions
- out.writeInt(allRegions.size());
- for (Map.Entry<HRegionInfo, HServerAddress> es : allRegions.entrySet()) {
- byte[] hriBytes = es.getKey().toDelimitedByteArray();
- out.write(hriBytes);
- es.getValue().write(out);
- }
- }
-
- /**
- * Read from <code>in</code> and deserialize the regions information.
- *
- * <p>It behaves similarly as {@link #getRegionsInfo getRegionsInfo}, except
- * that it loads the region map from a {@link DataInput} object.
- *
- * <p>It is supposed to be followed immediately by {@link
- * #prewarmRegionCache prewarmRegionCache}.
- *
- * <p>
- * Please refer to {@link #prewarmRegionCache prewarmRegionCache} for usage.
- *
- * @param in {@link DataInput} object.
- * @return A map of HRegionInfo with its server address.
- * @throws IOException if an I/O exception occurs.
- * @deprecated serializing/deserializing regioninfo's are deprecated
- */
- @Deprecated
- public Map<HRegionInfo, HServerAddress> deserializeRegionInfo(DataInput in)
- throws IOException {
- final Map<HRegionInfo, HServerAddress> allRegions =
- new TreeMap<HRegionInfo, HServerAddress>();
-
- DataInputStream is = null;
- if (in instanceof DataInputStream) {
- is = (DataInputStream) in;
- } else {
- is = new DataInputStream(DataInputInputStream.constructInputStream(in));
- }
-
- // the first integer is expected to be the size of records
- int regionsCount = is.readInt();
- for (int i = 0; i < regionsCount; ++i) {
- HRegionInfo hri = HRegionInfo.parseFrom(is);
- HServerAddress hsa = new HServerAddress();
- hsa.readFields(is);
- allRegions.put(hri, hsa);
- }
- return allRegions;
- }
-
- /**
* {@inheritDoc}
*/
@Override
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/RetriesExhaustedWithDetailsException.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/RetriesExhaustedWithDetailsException.java?rev=1415766&r1=1415765&r2=1415766&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/RetriesExhaustedWithDetailsException.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/RetriesExhaustedWithDetailsException.java Fri Nov 30 17:50:44 2012
@@ -22,9 +22,6 @@ package org.apache.hadoop.hbase.client;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.hbase.DoNotRetryIOException;
-import org.apache.hadoop.hbase.HServerAddress;
-import org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException;
-import org.apache.hadoop.hbase.util.Addressing;
import java.util.Collection;
import java.util.HashMap;
@@ -40,7 +37,7 @@ import java.util.Set;
* and if the result is false, you have input error problems, otherwise you
* may have cluster issues. You can iterate over the causes, rows and last
* known server addresses via {@link #getNumExceptions()} and
- * {@link #getCause(int)}, {@link #getRow(int)} and {@link #getAddress(int)}.
+ * {@link #getCause(int)}, {@link #getRow(int)} and {@link #getHostnamePort(int)}.
*/
@SuppressWarnings("serial")
@InterfaceAudience.Public
@@ -79,10 +76,6 @@ extends RetriesExhaustedException {
return actions.get(i);
}
- public HServerAddress getAddress(int i) {
- return new HServerAddress(Addressing.createInetSocketAddressFromHostAndPortStr(getHostnamePort(i)));
- }
-
public String getHostnamePort(final int i) {
return this.hostnameAndPort.get(i);
}
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/ScannerCallable.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/ScannerCallable.java?rev=1415766&r1=1415765&r2=1415766&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/ScannerCallable.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/ScannerCallable.java Fri Nov 30 17:50:44 2012
@@ -187,7 +187,7 @@ public class ScannerCallable extends Ser
connection.relocateRegion(tableName, scan.getStartRow());
LOG.info("Scanner=" + scannerId
+ " expired, current region location is " + location.toString()
- + " ip:" + location.getServerAddress().getBindAddress());
+ + " ip:" + location.getHostnamePort());
} catch (Throwable t) {
LOG.info("Failed to relocate region", t);
}
@@ -275,7 +275,7 @@ public class ScannerCallable extends Ser
if (logScannerActivity) {
LOG.info("Open scanner=" + id + " for scan=" + scan.toString()
+ " on region " + this.location.toString() + " ip:"
- + this.location.getServerAddress().getBindAddress());
+ + this.location.getHostnamePort());
}
return id;
} catch (ServiceException se) {
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HbaseObjectWritable.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HbaseObjectWritable.java?rev=1415766&r1=1415765&r2=1415766&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HbaseObjectWritable.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HbaseObjectWritable.java Fri Nov 30 17:50:44 2012
@@ -46,8 +46,6 @@ import org.apache.hadoop.hbase.ClusterSt
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionInfo;
-import org.apache.hadoop.hbase.HServerAddress;
-import org.apache.hadoop.hbase.HServerInfo;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.client.Action;
@@ -185,8 +183,8 @@ public class HbaseObjectWritable impleme
addToMap(HRegion[].class, code++);
addToMap(HRegionInfo.class, code++);
addToMap(HRegionInfo[].class, code++);
- addToMap(HServerAddress.class, code++);
- addToMap(HServerInfo.class, code++);
+ code++; // Removed
+ code++; // Removed
addToMap(HTableDescriptor.class, code++);
addToMap(MapWritable.class, code++);
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableMapReduceUtil.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableMapReduceUtil.java?rev=1415766&r1=1415765&r2=1415766&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableMapReduceUtil.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableMapReduceUtil.java Fri Nov 30 17:50:44 2012
@@ -21,7 +21,7 @@ package org.apache.hadoop.hbase.mapred;
import java.io.IOException;
import org.apache.hadoop.hbase.HBaseConfiguration;
-import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.catalog.MetaReader;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.mapreduce.MutationSerialization;
@@ -33,6 +33,7 @@ import org.apache.hadoop.mapred.InputFor
import org.apache.hadoop.mapred.OutputFormat;
import org.apache.hadoop.mapred.TextInputFormat;
import org.apache.hadoop.mapred.TextOutputFormat;
+import org.apache.hadoop.mapred.jobcontrol.Job;
/**
* Utility for {@link TableMap} and {@link TableReduce}
@@ -157,10 +158,9 @@ public class TableMapReduceUtil {
MutationSerialization.class.getName(), ResultSerialization.class.getName());
if (partitioner == HRegionPartitioner.class) {
job.setPartitionerClass(HRegionPartitioner.class);
- HTable outputTable = new HTable(HBaseConfiguration.create(job), table);
- int regions = outputTable.getRegionsInfo().size();
+ int regions = MetaReader.getRegionCount(HBaseConfiguration.create(job), table);
if (job.getNumReduceTasks() > regions) {
- job.setNumReduceTasks(outputTable.getRegionsInfo().size());
+ job.setNumReduceTasks(regions);
}
} else if (partitioner != null) {
job.setPartitionerClass(partitioner);
@@ -192,8 +192,7 @@ public class TableMapReduceUtil {
*/
public static void limitNumReduceTasks(String table, JobConf job)
throws IOException {
- HTable outputTable = new HTable(HBaseConfiguration.create(job), table);
- int regions = outputTable.getRegionsInfo().size();
+ int regions = MetaReader.getRegionCount(HBaseConfiguration.create(job), table);
if (job.getNumReduceTasks() > regions)
job.setNumReduceTasks(regions);
}
@@ -208,8 +207,7 @@ public class TableMapReduceUtil {
*/
public static void limitNumMapTasks(String table, JobConf job)
throws IOException {
- HTable outputTable = new HTable(HBaseConfiguration.create(job), table);
- int regions = outputTable.getRegionsInfo().size();
+ int regions = MetaReader.getRegionCount(HBaseConfiguration.create(job), table);
if (job.getNumMapTasks() > regions)
job.setNumMapTasks(regions);
}
@@ -224,9 +222,7 @@ public class TableMapReduceUtil {
*/
public static void setNumReduceTasks(String table, JobConf job)
throws IOException {
- HTable outputTable = new HTable(HBaseConfiguration.create(job), table);
- int regions = outputTable.getRegionsInfo().size();
- job.setNumReduceTasks(regions);
+ job.setNumReduceTasks(MetaReader.getRegionCount(HBaseConfiguration.create(job), table));
}
/**
@@ -239,9 +235,7 @@ public class TableMapReduceUtil {
*/
public static void setNumMapTasks(String table, JobConf job)
throws IOException {
- HTable outputTable = new HTable(HBaseConfiguration.create(job), table);
- int regions = outputTable.getRegionsInfo().size();
- job.setNumMapTasks(regions);
+ job.setNumMapTasks(MetaReader.getRegionCount(HBaseConfiguration.create(job), table));
}
/**
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableInputFormatBase.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableInputFormatBase.java?rev=1415766&r1=1415765&r2=1415766&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableInputFormatBase.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableInputFormatBase.java Fri Nov 30 17:50:44 2012
@@ -21,6 +21,7 @@ package org.apache.hadoop.hbase.mapreduc
import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.InetAddress;
+import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -33,7 +34,6 @@ import org.apache.hadoop.classification.
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionLocation;
-import org.apache.hadoop.hbase.HServerAddress;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.Scan;
@@ -160,8 +160,7 @@ extends InputFormat<ImmutableBytesWritab
Pair<byte[][], byte[][]> keys = table.getStartEndKeys();
if (keys == null || keys.getFirst() == null ||
keys.getFirst().length == 0) {
- HRegionLocation regLoc = table.getRegionLocation(
- HConstants.EMPTY_BYTE_ARRAY, false);
+ HRegionLocation regLoc = table.getRegionLocation(HConstants.EMPTY_BYTE_ARRAY, false);
if (null == regLoc) {
throw new IOException("Expecting at least one region.");
}
@@ -177,24 +176,26 @@ extends InputFormat<ImmutableBytesWritab
if ( !includeRegionInSplit(keys.getFirst()[i], keys.getSecond()[i])) {
continue;
}
- HServerAddress regionServerAddress =
- table.getRegionLocation(keys.getFirst()[i]).getServerAddress();
- InetAddress regionAddress =
- regionServerAddress.getInetSocketAddress().getAddress();
+ HRegionLocation location = table.getRegionLocation(keys.getFirst()[i], false);
+ // The below InetSocketAddress creation does a name resolution.
+ InetSocketAddress isa = new InetSocketAddress(location.getHostname(), location.getPort());
+ if (isa.isUnresolved()) {
+ LOG.warn("Failed resolve " + isa);
+ }
+ InetAddress regionAddress = isa.getAddress();
String regionLocation;
try {
regionLocation = reverseDNS(regionAddress);
} catch (NamingException e) {
- LOG.error("Cannot resolve the host name for " + regionAddress +
- " because of " + e);
- regionLocation = regionServerAddress.getHostname();
+ LOG.error("Cannot resolve the host name for " + regionAddress + " because of " + e);
+ regionLocation = location.getHostname();
}
- byte[] startRow = scan.getStartRow();
- byte[] stopRow = scan.getStopRow();
- // determine if the given start an stop key fall into the region
+ byte[] startRow = scan.getStartRow();
+ byte[] stopRow = scan.getStopRow();
+ // determine if the given start an stop key fall into the region
if ((startRow.length == 0 || keys.getSecond()[i].length == 0 ||
- Bytes.compareTo(startRow, keys.getSecond()[i]) < 0) &&
+ Bytes.compareTo(startRow, keys.getSecond()[i]) < 0) &&
(stopRow.length == 0 ||
Bytes.compareTo(stopRow, keys.getFirst()[i]) > 0)) {
byte[] splitStart = startRow.length == 0 ||
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableMapReduceUtil.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableMapReduceUtil.java?rev=1415766&r1=1415765&r2=1415766&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableMapReduceUtil.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableMapReduceUtil.java Fri Nov 30 17:50:44 2012
@@ -19,8 +19,8 @@
package org.apache.hadoop.hbase.mapreduce;
import java.io.IOException;
-import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLDecoder;
import java.util.Enumeration;
@@ -35,7 +35,7 @@ import org.apache.hadoop.conf.Configurat
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseConfiguration;
-import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.catalog.MetaReader;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
@@ -59,7 +59,7 @@ import com.google.protobuf.InvalidProtoc
@InterfaceStability.Stable
public class TableMapReduceUtil {
static Log LOG = LogFactory.getLog(TableMapReduceUtil.class);
-
+
/**
* Use this before submitting a TableMap job. It will appropriately set up
* the job.
@@ -75,7 +75,7 @@ public class TableMapReduceUtil {
*/
public static void initTableMapperJob(String table, Scan scan,
Class<? extends TableMapper> mapper,
- Class<?> outputKeyClass,
+ Class<?> outputKeyClass,
Class<?> outputValueClass, Job job)
throws IOException {
initTableMapperJob(table, scan, mapper, outputKeyClass, outputValueClass,
@@ -97,8 +97,8 @@ public class TableMapReduceUtil {
* @throws IOException When setting up the details fails.
*/
public static void initTableMapperJob(byte[] table, Scan scan,
- Class<? extends TableMapper> mapper,
- Class<?> outputKeyClass,
+ Class<? extends TableMapper> mapper,
+ Class<?> outputKeyClass,
Class<?> outputValueClass, Job job)
throws IOException {
initTableMapperJob(Bytes.toString(table), scan, mapper, outputKeyClass, outputValueClass,
@@ -141,7 +141,7 @@ public class TableMapReduceUtil {
}
initCredentials(job);
}
-
+
/**
* Use this before submitting a TableMap job. It will appropriately set up
* the job.
@@ -167,7 +167,7 @@ public class TableMapReduceUtil {
initTableMapperJob(Bytes.toString(table), scan, mapper, outputKeyClass,
outputValueClass, job, addDependencyJars, inputFormatClass);
}
-
+
/**
* Use this before submitting a TableMap job. It will appropriately set up
* the job.
@@ -192,7 +192,7 @@ public class TableMapReduceUtil {
initTableMapperJob(Bytes.toString(table), scan, mapper, outputKeyClass,
outputValueClass, job, addDependencyJars, TableInputFormat.class);
}
-
+
/**
* Use this before submitting a TableMap job. It will appropriately set up
* the job.
@@ -353,7 +353,7 @@ public class TableMapReduceUtil {
Class partitioner, String quorumAddress, String serverClass,
String serverImpl, boolean addDependencyJars) throws IOException {
- Configuration conf = job.getConfiguration();
+ Configuration conf = job.getConfiguration();
HBaseConfiguration.merge(conf, HBaseConfiguration.create(conf));
job.setOutputFormatClass(TableOutputFormat.class);
if (reducer != null) job.setReducerClass(reducer);
@@ -374,10 +374,9 @@ public class TableMapReduceUtil {
job.setOutputValueClass(Writable.class);
if (partitioner == HRegionPartitioner.class) {
job.setPartitionerClass(HRegionPartitioner.class);
- HTable outputTable = new HTable(conf, table);
- int regions = outputTable.getRegionsInfo().size();
+ int regions = MetaReader.getRegionCount(conf, table);
if (job.getNumReduceTasks() > regions) {
- job.setNumReduceTasks(outputTable.getRegionsInfo().size());
+ job.setNumReduceTasks(regions);
}
} else if (partitioner != null) {
job.setPartitionerClass(partitioner);
@@ -400,8 +399,7 @@ public class TableMapReduceUtil {
*/
public static void limitNumReduceTasks(String table, Job job)
throws IOException {
- HTable outputTable = new HTable(job.getConfiguration(), table);
- int regions = outputTable.getRegionsInfo().size();
+ int regions = MetaReader.getRegionCount(job.getConfiguration(), table);
if (job.getNumReduceTasks() > regions)
job.setNumReduceTasks(regions);
}
@@ -416,9 +414,7 @@ public class TableMapReduceUtil {
*/
public static void setNumReduceTasks(String table, Job job)
throws IOException {
- HTable outputTable = new HTable(job.getConfiguration(), table);
- int regions = outputTable.getRegionsInfo().size();
- job.setNumReduceTasks(regions);
+ job.setNumReduceTasks(MetaReader.getRegionCount(job.getConfiguration(), table));
}
/**
@@ -454,9 +450,9 @@ public class TableMapReduceUtil {
job.getCombinerClass());
} catch (ClassNotFoundException e) {
throw new IOException(e);
- }
+ }
}
-
+
/**
* Add the jars containing the given classes to the job's configuration
* such that JobClient will ship them to the cluster and add them to
@@ -539,9 +535,9 @@ public class TableMapReduceUtil {
* Find a jar that contains a class of the same name, if any.
* It will return a jar file, even if that is not the first thing
* on the class path that has a class with the same name.
- *
+ *
* This is shamelessly copied from JobConf
- *
+ *
* @param my_class the class to find.
* @return a jar file that contains the class, or null.
* @throws IOException
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java?rev=1415766&r1=1415765&r2=1415766&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java Fri Nov 30 17:50:44 2012
@@ -53,6 +53,7 @@ import org.apache.hadoop.hbase.HRegionIn
import org.apache.hadoop.hbase.HRegionLocation;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.ServerName;
+import org.apache.hadoop.hbase.catalog.MetaReader;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.NoServerForRegionException;
@@ -370,20 +371,18 @@ public class RegionSplitter {
Preconditions.checkArgument(!admin.tableExists(tableName),
"Table already exists: " + tableName);
admin.createTable(desc, splitAlgo.split(splitCount));
+ admin.close();
LOG.debug("Table created! Waiting for regions to show online in META...");
-
if (!conf.getBoolean("split.verify", true)) {
// NOTE: createTable is synchronous on the table, but not on the regions
- HTable table = new HTable(conf, tableName);
int onlineRegions = 0;
while (onlineRegions < splitCount) {
- onlineRegions = table.getRegionsInfo().size();
+ onlineRegions = MetaReader.getRegionCount(conf, tableName);
LOG.debug(onlineRegions + " of " + splitCount + " regions online...");
if (onlineRegions < splitCount) {
Thread.sleep(10 * 1000); // sleep
}
}
- table.close();
}
LOG.debug("Finished creating table with " + splitCount + " regions");
@@ -1019,4 +1018,4 @@ public class RegionSplitter {
+ "," + rowToStr(lastRow()) + "]";
}
}
-}
+}
\ No newline at end of file
Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java?rev=1415766&r1=1415765&r2=1415766&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java Fri Nov 30 17:50:44 2012
@@ -343,7 +343,7 @@ public class TestAdmin {
public void testHColumnValidName() {
boolean exceptionThrown = false;
try {
- HColumnDescriptor fam1 = new HColumnDescriptor("\\test\\abc");
+ new HColumnDescriptor("\\test\\abc");
} catch(IllegalArgumentException iae) {
exceptionThrown = true;
assertTrue(exceptionThrown);
@@ -526,10 +526,10 @@ public class TestAdmin {
protected void verifyRoundRobinDistribution(HTable ht, int expectedRegions) throws IOException {
int numRS = ht.getConnection().getCurrentNrHRS();
- Map<HRegionInfo,HServerAddress> regions = ht.getRegionsInfo();
- Map<HServerAddress, List<HRegionInfo>> server2Regions = new HashMap<HServerAddress, List<HRegionInfo>>();
- for (Map.Entry<HRegionInfo,HServerAddress> entry : regions.entrySet()) {
- HServerAddress server = entry.getValue();
+ Map<HRegionInfo, ServerName> regions = ht.getRegionLocations();
+ Map<ServerName, List<HRegionInfo>> server2Regions = new HashMap<ServerName, List<HRegionInfo>>();
+ for (Map.Entry<HRegionInfo, ServerName> entry : regions.entrySet()) {
+ ServerName server = entry.getValue();
List<HRegionInfo> regs = server2Regions.get(server);
if (regs == null) {
regs = new ArrayList<HRegionInfo>();
@@ -568,7 +568,7 @@ public class TestAdmin {
admin.createTable(desc, splitKeys);
HTable ht = new HTable(TEST_UTIL.getConfiguration(), tableName);
- Map<HRegionInfo,HServerAddress> regions = ht.getRegionsInfo();
+ Map<HRegionInfo, ServerName> regions = ht.getRegionLocations();
assertEquals("Tried to create " + expectedRegions + " regions " +
"but only found " + regions.size(),
expectedRegions, regions.size());
@@ -628,7 +628,7 @@ public class TestAdmin {
admin.createTable(desc, startKey, endKey, expectedRegions);
HTable ht2 = new HTable(TEST_UTIL.getConfiguration(), TABLE_2);
- regions = ht2.getRegionsInfo();
+ regions = ht2.getRegionLocations();
assertEquals("Tried to create " + expectedRegions + " regions " +
"but only found " + regions.size(),
expectedRegions, regions.size());
@@ -685,7 +685,7 @@ public class TestAdmin {
HTable ht3 = new HTable(TEST_UTIL.getConfiguration(), TABLE_3);
- regions = ht3.getRegionsInfo();
+ regions = ht3.getRegionLocations();
assertEquals("Tried to create " + expectedRegions + " regions " +
"but only found " + regions.size(),
expectedRegions, regions.size());
@@ -792,7 +792,7 @@ public class TestAdmin {
desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY));
admin.createTable(desc, splitKeys);
HTable ht = new HTable(TEST_UTIL.getConfiguration(), tableName);
- Map<HRegionInfo, HServerAddress> regions = ht.getRegionsInfo();
+ Map<HRegionInfo, ServerName> regions = ht.getRegionLocations();
ht.close();
assertEquals("Tried to create " + expectedRegions + " regions "
+ "but only found " + regions.size(), expectedRegions, regions.size());
@@ -819,6 +819,7 @@ public class TestAdmin {
regioncount++;
serverMap.put(server, regioncount);
}
+ metaTable.close();
List<Map.Entry<String, Integer>> entryList = new ArrayList<Map.Entry<String, Integer>>(
serverMap.entrySet());
Collections.sort(entryList, new Comparator<Map.Entry<String, Integer>>() {
@@ -893,7 +894,7 @@ public class TestAdmin {
}
// get the initial layout (should just be one region)
- Map<HRegionInfo,HServerAddress> m = table.getRegionsInfo();
+ Map<HRegionInfo, ServerName> m = table.getRegionLocations();
System.out.println("Initial regions (" + m.size() + "): " + m);
assertTrue(m.size() == 1);
@@ -923,9 +924,9 @@ public class TestAdmin {
continue;
}
// check again table = new HTable(conf, tableName);
- Map<HRegionInfo, HServerAddress> regions = null;
+ Map<HRegionInfo, ServerName> regions = null;
try {
- regions = table.getRegionsInfo();
+ regions = table.getRegionLocations();
} catch (IOException e) {
e.printStackTrace();
}
@@ -953,9 +954,9 @@ public class TestAdmin {
scanner.close();
assertEquals(rowCount, rows);
- Map<HRegionInfo, HServerAddress> regions = null;
+ Map<HRegionInfo, ServerName> regions = null;
try {
- regions = table.getRegionsInfo();
+ regions = table.getRegionLocations();
} catch (IOException e) {
e.printStackTrace();
}
@@ -991,7 +992,7 @@ public class TestAdmin {
* @throws IOException
*/
@Test (expected=IllegalArgumentException.class)
- public void testEmptyHHTableDescriptor() throws IOException {
+ public void testEmptyHTableDescriptor() throws IOException {
this.admin.createTable(new HTableDescriptor());
}
@@ -1223,8 +1224,7 @@ public class TestAdmin {
*/
@Test (expected=TableNotFoundException.class)
public void testTableNotFoundExceptionWithoutAnyTables() throws IOException {
- new HTable(TEST_UTIL.getConfiguration(),
- "testTableNotFoundExceptionWithoutAnyTables");
+ new HTable(TEST_UTIL.getConfiguration(),"testTableNotFoundExceptionWithoutAnyTables");
}
@Test
public void testShouldCloseTheRegionBasedOnTheEncodedRegionName()
Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java?rev=1415766&r1=1415765&r2=1415766&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java Fri Nov 30 17:50:44 2012
@@ -18,11 +18,15 @@
*/
package org.apache.hadoop.hbase.client;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.ArrayList;
@@ -44,8 +48,18 @@ import java.util.concurrent.atomic.Atomi
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.*;
+import org.apache.hadoop.hbase.Abortable;
+import org.apache.hadoop.hbase.DoNotRetryIOException;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.HColumnDescriptor;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.HRegionLocation;
+import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.LargeTests;
+import org.apache.hadoop.hbase.MiniHBaseCluster;
+import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.client.metrics.ScanMetrics;
import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
import org.apache.hadoop.hbase.coprocessor.MultiRowMutationEndpoint;
@@ -86,8 +100,6 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import static org.junit.Assert.*;
-
/**
* Run tests that use the HBase clients; {@link HTable} and {@link HTablePool}.
* Sets up the HBase mini cluster once at start and runs through all client tests.
@@ -292,77 +304,6 @@ public class TestFromClientSide {
}
}
-
- /**
- * HBASE-2468 use case 1 and 2: region info de/serialization
- */
- @Test
- public void testRegionCacheDeSerialization() throws Exception {
- // 1. test serialization.
- LOG.info("Starting testRegionCacheDeSerialization");
- final byte[] TABLENAME = Bytes.toBytes("testCachePrewarm2");
- final byte[] FAMILY = Bytes.toBytes("family");
- Configuration conf = TEST_UTIL.getConfiguration();
- TEST_UTIL.createTable(TABLENAME, FAMILY);
-
- // Set up test table:
- // Create table:
- HTable table = new HTable(conf, TABLENAME);
-
- // Create multiple regions for this table
- TEST_UTIL.createMultiRegions(table, FAMILY);
- Scan s = new Scan();
- ResultScanner scanner = table.getScanner(s);
- while (scanner.next() != null) continue;
-
- Path tempPath = new Path(TEST_UTIL.getDataTestDir(), "regions.dat");
-
- final String tempFileName = tempPath.toString();
-
- FileOutputStream fos = new FileOutputStream(tempFileName);
- DataOutputStream dos = new DataOutputStream(fos);
-
- // serialize the region info and output to a local file.
- table.serializeRegionInfo(dos);
- dos.flush();
- dos.close();
-
- // read a local file and deserialize the region info from it.
- FileInputStream fis = new FileInputStream(tempFileName);
- DataInputStream dis = new DataInputStream(fis);
-
- Map<HRegionInfo, HServerAddress> deserRegions =
- table.deserializeRegionInfo(dis);
- dis.close();
-
- // regions obtained from meta scanner.
- Map<HRegionInfo, HServerAddress> loadedRegions =
- table.getRegionsInfo();
-
- // set the deserialized regions to the global cache.
- table.getConnection().clearRegionCache();
-
- table.getConnection().prewarmRegionCache(table.getTableName(),
- deserRegions);
-
- // verify whether the 2 maps are identical or not.
- assertEquals("Number of cached region is incorrect",
- HConnectionManager.getCachedRegionCount(conf, TABLENAME),
- loadedRegions.size());
-
- // verify each region is prefetched or not.
- for (Map.Entry<HRegionInfo, HServerAddress> e: loadedRegions.entrySet()) {
- HRegionInfo hri = e.getKey();
- assertTrue(HConnectionManager.isRegionCached(conf,
- hri.getTableName(), hri.getStartKey()));
- }
-
- // delete the temp file
- File f = new java.io.File(tempFileName);
- f.delete();
- LOG.info("Finishing testRegionCacheDeSerialization");
- }
-
/**
* HBASE-2468 use case 3:
*/
@@ -600,7 +541,7 @@ public class TestFromClientSide {
int rowCount = TEST_UTIL.loadTable(t, FAMILY);
assertRowCount(t, rowCount);
// Split the table. Should split on a reasonable key; 'lqj'
- Map<HRegionInfo, HServerAddress> regions = splitTable(t);
+ Map<HRegionInfo, ServerName> regions = splitTable(t);
assertRowCount(t, rowCount);
// Get end key of first region.
byte [] endKey = regions.keySet().iterator().next().getEndKey();
@@ -702,12 +643,13 @@ public class TestFromClientSide {
* @return Map of regions to servers.
* @throws IOException
*/
- private Map<HRegionInfo, HServerAddress> splitTable(final HTable t)
+ private Map<HRegionInfo, ServerName> splitTable(final HTable t)
throws IOException, InterruptedException {
// Split this table in two.
HBaseAdmin admin = new HBaseAdmin(TEST_UTIL.getConfiguration());
admin.split(t.getTableName());
- Map<HRegionInfo, HServerAddress> regions = waitOnSplit(t);
+ admin.close();
+ Map<HRegionInfo, ServerName> regions = waitOnSplit(t);
assertTrue(regions.size() > 1);
return regions;
}
@@ -718,9 +660,9 @@ public class TestFromClientSide {
* @param t
* @return Map of table regions; caller needs to check table actually split.
*/
- private Map<HRegionInfo, HServerAddress> waitOnSplit(final HTable t)
+ private Map<HRegionInfo, ServerName> waitOnSplit(final HTable t)
throws IOException {
- Map<HRegionInfo, HServerAddress> regions = t.getRegionsInfo();
+ Map<HRegionInfo, ServerName> regions = t.getRegionLocations();
int originalCount = regions.size();
for (int i = 0; i < TEST_UTIL.getConfiguration().getInt("hbase.test.retries", 30); i++) {
Thread.currentThread();
@@ -729,7 +671,7 @@ public class TestFromClientSide {
} catch (InterruptedException e) {
e.printStackTrace();
}
- regions = t.getRegionsInfo();
+ regions = t.getRegionLocations();
if (regions.size() > originalCount) break;
}
return regions;
@@ -4902,11 +4844,8 @@ public class TestFromClientSide {
HRegionInfo regionInfo = regionsMap.keySet().iterator().next();
ServerName addrBefore = regionsMap.get(regionInfo);
// Verify region location before move.
- HServerAddress addrCache =
- table.getRegionLocation(regionInfo.getStartKey(), false).getServerAddress();
- HServerAddress addrNoCache =
- table.getRegionLocation(regionInfo.getStartKey(),
- true).getServerAddress();
+ HRegionLocation addrCache = table.getRegionLocation(regionInfo.getStartKey(), false);
+ HRegionLocation addrNoCache = table.getRegionLocation(regionInfo.getStartKey(), true);
assertEquals(addrBefore.getPort(), addrCache.getPort());
assertEquals(addrBefore.getPort(), addrNoCache.getPort());
@@ -4927,11 +4866,8 @@ public class TestFromClientSide {
}
// Verify the region was moved.
- addrCache =
- table.getRegionLocation(regionInfo.getStartKey(), false).getServerAddress();
- addrNoCache =
- table.getRegionLocation(regionInfo.getStartKey(),
- true).getServerAddress();
+ addrCache = table.getRegionLocation(regionInfo.getStartKey(), false);
+ addrNoCache = table.getRegionLocation(regionInfo.getStartKey(), true);
assertNotNull(addrAfter);
assertTrue(addrAfter.getPort() != addrCache.getPort());
assertEquals(addrAfter.getPort(), addrNoCache.getPort());
Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/io/TestHbaseObjectWritable.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/io/TestHbaseObjectWritable.java?rev=1415766&r1=1415765&r2=1415766&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/io/TestHbaseObjectWritable.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/io/TestHbaseObjectWritable.java Fri Nov 30 17:50:44 2012
@@ -40,8 +40,6 @@ import org.apache.hadoop.hbase.HBaseConf
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionInfo;
-import org.apache.hadoop.hbase.HServerAddress;
-import org.apache.hadoop.hbase.HServerInfo;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.SmallTests;
@@ -486,8 +484,7 @@ public class TestHbaseObjectWritable ext
assertEquals(23,HbaseObjectWritable.getClassCode(HRegion[].class).intValue());
assertEquals(24,HbaseObjectWritable.getClassCode(HRegionInfo.class).intValue());
assertEquals(25,HbaseObjectWritable.getClassCode(HRegionInfo[].class).intValue());
- assertEquals(26,HbaseObjectWritable.getClassCode(HServerAddress.class).intValue());
- assertEquals(27,HbaseObjectWritable.getClassCode(HServerInfo.class).intValue());
+ // Intentional hole... these objects have been removed.
assertEquals(28,HbaseObjectWritable.getClassCode(HTableDescriptor.class).intValue());
assertEquals(29,HbaseObjectWritable.getClassCode(MapWritable.class).intValue());
Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat.java?rev=1415766&r1=1415765&r2=1415766&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat.java Fri Nov 30 17:50:44 2012
@@ -358,11 +358,11 @@ public class TestHFileOutputFormat {
util = new HBaseTestingUtility();
Configuration conf = util.getConfiguration();
byte[][] startKeys = generateRandomStartKeys(5);
-
+ HBaseAdmin admin = null;
try {
util.startMiniCluster();
Path testDir = util.getDataTestDirOnTestFS("testLocalMRIncrementalLoad");
- HBaseAdmin admin = new HBaseAdmin(conf);
+ admin = new HBaseAdmin(conf);
HTable table = util.createTable(TABLE_NAME, FAMILIES);
assertEquals("Should start with empty table",
0, util.countRows(table));
@@ -402,7 +402,7 @@ public class TestHFileOutputFormat {
util.createMultiRegions(
util.getConfiguration(), table, FAMILIES[0], newStartKeys);
admin.enableTable(table.getTableName());
- while (table.getRegionsInfo().size() != 15 ||
+ while (table.getRegionLocations().size() != 15 ||
!admin.isTableAvailable(table.getTableName())) {
Thread.sleep(200);
LOG.info("Waiting for new region assignment to happen");
@@ -440,6 +440,7 @@ public class TestHFileOutputFormat {
assertEquals("Data should remain after reopening of regions",
tableDigestBefore, util.checksumRows(table));
} finally {
+ if (admin != null) admin.close();
util.shutdownMiniMapReduceCluster();
util.shutdownMiniCluster();
}
@@ -456,8 +457,7 @@ public class TestHFileOutputFormat {
Assert.assertFalse( util.getTestFileSystem().exists(outDir)) ;
- assertEquals(table.getRegionsInfo().size(),
- job.getNumReduceTasks());
+ assertEquals(table.getRegionLocations().size(), job.getNumReduceTasks());
assertTrue(job.waitForCompletion(true));
}
Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestEndToEndSplitTransaction.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestEndToEndSplitTransaction.java?rev=1415766&r1=1415765&r2=1415766&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestEndToEndSplitTransaction.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestEndToEndSplitTransaction.java Fri Nov 30 17:50:44 2012
@@ -37,7 +37,6 @@ import org.apache.hadoop.hbase.Chore;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionInfo;
-import org.apache.hadoop.hbase.HServerAddress;
import org.apache.hadoop.hbase.LargeTests;
import org.apache.hadoop.hbase.NotServingRegionException;
import org.apache.hadoop.hbase.ServerName;
@@ -419,7 +418,7 @@ public class TestEndToEndSplitTransactio
verifyStartEndKeys(keys);
//HTable.getRegionsInfo()
- Map<HRegionInfo, HServerAddress> regions = table.getRegionsInfo();
+ Map<HRegionInfo, ServerName> regions = table.getRegionLocations();
verifyTableRegions(regions.keySet());
} finally {
IOUtils.closeQuietly(table);
Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java?rev=1415766&r1=1415765&r2=1415766&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/rest/TestTableResource.java Fri Nov 30 17:50:44 2012
@@ -57,7 +57,7 @@ public class TestTableResource {
private static String TABLE = "TestTableResource";
private static String COLUMN_FAMILY = "test";
private static String COLUMN = COLUMN_FAMILY + ":qualifier";
- private static Map<HRegionInfo,HServerAddress> regionMap;
+ private static Map<HRegionInfo, ServerName> regionMap;
private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
private static final HBaseRESTTestingUtility REST_TEST_UTIL =
@@ -101,7 +101,7 @@ public class TestTableResource {
}
table.flushCommits();
// get the initial layout (should just be one region)
- Map<HRegionInfo,HServerAddress> m = table.getRegionsInfo();
+ Map<HRegionInfo, ServerName> m = table.getRegionLocations();
assertEquals(m.size(), 1);
// tell the master to split the table
admin.split(TABLE);
@@ -115,7 +115,7 @@ public class TestTableResource {
LOG.warn(StringUtils.stringifyException(e));
}
// check again
- m = table.getRegionsInfo();
+ m = table.getRegionLocations();
}
// should have two regions now
@@ -152,7 +152,7 @@ public class TestTableResource {
while (regions.hasNext()) {
TableRegionModel region = regions.next();
boolean found = false;
- for (Map.Entry<HRegionInfo,HServerAddress> e: regionMap.entrySet()) {
+ for (Map.Entry<HRegionInfo, ServerName> e: regionMap.entrySet()) {
HRegionInfo hri = e.getKey();
String hriRegionName = hri.getRegionNameAsString();
String regionName = region.getName();
@@ -160,7 +160,7 @@ public class TestTableResource {
found = true;
byte[] startKey = hri.getStartKey();
byte[] endKey = hri.getEndKey();
- InetSocketAddress sa = e.getValue().getInetSocketAddress();
+ InetSocketAddress sa = new InetSocketAddress(e.getValue().getHostname(), e.getValue().getPort());
String location = sa.getHostName() + ":" +
Integer.valueOf(sa.getPort());
assertEquals(hri.getRegionId(), region.getId());
Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java?rev=1415766&r1=1415765&r2=1415766&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java Fri Nov 30 17:50:44 2012
@@ -18,8 +18,6 @@
package org.apache.hadoop.hbase.security.access;
-import static org.apache.hadoop.hbase.protobuf.generated.AccessControlProtos.AccessControlService;
-import static org.apache.hadoop.hbase.protobuf.generated.AccessControlProtos.CheckPermissionsRequest;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -29,17 +27,11 @@ import java.security.PrivilegedException
import java.util.List;
import java.util.Map;
-import com.google.common.collect.Lists;
-import com.google.protobuf.BlockingRpcChannel;
-import com.google.protobuf.ByteString;
-import com.google.protobuf.RpcChannel;
-import com.google.protobuf.ServiceException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Coprocessor;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HRegionInfo;
-import org.apache.hadoop.hbase.HServerAddress;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.LargeTests;
import org.apache.hadoop.hbase.ServerName;
@@ -54,13 +46,14 @@ import org.apache.hadoop.hbase.client.Re
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException;
import org.apache.hadoop.hbase.client.Scan;
-import org.apache.hadoop.hbase.coprocessor.CoprocessorException;
import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment;
import org.apache.hadoop.hbase.coprocessor.ObserverContext;
import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
import org.apache.hadoop.hbase.master.MasterCoprocessorHost;
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.protobuf.generated.AccessControlProtos;
+import org.apache.hadoop.hbase.protobuf.generated.AccessControlProtos.AccessControlService;
+import org.apache.hadoop.hbase.protobuf.generated.AccessControlProtos.CheckPermissionsRequest;
import org.apache.hadoop.hbase.regionserver.HRegion;
import org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost;
import org.apache.hadoop.hbase.security.AccessDeniedException;
@@ -72,6 +65,11 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
+import com.google.common.collect.Lists;
+import com.google.protobuf.BlockingRpcChannel;
+import com.google.protobuf.ByteString;
+import com.google.protobuf.ServiceException;
+
/**
* Performs authorization checks for common operations, according to different
* levels of authorized users.
@@ -385,8 +383,8 @@ public class TestAccessController {
@Test
public void testMove() throws Exception {
HTable table = new HTable(TEST_UTIL.getConfiguration(), TEST_TABLE);
- Map<HRegionInfo, HServerAddress> regions = table.getRegionsInfo();
- final Map.Entry<HRegionInfo, HServerAddress> firstRegion = regions.entrySet().iterator().next();
+ Map<HRegionInfo, ServerName> regions = table.getRegionLocations();
+ final Map.Entry<HRegionInfo, ServerName> firstRegion = regions.entrySet().iterator().next();
final ServerName server = TEST_UTIL.getHBaseCluster().getRegionServer(0).getServerName();
PrivilegedExceptionAction action = new PrivilegedExceptionAction() {
public Object run() throws Exception {
@@ -403,8 +401,8 @@ public class TestAccessController {
@Test
public void testAssign() throws Exception {
HTable table = new HTable(TEST_UTIL.getConfiguration(), TEST_TABLE);
- Map<HRegionInfo, HServerAddress> regions = table.getRegionsInfo();
- final Map.Entry<HRegionInfo, HServerAddress> firstRegion = regions.entrySet().iterator().next();
+ Map<HRegionInfo, ServerName> regions = table.getRegionLocations();
+ final Map.Entry<HRegionInfo, ServerName> firstRegion = regions.entrySet().iterator().next();
PrivilegedExceptionAction action = new PrivilegedExceptionAction() {
public Object run() throws Exception {
@@ -421,8 +419,8 @@ public class TestAccessController {
@Test
public void testUnassign() throws Exception {
HTable table = new HTable(TEST_UTIL.getConfiguration(), TEST_TABLE);
- Map<HRegionInfo, HServerAddress> regions = table.getRegionsInfo();
- final Map.Entry<HRegionInfo, HServerAddress> firstRegion = regions.entrySet().iterator().next();
+ Map<HRegionInfo, ServerName> regions = table.getRegionLocations();
+ final Map.Entry<HRegionInfo, ServerName> firstRegion = regions.entrySet().iterator().next();
PrivilegedExceptionAction action = new PrivilegedExceptionAction() {
public Object run() throws Exception {
Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestRegionSplitter.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestRegionSplitter.java?rev=1415766&r1=1415765&r2=1415766&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestRegionSplitter.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestRegionSplitter.java Fri Nov 30 17:50:44 2012
@@ -18,12 +18,13 @@
*/
package org.apache.hadoop.hbase.util;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertTrue;
-import java.io.IOException;
-import java.math.BigInteger;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -31,9 +32,11 @@ import org.apache.commons.lang.ArrayUtil
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.*;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.MediumTests;
+import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.util.RegionSplitter.HexStringSplit;
import org.apache.hadoop.hbase.util.RegionSplitter.SplitAlgorithm;
import org.apache.hadoop.hbase.util.RegionSplitter.UniformSplit;
@@ -296,11 +299,9 @@ public class TestRegionSplitter {
final Configuration conf = UTIL.getConfiguration();
final int numRegions = expectedBounds.size()-1;
final HTable hTable = new HTable(conf, tableName.getBytes());
- final Map<HRegionInfo, HServerAddress> regionInfoMap =
- hTable.getRegionsInfo();
+ final Map<HRegionInfo, ServerName> regionInfoMap = hTable.getRegionLocations();
assertEquals(numRegions, regionInfoMap.size());
- for (Map.Entry<HRegionInfo, HServerAddress> entry:
- regionInfoMap.entrySet()) {
+ for (Map.Entry<HRegionInfo, ServerName> entry: regionInfoMap.entrySet()) {
final HRegionInfo regionInfo = entry.getKey();
byte[] regionStart = regionInfo.getStartKey();
byte[] regionEnd = regionInfo.getEndKey();
Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/OfflineMetaRebuildTestCore.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/OfflineMetaRebuildTestCore.java?rev=1415766&r1=1415765&r2=1415766&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/OfflineMetaRebuildTestCore.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/util/hbck/OfflineMetaRebuildTestCore.java Fri Nov 30 17:50:44 2012
@@ -35,9 +35,9 @@ import org.apache.hadoop.hbase.HBaseTest
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionInfo;
-import org.apache.hadoop.hbase.HServerAddress;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.LargeTests;
+import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.catalog.MetaEditor;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.HBaseAdmin;
@@ -169,10 +169,10 @@ public class OfflineMetaRebuildTestCore
HTableDescriptor htd = tbl.getTableDescriptor();
dumpMeta(htd);
- Map<HRegionInfo, HServerAddress> hris = tbl.getRegionsInfo();
- for (Entry<HRegionInfo, HServerAddress> e : hris.entrySet()) {
+ Map<HRegionInfo, ServerName> hris = tbl.getRegionLocations();
+ for (Entry<HRegionInfo, ServerName> e : hris.entrySet()) {
HRegionInfo hri = e.getKey();
- HServerAddress hsa = e.getValue();
+ ServerName hsa = e.getValue();
if (Bytes.compareTo(hri.getStartKey(), startKey) == 0
&& Bytes.compareTo(hri.getEndKey(), endKey) == 0) {
@@ -190,6 +190,7 @@ public class OfflineMetaRebuildTestCore
HTable meta = new HTable(conf, HConstants.META_TABLE_NAME);
Delete delete = new Delete(deleteRow);
meta.delete(delete);
+ meta.close();
}
LOG.info(hri.toString() + hsa.toString());
}
@@ -257,6 +258,7 @@ public class OfflineMetaRebuildTestCore
Result rt : rst) {
count++;
}
+ t.close();
return count;
}
@@ -274,6 +276,7 @@ public class OfflineMetaRebuildTestCore
LOG.info(Bytes.toString(res.getRow()));
count++;
}
+ meta.close();
return count;
}
}