Loading RELEASE.md +2 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ v0.11.0 (kinetic-protocol 3.0.5) -------------------------------- * Changed API to use a `KineticClientConfig` struct, to keep future configuration changes from breaking the source API. * Added options for the number of writer, reader, and max threadpool threads, with defaults. * Added KineticClient_FreeDeviceInfo to free the `KineticDeviceInfo` structure allocated by `KineticClient_GetLog`. * Added several new examples under src/examples/. v0.10.1 (kinetic-protocol 3.0.5) -------------------------------- Loading include/kinetic_client.h +9 −0 Original line number Diff line number Diff line Loading @@ -244,6 +244,15 @@ KineticStatus KineticClient_GetLog(KineticSession const * const session, KineticDeviceInfo** info, KineticCompletionClosure* closure); /** * @brief Free the KineticDeviceInfo result from KineticClient_GetLog. * * @param session The connected KineticSession to use for the operation * @param info The KineticDeviceInfo result to free. */ void KineticClient_FreeDeviceInfo(KineticSession const * const session, KineticDeviceInfo* info); /** * @brief Executes a PEER2PEERPUSH operation allows a client to instruct a Kinetic * Device to copy a set of keys (and associated value and metadata) to another Loading include/kinetic_types.h +0 −1 Original line number Diff line number Diff line Loading @@ -326,7 +326,6 @@ typedef struct { ByteArray name; } KineticDeviceInfo_Device; typedef struct { size_t totalLength; KineticDeviceInfo_Utilization* utilizations; size_t numUtilizations; KineticDeviceInfo_Temperature* temperatures; Loading src/examples/blocking_flush.c 0 → 100644 +80 −0 Original line number Diff line number Diff line /* * kinetic-c * Copyright (C) 2014 Seagate Technology. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ #include "kinetic_client.h" #include "kinetic_types.h" #include "byte_array.h" #include <stdlib.h> #include <getopt.h> #include <stdio.h> #include <sys/param.h> #include <sys/stat.h> #include <sys/file.h> #include <ctype.h> #include <openssl/sha.h> static void do_flush(KineticSession *session) { /* Send a Flush command. * Blocking, because the completion closure is NULL. */ KineticStatus status = KineticClient_Flush(session, NULL); printf("Flush status: %s\n", Kinetic_GetStatusDescription(status)); /* No cleanup necessary */ } int main(int argc, char** argv) { (void)argc; (void)argv; // Establish connection KineticStatus status; const char HmacKeyString[] = "asdfasdf"; KineticSession session = { .config = (KineticSessionConfig) { .host = "localhost", .port = KINETIC_PORT, .clusterVersion = 0, .identity = 1, .hmacKey = ByteArray_CreateWithCString(HmacKeyString) } }; KineticClientConfig client_config = { .logFile = "stdout", .logLevel = 1, }; KineticClient * client = KineticClient_Init(&client_config); if (client == NULL) { return 1; } status = KineticClient_CreateConnection(&session, client); if (status != KINETIC_STATUS_SUCCESS) { fprintf(stderr, "Connection to host '%s' failed w/ status: %s\n", session.config.host, Kinetic_GetStatusDescription(status)); exit(1); } do_flush(&session); // Shutdown client connection and cleanup KineticClient_DestroyConnection(&session); KineticClient_Shutdown(client); return 0; } src/examples/blocking_getnext_getprevious.c 0 → 100644 +167 −0 Original line number Diff line number Diff line /* * kinetic-c * Copyright (C) 2014 Seagate Technology. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ #include "kinetic_client.h" #include "kinetic_types.h" #include "byte_array.h" #include <stdlib.h> #include <getopt.h> #include <stdio.h> #include <sys/param.h> #include <sys/stat.h> #include <sys/file.h> #include <ctype.h> #include <openssl/sha.h> static void do_put_and_getprevious_getnext(KineticSession *session) { for (int i = 0; i < 3; i++) { char key[] = "keyX"; key[3] = '0' + i; ByteBuffer put_key_buf = ByteBuffer_MallocAndAppend(key, strlen(key)); uint8_t value[] = "valueX"; value[5] = '0' + i; ByteBuffer put_value_buf = ByteBuffer_MallocAndAppend(value, sizeof(value)); /* Populate tag with SHA1 of value */ ByteBuffer put_tag_buf = ByteBuffer_Malloc(20); uint8_t sha1[20]; SHA1(put_value_buf.array.data, put_value_buf.bytesUsed, &sha1[0]); ByteBuffer_Append(&put_tag_buf, sha1, sizeof(sha1)); KineticEntry put_entry = { .key = put_key_buf, .value = put_value_buf, .tag = put_tag_buf, .algorithm = KINETIC_ALGORITHM_SHA1, /* Set sync to WRITETHROUGH, which will wait to complete * until the drive has persistend the write. (WRITEBACK * returns as soon as the drive has buffered the write.) */ .synchronization = KINETIC_SYNCHRONIZATION_WRITETHROUGH, }; /* Put "keyX" => "valueX", where 'X' is 0..4. * This will block, because the callback field (arg 3) is NULL. */ KineticStatus status = KineticClient_Put(session, &put_entry, NULL); printf("Put status: %s\n", Kinetic_GetStatusDescription(status)); ByteBuffer_Free(put_key_buf); ByteBuffer_Free(put_value_buf); ByteBuffer_Free(put_tag_buf); } printf("\n\n\n"); for (int i = 1; i < 3; i++) { KineticStatus status = KINETIC_STATUS_INVALID; static const ssize_t sz = 100; char key_buf[sz]; char tag_buf[sz]; char value_buf[sz]; ByteBuffer keyBuffer = ByteBuffer_CreateAndAppendFormattedCString(key_buf, sz, "key%d", i); ByteBuffer tagBuffer = ByteBuffer_CreateAndAppendFormattedCString(tag_buf, sz, "tag%d", i); ByteBuffer valueBuffer = ByteBuffer_Create(value_buf, sz, 0); KineticEntry entry = { .key = keyBuffer, .tag = tagBuffer, .value = valueBuffer, .algorithm = KINETIC_ALGORITHM_SHA1, }; if (i > 0) { status = KineticClient_GetPrevious(session, &entry, NULL); printf("GetPrevious status: %s\n", Kinetic_GetStatusDescription(status)); if (status == KINETIC_STATUS_SUCCESS) { printf("Previous key before 'key%d': '%s', value '%s'\n", i, key_buf, value_buf); } } } for (int i = 0; i < 2; i++) { KineticStatus status = KINETIC_STATUS_INVALID; static const ssize_t sz = 100; char key_buf[sz]; char tag_buf[sz]; char value_buf[sz]; ByteBuffer keyBuffer = ByteBuffer_CreateAndAppendFormattedCString(key_buf, sz, "key%d", i); ByteBuffer tagBuffer = ByteBuffer_CreateAndAppendFormattedCString(tag_buf, sz, "tag%d", i); ByteBuffer valueBuffer = ByteBuffer_Create(value_buf, sz, 0); KineticEntry entry = { .key = keyBuffer, .tag = tagBuffer, .value = valueBuffer, .algorithm = KINETIC_ALGORITHM_SHA1, }; if (i < 2) { status = KineticClient_GetNext(session, &entry, NULL); printf("GetNext status: %s\n", Kinetic_GetStatusDescription(status)); if (status == KINETIC_STATUS_SUCCESS) { printf("Next key after 'key%d': '%s', value '%s'\n", i, key_buf, value_buf); } } } /* No cleanup necessary */ } int main(int argc, char** argv) { (void)argc; (void)argv; // Establish connection KineticStatus status; const char HmacKeyString[] = "asdfasdf"; KineticSession session = { .config = (KineticSessionConfig) { .host = "localhost", .port = KINETIC_PORT, .clusterVersion = 0, .identity = 1, .hmacKey = ByteArray_CreateWithCString(HmacKeyString) } }; KineticClientConfig client_config = { .logFile = "stdout", .logLevel = 1, }; KineticClient * client = KineticClient_Init(&client_config); if (client == NULL) { return 1; } status = KineticClient_CreateConnection(&session, client); if (status != KINETIC_STATUS_SUCCESS) { fprintf(stderr, "Connection to host '%s' failed w/ status: %s\n", session.config.host, Kinetic_GetStatusDescription(status)); exit(1); } do_put_and_getprevious_getnext(&session); // Shutdown client connection and cleanup KineticClient_DestroyConnection(&session); KineticClient_Shutdown(client); return 0; } Loading
RELEASE.md +2 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ v0.11.0 (kinetic-protocol 3.0.5) -------------------------------- * Changed API to use a `KineticClientConfig` struct, to keep future configuration changes from breaking the source API. * Added options for the number of writer, reader, and max threadpool threads, with defaults. * Added KineticClient_FreeDeviceInfo to free the `KineticDeviceInfo` structure allocated by `KineticClient_GetLog`. * Added several new examples under src/examples/. v0.10.1 (kinetic-protocol 3.0.5) -------------------------------- Loading
include/kinetic_client.h +9 −0 Original line number Diff line number Diff line Loading @@ -244,6 +244,15 @@ KineticStatus KineticClient_GetLog(KineticSession const * const session, KineticDeviceInfo** info, KineticCompletionClosure* closure); /** * @brief Free the KineticDeviceInfo result from KineticClient_GetLog. * * @param session The connected KineticSession to use for the operation * @param info The KineticDeviceInfo result to free. */ void KineticClient_FreeDeviceInfo(KineticSession const * const session, KineticDeviceInfo* info); /** * @brief Executes a PEER2PEERPUSH operation allows a client to instruct a Kinetic * Device to copy a set of keys (and associated value and metadata) to another Loading
include/kinetic_types.h +0 −1 Original line number Diff line number Diff line Loading @@ -326,7 +326,6 @@ typedef struct { ByteArray name; } KineticDeviceInfo_Device; typedef struct { size_t totalLength; KineticDeviceInfo_Utilization* utilizations; size_t numUtilizations; KineticDeviceInfo_Temperature* temperatures; Loading
src/examples/blocking_flush.c 0 → 100644 +80 −0 Original line number Diff line number Diff line /* * kinetic-c * Copyright (C) 2014 Seagate Technology. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ #include "kinetic_client.h" #include "kinetic_types.h" #include "byte_array.h" #include <stdlib.h> #include <getopt.h> #include <stdio.h> #include <sys/param.h> #include <sys/stat.h> #include <sys/file.h> #include <ctype.h> #include <openssl/sha.h> static void do_flush(KineticSession *session) { /* Send a Flush command. * Blocking, because the completion closure is NULL. */ KineticStatus status = KineticClient_Flush(session, NULL); printf("Flush status: %s\n", Kinetic_GetStatusDescription(status)); /* No cleanup necessary */ } int main(int argc, char** argv) { (void)argc; (void)argv; // Establish connection KineticStatus status; const char HmacKeyString[] = "asdfasdf"; KineticSession session = { .config = (KineticSessionConfig) { .host = "localhost", .port = KINETIC_PORT, .clusterVersion = 0, .identity = 1, .hmacKey = ByteArray_CreateWithCString(HmacKeyString) } }; KineticClientConfig client_config = { .logFile = "stdout", .logLevel = 1, }; KineticClient * client = KineticClient_Init(&client_config); if (client == NULL) { return 1; } status = KineticClient_CreateConnection(&session, client); if (status != KINETIC_STATUS_SUCCESS) { fprintf(stderr, "Connection to host '%s' failed w/ status: %s\n", session.config.host, Kinetic_GetStatusDescription(status)); exit(1); } do_flush(&session); // Shutdown client connection and cleanup KineticClient_DestroyConnection(&session); KineticClient_Shutdown(client); return 0; }
src/examples/blocking_getnext_getprevious.c 0 → 100644 +167 −0 Original line number Diff line number Diff line /* * kinetic-c * Copyright (C) 2014 Seagate Technology. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ #include "kinetic_client.h" #include "kinetic_types.h" #include "byte_array.h" #include <stdlib.h> #include <getopt.h> #include <stdio.h> #include <sys/param.h> #include <sys/stat.h> #include <sys/file.h> #include <ctype.h> #include <openssl/sha.h> static void do_put_and_getprevious_getnext(KineticSession *session) { for (int i = 0; i < 3; i++) { char key[] = "keyX"; key[3] = '0' + i; ByteBuffer put_key_buf = ByteBuffer_MallocAndAppend(key, strlen(key)); uint8_t value[] = "valueX"; value[5] = '0' + i; ByteBuffer put_value_buf = ByteBuffer_MallocAndAppend(value, sizeof(value)); /* Populate tag with SHA1 of value */ ByteBuffer put_tag_buf = ByteBuffer_Malloc(20); uint8_t sha1[20]; SHA1(put_value_buf.array.data, put_value_buf.bytesUsed, &sha1[0]); ByteBuffer_Append(&put_tag_buf, sha1, sizeof(sha1)); KineticEntry put_entry = { .key = put_key_buf, .value = put_value_buf, .tag = put_tag_buf, .algorithm = KINETIC_ALGORITHM_SHA1, /* Set sync to WRITETHROUGH, which will wait to complete * until the drive has persistend the write. (WRITEBACK * returns as soon as the drive has buffered the write.) */ .synchronization = KINETIC_SYNCHRONIZATION_WRITETHROUGH, }; /* Put "keyX" => "valueX", where 'X' is 0..4. * This will block, because the callback field (arg 3) is NULL. */ KineticStatus status = KineticClient_Put(session, &put_entry, NULL); printf("Put status: %s\n", Kinetic_GetStatusDescription(status)); ByteBuffer_Free(put_key_buf); ByteBuffer_Free(put_value_buf); ByteBuffer_Free(put_tag_buf); } printf("\n\n\n"); for (int i = 1; i < 3; i++) { KineticStatus status = KINETIC_STATUS_INVALID; static const ssize_t sz = 100; char key_buf[sz]; char tag_buf[sz]; char value_buf[sz]; ByteBuffer keyBuffer = ByteBuffer_CreateAndAppendFormattedCString(key_buf, sz, "key%d", i); ByteBuffer tagBuffer = ByteBuffer_CreateAndAppendFormattedCString(tag_buf, sz, "tag%d", i); ByteBuffer valueBuffer = ByteBuffer_Create(value_buf, sz, 0); KineticEntry entry = { .key = keyBuffer, .tag = tagBuffer, .value = valueBuffer, .algorithm = KINETIC_ALGORITHM_SHA1, }; if (i > 0) { status = KineticClient_GetPrevious(session, &entry, NULL); printf("GetPrevious status: %s\n", Kinetic_GetStatusDescription(status)); if (status == KINETIC_STATUS_SUCCESS) { printf("Previous key before 'key%d': '%s', value '%s'\n", i, key_buf, value_buf); } } } for (int i = 0; i < 2; i++) { KineticStatus status = KINETIC_STATUS_INVALID; static const ssize_t sz = 100; char key_buf[sz]; char tag_buf[sz]; char value_buf[sz]; ByteBuffer keyBuffer = ByteBuffer_CreateAndAppendFormattedCString(key_buf, sz, "key%d", i); ByteBuffer tagBuffer = ByteBuffer_CreateAndAppendFormattedCString(tag_buf, sz, "tag%d", i); ByteBuffer valueBuffer = ByteBuffer_Create(value_buf, sz, 0); KineticEntry entry = { .key = keyBuffer, .tag = tagBuffer, .value = valueBuffer, .algorithm = KINETIC_ALGORITHM_SHA1, }; if (i < 2) { status = KineticClient_GetNext(session, &entry, NULL); printf("GetNext status: %s\n", Kinetic_GetStatusDescription(status)); if (status == KINETIC_STATUS_SUCCESS) { printf("Next key after 'key%d': '%s', value '%s'\n", i, key_buf, value_buf); } } } /* No cleanup necessary */ } int main(int argc, char** argv) { (void)argc; (void)argv; // Establish connection KineticStatus status; const char HmacKeyString[] = "asdfasdf"; KineticSession session = { .config = (KineticSessionConfig) { .host = "localhost", .port = KINETIC_PORT, .clusterVersion = 0, .identity = 1, .hmacKey = ByteArray_CreateWithCString(HmacKeyString) } }; KineticClientConfig client_config = { .logFile = "stdout", .logLevel = 1, }; KineticClient * client = KineticClient_Init(&client_config); if (client == NULL) { return 1; } status = KineticClient_CreateConnection(&session, client); if (status != KINETIC_STATUS_SUCCESS) { fprintf(stderr, "Connection to host '%s' failed w/ status: %s\n", session.config.host, Kinetic_GetStatusDescription(status)); exit(1); } do_put_and_getprevious_getnext(&session); // Shutdown client connection and cleanup KineticClient_DestroyConnection(&session); KineticClient_Shutdown(client); return 0; }