.META..
- *
+ *
* This class is "read-only" in that the locations of the catalog tables cannot
* be explicitly set. Instead, ZooKeeper is used to learn of the availability
* and location of .META..
@@ -65,7 +65,7 @@ public class CatalogTracker {
// servers when they needed to know of meta movement but also by
// client-side (inside in HTable) so rather than figure meta
// locations on fault, the client would instead get notifications out of zk.
- //
+ //
// But this original intent is frustrated by the fact that this class has to
// read an hbase table, the -ROOT- table, to figure out the .META. region
// location which means we depend on an HConnection. HConnection will do
@@ -110,13 +110,6 @@ public class CatalogTracker {
private boolean instantiatedzkw = false;
private Abortable abortable;
- /*
- * Do not clear this address once set. Its needed when we do
- * server shutdown processing -- we need to know who had .META. last. If you
- * want to know if the address is good, rely on {@link #metaAvailable} value.
- */
- private ServerName metaLocation;
-
private boolean stopped = false;
static final byte [] META_REGION_NAME =
@@ -147,7 +140,7 @@ public class CatalogTracker {
* @param abortable If fatal exception we'll call abort on this. May be null.
* If it is we'll use the Connection associated with the passed
* {@link Configuration} as our Abortable.
- * @throws IOException
+ * @throws IOException
*/
public CatalogTracker(final ZooKeeperWatcher zk, final Configuration conf,
Abortable abortable)
@@ -193,7 +186,7 @@ public class CatalogTracker {
* Determines current availability of catalog tables and ensures all further
* transitions of either region are tracked.
* @throws IOException
- * @throws InterruptedException
+ * @throws InterruptedException
*/
public void start() throws IOException, InterruptedException {
LOG.debug("Starting catalog tracker " + this);
@@ -235,7 +228,7 @@ public class CatalogTracker {
* not currently available.
* @return {@link ServerName} for server hosting .META. or null
* if none available
- * @throws InterruptedException
+ * @throws InterruptedException
*/
public ServerName getMetaLocation() throws InterruptedException {
return this.metaRegionTracker.getMetaRegionLocation();
@@ -309,8 +302,6 @@ public class CatalogTracker {
LOG.info(".META. still not available, sleeping and retrying." +
" Reason: " + e.getMessage());
}
- } catch (IOException e) {
- LOG.info("Retrying", e);
}
}
}
@@ -356,7 +347,7 @@ public class CatalogTracker {
} else {
throw ioe;
}
-
+
}
return protocol;
}
@@ -406,7 +397,7 @@ public class CatalogTracker {
}
}
LOG.info("Failed verification of " + Bytes.toStringBinary(regionName) +
- " at address=" + address + "; " + t);
+ " at address=" + address + ", exception=" + t);
return false;
}
@@ -416,7 +407,7 @@ public class CatalogTracker {
* the internal call to {@link #waitForMetaServerConnection(long)}.
* @return True if the .META. location is healthy.
* @throws IOException
- * @throws InterruptedException
+ * @throws InterruptedException
*/
public boolean verifyMetaRegionLocation(final long timeout)
throws InterruptedException, IOException {
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Action.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Action.java
index ba14702..9a41fcb 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Action.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Action.java
@@ -63,6 +63,11 @@ public class Action@@ -66,10 +65,21 @@ public class Append extends Mutation { * Create a Append operation for the specified row. *
* At least one column must be appended to. - * @param row row key + * @param row row key; makes a local copy of passed in array. */ public Append(byte[] row) { - this.row = Arrays.copyOf(row, row.length); + this.row = Bytes.copy(row); + } + + /** Create a Append operation for the specified row. + *
+ * At least one column must be appended to.
+ * @param rowArray Makes a copy out of this buffer.
+ * @param rowOffset
+ * @param rowLength
+ */
+ public Append(final byte [] rowArray, final int rowOffset, final int rowLength) {
+ this.row = Bytes.copy(rowArray, rowOffset, rowLength);
}
/**
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Delete.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Delete.java
index 0db0167..f22c4ed 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Delete.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Delete.java
@@ -28,6 +28,7 @@ import org.apache.hadoop.hbase.util.Bytes;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -96,6 +97,25 @@ public class Delete extends Mutation implements Comparable
+ *
+ * If no further operations are done, this will delete all columns in all
+ * families of the specified row with a timestamp less than or equal to the
+ * specified timestamp.
+ *
+ * This timestamp is ONLY used for a delete row operation. If specifying
+ * families or columns, you must specify each timestamp individually.
+ * @param rowArray We make a local copy of this passed in row.
+ * @param rowOffset
+ * @param rowLength
+ * @param ts maximum version timestamp (only for delete row)
+ */
+ public Delete(final byte [] rowArray, final int rowOffset, final int rowLength, long ts) {
+ this.row = Bytes.copy(rowArray, rowOffset, rowLength);
+ this.ts = ts;
+ }
+
+ /**
* @param d Delete to clone.
*/
public Delete(final Delete d) {
@@ -121,10 +141,8 @@ public class Delete extends Mutation implements Comparable
* At least one column must be incremented.
- * @param row row key
+ * @param row row key (we will make a copy of this).
*/
public Increment(byte [] row) {
- if (row == null || row.length > HConstants.MAX_ROW_LENGTH) {
+ this(row, 0, row.length);
+ }
+
+ /**
+ * Create a Increment operation for the specified row.
+ *
+ * At least one column must be incremented.
+ * @param row row key (we will make a copy of this).
+ */
+ public Increment(final byte [] row, final int offset, final int length) {
+ if (row == null || length <= 0 || length > HConstants.MAX_ROW_LENGTH) {
throw new IllegalArgumentException("Row key is invalid");
}
- this.row = Arrays.copyOf(row, row.length);
+ this.row = Bytes.copy(row, offset, length);
+ }
+
+ /**
+ * Add the specified KeyValue to this operation.
+ * @param cell individual Cell
+ * @return this
+ * @throws java.io.IOException e
+ */
+ @SuppressWarnings("unchecked")
+ public Increment add(Cell cell) throws IOException{
+ KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
+ byte [] family = kv.getFamily();
+ List extends Cell> list = getCellList(family);
+ //Checking that the row of the kv is the same as the put
+ int res = Bytes.compareTo(this.row, 0, row.length,
+ kv.getBuffer(), kv.getRowOffset(), kv.getRowLength());
+ if (res != 0) {
+ throw new WrongRowIOException("The row in " + kv.toString() +
+ " doesn't match the original one " + Bytes.toStringBinary(this.row));
+ }
+ ((List