Index: src/contrib/hbase/src/java/org/apache/hadoop/hbase/HConnectionManager.java =================================================================== --- src/contrib/hbase/src/java/org/apache/hadoop/hbase/HConnectionManager.java (revision 598834) +++ src/contrib/hbase/src/java/org/apache/hadoop/hbase/HConnectionManager.java (working copy) @@ -503,9 +503,6 @@ } if (!waited) { try { - for (int tries = 0; tries < numRetries; tries++) { - boolean success = true; // assume this works - SortedMap metaServers = this.tablesToServers.get(META_TABLE_NAME); if (metaServers == null) { @@ -515,22 +512,9 @@ metaServers = metaServers.tailMap(firstMetaRegion); for (HRegionLocation t: metaServers.values()) { - try { srvrs.putAll(scanOneMetaRegion(t, tableName)); - - } catch (IOException e) { - if (tries < numRetries - 1) { - metaServers = findServersForTable(META_TABLE_NAME); - success = false; - break; - } - throw e; - } } - if (success) { - break; - } - } + } finally { synchronized (this.tablesBeingLocated) { // Wake up the threads waiting for us to find the table @@ -738,9 +722,6 @@ regionInfo, new HServerAddress(serverAddress))); } } catch (IOException e) { - if (e instanceof TableNotFoundException) { - throw e; // don't retry - } if (tries == numRetries - 1) { // no retries left if (e instanceof RemoteException) { e = RemoteExceptionHandler.decodeRemoteException((RemoteException) e); Index: src/contrib/hbase/src/java/org/apache/hadoop/hbase/HTable.java =================================================================== --- src/contrib/hbase/src/java/org/apache/hadoop/hbase/HTable.java (revision 598834) +++ src/contrib/hbase/src/java/org/apache/hadoop/hbase/HTable.java (working copy) @@ -573,6 +573,32 @@ * Start an atomic row insertion/update. No changes are committed until the * call to commit() returns. A call to abort() will abandon any updates in * progress. + * + *

+ * Example: + *
+ *


+   * long lockid = table.startUpdate(new Text(article.getName()));
+   * for (File articleInfo: article.listFiles(new NonDirectories())) {
+   *   String article = null;
+   *   try {
+   *     DataInputStream in = new DataInputStream(new FileInputStream(articleInfo));
+   *     article = in.readUTF();
+   *   } catch (IOException e) {
+   *     // Input error - abandon update
+   *     table.abort(lockid);
+   *     throw e;
+   *   }
+   *   try {
+   *     table.put(lockid, columnName(articleInfo.getName()), article.getBytes());
+   *   } catch (RuntimeException e) {
+   *     // Put failed - abandon update
+   *     table.abort(lockid);
+   *     throw e;
+   *   }
+   * }
+   * table.commit(lockid);
+   * 
* * * @param row Name of row to start update against. Note, choose row names @@ -686,7 +712,12 @@ } /** - * Abort a row mutation + * Abort a row mutation. + * + * This method should be called only when an update has been started and it + * is determined that the update should not be committed. + * + * Releases resources being held by the update in progress. * * @param lockid lock id returned from startUpdate */ @@ -699,12 +730,16 @@ } /** - * Finalize a row mutation + * Finalize a row mutation. + * * When this method is specified, we pass the server a value that says use * the 'latest' timestamp. If we are doing a put, on the server-side, cells * will be given the servers's current timestamp. If the we are commiting * deletes, then delete removes the most recently modified cell of stipulated * column. + * + * @see #commit(long, long) + * * @param lockid lock id returned from startUpdate * @throws IOException */ @@ -713,7 +748,8 @@ } /** - * Finalize a row mutation + * Finalize a row mutation and release any resources associated with the update. + * * @param lockid lock id returned from startUpdate * @param timestamp time to associate with the change * @throws IOException Index: src/contrib/hbase/src/java/org/apache/hadoop/hbase/HMaster.java =================================================================== --- src/contrib/hbase/src/java/org/apache/hadoop/hbase/HMaster.java (revision 598834) +++ src/contrib/hbase/src/java/org/apache/hadoop/hbase/HMaster.java (working copy) @@ -1293,42 +1293,51 @@ /** {@inheritDoc} */ public HMsg[] regionServerReport(HServerInfo serverInfo, HMsg msgs[]) throws IOException { + synchronized (serversToServerInfo) { + serversToServerInfo.notifyAll(); + } String serverName = serverInfo.getServerAddress().toString().trim(); long serverLabel = getServerLabel(serverName); if (msgs.length > 0 && msgs[0].getMsg() == HMsg.MSG_REPORT_EXITING) { - // HRegionServer is shutting down. Cancel the server's lease. - // Note that canceling the server's lease takes care of updating - // serversToServerInfo, etc. - if (LOG.isDebugEnabled()) { - LOG.debug("Region server " + serverName + + synchronized (serversToServerInfo) { + try { + // HRegionServer is shutting down. Cancel the server's lease. + // Note that canceling the server's lease takes care of updating + // serversToServerInfo, etc. + if (LOG.isDebugEnabled()) { + LOG.debug("Region server " + serverName + ": MSG_REPORT_EXITING -- cancelling lease"); - } - - if (cancelLease(serverName, serverLabel)) { - // Only process the exit message if the server still has a lease. - // Otherwise we could end up processing the server exit twice. - LOG.info("Region server " + serverName + + } + + if (cancelLease(serverName, serverLabel)) { + // Only process the exit message if the server still has a lease. + // Otherwise we could end up processing the server exit twice. + LOG.info("Region server " + serverName + ": MSG_REPORT_EXITING -- lease cancelled"); - // Get all the regions the server was serving reassigned - // (if we are not shutting down). - if (!closed.get()) { - for (int i = 1; i < msgs.length; i++) { - HRegionInfo info = msgs[i].getRegionInfo(); - if (info.getTableDesc().getName().equals(ROOT_TABLE_NAME)) { - rootRegionLocation.set(null); - } else if (info.getTableDesc().getName().equals(META_TABLE_NAME)) { - onlineMetaRegions.remove(info.getStartKey()); + // Get all the regions the server was serving reassigned + // (if we are not shutting down). + if (!closed.get()) { + for (int i = 1; i < msgs.length; i++) { + HRegionInfo info = msgs[i].getRegionInfo(); + if (info.getTableDesc().getName().equals(ROOT_TABLE_NAME)) { + rootRegionLocation.set(null); + } else if (info.getTableDesc().getName().equals(META_TABLE_NAME)) { + onlineMetaRegions.remove(info.getStartKey()); + } + + this.unassignedRegions.put(info.getRegionName(), info); + this.assignAttempts.put(info.getRegionName(), Long.valueOf(0L)); + } } + } - this.unassignedRegions.put(info.getRegionName(), info); - this.assignAttempts.put(info.getRegionName(), Long.valueOf(0L)); - } + // We don't need to return anything to the server because it isn't + // going to do any more work. + return new HMsg[0]; + } finally { + serversToServerInfo.notifyAll(); } } - - // We don't need to return anything to the server because it isn't - // going to do any more work. - return new HMsg[0]; } if (closed.get()) { @@ -1434,9 +1443,6 @@ } } } - synchronized (serversToServerInfo) { - serversToServerInfo.notifyAll(); - } return leaseCancelled; }