Skip to content

Commit a66ff5b

Browse files
gvprathyusha6Prathyusha Garre
authored andcommitted
HBASE-28861 Use hasReferences() api of SFT in RegionSplitter and remove Reference.read(), HRegionFS.hasReferences() (#6428)
Signed-off-by: Andrew Purtell <apurtell@apache.org> Co-authored-by: Prathyusha Garre <pgarre@pgarre-ltmqft8.internal.salesforce.com>
1 parent 793755e commit a66ff5b

File tree

3 files changed

+0
-58
lines changed

3 files changed

+0
-58
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/io/Reference.java

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,9 @@
1717
*/
1818
package org.apache.hadoop.hbase.io;
1919

20-
import java.io.BufferedInputStream;
2120
import java.io.DataInput;
22-
import java.io.DataInputStream;
2321
import java.io.IOException;
24-
import java.io.InputStream;
2522
import java.util.Arrays;
26-
import org.apache.commons.io.IOUtils;
2723
import org.apache.hadoop.fs.FSDataOutputStream;
2824
import org.apache.hadoop.fs.FileSystem;
2925
import org.apache.hadoop.fs.Path;
@@ -144,36 +140,6 @@ public Path write(final FileSystem fs, final Path p) throws IOException {
144140
return p;
145141
}
146142

147-
/**
148-
* Read a Reference from FileSystem.
149-
* @return New Reference made from passed <code>p</code>
150-
*/
151-
public static Reference read(final FileSystem fs, final Path p) throws IOException {
152-
InputStream in = fs.open(p);
153-
try {
154-
// I need to be able to move back in the stream if this is not a pb serialization so I can
155-
// do the Writable decoding instead.
156-
in = in.markSupported() ? in : new BufferedInputStream(in);
157-
int pblen = ProtobufUtil.lengthOfPBMagic();
158-
in.mark(pblen);
159-
byte[] pbuf = new byte[pblen];
160-
IOUtils.readFully(in, pbuf, 0, pblen);
161-
// WATCHOUT! Return in middle of function!!!
162-
if (ProtobufUtil.isPBMagicPrefix(pbuf)) return convert(FSProtos.Reference.parseFrom(in));
163-
// Else presume Writables. Need to reset the stream since it didn't start w/ pb.
164-
// We won't bother rewriting thie Reference as a pb since Reference is transitory.
165-
in.reset();
166-
Reference r = new Reference();
167-
DataInputStream dis = new DataInputStream(in);
168-
// Set in = dis so it gets the close below in the finally on our way out.
169-
in = dis;
170-
r.readFields(dis);
171-
return r;
172-
} finally {
173-
in.close();
174-
}
175-
}
176-
177143
public FSProtos.Reference convert() {
178144
FSProtos.Reference.Builder builder = FSProtos.Reference.newBuilder();
179145
builder.setRange(isTopFileRegion(getFileRegion())

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionFileSystem.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -313,28 +313,6 @@ StoreFileInfo getStoreFileInfo(final String familyName, final String fileName,
313313
familyName, new Path(familyDir, fileName), tracker);
314314
}
315315

316-
/**
317-
* Returns true if the specified family has reference files
318-
* @param familyName Column Family Name
319-
* @return true if family contains reference files
320-
*/
321-
public boolean hasReferences(final String familyName) throws IOException {
322-
Path storeDir = getStoreDir(familyName);
323-
FileStatus[] files = CommonFSUtils.listStatus(fs, storeDir);
324-
if (files != null) {
325-
for (FileStatus stat : files) {
326-
if (stat.isDirectory()) {
327-
continue;
328-
}
329-
if (StoreFileInfo.isReference(stat.getPath())) {
330-
LOG.trace("Reference {}", stat.getPath());
331-
return true;
332-
}
333-
}
334-
}
335-
return false;
336-
}
337-
338316
/** Returns the set of families present on disk n */
339317
public Collection<String> getFamilies() throws IOException {
340318
FileStatus[] fds =

hbase-server/src/test/java/org/apache/hadoop/hbase/util/compaction/TestMajorCompactionRequest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import static org.junit.Assert.assertFalse;
2222
import static org.junit.Assert.assertTrue;
2323
import static org.mockito.ArgumentMatchers.any;
24-
import static org.mockito.ArgumentMatchers.anyString;
2524
import static org.mockito.ArgumentMatchers.isA;
2625
import static org.mockito.Mockito.doReturn;
2726
import static org.mockito.Mockito.mock;
@@ -146,7 +145,6 @@ private HRegionFileSystem mockFileSystem(RegionInfo info, boolean hasReferenceFi
146145
HRegionFileSystem mockSystem = mock(HRegionFileSystem.class);
147146
doReturn(info).when(mockSystem).getRegionInfo();
148147
doReturn(regionStoreDir).when(mockSystem).getStoreDir(FAMILY);
149-
doReturn(hasReferenceFiles).when(mockSystem).hasReferences(anyString());
150148
doReturn(fileSystem).when(mockSystem).getFileSystem();
151149
return mockSystem;
152150
}

0 commit comments

Comments
 (0)