Commit 83c183b8 authored by Greg Williams's avatar Greg Williams
Browse files

Refacatored out per-operation duplication into new kinetic_controller

parents 5ae0d00e f2f16109
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ VERSION = ${shell head -n1 $(VERSION_FILE)}

KINETIC_LIB_NAME = $(PROJECT).$(VERSION)
KINETIC_LIB = $(BIN_DIR)/lib$(KINETIC_LIB_NAME).a
LIB_INCS = -I$(LIB_DIR) -I$(PUB_INC) -I$(PROTOBUFC) -I$(VENDOR)
LIB_INCS = -I$(LIB_DIR) -I$(PUB_INC) -I$(PROTOBUFC) -I$(SOCKET99) -I$(VENDOR)
LIB_DEPS = \
	$(PROTOBUFC)/protobuf-c/protobuf-c.h \
	$(SOCKET99)/socket99.h \
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@
  :include:
    - src/**
    - include/**
    - vendor/
    - vendor/socket99/**
    - vendor/protobuf-c/**

:defines:
+1 −0
Original line number Diff line number Diff line
@@ -211,6 +211,7 @@ typedef enum {
    KINETIC_LOG_DATA_TYPE_STATISTICS,
    KINETIC_LOG_DATA_TYPE_MESSAGES,
    KINETIC_LOG_DATA_TYPE_LIMITS,
    KINETIC_LOG_DATA_TYPE_DEVICE,
} KineticLogDataType;

#endif // _KINETIC_TYPES_H
+42 −33
Original line number Diff line number Diff line
@@ -20,12 +20,9 @@

#include "kinetic_client.h"
#include "kinetic_types_internal.h"
#include "kinetic_pdu.h"
#include "kinetic_operation.h"
#include "kinetic_connection.h"
#include "kinetic_message.h"
#include "kinetic_pdu.h"
#include "kinetic_allocator.h"
#include "kinetic_controller.h"
#include "kinetic_operation.h"
#include "kinetic_logger.h"
#include <stdlib.h>
#include <sys/time.h>
@@ -114,70 +111,68 @@ KineticStatus KineticClient_Disconnect(KineticSessionHandle* const handle)

KineticStatus KineticClient_NoOp(KineticSessionHandle handle)
{
    KineticOperation* operation;
    KineticStatus status = KineticController_CreateOperation(&operation, handle);
    if (status != KINETIC_STATUS_SUCCESS) {return status;}

    // Initialize request
    KineticOperation_BuildNoop(operation);
    assert(handle != KINETIC_HANDLE_INVALID);

    // Execute the operation
    status = KineticController_ExecuteOperation(operation);
    KineticOperation* operation = KineticController_CreateOperation(handle);
    if (operation == NULL) {return KINETIC_STATUS_MEMORY_ERROR;}

    return status;
    KineticOperation_BuildNoop(operation);
    return KineticController_ExecuteOperation(operation, NULL);
}

KineticStatus KineticClient_Put(KineticSessionHandle handle,
                                KineticEntry* const entry,
                                KineticCompletionClosure* closure)
{
    assert(handle != KINETIC_HANDLE_INVALID);
    assert(entry != NULL);
    assert(entry->value.array.data != NULL);
    KineticOperation* operation;
    KineticStatus status = KineticController_CreateOperation(&operation, handle);
    if (status != KINETIC_STATUS_SUCCESS) {return status;}

    KineticOperation* operation = KineticController_CreateOperation(handle);
    if (operation == NULL) {return KINETIC_STATUS_MEMORY_ERROR;}

    // Initialize request
    KineticOperation_BuildPut(operation, entry);
    if (closure != NULL) {operation->closure = *closure;}

    // Execute the operation
    return KineticController_ExecuteOperation(operation);
    return KineticController_ExecuteOperation(operation, closure);
}

KineticStatus KineticClient_Get(KineticSessionHandle handle,
                                KineticEntry* const entry,
                                KineticCompletionClosure* closure)
{
    assert(handle != KINETIC_HANDLE_INVALID);
    assert(entry != NULL);
    if (!entry->metadataOnly) {assert(entry->value.array.data != NULL);}
    KineticOperation* operation;
    KineticStatus status = KineticController_CreateOperation(&operation, handle);
    if (status != KINETIC_STATUS_SUCCESS) {return status;}

    KineticOperation* operation = KineticController_CreateOperation(handle);
    if (operation == NULL) {return KINETIC_STATUS_MEMORY_ERROR;}

    // Initialize request
    KineticOperation_BuildGet(operation, entry);
    if (closure != NULL) {operation->closure = *closure;}

    // Execute the operation
    return KineticController_ExecuteOperation(operation);
    return KineticController_ExecuteOperation(operation, closure);
}

KineticStatus KineticClient_Delete(KineticSessionHandle handle,
                                   KineticEntry* const entry,
                                   KineticCompletionClosure* closure)
{
    assert(handle != KINETIC_HANDLE_INVALID);
    assert(entry != NULL);
    KineticOperation* operation;
    KineticStatus status = KineticController_CreateOperation(&operation, handle);
    if (status != KINETIC_STATUS_SUCCESS) {return status;}

    KineticOperation* operation = KineticController_CreateOperation(handle);
    if (operation == NULL) {return KINETIC_STATUS_MEMORY_ERROR;}

    // Initialize request
    KineticOperation_BuildDelete(operation, entry);
    if (closure != NULL) {operation->closure = *closure;}

    // Execute the operation
    return KineticController_ExecuteOperation(operation);
    return KineticController_ExecuteOperation(operation, closure);
}

KineticStatus KineticClient_GetKeyRange(KineticSessionHandle handle,
@@ -191,16 +186,30 @@ KineticStatus KineticClient_GetKeyRange(KineticSessionHandle handle,
    assert(keys->buffers != NULL);
    assert(keys->count > 0);

    KineticOperation* operation;
    KineticStatus status = KineticController_CreateOperation(&operation, handle);
    if (status != KINETIC_STATUS_SUCCESS) {
        return status;
    }
    KineticOperation* operation = KineticController_CreateOperation(handle);
    if (operation == NULL) {return KINETIC_STATUS_MEMORY_ERROR;}

    // Initialize request
    KineticOperation_BuildGetKeyRange(operation, range, keys);
    if (closure != NULL) {operation->closure = *closure;}

    // Execute the operation
    return KineticController_ExecuteOperation(operation);
    return KineticController_ExecuteOperation(operation, closure);
}

KineticStatus KineticClient_GetLog(KineticSessionHandle handle,
                                   KineticLogDataType type,
                                   KineticCompletionClosure* closure)
{
    assert(handle != KINETIC_HANDLE_INVALID);

    KineticOperation* operation = KineticController_CreateOperation(handle);
    if (operation == NULL) {return KINETIC_STATUS_MEMORY_ERROR;}

    // Initialize request
    KineticOperation_BuildGetLog(operation, type);
    if (closure != NULL) {operation->closure = *closure;}

    // Execute the operation
    return KineticController_ExecuteOperation(operation, closure);
}
+1 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@

#include "kinetic_connection.h"
#include "kinetic_types_internal.h"
#include "kinetic_controller.h"
#include "kinetic_socket.h"
#include "kinetic_pdu.h"
#include "kinetic_operation.h"
Loading