You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2014/08/02 02:18:24 UTC
[1/3] git commit: HBASE-11650 Write hbase.id to a temporary location
and move into place
Repository: hbase
Updated Branches:
refs/heads/0.98 dfef20ed4 -> 43ab9979a
refs/heads/branch-1 4d272fa5e -> ec5a859b9
refs/heads/master db15d6e6a -> 543c64d2e
HBASE-11650 Write hbase.id to a temporary location and move into place
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/543c64d2
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/543c64d2
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/543c64d2
Branch: refs/heads/master
Commit: 543c64d2e9d2fc608ef65cafd485a910d4b8d480
Parents: db15d6e
Author: Andrew Purtell <ap...@apache.org>
Authored: Fri Aug 1 17:18:00 2014 -0700
Committer: Andrew Purtell <ap...@apache.org>
Committed: Fri Aug 1 17:18:00 2014 -0700
----------------------------------------------------------------------
.../org/apache/hadoop/hbase/util/FSUtils.java | 21 ++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/543c64d2/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
index 23d3437..7b3b636 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
@@ -787,15 +787,28 @@ public abstract class FSUtils {
int wait) throws IOException {
while (true) {
try {
- Path filePath = new Path(rootdir, HConstants.CLUSTER_ID_FILE_NAME);
- FSDataOutputStream s = fs.create(filePath);
+ Path idFile = new Path(rootdir, HConstants.CLUSTER_ID_FILE_NAME);
+ Path tempIdFile = new Path(rootdir, HConstants.HBASE_TEMP_DIRECTORY +
+ Path.SEPARATOR + HConstants.CLUSTER_ID_FILE_NAME);
+ // Write the id file to a temporary location
+ FSDataOutputStream s = fs.create(tempIdFile);
try {
s.write(clusterId.toByteArray());
- } finally {
s.close();
+ s = null;
+ // Move the temporary file to its normal location. Throw an IOE if
+ // the rename failed
+ if (!fs.rename(tempIdFile, idFile)) {
+ throw new IOException("Unable to move temp version file to " + idFile);
+ }
+ } finally {
+ // Attempt to close the stream if still open on the way out
+ try {
+ if (s != null) s.close();
+ } catch (IOException ignore) { }
}
if (LOG.isDebugEnabled()) {
- LOG.debug("Created cluster ID file at " + filePath.toString() + " with ID: " + clusterId);
+ LOG.debug("Created cluster ID file at " + idFile.toString() + " with ID: " + clusterId);
}
return;
} catch (IOException ioe) {
[3/3] git commit: HBASE-11650 Write hbase.id to a temporary location
and move into place
Posted by ap...@apache.org.
HBASE-11650 Write hbase.id to a temporary location and move into place
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/43ab9979
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/43ab9979
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/43ab9979
Branch: refs/heads/0.98
Commit: 43ab9979a5f496b2a1d9132d14bbadff7dd950a0
Parents: dfef20e
Author: Andrew Purtell <ap...@apache.org>
Authored: Fri Aug 1 17:18:02 2014 -0700
Committer: Andrew Purtell <ap...@apache.org>
Committed: Fri Aug 1 17:18:02 2014 -0700
----------------------------------------------------------------------
.../org/apache/hadoop/hbase/util/FSUtils.java | 21 ++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/43ab9979/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
index b870b37..c418ec3 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
@@ -799,15 +799,28 @@ public abstract class FSUtils {
int wait) throws IOException {
while (true) {
try {
- Path filePath = new Path(rootdir, HConstants.CLUSTER_ID_FILE_NAME);
- FSDataOutputStream s = fs.create(filePath);
+ Path idFile = new Path(rootdir, HConstants.CLUSTER_ID_FILE_NAME);
+ Path tempIdFile = new Path(rootdir, HConstants.HBASE_TEMP_DIRECTORY +
+ Path.SEPARATOR + HConstants.CLUSTER_ID_FILE_NAME);
+ // Write the id file to a temporary location
+ FSDataOutputStream s = fs.create(tempIdFile);
try {
s.write(clusterId.toByteArray());
- } finally {
s.close();
+ s = null;
+ // Move the temporary file to its normal location. Throw an IOE if
+ // the rename failed
+ if (!fs.rename(tempIdFile, idFile)) {
+ throw new IOException("Unable to move temp version file to " + idFile);
+ }
+ } finally {
+ // Attempt to close the stream if still open on the way out
+ try {
+ if (s != null) s.close();
+ } catch (IOException ignore) { }
}
if (LOG.isDebugEnabled()) {
- LOG.debug("Created cluster ID file at " + filePath.toString() + " with ID: " + clusterId);
+ LOG.debug("Created cluster ID file at " + idFile.toString() + " with ID: " + clusterId);
}
return;
} catch (IOException ioe) {
[2/3] git commit: HBASE-11650 Write hbase.id to a temporary location
and move into place
Posted by ap...@apache.org.
HBASE-11650 Write hbase.id to a temporary location and move into place
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/ec5a859b
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/ec5a859b
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/ec5a859b
Branch: refs/heads/branch-1
Commit: ec5a859b92f2f7177801f7b686759362172dc6c3
Parents: 4d272fa
Author: Andrew Purtell <ap...@apache.org>
Authored: Fri Aug 1 17:18:01 2014 -0700
Committer: Andrew Purtell <ap...@apache.org>
Committed: Fri Aug 1 17:18:01 2014 -0700
----------------------------------------------------------------------
.../org/apache/hadoop/hbase/util/FSUtils.java | 21 ++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/ec5a859b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
index fb00cf5..53f5874 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
@@ -786,15 +786,28 @@ public abstract class FSUtils {
int wait) throws IOException {
while (true) {
try {
- Path filePath = new Path(rootdir, HConstants.CLUSTER_ID_FILE_NAME);
- FSDataOutputStream s = fs.create(filePath);
+ Path idFile = new Path(rootdir, HConstants.CLUSTER_ID_FILE_NAME);
+ Path tempIdFile = new Path(rootdir, HConstants.HBASE_TEMP_DIRECTORY +
+ Path.SEPARATOR + HConstants.CLUSTER_ID_FILE_NAME);
+ // Write the id file to a temporary location
+ FSDataOutputStream s = fs.create(tempIdFile);
try {
s.write(clusterId.toByteArray());
- } finally {
s.close();
+ s = null;
+ // Move the temporary file to its normal location. Throw an IOE if
+ // the rename failed
+ if (!fs.rename(tempIdFile, idFile)) {
+ throw new IOException("Unable to move temp version file to " + idFile);
+ }
+ } finally {
+ // Attempt to close the stream if still open on the way out
+ try {
+ if (s != null) s.close();
+ } catch (IOException ignore) { }
}
if (LOG.isDebugEnabled()) {
- LOG.debug("Created cluster ID file at " + filePath.toString() + " with ID: " + clusterId);
+ LOG.debug("Created cluster ID file at " + idFile.toString() + " with ID: " + clusterId);
}
return;
} catch (IOException ioe) {