27 #include <sys/param.h>
35 #define REPORT_ERRNO(en, msg) if(en != 0){errno = en; perror(msg);}
40 KineticSession* session;
53 write_args* thread_args = (write_args*)args;
60 snprintf(keySuffix,
sizeof(keySuffix),
"%02d", objIndex);
71 fprintf(stderr,
"Failed writing entry %d to disk w/status: %s",
76 printf(
"File stored successfully to Kinetic device across %d entries!\n", objIndex);
80 int main(
int argc,
char** argv)
86 KineticSession* session;
92 if (client == NULL) {
return 1; }
93 const char HmacKeyString[] =
"asdfasdf";
103 fprintf(stderr,
"Failed connecting to the Kinetic device w/status: %s\n",
109 const char* dataFile =
"test/support/data/test.data";
112 char* buf = malloc(st.st_size);
113 int fd = open(dataFile, O_RDONLY);
114 long dataLen = read(fd, buf, st.st_size);
117 fprintf(stderr,
"Failed reading data file to store: %s\n", dataFile);
121 write_args* writeArgs = calloc(
NUM_FILES,
sizeof(write_args));
122 if (writeArgs == NULL) {
123 fprintf(stderr,
"Failed allocating overlapped thread arguments!\n");
132 fprintf(stderr,
"Failed connecting to the Kinetic device w/status: %s\n",
136 strcpy(writeArgs[i].ip, sessionConfig.
host);
143 gettimeofday(&now, NULL);
144 snprintf(writeArgs[i].keyPrefix,
sizeof(writeArgs[i].keyPrefix),
"%010llu_%02d_",
145 (
unsigned long long)now.tv_sec, i);
149 writeArgs[i].key,
sizeof(writeArgs[i].key), writeArgs[i].keyPrefix),
151 writeArgs[i].tag,
sizeof(writeArgs[i].tag),
"some_value_tag..."),
157 int threadCreateStatus = pthread_create(&writeArgs[i].threadID, NULL,
store_data, &writeArgs[i]);
159 if (threadCreateStatus != 0) {
160 fprintf(stderr,
"pthread create failed!\n");
167 int joinStatus = pthread_join(writeArgs[i].threadID, NULL);
168 if (joinStatus != 0) {
169 fprintf(stderr,
"pthread join failed!\n");
Structure for an embedded ByteArray as a buffer.
KineticStatus KineticClient_CreateSession(KineticSessionConfig *const config, KineticClient *const client, KineticSession **session)
Creates a session with the Kinetic Device per specified configuration.
Structure used to specify the configuration for a session.
#define KINETIC_OBJ_SIZE
Max object/value size.
ByteBuffer * ByteBuffer_AppendArray(ByteBuffer *buffer, const ByteArray array)
#define REPORT_ERRNO(en, msg)
KineticStatus KineticClient_DestroySession(KineticSession *const session)
Closes the connection to a host.
char host[256]
Host name/IP address of Kinetic Device.
ByteBuffer * ByteBuffer_AppendCString(ByteBuffer *buffer, const char *data)
const char * Kinetic_GetStatusDescription(KineticStatus status)
Provides a string representation for a KineticStatus code.
ByteBuffer ByteBuffer_Create(void *data, size_t max_len, size_t used)
#define KINETIC_PORT
Default kinetic port.
They can be made persistent when the drive chooses, or when a subsequent FLUSH is sent to the drive...
long ByteBuffer_BytesRemaining(const ByteBuffer buffer)
const char * logFile
Path to log file. Specify 'stdout' to log to STDOUT or NULL to disable logging.
ByteBuffer key
Key associated with the object stored on disk.
ByteArray ByteBuffer_Consume(ByteBuffer *buffer, size_t max_len)
#define KINETIC_DEFAULT_KEY_LEN
Default key length.
KineticStatus
Kinetic status codes.
KineticStatus KineticClient_Put(KineticSession *const session, KineticEntry *const entry, KineticCompletionClosure *closure)
Executes a PUT operation to store/update an entry on the Kinetic Device.
Configuration values for the KineticClient connection.
void KineticClient_Shutdown(KineticClient *const client)
Performs shutdown/cleanup of the kinetic-c client library.
KineticClient * KineticClient_Init(KineticClientConfig *config)
Initializes the Kinetic API and configures logging.
size_t bytesUsed
Reflects the number of bytes used from the array
int main(int argc, char **argv)
KineticSynchronization synchronization
Synchronization method to use for PUT/DELETE requests.
void * store_data(void *args)
ByteArray ByteArray_CreateWithCString(const char *str)
ByteBuffer ByteBuffer_CreateAndAppendCString(void *data, size_t max_len, const char *value)
ByteBuffer value
Value data associated with the key.