Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
|
#include <hdfs-bulk-ops.h>
Public Types | |
typedef std::pair< const HdfsOp *, std::string > | Error |
typedef std::vector< Error > | Errors |
Public Member Functions | |
HdfsOperationSet (hdfsFS *hdfs_connection) | |
void | Add (HdfsOpType op, const std::string &src) |
void | Add (HdfsOpType op, const std::string &src, const std::string &dst) |
Add an operation that takes two parameters (e.g. RENAME) More... | |
void | Add (HdfsOpType op, const std::string &src, short permissions) |
Add an operation that takes a permission argument (i.e. CHMOD) More... | |
bool | Execute (HdfsOpThreadPool *pool, bool abort_on_error) |
const Errors & | errors () |
hdfsFS * | hdfs_connection () const |
Private Member Functions | |
void | MarkOneOpDone () |
void | AddError (const std::string &err, const HdfsOp *op) |
Called by HdfsOp to record an error. More... | |
bool | ShouldAbort () |
Private Attributes | |
std::vector< HdfsOp > | ops_ |
The set of operations to be submitted to HDFS. More... | |
Promise< bool > | promise_ |
AtomicInt< int64_t > | num_ops_ |
hdfsFS * | hdfs_connection_ |
HDFS connection shared between all operations. Not owned by this class. More... | |
boost::mutex | errors_lock_ |
Protects errors_ and abort_on_error_ during Execute. More... | |
Errors | errors_ |
All errors produced during Execute. More... | |
bool | abort_on_error_ |
True if a single error should cause any subsequent operations to become no-ops. More... | |
Friends | |
class | HdfsOp |
This class contains a set of operations to be executed in parallel on an HdfsOpThreadPool. These operations may not be executed in the order that they are added.
Definition at line 87 of file hdfs-bulk-ops.h.
typedef std::pair<const HdfsOp*, std::string> impala::HdfsOperationSet::Error |
Definition at line 109 of file hdfs-bulk-ops.h.
typedef std::vector<Error> impala::HdfsOperationSet::Errors |
Definition at line 110 of file hdfs-bulk-ops.h.
HdfsOperationSet::HdfsOperationSet | ( | hdfsFS * | hdfs_connection | ) |
Constructs a new operation set. The hdfsFS parameter is shared between all operations, and is not owned by this class (and therefore should remain valid until Execute returns).
Definition at line 125 of file hdfs-bulk-ops.cc.
void impala::HdfsOperationSet::Add | ( | HdfsOpType | op, |
const std::string & | src | ||
) |
Add an operation that takes only a single 'src' parameter (e.g. DELETE, CREATE_DIR, DELETE_THEN_CREATE)
void impala::HdfsOperationSet::Add | ( | HdfsOpType | op, |
const std::string & | src, | ||
const std::string & | dst | ||
) |
Add an operation that takes two parameters (e.g. RENAME)
void impala::HdfsOperationSet::Add | ( | HdfsOpType | op, |
const std::string & | src, | ||
short | permissions | ||
) |
Add an operation that takes a permission argument (i.e. CHMOD)
|
private |
Called by HdfsOp to record an error.
Definition at line 157 of file hdfs-bulk-ops.cc.
References errors_, and errors_lock_.
Referenced by impala::HdfsOp::Execute().
|
inline |
Returns the (possible zero-length) list of errors during op execution. Not valid until Execute has returned.
Definition at line 114 of file hdfs-bulk-ops.h.
References errors_.
Referenced by MarkOneOpDone().
bool HdfsOperationSet::Execute | ( | HdfsOpThreadPool * | pool, |
bool | abort_on_error | ||
) |
Run all operations on the given pool, blocking until all are complete. Returns false if there were any errors, true otherwise. If abort_on_error is true, execution will finish after the first error seen.
Definition at line 129 of file hdfs-bulk-ops.cc.
References abort_on_error_, errors_lock_, impala::Promise< T >::Get(), num_ops_, impala::ThreadPool< T >::Offer(), ops_, and promise_.
|
inline |
Definition at line 116 of file hdfs-bulk-ops.h.
References hdfs_connection_.
Referenced by impala::HdfsOp::Execute().
|
private |
Called by HdfsOp to signal its completion. When the last op has finished, this method signals Execute() so that it can return.
Definition at line 162 of file hdfs-bulk-ops.cc.
References errors(), num_ops_, promise_, impala::Promise< T >::Set(), and impala::AtomicInt< T >::UpdateAndFetch().
Referenced by impala::HdfsOp::Execute().
|
private |
Called by HdfsOp at the start of execution to decide whether to continue. Returns true iff abort_on_error_ is true and at least one error has been recorded.
Definition at line 168 of file hdfs-bulk-ops.cc.
References abort_on_error_, errors_, and errors_lock_.
Referenced by impala::HdfsOp::Execute().
|
friend |
Definition at line 142 of file hdfs-bulk-ops.h.
|
private |
True if a single error should cause any subsequent operations to become no-ops.
Definition at line 140 of file hdfs-bulk-ops.h.
Referenced by Execute(), and ShouldAbort().
|
private |
All errors produced during Execute.
Definition at line 137 of file hdfs-bulk-ops.h.
Referenced by AddError(), errors(), and ShouldAbort().
|
private |
Protects errors_ and abort_on_error_ during Execute.
Definition at line 134 of file hdfs-bulk-ops.h.
Referenced by AddError(), Execute(), and ShouldAbort().
|
private |
HDFS connection shared between all operations. Not owned by this class.
Definition at line 131 of file hdfs-bulk-ops.h.
Referenced by hdfs_connection().
|
private |
The number of ops remaining to be executed. Used to coordinate between executor threads so that when all ops are finished, promise_ is signalled.
Definition at line 128 of file hdfs-bulk-ops.h.
Referenced by Execute(), and MarkOneOpDone().
|
private |
The set of operations to be submitted to HDFS.
Definition at line 120 of file hdfs-bulk-ops.h.
Referenced by Execute().
Used to coordinate between the executing threads and the caller; Execute blocks until this is signalled.
Definition at line 124 of file hdfs-bulk-ops.h.
Referenced by Execute(), and MarkOneOpDone().