[18/50] [abbrv] hbase git commit: HBASE-20141 Fix TooManyFiles exception when RefreshingChannels
HBASE-20141 Fix TooManyFiles exception when RefreshingChannels HBASE-19435 implements a fix for reopening file channels when they are unnexpected closed to avoid disabling the BucketCache. However, it was missed that the the channels might not actually be completely closed (the write or read channel might still be open (see https://docs.oracle.com/javase/7/docs/api/java/nio/channels/ClosedChannelException.html) This commit closes any open channels before creating a new channel. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/ecfa9a8a Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/ecfa9a8a Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/ecfa9a8a Branch: refs/heads/branch-1.3 Commit: ecfa9a8a7997a188c1f3ec2d7776245664dc7dbe Parents: 8bc84fd Author: Zach York Authored: Wed Feb 28 10:40:38 2018 -0800 Committer: Andrew Purtell Committed: Wed Dec 12 18:08:18 2018 -0800 -- .../hadoop/hbase/io/hfile/bucket/FileIOEngine.java | 13 +++-- .../hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java | 11 +++ 2 files changed, 22 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/ecfa9a8a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java index cb454d4..7b773bd 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java @@ -19,7 +19,6 @@ package org.apache.hadoop.hbase.io.hfile.bucket; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.RandomAccessFile; import java.nio.ByteBuffer; @@ -234,7 +233,17 @@ public class FileIOEngine implements IOEngine { return fileNum; } - private void refreshFileConnection(int accessFileNum) throws FileNotFoundException { + @VisibleForTesting + FileChannel[] getFileChannels() { +return fileChannels; + } + + @VisibleForTesting + void refreshFileConnection(int accessFileNum) throws IOException { +FileChannel fileChannel = fileChannels[accessFileNum]; +if (fileChannel != null) { + fileChannel.close(); +} rafs[accessFileNum] = new RandomAccessFile(filePaths[accessFileNum], "rw"); fileChannels[accessFileNum] = rafs[accessFileNum].getChannel(); } http://git-wip-us.apache.org/repos/asf/hbase/blob/ecfa9a8a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java index adf7fd0..8c2bc6e 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java @@ -19,10 +19,13 @@ package org.apache.hadoop.hbase.io.hfile.bucket; import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import java.io.File; import java.io.IOException; import java.nio.ByteBuffer; +import java.nio.channels.FileChannel; import java.util.ArrayList; import java.util.List; @@ -129,4 +132,12 @@ public class TestFileIOEngine { fileIOEngine.read(ByteBuffer.wrap(data2), offset); assertArrayEquals(data1, data2); } + + @Test + public void testRefreshFileConnectionClosesConnections() throws IOException { +FileChannel fileChannel = fileIOEngine.getFileChannels()[0]; +assertNotNull(fileChannel); +fileIOEngine.refreshFileConnection(0); +assertFalse(fileChannel.isOpen()); + } }
hbase git commit: [HBASE-20141] Fix TooManyFiles exception when RefreshingChannels
Repository: hbase Updated Branches: refs/heads/branch-1.4 ac0fb1ce8 -> 51a35aafc [HBASE-20141] Fix TooManyFiles exception when RefreshingChannels HBASE-19435 implements a fix for reopening file channels when they are unnexpected closed to avoid disabling the BucketCache. However, it was missed that the the channels might not actually be completely closed (the write or read channel might still be open (see https://docs.oracle.com/javase/7/docs/api/java/nio/channels/ClosedChannelException.html) This commit closes any open channels before creating a new channel. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/51a35aaf Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/51a35aaf Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/51a35aaf Branch: refs/heads/branch-1.4 Commit: 51a35aafcdac7954fd6851958851c13db417 Parents: ac0fb1c Author: Zach York Authored: Wed Feb 28 10:40:38 2018 -0800 Committer: Zach York Committed: Fri Mar 16 11:02:58 2018 -0700 -- .../hadoop/hbase/io/hfile/bucket/FileIOEngine.java | 13 +++-- .../hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java | 11 +++ 2 files changed, 22 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/51a35aaf/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java index cb454d4..7b773bd 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java @@ -19,7 +19,6 @@ package org.apache.hadoop.hbase.io.hfile.bucket; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.RandomAccessFile; import java.nio.ByteBuffer; @@ -234,7 +233,17 @@ public class FileIOEngine implements IOEngine { return fileNum; } - private void refreshFileConnection(int accessFileNum) throws FileNotFoundException { + @VisibleForTesting + FileChannel[] getFileChannels() { +return fileChannels; + } + + @VisibleForTesting + void refreshFileConnection(int accessFileNum) throws IOException { +FileChannel fileChannel = fileChannels[accessFileNum]; +if (fileChannel != null) { + fileChannel.close(); +} rafs[accessFileNum] = new RandomAccessFile(filePaths[accessFileNum], "rw"); fileChannels[accessFileNum] = rafs[accessFileNum].getChannel(); } http://git-wip-us.apache.org/repos/asf/hbase/blob/51a35aaf/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java index adf7fd0..8c2bc6e 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java @@ -19,10 +19,13 @@ package org.apache.hadoop.hbase.io.hfile.bucket; import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import java.io.File; import java.io.IOException; import java.nio.ByteBuffer; +import java.nio.channels.FileChannel; import java.util.ArrayList; import java.util.List; @@ -129,4 +132,12 @@ public class TestFileIOEngine { fileIOEngine.read(ByteBuffer.wrap(data2), offset); assertArrayEquals(data1, data2); } + + @Test + public void testRefreshFileConnectionClosesConnections() throws IOException { +FileChannel fileChannel = fileIOEngine.getFileChannels()[0]; +assertNotNull(fileChannel); +fileIOEngine.refreshFileConnection(0); +assertFalse(fileChannel.isOpen()); + } }
hbase git commit: [HBASE-20141] Fix TooManyFiles exception when RefreshingChannels
Repository: hbase Updated Branches: refs/heads/branch-1 a0b2141a9 -> 009295a3a [HBASE-20141] Fix TooManyFiles exception when RefreshingChannels HBASE-19435 implements a fix for reopening file channels when they are unnexpected closed to avoid disabling the BucketCache. However, it was missed that the the channels might not actually be completely closed (the write or read channel might still be open (see https://docs.oracle.com/javase/7/docs/api/java/nio/channels/ClosedChannelException.html) This commit closes any open channels before creating a new channel. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/009295a3 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/009295a3 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/009295a3 Branch: refs/heads/branch-1 Commit: 009295a3a69375822adafed1e993e80d45c680ce Parents: a0b2141 Author: Zach York Authored: Wed Feb 28 10:40:38 2018 -0800 Committer: Zach York Committed: Fri Mar 16 10:58:22 2018 -0700 -- .../hadoop/hbase/io/hfile/bucket/FileIOEngine.java | 13 +++-- .../hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java | 11 +++ 2 files changed, 22 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/009295a3/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java index cb454d4..7b773bd 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java @@ -19,7 +19,6 @@ package org.apache.hadoop.hbase.io.hfile.bucket; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.RandomAccessFile; import java.nio.ByteBuffer; @@ -234,7 +233,17 @@ public class FileIOEngine implements IOEngine { return fileNum; } - private void refreshFileConnection(int accessFileNum) throws FileNotFoundException { + @VisibleForTesting + FileChannel[] getFileChannels() { +return fileChannels; + } + + @VisibleForTesting + void refreshFileConnection(int accessFileNum) throws IOException { +FileChannel fileChannel = fileChannels[accessFileNum]; +if (fileChannel != null) { + fileChannel.close(); +} rafs[accessFileNum] = new RandomAccessFile(filePaths[accessFileNum], "rw"); fileChannels[accessFileNum] = rafs[accessFileNum].getChannel(); } http://git-wip-us.apache.org/repos/asf/hbase/blob/009295a3/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java index adf7fd0..8c2bc6e 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java @@ -19,10 +19,13 @@ package org.apache.hadoop.hbase.io.hfile.bucket; import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import java.io.File; import java.io.IOException; import java.nio.ByteBuffer; +import java.nio.channels.FileChannel; import java.util.ArrayList; import java.util.List; @@ -129,4 +132,12 @@ public class TestFileIOEngine { fileIOEngine.read(ByteBuffer.wrap(data2), offset); assertArrayEquals(data1, data2); } + + @Test + public void testRefreshFileConnectionClosesConnections() throws IOException { +FileChannel fileChannel = fileIOEngine.getFileChannels()[0]; +assertNotNull(fileChannel); +fileIOEngine.refreshFileConnection(0); +assertFalse(fileChannel.isOpen()); + } }
hbase git commit: [HBASE-20141] Fix TooManyFiles exception when RefreshingChannels
Repository: hbase Updated Branches: refs/heads/branch-2.0 a18fb33d5 -> 10a7b5ea1 [HBASE-20141] Fix TooManyFiles exception when RefreshingChannels HBASE-19435 implements a fix for reopening file channels when they are unnexpected closed to avoid disabling the BucketCache. However, it was missed that the the channels might not actually be completely closed (the write or read channel might still be open (see https://docs.oracle.com/javase/7/docs/api/java/nio/channels/ClosedChannelException.html) This commit closes any open channels before creating a new channel. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/10a7b5ea Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/10a7b5ea Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/10a7b5ea Branch: refs/heads/branch-2.0 Commit: 10a7b5ea1591e93fff39a0c9fc35ee2c8805d49f Parents: a18fb33 Author: Zach York Authored: Wed Feb 28 10:40:38 2018 -0800 Committer: Zach York Committed: Fri Mar 16 10:56:06 2018 -0700 -- .../hadoop/hbase/io/hfile/bucket/FileIOEngine.java | 13 +++-- .../hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java | 11 +++ 2 files changed, 22 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/10a7b5ea/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java index cf963f0..648d4bc 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java @@ -19,7 +19,6 @@ package org.apache.hadoop.hbase.io.hfile.bucket; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.RandomAccessFile; import java.nio.ByteBuffer; @@ -274,7 +273,17 @@ public class FileIOEngine implements IOEngine { return fileNum; } - private void refreshFileConnection(int accessFileNum) throws FileNotFoundException { + @VisibleForTesting + FileChannel[] getFileChannels() { +return fileChannels; + } + + @VisibleForTesting + void refreshFileConnection(int accessFileNum) throws IOException { +FileChannel fileChannel = fileChannels[accessFileNum]; +if (fileChannel != null) { + fileChannel.close(); +} rafs[accessFileNum] = new RandomAccessFile(filePaths[accessFileNum], "rw"); fileChannels[accessFileNum] = rafs[accessFileNum].getChannel(); } http://git-wip-us.apache.org/repos/asf/hbase/blob/10a7b5ea/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java index 5086265..6480986 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java @@ -18,10 +18,13 @@ package org.apache.hadoop.hbase.io.hfile.bucket; import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import java.io.File; import java.io.IOException; import java.nio.ByteBuffer; +import java.nio.channels.FileChannel; import java.util.ArrayList; import java.util.List; import org.apache.hadoop.hbase.HBaseClassTestRule; @@ -138,4 +141,12 @@ public class TestFileIOEngine { ByteBuff data2 = deserializer.getDeserializedByteBuff(); assertArrayEquals(data1, data2.array()); } + + @Test + public void testRefreshFileConnectionClosesConnections() throws IOException { +FileChannel fileChannel = fileIOEngine.getFileChannels()[0]; +assertNotNull(fileChannel); +fileIOEngine.refreshFileConnection(0); +assertFalse(fileChannel.isOpen()); + } }
hbase git commit: [HBASE-20141] Fix TooManyFiles exception when RefreshingChannels
Repository: hbase Updated Branches: refs/heads/branch-2 79d47dd57 -> 6bf967adf [HBASE-20141] Fix TooManyFiles exception when RefreshingChannels HBASE-19435 implements a fix for reopening file channels when they are unnexpected closed to avoid disabling the BucketCache. However, it was missed that the the channels might not actually be completely closed (the write or read channel might still be open (see https://docs.oracle.com/javase/7/docs/api/java/nio/channels/ClosedChannelException.html) This commit closes any open channels before creating a new channel. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/6bf967ad Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/6bf967ad Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/6bf967ad Branch: refs/heads/branch-2 Commit: 6bf967adfb53001365bf4f9d5a72a1e095ee2900 Parents: 79d47dd Author: Zach York Authored: Wed Feb 28 10:40:38 2018 -0800 Committer: Zach York Committed: Fri Mar 16 10:54:43 2018 -0700 -- .../hadoop/hbase/io/hfile/bucket/FileIOEngine.java | 13 +++-- .../hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java | 11 +++ 2 files changed, 22 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/6bf967ad/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java index cf963f0..648d4bc 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java @@ -19,7 +19,6 @@ package org.apache.hadoop.hbase.io.hfile.bucket; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.RandomAccessFile; import java.nio.ByteBuffer; @@ -274,7 +273,17 @@ public class FileIOEngine implements IOEngine { return fileNum; } - private void refreshFileConnection(int accessFileNum) throws FileNotFoundException { + @VisibleForTesting + FileChannel[] getFileChannels() { +return fileChannels; + } + + @VisibleForTesting + void refreshFileConnection(int accessFileNum) throws IOException { +FileChannel fileChannel = fileChannels[accessFileNum]; +if (fileChannel != null) { + fileChannel.close(); +} rafs[accessFileNum] = new RandomAccessFile(filePaths[accessFileNum], "rw"); fileChannels[accessFileNum] = rafs[accessFileNum].getChannel(); } http://git-wip-us.apache.org/repos/asf/hbase/blob/6bf967ad/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java index 5086265..6480986 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java @@ -18,10 +18,13 @@ package org.apache.hadoop.hbase.io.hfile.bucket; import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import java.io.File; import java.io.IOException; import java.nio.ByteBuffer; +import java.nio.channels.FileChannel; import java.util.ArrayList; import java.util.List; import org.apache.hadoop.hbase.HBaseClassTestRule; @@ -138,4 +141,12 @@ public class TestFileIOEngine { ByteBuff data2 = deserializer.getDeserializedByteBuff(); assertArrayEquals(data1, data2.array()); } + + @Test + public void testRefreshFileConnectionClosesConnections() throws IOException { +FileChannel fileChannel = fileIOEngine.getFileChannels()[0]; +assertNotNull(fileChannel); +fileIOEngine.refreshFileConnection(0); +assertFalse(fileChannel.isOpen()); + } }
hbase git commit: [HBASE-20141] Fix TooManyFiles exception when RefreshingChannels
Repository: hbase Updated Branches: refs/heads/master 13f3ba3ce -> aaa90d806 [HBASE-20141] Fix TooManyFiles exception when RefreshingChannels HBASE-19435 implements a fix for reopening file channels when they are unnexpected closed to avoid disabling the BucketCache. However, it was missed that the the channels might not actually be completely closed (the write or read channel might still be open (see https://docs.oracle.com/javase/7/docs/api/java/nio/channels/ClosedChannelException.html) This commit closes any open channels before creating a new channel. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/aaa90d80 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/aaa90d80 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/aaa90d80 Branch: refs/heads/master Commit: aaa90d80690114ca3300084cdba977024b5a7fd5 Parents: 13f3ba3 Author: Zach York Authored: Wed Feb 28 10:40:38 2018 -0800 Committer: Zach York Committed: Fri Mar 16 10:51:39 2018 -0700 -- .../hadoop/hbase/io/hfile/bucket/FileIOEngine.java | 13 +++-- .../hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java | 11 +++ 2 files changed, 22 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/aaa90d80/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java index cf963f0..648d4bc 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/FileIOEngine.java @@ -19,7 +19,6 @@ package org.apache.hadoop.hbase.io.hfile.bucket; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.RandomAccessFile; import java.nio.ByteBuffer; @@ -274,7 +273,17 @@ public class FileIOEngine implements IOEngine { return fileNum; } - private void refreshFileConnection(int accessFileNum) throws FileNotFoundException { + @VisibleForTesting + FileChannel[] getFileChannels() { +return fileChannels; + } + + @VisibleForTesting + void refreshFileConnection(int accessFileNum) throws IOException { +FileChannel fileChannel = fileChannels[accessFileNum]; +if (fileChannel != null) { + fileChannel.close(); +} rafs[accessFileNum] = new RandomAccessFile(filePaths[accessFileNum], "rw"); fileChannels[accessFileNum] = rafs[accessFileNum].getChannel(); } http://git-wip-us.apache.org/repos/asf/hbase/blob/aaa90d80/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java -- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java index 5086265..6480986 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestFileIOEngine.java @@ -18,10 +18,13 @@ package org.apache.hadoop.hbase.io.hfile.bucket; import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import java.io.File; import java.io.IOException; import java.nio.ByteBuffer; +import java.nio.channels.FileChannel; import java.util.ArrayList; import java.util.List; import org.apache.hadoop.hbase.HBaseClassTestRule; @@ -138,4 +141,12 @@ public class TestFileIOEngine { ByteBuff data2 = deserializer.getDeserializedByteBuff(); assertArrayEquals(data1, data2.array()); } + + @Test + public void testRefreshFileConnectionClosesConnections() throws IOException { +FileChannel fileChannel = fileIOEngine.getFileChannels()[0]; +assertNotNull(fileChannel); +fileIOEngine.refreshFileConnection(0); +assertFalse(fileChannel.isOpen()); + } }