0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
FsTestThreadFunction.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 3
9  * of the License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
26 
27 #include <Common/Compat.h>
28 
29 #include "FsTestThreadFunction.h"
30 
31 #include <FsBroker/Lib/Utility.h>
32 
33 #include <Common/Error.h>
34 #include <Common/Logger.h>
35 
36 #include <cerrno>
37 #include <iostream>
38 #include <vector>
39 
40 extern "C" {
41 #include <sys/types.h>
42 #include <sys/stat.h>
43 }
44 
45 using namespace Hypertable;
46 using namespace Tools::client;
47 using namespace std;
48 
49 void fsbroker::FsTestThreadFunction::operator()() {
50 
51  try {
52 
53  FsBroker::Lib::copy_from_local(m_client, m_input_file, m_dfs_file);
54 
55  FsBroker::Lib::copy_to_local(m_client, m_dfs_file, m_output_file);
56 
57  // Determine original file size
58  struct stat statbuf;
59  if (stat(m_input_file.c_str(), &statbuf) != 0)
60  HT_THROW(Error::EXTERNAL, (std::string)"Unable to stat file '"
61  + m_input_file + "' - " + strerror(errno));
62 
63  int64_t origsz = statbuf.st_size;
64 
65  // Make sure file exists
66  HT_ASSERT(m_client->exists(m_dfs_file));
67 
68  // Determine DFS file size
69  int64_t dfssz1 = m_client->length(m_dfs_file, false);
70  int64_t dfssz2 = m_client->length(m_dfs_file, true);
71 
72  if (origsz != dfssz1) {
73  HT_ERRORF("Length mismatch: %lld != %lld", (Lld)origsz, (Lld)dfssz1);
74  quick_exit(EXIT_FAILURE);
75  }
76  if (origsz != dfssz2) {
77  HT_ERRORF("Length mismatch: %lld != %lld", (Lld)origsz, (Lld)dfssz2);
78  quick_exit(EXIT_FAILURE);
79  }
80  }
81  catch (Exception &e) {
82  HT_ERROR_OUT << e << HT_END;
83  quick_exit(EXIT_FAILURE);
84  }
85 
91 }
STL namespace.
void copy_to_local(ClientPtr &client, const std::string &from, const std::string &to, int64_t offset=0)
Definition: Utility.cc:150
#define HT_ASSERT(_e_)
Definition: Logger.h:396
Logging routines and macros.
Compatibility Macros for C/C++.
#define HT_END
Definition: Logger.h:220
#define HT_ERROR_OUT
Definition: Logger.h:301
Declarations for FsTestThreadFunction.
Hypertable definitions
long long int Lld
Shortcut for printf formats.
Definition: String.h:53
void copy_from_local(ClientPtr &client, const std::string &from, const std::string &to, int64_t offset=0)
Definition: Utility.cc:100
This is a generic exception class for Hypertable.
Definition: Error.h:314
#define HT_ERRORF(msg,...)
Definition: Logger.h:300
Declarations of utility functions.
Error codes, Exception handling, error logging.
#define HT_THROW(_code_, _msg_)
Definition: Error.h:478