Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
disk-io-mgr-stress.h
Go to the documentation of this file.
1 // Copyright 2012 Cloudera Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 
16 #ifndef IMPALA_RUNTIME_DISK_IO_MGR_STRESS_H
17 #define IMPALA_RUNTIME_DISK_IO_MGR_STRESS_H
18 
19 #include <vector>
20 #include <boost/scoped_ptr.hpp>
21 #include <boost/thread/mutex.hpp>
22 #include <boost/thread/condition_variable.hpp>
23 #include <boost/thread/thread.hpp>
24 #include <boost/unordered_map.hpp>
25 
26 #include "runtime/disk-io-mgr.h"
27 #include "runtime/mem-tracker.h"
29 
30 namespace impala {
31 
37  public:
38  DiskIoMgrStress(int num_disks, int num_threads_per_disk, int num_clients,
39  bool includes_cancellation);
40 
42  void Run(int sec);
43 
44  private:
45  struct Client;
46 
47  struct File {
48  std::string filename;
49  std::string data; // the data in the file, used to validate
50  };
51 
52 
55  std::vector<File> files_;
56 
59 
61  boost::scoped_ptr<DiskIoMgr> io_mgr_;
62 
64  boost::thread_group readers_;
65 
69 
72 
74  volatile bool shutdown_;
75 
78  void NewClient(int i);
79 
82  void ClientThread(int client_id);
83 
85  void CancelRandomReader();
86 };
87 
88 }
89 
90 #endif
std::vector< File > files_
DiskIoMgrStress(int num_disks, int num_threads_per_disk, int num_clients, bool includes_cancellation)
boost::thread_group readers_
Thread group for reader threads.
int num_clients_
Array of clients.
bool includes_cancellation_
If true, tests cancelling readers.
volatile bool shutdown_
Flag to signal that client reader threads should exit.
boost::scoped_ptr< DiskIoMgr > io_mgr_
io manager
void ClientThread(int client_id)
MemTracker dummy_tracker_
Dummy mem tracker.
This class is thread-safe.
Definition: mem-tracker.h:61
void CancelRandomReader()
Possibly cancels a random reader.
void Run(int sec)
Run the test for 'sec'. If 0, run forever.