Commit 5de5e6fc authored by Greg Williams's avatar Greg Williams
Browse files

Merged develop. Completed internalization of KineticSession which is now...

Merged develop. Completed internalization of KineticSession which is now exposed as an opaque pointer for pub API.
API Change: Forgot to note in previous commit that the PIN auth type was removed from the KineticSessionConfig and is now passed in to PIN-related ops directly.
parents 39546c1a cf9c8e7c
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -13,3 +13,6 @@
[submodule "vendor/unity"]
	path = vendor/unity
	url = https://github.com/ThrowTheSwitch/Unity.git
[submodule "vendor/FlameGraph"]
	path = vendor/FlameGraph
	url = https://github.com/brendangregg/FlameGraph.git
+4 −12
Original line number Diff line number Diff line
@@ -88,7 +88,6 @@ typedef enum _KineticSynchronization {
} KineticSynchronization;


struct _KineticClient;
/**
 * @brief Handle to the kinetic client, which is shared by all connections
 */
@@ -96,10 +95,11 @@ typedef struct _KineticClient KineticClient;


/**
 * @brief Kinetic Connection Instance
 * @brief Kinetic connection instance
 */
struct _KineticConnection;


/**
 * @brief Structure used to specify the configuration for a session.
 */
@@ -129,19 +129,11 @@ typedef struct _KineticSessionConfig {
    bool useSsl;
} KineticSessionConfig;


/**
 * @brief An instance of a session with a Kinetic device.
 */
// FIXME: Internalize session w/ copy of config
typedef struct _KineticSession {
    // Session configuration structure which must be configured 
    KineticSessionConfig config;

    // Connection instance which is dynamically allocated upon call to KineticClient_CreateSession.
    // Client must call KineticAdminClient_DestroySession when finished with a session to shutdown
    // a session cleanly and free the `connection`.
    struct _KineticConnection* connection;
} KineticSession;
typedef struct _KineticSession KineticSession;

#define KINETIC_SESSION_INIT(_session, _host, _clusterVersion, _identity, _hmacKey) { \
    (*_session).config = (KineticSessionConfig) { \

mk_flamegraph

0 → 100755
+16 −0
Original line number Diff line number Diff line
#!/bin/sh
##################################################
# Construct a flame graph for a specific command.
# Linux-specific, and requires the "perf" package.
##################################################

CMD="$*"

if [ -z ${CMD} ]; then
    echo Usage: mk_flamegraph COMMAND
else
    # -g: call graph
    sudo perf record --freq=993 --all-cpus -g --output=perf.out -- ${CMD}
    sudo perf script --input=perf.out | vendor/FlameGraph/stackcollapse-perf.pl > out.perf-folded
    vendor/FlameGraph/flamegraph.pl out.perf-folded > perf_out.svg
fi
+89 −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 <getopt.h>

static char *kinetic_host = "localhost";
static long idle_seconds = 0;

static void usage(void) {
    fprintf(stderr, "usage: setup_teardown [-h KINETIC_HOST] [-i IDLE_SECONDS]\n");
    exit(1);
}

static void handle_args(int argc, char **argv) {
    int fl = 0;
    while ((fl = getopt(argc, argv, "i:h:")) != -1) {
        switch (fl) {
        case 'h':               /* host */
            kinetic_host = optarg;
            break;
        case 'i':               /* idle seconds */
            idle_seconds = strtol(optarg, NULL, 10);
            break;
        case '?':
        default:
            usage();
        }
    }
}

int main(int argc, char** argv)
{
    handle_args(argc, argv);

    // Initialize kinetic-c and establish session
    KineticSession* session;
    KineticClient * client = KineticClient_Init("stdout", 0);
    if (client == NULL) { return 1; }
    const char HmacKeyString[] = "asdfasdf";
    KineticSessionConfig config = {
        .host = SYSTEM_TEST_HOST,
        .port = KINETIC_PORT,
        .clusterVersion = 0,
        .identity = 1,
        .hmacKey = ByteArray_CreateWithCString(HmacKeyString),
    };
    KineticStatus connect_status = KineticClient_CreateSession(&config, client, &session);
    if (connect_status != KINETIC_STATUS_SUCCESS) {
        fprintf(stderr, "Failed connecting to the Kinetic device w/status: %s\n",
            Kinetic_GetStatusDescription(connect_status));
        exit(1);
    }

    if (idle_seconds > 0) {
        printf(" -- Sleeping %ld seconds\n", idle_seconds);
        sleep(idle_seconds);
    }

    // Shutdown client connection and cleanup
    KineticClient_DestroySession(session);
    KineticClient_Shutdown(client);
    return 0;
}
+1 −1
Original line number Diff line number Diff line
@@ -442,7 +442,7 @@ static void tick_handler(example_state *s) {

static time_t get_cur_second(void) {
    struct timeval tv;
    gettimeofday(&tv, 0);
    gettimeofday(&tv, 0);  // TODO: clock_gettime
    return tv.tv_sec;
}

Loading