[jira] [HBASE-4661] get list of store files.

Summary:
1. Ported getStoreFileList API to trunk.
2. Also ported flushRegion API to trunk (with option of flushing if
lastFlushTime < TS).

Test Plan: Tested on 89.

Reviewers: Karthik, Kannan, nspiegelberg, JIRA

Reviewed By: Karthik

CC: HBase Diffs Facebook Group, Karthik, Kannan, stack, madhuvaidya

Differential Revision: 729

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1213487 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
karthik 2011-12-12 22:58:51 +00:00
parent 4b8eb16ea9
commit 34dc2a4b66
3 changed files with 141 additions and 0 deletions

View File

@ -82,6 +82,53 @@ public interface HRegionInterface extends VersionedProtocol, Stoppable, Abortabl
public HRegionInfo getRegionInfo(final byte [] regionName)
throws NotServingRegionException, ConnectException, IOException;
/**
* Flush the given region
* @param region name
*/
public void flushRegion(byte[] regionName)
throws IllegalArgumentException, IOException;
/**
* Flush the given region if lastFlushTime < ifOlderThanTS
* @param region name
* @param timestamp
*/
public void flushRegion(byte[] regionName, long ifOlderThanTS)
throws IllegalArgumentException, IOException;
/**
* Gets last flush time for the given region
* @return the last flush time for a region
*/
public long getLastFlushTime(byte[] regionName);
/**
* Get a list of store files for a particular CF in a particular region
* @param region name
* @param CF name
* @return the list of store files
*/
public List<String> getStoreFileList(byte[] regionName, byte[] columnFamily)
throws IllegalArgumentException;
/**
* Get a list of store files for a set of CFs in a particular region
* @param region name
* @param CF names
* @return the list of store files
*/
public List<String> getStoreFileList(byte[] regionName, byte[][] columnFamilies)
throws IllegalArgumentException;
/**
* Get a list of store files for all CFs in a particular region
* @param region name
* @return the list of store files
*/
public List<String> getStoreFileList(byte[] regionName)
throws IllegalArgumentException;
/**
* Return all the data for the row that matches <i>row</i> exactly,
* or the one that immediately preceeds it.
@ -423,6 +470,7 @@ public interface HRegionInterface extends VersionedProtocol, Stoppable, Abortabl
* @param regionInfo region to flush
* @throws NotServingRegionException
* @throws IOException
* @deprecated use {@link #flushRegion(byte[])} instead
*/
void flushRegion(HRegionInfo regionInfo)
throws NotServingRegionException, IOException;

View File

@ -2769,6 +2769,31 @@ public class HRegion implements HeapSize { // , Writable{
return this.stores;
}
/**
* Return list of storeFiles for the set of CFs.
* Uses closeLock to prevent the race condition where a region closes
* in between the for loop - closing the stores one by one, some stores
* will return 0 files.
* @return List of storeFiles.
*/
public List<String> getStoreFileList(final byte [][] columns)
throws IllegalArgumentException {
List<String> storeFileNames = new ArrayList<String>();
synchronized(closeLock) {
for(byte[] column : columns) {
Store store = this.stores.get(column);
if (store == null) {
throw new IllegalArgumentException("No column family : " +
new String(column) + " available");
}
List<StoreFile> storeFiles = store.getStorefiles();
for (StoreFile storeFile: storeFiles) {
storeFileNames.add(storeFile.getPath().toString());
}
}
}
return storeFileNames;
}
//////////////////////////////////////////////////////////////////////////////
// Support code
//////////////////////////////////////////////////////////////////////////////

View File

@ -2127,6 +2127,74 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
return result;
}
@Override
public List<String> getStoreFileList(byte[] regionName, byte[] columnFamily)
throws IllegalArgumentException {
return getStoreFileList(regionName, new byte[][]{columnFamily});
}
@Override
public List<String> getStoreFileList(byte[] regionName, byte[][] columnFamilies)
throws IllegalArgumentException {
HRegion region = getOnlineRegion(regionName);
if (region == null) {
throw new IllegalArgumentException("No region: " + new String(regionName)
+ " available");
}
return region.getStoreFileList(columnFamilies);
}
public List<String> getStoreFileList(byte[] regionName)
throws IllegalArgumentException {
HRegion region = getOnlineRegion(regionName);
if (region == null) {
throw new IllegalArgumentException("No region: " + new String(regionName)
+ " available");
}
Set<byte[]> columnFamilies = region.getStores().keySet();
int nCF = columnFamilies.size();
return region.getStoreFileList(columnFamilies.toArray(new byte[nCF][]));
}
/**
* Flushes the given region
*/
public void flushRegion(byte[] regionName)
throws IllegalArgumentException, IOException {
HRegion region = getOnlineRegion(regionName);
if (region == null) {
throw new IllegalArgumentException("No region : " + new String(regionName)
+ " available");
}
region.flushcache();
}
/**
* Flushes the given region if lastFlushTime < ifOlderThanTS
*/
public void flushRegion(byte[] regionName, long ifOlderThanTS)
throws IllegalArgumentException, IOException {
HRegion region = getOnlineRegion(regionName);
if (region == null) {
throw new IllegalArgumentException("No region : " + new String(regionName)
+ " available");
}
if (region.getLastFlushTime() < ifOlderThanTS) region.flushcache();
}
/**
* Gets last flush time for the given region
* @return the last flush time for a region
*/
public long getLastFlushTime(byte[] regionName) {
HRegion region = getOnlineRegion(regionName);
if (region == null) {
throw new IllegalArgumentException("No region : " + new String(regionName)
+ " available");
}
return region.getLastFlushTime();
}
/**
*
* @param regionName