Kinetic C/C++ Client
 All Classes Functions Variables Pages
nonblocking_kinetic_connection.h
1 /*
2  * kinetic-cpp-client
3  * Copyright (C) 2014 Seagate Technology.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  *
19  */
20 
21 #ifndef KINETIC_CPP_CLIENT_NONBLOCKING_KINETIC_CONNECTION_H_
22 #define KINETIC_CPP_CLIENT_NONBLOCKING_KINETIC_CONNECTION_H_
23 
24 #include "nonblocking_kinetic_connection_interface.h"
25 
26 namespace kinetic {
27 
29  public:
32  bool Run(fd_set *read_fds, fd_set *write_fds, int *nfds);
33  bool RemoveHandler(HandlerKey handler_key);
34  void SetClientClusterVersion(int64_t cluster_version);
35 
36  HandlerKey NoOp(const shared_ptr<SimpleCallbackInterface> callback);
37  HandlerKey Get(const string key, const shared_ptr<GetCallbackInterface> callback);
38  HandlerKey Get(const shared_ptr<const string> key, const shared_ptr<GetCallbackInterface> callback);
39  HandlerKey GetNext(const shared_ptr<const string> key, const shared_ptr<GetCallbackInterface> callback);
40  HandlerKey GetNext(const string key, const shared_ptr<GetCallbackInterface> callback);
41  HandlerKey GetPrevious(const shared_ptr<const string> key, const shared_ptr<GetCallbackInterface> callback);
42  HandlerKey GetPrevious(const string key, const shared_ptr<GetCallbackInterface> callback);
43  HandlerKey GetVersion(const shared_ptr<const string> key, const shared_ptr<GetVersionCallbackInterface> callback);
44  HandlerKey GetVersion(const string key, const shared_ptr<GetVersionCallbackInterface> callback);
45  HandlerKey GetKeyRange(const shared_ptr<const string> start_key, bool start_key_inclusive,
46  const shared_ptr<const string> end_key, bool end_key_inclusive,
47  bool reverse_results, int32_t max_results, const shared_ptr<GetKeyRangeCallbackInterface> callback);
48  HandlerKey GetKeyRange(const string start_key, bool start_key_inclusive,
49  const string end_key, bool end_key_inclusive,
50  bool reverse_results, int32_t max_results, const shared_ptr<GetKeyRangeCallbackInterface> callback);
51  HandlerKey Put(const shared_ptr<const string> key, const shared_ptr<const string> current_version, WriteMode mode,
52  const shared_ptr<const KineticRecord> record, const shared_ptr<PutCallbackInterface> callback);
53  HandlerKey Put(const string key, const string current_version, WriteMode mode,
54  const shared_ptr<const KineticRecord> record, const shared_ptr<PutCallbackInterface> callback);
55  HandlerKey Put(const shared_ptr<const string> key, const shared_ptr<const string> current_version, WriteMode mode,
56  const shared_ptr<const KineticRecord> record, const shared_ptr<PutCallbackInterface> callback,
57  PersistMode persistMode);
58  HandlerKey Put(const string key, const string current_version, WriteMode mode,
59  const shared_ptr<const KineticRecord> record, const shared_ptr<PutCallbackInterface> callback,
60  PersistMode persistMode);
61  HandlerKey Delete(const shared_ptr<const string> key, const shared_ptr<const string> version, WriteMode mode,
62  const shared_ptr<SimpleCallbackInterface> callback, PersistMode persistMode);
63  HandlerKey Delete(const string key, const string version, WriteMode mode,
64  const shared_ptr<SimpleCallbackInterface> callback, PersistMode persistMode);
65  HandlerKey Delete(const shared_ptr<const string> key, const shared_ptr<const string> version, WriteMode mode,
66  const shared_ptr<SimpleCallbackInterface> callback);
67  HandlerKey Delete(const string key, const string version, WriteMode mode,
68  const shared_ptr<SimpleCallbackInterface> callback);
69  HandlerKey P2PPush(const P2PPushRequest& push_request, const shared_ptr<P2PPushCallbackInterface> callback);
70  HandlerKey P2PPush(const shared_ptr<const P2PPushRequest> push_request,
71  const shared_ptr<P2PPushCallbackInterface> callback);
72  HandlerKey GetLog(const shared_ptr<GetLogCallbackInterface> callback);
73  HandlerKey GetLog(const vector<Command_GetLog_Type>& types, const shared_ptr<GetLogCallbackInterface> callback);
74 
75  HandlerKey UpdateFirmware(const shared_ptr<const string> new_firmware, const shared_ptr<SimpleCallbackInterface> callback);
76  HandlerKey SetClusterVersion(int64_t new_cluster_version, const shared_ptr<SimpleCallbackInterface> callback);
77 
78  HandlerKey InstantErase(const shared_ptr<string> pin, const shared_ptr<SimpleCallbackInterface> callback);
79  HandlerKey InstantErase(const string pin, const shared_ptr<SimpleCallbackInterface> callback);
80  HandlerKey SecureErase(const shared_ptr<string> pin, const shared_ptr<SimpleCallbackInterface> callback);
81  HandlerKey SecureErase(const string pin, const shared_ptr<SimpleCallbackInterface> callback);
82  HandlerKey LockDevice(const shared_ptr<string> pin, const shared_ptr<SimpleCallbackInterface> callback);
83  HandlerKey LockDevice(const string pin, const shared_ptr<SimpleCallbackInterface> callback);
84  HandlerKey UnlockDevice(const shared_ptr<string> pin, const shared_ptr<SimpleCallbackInterface> callback);
85  HandlerKey UnlockDevice(const string pin, const shared_ptr<SimpleCallbackInterface> callback);
86 
87  HandlerKey SetACLs(const shared_ptr<const list<ACL>> acls, const shared_ptr<SimpleCallbackInterface> callback);
88  HandlerKey SetErasePIN(const shared_ptr<const string> new_pin, const shared_ptr<const string> current_pin,
89  const shared_ptr<SimpleCallbackInterface> callback);
90  HandlerKey SetErasePIN(const string new_pin, const string current_pin,
91  const shared_ptr<SimpleCallbackInterface> callback);
92  HandlerKey SetLockPIN(const shared_ptr<const string> new_pin, const shared_ptr<const string> current_pin,
93  const shared_ptr<SimpleCallbackInterface> callback);
94  HandlerKey SetLockPIN(const string new_pin, const string current_pin,
95  const shared_ptr<SimpleCallbackInterface> callback);
96 
97 
98  private:
99  HandlerKey GenericGet(const shared_ptr<const string> key,
100  const shared_ptr<GetCallbackInterface> callback, Command_MessageType message_type);
101  void PopulateP2PMessage(Command_P2POperation *mutable_p2pop,
102  const shared_ptr<const P2PPushRequest> push_request);
103  unique_ptr<Command> NewCommand(Command_MessageType message_type);
104  Command_Synchronization GetSynchronizationForPersistMode(PersistMode persistMode);
105 
107  const shared_ptr<const string> empty_str_;
108 
109  int64_t cluster_version_;
110 
111  DISALLOW_COPY_AND_ASSIGN(NonblockingKineticConnection);
112 };
113 
114 } // namespace kinetic
115 
116 #endif // KINETIC_CPP_CLIENT_NONBLOCKING_KINETIC_CONNECTION_H_
Represents a collection of P2P operations.