Class TableSnapshotScanner
- All Implemented Interfaces:
Closeable,AutoCloseable,Iterable<Result>,ResultScanner
This also allows one to run the scan from an online or offline hbase cluster. The snapshot files can be exported by using the org.apache.hadoop.hbase.snapshot.ExportSnapshot tool, to a pure-hdfs cluster, and this scanner can be used to run the scan directly over the snapshot files. The snapshot should not be deleted while there are open scanners reading from snapshot files.
An internal RegionScanner is used to execute the Scan obtained from the user for each
region in the snapshot.
HBase owns all the data and snapshot files on the filesystem. Only the HBase user can read from snapshot files and data files. HBase also enforces security because all the requests are handled by the server layer, and the user cannot read from the data files directly. To read from snapshot files directly from the file system, the user who is running the MR job must have sufficient permissions to access snapshot and reference files. This means that to run mapreduce over snapshot files, the job has to be run as the HBase user or the user must have group or other priviledges in the filesystem (See HBASE-8369). Note that, given other users access to read from snapshot/data files will completely circumvent the access control enforced by HBase. See org.apache.hadoop.hbase.mapreduce.TableSnapshotInputFormat.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.apache.hadoop.conf.Configurationprivate intprivate ClientSideRegionScannerprivate org.apache.hadoop.fs.FileSystemprivate TableDescriptorprivate static final org.slf4j.Loggerprivate intprivate ArrayList<RegionInfo>private org.apache.hadoop.fs.Pathprivate org.apache.hadoop.fs.Pathprivate Scanprivate final booleanprivate StringFields inherited from class org.apache.hadoop.hbase.client.AbstractClientScanner
scanMetrics -
Constructor Summary
ConstructorsConstructorDescriptionTableSnapshotScanner(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path restoreDir, String snapshotName, Scan scan) Creates a TableSnapshotScanner.TableSnapshotScanner(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.fs.Path restoreDir, String snapshotName, Scan scan) TableSnapshotScanner(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.fs.Path restoreDir, String snapshotName, Scan scan, boolean snapshotAlreadyRestored) Creates a TableSnapshotScanner. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcleanup()voidclose()Closes the scanner and releases any resources it has allocatedprivate booleanisValidRegion(RegionInfo hri) next()Grab the next row's worth of values.private voidprivate voidbooleanAllow the client to renew the scanner's lease on the server.Methods inherited from class org.apache.hadoop.hbase.client.AbstractClientScanner
getScanMetrics, initScanMetricsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.apache.hadoop.hbase.client.ResultScanner
iterator, next
-
Field Details
-
LOG
-
conf
-
snapshotName
-
fs
-
rootDir
-
restoreDir
-
scan
-
regions
-
htd
-
snapshotAlreadyRestored
-
currentRegionScanner
-
currentRegion
-
numOfCompleteRows
-
-
Constructor Details
-
TableSnapshotScanner
public TableSnapshotScanner(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path restoreDir, String snapshotName, Scan scan) throws IOException Creates a TableSnapshotScanner.- Parameters:
conf- the configurationrestoreDir- a temporary directory to copy the snapshot files into. Current user should have write permissions to this directory, and this should not be a subdirectory of rootDir. The scanner deletes the contents of the directory once the scanner is closed.snapshotName- the name of the snapshot to read fromscan- a Scan representing scan parameters- Throws:
IOException- in case of error
-
TableSnapshotScanner
public TableSnapshotScanner(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.fs.Path restoreDir, String snapshotName, Scan scan) throws IOException - Throws:
IOException
-
TableSnapshotScanner
public TableSnapshotScanner(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path rootDir, org.apache.hadoop.fs.Path restoreDir, String snapshotName, Scan scan, boolean snapshotAlreadyRestored) throws IOException Creates a TableSnapshotScanner.- Parameters:
conf- the configurationrootDir- root directory for HBase.restoreDir- a temporary directory to copy the snapshot files into. Current user should have write permissions to this directory, and this should not be a subdirectory of rootdir. The scanner deletes the contents of the directory once the scanner is closed.snapshotName- the name of the snapshot to read fromscan- a Scan representing scan parameterssnapshotAlreadyRestored- true to indicate that snapshot has been restored.- Throws:
IOException- in case of error
-
-
Method Details
-
openWithoutRestoringSnapshot
- Throws:
IOException
-
isValidRegion
-
openWithRestoringSnapshot
- Throws:
IOException
-
next
Description copied from interface:ResultScannerGrab the next row's worth of values. The scanner will return a Result.- Returns:
- Result object if there is another row, null if the scanner is exhausted.
- Throws:
IOException- e
-
cleanup
-
close
Description copied from interface:ResultScannerCloses the scanner and releases any resources it has allocated -
renewLease
Description copied from interface:ResultScannerAllow the client to renew the scanner's lease on the server.- Returns:
- true if the lease was successfully renewed, false otherwise.
-