kinetic-c  v0.12.0
Seagate Kinetic Protocol Client Library for C
kinetic_types.h
Go to the documentation of this file.
1 /*
2 * kinetic-c
3 * Copyright (C) 2015 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_TYPES_H
22 #define _KINETIC_TYPES_H
23 
24 // Include C99 bool definition, if not already defined
25 #if !defined(__bool_true_false_are_defined) || (__bool_true_false_are_defined == 0)
26 #include <stdbool.h>
27 #endif
28 #include <stdint.h>
29 #include <inttypes.h>
30 #include <stddef.h>
31 #include <string.h>
32 #include <stdio.h>
33 #include <assert.h>
34 #include <limits.h>
35 #include <sys/time.h>
36 #include "byte_array.h"
37 
38 
39 #define KINETIC_SOCKET_INVALID (-1)
40 #define KINETIC_PORT (8123)
41 #define KINETIC_TLS_PORT (8443)
42 #define KINETIC_HMAC_SHA1_LEN (SHA_DIGEST_LENGTH)
43 #define KINETIC_HMAC_MAX_LEN (KINETIC_HMAC_SHA1_LEN)
44 #define KINETIC_PIN_MAX_LEN (1024)
45 #define KINETIC_DEFAULT_KEY_LEN (1024)
46 #define KINETIC_MAX_KEY_LEN (4096)
47 #define KINETIC_OBJ_SIZE (1024 * 1024)
48 
49 // Define max host name length
50 // Some Linux environments require this, although not all, but it's benign.
51 #ifndef _BSD_SOURCE
52 #define _BSD_SOURCE
53 #endif // _BSD_SOURCE
54 #include <unistd.h>
55 #include <sys/types.h>
56 #ifndef HOST_NAME_MAX
57 #define HOST_NAME_MAX 256
58 #endif // HOST_NAME_MAX
59 
60 
64  typedef struct {
65  const char * version;
66  const char * protocolVersion;
67  const char * repoCommitHash;
69 
73 typedef enum _KineticAlgorithm {
81 
82 
86 typedef enum _KineticSynchronization {
87 
90 
94 
98 
106 
107 
108 struct _KineticClient;
112 typedef struct _KineticClient KineticClient;
113 
114 
118 typedef struct _KineticSessionConfig {
120  char host[HOST_NAME_MAX];
121 
123  int port;
124 
128  int64_t clusterVersion;
129 
133  int64_t identity;
134 
137  uint8_t keyData[KINETIC_MAX_KEY_LEN];
139 
141  bool useSsl;
142 
144  uint16_t timeoutSeconds;
146 
150 typedef struct _KineticSession KineticSession;
151 
155 typedef enum {
192 } KineticStatus;
193 
201 const char* Kinetic_GetStatusDescription(KineticStatus status);
202 
206 typedef struct _KineticCompletionData {
207  int64_t connectionID;
208  int64_t sequence;
209  struct timeval requestTime;
212 
219 typedef void (*KineticCompletionCallback)(KineticCompletionData* kinetic_data, void* client_data);
220 
221 
225 typedef struct _KineticCompletionClosure {
227  void* clientData;
229 
235 typedef struct _KineticEntry {
238 
239  // Metadata
243 
244  // Operation-specific attributes (TODO: remove from struct, and specify a attributes to PUT/GET operations)
247  bool force;
248  bool computeTag;
250 } KineticEntry;
251 
255 typedef struct _KineticKeyRange {
256 
259 
262 
266 
270 
273  int32_t maxReturned;
274 
281  bool reverse;
283 
284 // Kinetic GetLog data types
285 
289 typedef enum {
298 
302 typedef struct {
303  char* name;
304  float value;
306 
310 typedef struct {
311  char* name;
312  float current;
313  float minimum;
314  float maximum;
315  float target;
317 
321 typedef struct {
323  float portionFull;
325 
329 typedef struct {
330  char* name;
335 
339 typedef struct {
340  char* vendor;
341  char* model;
344  char* version;
346  char* sourceHash;
352  int32_t port;
353  int32_t tlsPort;
355 
359 typedef enum {
394 
398 typedef struct {
400  uint64_t count;
401  uint64_t bytes;
403 
407 typedef struct {
408  uint32_t maxKeySize;
409  uint32_t maxValueSize;
410  uint32_t maxVersionSize;
411  uint32_t maxTagSize;
412  uint32_t maxConnections;
415  uint32_t maxMessageSize;
418  uint32_t maxPinSize;
420 
424 typedef struct {
427 
431 typedef struct {
444 
448 typedef struct {
449  char* hostname;
450  int32_t port;
451  bool tls;
453 
457 typedef struct _KineticP2P_Operation KineticP2P_Operation;
458 
462 typedef struct {
464  ByteBuffer version; // optional (defaults to force if not specified)
466  KineticP2P_Operation* chainedOperation;
467  KineticStatus resultStatus; // populated with the result of the operation
469 
472  size_t numOperations;
474 };
475 
479 #define KINETIC_P2P_OPERATION_LIMIT 100000
480 
484 #define KINETIC_P2P_MAX_NESTING 1000
485 
490 #define KINETIC_CLIENT_DEFAULT_LOG_LEVEL 0
491 #define KINETIC_CLIENT_DEFAULT_READER_THREADS 4
492 #define KINETIC_CLIENT_DEFAULT_MAX_THREADPOOL_THREADS 8
493 
500 typedef struct {
501  const char *logFile;
502  int logLevel;
503  uint8_t readerThreads;
506 
515 
516 #endif // _KINETIC_TYPES_H
Log info device limits.
Handle to the kinetic client, which is shared by all connections.
An HMAC validation error was detected.
uint8_t maxThreadpoolThreads
Max number of threads to use for the threadpool that handles response callbacks.
Structure for handling generic arrays of bytes.
Definition: byte_array.h:34
KineticSynchronization
Enumeration of synchronization types for an operation on a KineticEntry.
Definition: kinetic_types.h:86
KineticP2P_Peer peer
Structure for an embedded ByteArray as a buffer.
Definition: byte_array.h:53
One or more of byte buffers did not fit all data.
bool reverse
Optional bool, defaults to false If true, the key range will be returned in reverse order...
This request is made persistent before returning.
Definition: kinetic_types.h:93
int logLevel
Logging level (-1:none, 0:error, 1:info, 2:verbose, 3:full)
size_t numStatistics
Invalid algorithm value.
Definition: kinetic_types.h:74
int64_t sequence
Sequence count for the operation.
ByteBuffer tag
Generated authentication hash per the specified algorithm
Operation successful.
Log info device name (used as a key for device-specific log data)
bool tls
If set, will use TLS for peer connection. Optional, defaults to false.
size_t numTemperatures
Structure used to specify the configuration for a session.
No request was attempted.
bool endKeyInclusive
Optional bool, defaults to false If set, indicates that the end key should be included in the returne...
KineticMessageType messageType
Authorization failure.
Device did not respond to the operation in time.
All pending information that has not been written is pushed to the disk and the command that specifie...
Host was empty in request.
const char * protocolVersion
kinetic-protocol version library is built with
Definition: kinetic_types.h:66
bool force
If set for a GET/DELETE request, will override version checking.
bool metadataOnly
If set for a GET request, will return only the metadata for the specified object (value will not be r...
#define KINETIC_MAX_KEY_LEN
Max key length.
Definition: kinetic_types.h:46
The operation failed because the device is securely locked. An UNLOCK must be issued to unlock for us...
Peer-to-peer opearation instance.
The specified object version info for a PUT/GET do not match stored object.
uint32_t maxOutstandingWriteRequests
Something about the request is invalid.
KineticLogInfo_Capacity * capacity
Log info network interface entry.
The operation requires an SSL connection and the specified connection is non-SSL. ...
char * hostname
Host name of peer/destination. Pointer must remain valid until operation completes.
KineticAlgorithm algorithm
Algorithm used to generate the specified tag
KineticLogInfo_Configuration * configuration
int64_t identity
The identity associated with this request.
Failed allocating/deallocating memory.
KineticAlgorithm
Enumeration of encryption/checksum key algorithms.
Definition: kinetic_types.h:73
int32_t port
Port to etablish peer connection to destination host.
Log info device configuration.
const char * repoCommitHash
repository commit hash which library is built from
Definition: kinetic_types.h:67
uint32_t maxOutstandingReadRequests
Number of status codes in KineticStatusDescriptor.
const char * version
kinetic-c library version
Definition: kinetic_types.h:65
Device busy (retry later)
uint16_t timeoutSeconds
Operation timeout. If 0, use the default (10 seconds).
The device log type specified was invalid.
KineticLogInfo_Limits * limits
Closure which can be specified for operations which support asynchronous mode.
Kinetic object instance.
Configuration of remote peer for a PEER2PEERPUSH operation.
ByteArray messages
const char * Kinetic_GetStatusDescription(KineticStatus status)
Provides a string representation for a KineticStatus code.
Definition: kinetic_types.c:67
KineticLogInfo_Type
Log info type.
A security operation failed due to bad ACL(s)
The requested object does not exist.
int32_t maxReturned
Required int32, must be greater than 0 The maximum number of keys returned, in sorted order...
kinetic-c library version info (returned from KineticClient_Version())
Definition: kinetic_types.h:64
KineticP2P_OperationData * operations
Number of operations in operations array
Kinetic Key Range request structure.
Base log info structure which is allocated by client and passed to KineticAdminClient_GetLog.
No connection/disconnected.
A timeout occurred while waiting for a socket operation.
KineticLogInfo_Interface * interfaces
uint8_t readerThreads
Number of threads used for handling incoming responses and status messages.
KineticLogInfo_Device * device
Specified file does not exist or could not be read/writtten.
void(* KineticCompletionCallback)(KineticCompletionData *kinetic_data, void *client_data)
Operation completion callback function prototype.
KineticCompletionCallback callback
Function to be called upon completion.
An instance of a session with a Kinetic device.
They can be made persistent when the drive chooses, or when a subsequent FLUSH is sent to the drive...
Definition: kinetic_types.h:97
int64_t clusterVersion
The version number of this cluster definition.
ByteBuffer startKey
Required bytes, the beginning of the requested range.
Completion data which will be provided to KineticCompletionClosure for asynchronous operations...
Invalid synchronization value.
Definition: kinetic_types.h:89
int port
Port for Kinetic Device session.
Log info statistics entry.
No operation has been attempted.
Operation was invalid.
Session was NULL in request.
size_t numOperations
Peer to perform operations with
Device reported an operation error.
int64_t connectionID
Connection ID for the session.
KineticLogInfo_Utilization * utilizations
Log info untilization entry.
The session has been terminated by the Kinetic device.
KineticLogInfo_Statistics * statistics
const char * logFile
Path to log file. Specify 'stdout' to log to STDOUT or NULL to disable logging.
bool computeTag
If set and an algorithm is specified, the tag will be populated with the calculated hash for integrit...
KineticLogInfo_Temperature * temperatures
size_t numUtilizations
ByteBuffer newVersion
New version for the object to assume once written to disk (optional)
An operation is missing a PIN.
ByteBuffer key
Key associated with the object stored on disk.
bool startKeyInclusive
Optional bool, defaults to false If set, indicates that the start key should be included in the retur...
An operation is missing a required key.
const char * KineticMessageType_GetName(KineticMessageType type)
Provides a string representation for a Kinetic message type.
KineticStatus status
Resultant status of the operation.
Status not available (no reponse/status available)
A device name is required, but was empty.
All PDUs for the session have been allocated.
#define HOST_NAME_MAX
Definition: kinetic_types.h:57
KineticStatus
Kinetic status codes.
Device reported data error, no space or HMAC failure.
KineticMessageType
Log info message types.
An I/O error occurred during a socket operation.
Configuration values for the KineticClient connection.
bool useSsl
Set to `true' to enable SSL for for this session.
void * clientData
Optional client-supplied data which will be supplied to callback.
KineticStatus resultStatus
ByteBuffer dbVersion
Current version of the entry (optional)
ByteBuffer endKey
Required bytes, the end of the requested range.
Log info capacity entry.
An operation is missing a required value buffer.
KineticSynchronization synchronization
Synchronization method to use for PUT/DELETE requests.
Log info temperature entry.
HMAC key is empty or NULL.
Specified cluster version does not match device.
Peer-to-peer operation data structure.
ByteBuffer value
Value data associated with the key.
Session configuration was invalid or NULL.
KineticP2P_Operation * chainedOperation