-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstorageAccessManager.h
82 lines (69 loc) · 2.42 KB
/
storageAccessManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/**
* @file storageAccessManager.h
* @author Krzysztof Trzepla
* @copyright (C) 2016 ACK CYFRONET AGH
* @copyright This software is released under the MIT license cited in
* 'LICENSE.txt'
*/
#ifndef ONECLIENT_STORAGE_ACCESS_MANAGER_H
#define ONECLIENT_STORAGE_ACCESS_MANAGER_H
#include "communication/communicator.h"
#include "options/options.h"
#include <boost/filesystem.hpp>
#include <folly/FBString.h>
#include <vector>
namespace one {
namespace helpers {
class StorageHelper;
class StorageHelperCreator;
}
namespace messages {
namespace fuse {
class StorageTestFile;
}
}
namespace client {
/**
* The StorageAccessManager class is responsible for detecting storages that are
* directly accessible to the client.
*/
class StorageAccessManager {
public:
/**
* Constructor.
* @param helperFactory Instance of @c helpers::StorageHelperCreator.
*/
StorageAccessManager(helpers::StorageHelperCreator &helperFactory,
const options::Options &options);
/**
* Verifies the test file by reading it from the storage and checking its
* content with the one sent by the server.
* @param storageId Id of the storage
* @param testFile Instance of @c messages::fuse::StorageTestFile.
* @return Storage helper object used to access the test file or nullptr if
* verification fails.
*/
std::shared_ptr<helpers::StorageHelper> verifyStorageTestFile(
const folly::fbstring &storageId,
const messages::fuse::StorageTestFile &testFile);
/**
* Modifies the test file by writing random sequence of characters.
* @param storageId Id of the storage
* @param helper Storage helper object used to access the test file.
* @param testFile Instance of @c messages::fuse::StorageTestFile.
* @return Modified content of the test file.
*/
folly::fbstring modifyStorageTestFile(const folly::fbstring &storageId,
std::shared_ptr<helpers::StorageHelper> helper,
const messages::fuse::StorageTestFile &testFile);
private:
bool verifyStorageTestFile(const folly::fbstring &storageId,
std::shared_ptr<helpers::StorageHelper> helper,
const messages::fuse::StorageTestFile &testFile);
helpers::StorageHelperCreator &m_helperFactory;
// Reference to command line options provided to Oneclient
const options::Options &m_options;
};
} // namespace client
} // namespace one
#endif // ONECLIENT_STORAGE_ACCESS_MANAGER_H