Commit 1e3c1760 authored by Greg Williams's avatar Greg Williams
Browse files

Merged in DELETE operation from 'develop' branch.

parents 6d4145f2 b15bb072
Loading
Loading
Loading
Loading
+100 −31
Original line number Diff line number Diff line
LIB_NAME = kinetic_client
PROJECT = kinetic-c-client
UTILITY = kinetic-c-util

OUT_DIR = ./obj
BIN_DIR = ./bin
PUB_INC = ./include
PUB_API = $(PUB_INC)/$(LIB_NAME).h
API_NAME = kinetic_client
LIB_DIR = ./src/lib
UTIL_DIR = ./src/utility
UTIL_EX = $(UTIL_DIR)/examples
@@ -12,9 +12,19 @@ PBC_INC = ./vendor/protobuf-c
SOCKET99 = ./vendor/socket99
VND_INC = ./vendor
BIN = $(BIN_DIR)/kinetic_client
LDFLAGS += -lm -l crypto -l ssl

PREFIX ?= /usr/local
INSTALL ?= install
RM ?= rm

KINETIC_LIB = $(BIN_DIR)/lib${PROJECT}.a
UTIL_EXEC = $(BIN_DIR)/$(PROJECT)-util
VERSION = $(shell head -n1 ./VERSION)
KINETIC_SO = $(BIN_DIR)/lib${PROJECT}.${VERSION}.so
UTIL_EXEC_NAME = $(UTILITY).$(VERSION)
UTIL_EXEC = $(BIN_DIR)/$(UTIL_EXEC_NAME)
UTIL_EXEC_DYN_NAME = $(UTILITY)
UTIL_EXEC_DYN = $(BIN_DIR)/$(UTIL_EXEC_DYN_NAME)

CC = gcc
OPTIMIZE = -O3
@@ -22,22 +32,28 @@ WARN = -Wall -Wextra -pedantic
# This is necessary because the library depends on
# both C99 _and_ POSIX (for the BSD sockets API).
CDEFS += -D_POSIX_C_SOURCE=1
CFLAGS += -std=c99 -g ${WARN} ${CDEFS} ${OPTIMIZE}
CFLAGS += -std=c99 -fPIC -g ${WARN} ${CDEFS} ${OPTIMIZE}

LIB_INCS = -I$(LIB_DIR) -I$(PUB_INC) -I$(PBC_INC) -I$(VND_INC)
LIB_DEPS = $(PUB_INC)/kinetic_client.h $(PUB_INC)/kinetic_types.h $(LIB_DIR)/kinetic_connection.h $(LIB_DIR)/kinetic_hmac.h $(LIB_DIR)/kinetic_logger.h $(LIB_DIR)/kinetic_message.h $(LIB_DIR)/kinetic_nbo.h $(LIB_DIR)/kinetic_operation.h $(LIB_DIR)/kinetic_pdu.h $(LIB_DIR)/kinetic_proto.h $(LIB_DIR)/kinetic_socket.h
# LIB_OBJ = $(patsubst %,$(OUT_DIR)/%,$(LIB_OBJS))
LIB_OBJS = $(OUT_DIR)/kinetic_nbo.o $(OUT_DIR)/kinetic_operation.o $(OUT_DIR)/kinetic_pdu.o $(OUT_DIR)/kinetic_proto.o $(OUT_DIR)/kinetic_socket.o $(OUT_DIR)/kinetic_message.o $(OUT_DIR)/kinetic_message.o $(OUT_DIR)/kinetic_logger.o $(OUT_DIR)/kinetic_hmac.o $(OUT_DIR)/kinetic_connection.o $(OUT_DIR)/kinetic_operation.o $(OUT_DIR)/kinetic_types.o $(OUT_DIR)/kinetic_client.o $(OUT_DIR)/socket99.o $(OUT_DIR)/protobuf-c.o
LIB_OBJS = $(OUT_DIR)/kinetic_nbo.o $(OUT_DIR)/kinetic_operation.o $(OUT_DIR)/kinetic_pdu.o $(OUT_DIR)/kinetic_proto.o $(OUT_DIR)/kinetic_socket.o $(OUT_DIR)/kinetic_message.o $(OUT_DIR)/kinetic_logger.o $(OUT_DIR)/kinetic_hmac.o $(OUT_DIR)/kinetic_connection.o $(OUT_DIR)/kinetic_types.o $(OUT_DIR)/kinetic_client.o $(OUT_DIR)/socket99.o $(OUT_DIR)/protobuf-c.o

default: $(KINETIC_LIB)
default: $(KINETIC_SO)

test: Rakefile $(LIB_OBJS)
	@echo
	@echo --------------------------------------------------------------------------------
	@echo Testing $(PROJECT)
	@echo --------------------------------------------------------------------------------
	bundle install
	bundle exec rake ci

clean:
	rm -rf $(BIN_DIR)/* $(OUT_DIR)/*.o *.core

.PHONY: clean

# $(OUT_DIR)/%.o: %.c $(DEPS)
# 	$(CC) -c -o $@ $< $(CFLAGS)

@@ -62,20 +78,31 @@ $(OUT_DIR)/kinetic_operation.o: $(LIB_DIR)/kinetic_operation.c $(LIB_DEPS)
$(OUT_DIR)/socket99.o: $(SOCKET99)/socket99.c $(SOCKET99)/socket99.h
	$(CC) -c -o $@ $< $(CFLAGS) -I$(SOCKET99)
$(OUT_DIR)/protobuf-c.o: $(PBC_INC)/protobuf-c/protobuf-c.c $(PBC_INC)/protobuf-c/protobuf-c.h
	$(CC) -c -o $@ $< -std=c99 -g -Wall ${OPTIMIZE} -I$(PBC_INC)
	$(CC) -c -o $@ $< -std=c99 -fPIC -g -Wall ${OPTIMIZE} -I$(PBC_INC)
$(OUT_DIR)/kinetic_types.o: $(LIB_DIR)/kinetic_types.c $(LIB_DEPS)
	$(CC) -c -o $@ $< $(CFLAGS) $(LIB_INCS)
$(OUT_DIR)/kinetic_client.o: $(LIB_DIR)/kinetic_client.c $(LIB_DEPS)
	$(CC) -c -o $@ $< $(CFLAGS) $(LIB_INCS)

$(KINETIC_LIB): $(LIB_OBJS)
	@echo
	@echo --------------------------------------------------------------------------------
	@echo Building $(KINETIC_LIB) static library
	@echo --------------------------------------------------------------------------------
	ar -rcs $@ $(LIB_OBJS)
	ar -t $@

$(KINETIC_SO): $(KINETIC_LIB)
	@echo
	@echo --------------------------------------------------------------------------------
	@echo Building $(KINETIC_SO) dynamic library
	@echo --------------------------------------------------------------------------------
	$(CC) $(LIB_OBJS) -shared ${LDFLAGS} -o ${KINETIC_SO}

libso: $(KINETIC_SO)

UTIL_OBJS = $(OUT_DIR)/noop.o $(OUT_DIR)/put.o $(OUT_DIR)/get.o $(OUT_DIR)/delete.o
UTIL_INCS = -I/usr/local/include -I$(UTIL_DIR)
# TODO: Delete LIB_DIR dep after kinetic_proto is yanked out of public API
LDFLAGS += -lm -l kinetic-c-client -l crypto -l ssl

$(OUT_DIR)/noop.o: $(UTIL_EX)/noop.c
	$(CC) -c -o $@ $< $(CFLAGS) $(UTIL_INCS)
@@ -86,8 +113,19 @@ $(OUT_DIR)/get.o: $(UTIL_EX)/get.c
$(OUT_DIR)/delete.o: $(UTIL_EX)/delete.c
	$(CC) -c -o $@ $< $(CFLAGS) $(UTIL_INCS)
$(UTIL_EXEC): $(UTIL_DIR)/main.c $(UTIL_OBJS)
	${CC} -o $@ $< $(UTIL_OBJS) $(UTIL_INCS) ${CFLAGS} ${LDFLAGS}

	@echo
	@echo --------------------------------------------------------------------------------
	@echo Building $(UTIL_EXEC) $(PROJECT) test utility \(statically linked\)
	@echo --------------------------------------------------------------------------------
	${CC} -o $@ $< $(UTIL_OBJS) $(UTIL_INCS) ${CFLAGS} -l $(PROJECT) ${LDFLAGS}
$(UTIL_EXEC_DYN): $(UTIL_DIR)/main.c $(UTIL_OBJS)
	@echo
	@echo --------------------------------------------------------------------------------
	@echo Building $(UTIL_EXEC) $(PROJECT) test utility \(dynamically linked\)
	@echo --------------------------------------------------------------------------------
	${CC} -o $@ -L$(PREFIX) -l $(PROJECT).$(VERSION) $< $(UTIL_OBJS) $(UTIL_INCS) ${CFLAGS} ${LDFLAGS}

# utility: ${UTIL_EXEC} ${UTIL_EXEC_DYN}
utility: ${UTIL_EXEC}

# Configure to launch java simulator
@@ -98,48 +136,79 @@ SIM_RUNNER = com.seagate.kinetic.simulator.internal.SimulatorRunner
SIM_ADMIN = com.seagate.kinetic.admin.cli.KineticAdminCLI

run: ${UTIL_EXEC}
	sleep 2
	echo Running Executable ${UTIL_EXEC}:
	exec java -classpath "${CLASSPATH}" ${SIM_RUNNER} "$@" & > ./sim.log
	sleep 5
	exec java -classpath "${CLASSPATH}" ${SIM_ADMIN} -setup -erase true > ./erase.log
	@echo
	@echo --------------------------------------------------------------------------------
	@echo Running $(UTIL_EXEC) $(PROJECT) test utility \(statically linked\)
	@echo --------------------------------------------------------------------------------
	@sleep 2
	exec java -classpath "${CLASSPATH}" ${SIM_RUNNER} "$@" &
	@sleep 5
	exec java -classpath "${CLASSPATH}" ${SIM_ADMIN} -setup -erase true
	${UTIL_EXEC} noop
	${UTIL_EXEC} put
	${UTIL_EXEC} get
	${UTIL_EXEC} delete
	exec pkill -f 'java.*kinetic-simulator'

all: clean test default install run

.PHONY: clean
rund: ${UTIL_EXEC_DYN}
	@echo
	@echo --------------------------------------------------------------------------------
	@echo Running $(UTIL_EXEC) $(PROJECT) test utility \(dynamically linked\)
	@echo --------------------------------------------------------------------------------
	@sleep 2
	exec java -classpath "${CLASSPATH}" ${SIM_RUNNER} "$@" &
	@sleep 5
	exec java -classpath "${CLASSPATH}" ${SIM_ADMIN} -setup -erase true
	${UTIL_EXEC_DYN} noop
	${UTIL_EXEC_DYN} put
	${UTIL_EXEC_DYN} get
	${UTIL_EXEC_DYN} delete
	exec pkill -f 'java.*kinetic-simulator'

# Installation
PREFIX ?= /usr/local
INSTALL ?= install
RM ?= rm

install: ${KINETIC_LIB}
install: ${KINETIC_LIB} ${KINETIC_SO} VERSION
	@echo
	@echo --------------------------------------------------------------------------------
	@echo Installing $(PROJECT) v$(VERSION) into $(PREFIX)
	@echo --------------------------------------------------------------------------------
	@echo
	@echo You may be prompted for your password in order to proceed.
	@echo
	${INSTALL} -d ${PREFIX}/lib/
	${INSTALL} -c ${KINETIC_LIB} ${PREFIX}/lib/
	# ${INSTALL} -c ${KINETIC_SO} ${PREFIX}/lib/
	${INSTALL} -d ${PREFIX}/include/
	${INSTALL} -c ./include/${LIB_NAME}.h ${PREFIX}/include/
	${INSTALL} -c ./include/${API_NAME}.h ${PREFIX}/include/
	${INSTALL} -c ./include/kinetic_types.h ${PREFIX}/include/
	${INSTALL} -c ./src/lib/kinetic_proto.h ${PREFIX}/include/
	${INSTALL} -d ${PREFIX}/include/protobuf-c
	${INSTALL} -c ./vendor/protobuf-c/protobuf-c/protobuf-c.h ${PREFIX}/include/protobuf-c/

uninstall:
	${RM} -f ${PREFIX}/lib/lib${PROJECT}.a
	${RM} -f ${PREFIX}/include/${LIB_NAME}.h
	@echo
	@echo --------------------------------------------------------------------------------
	@echo Uninstalling $(PROJECT) from $(PREFIX)
	@echo --------------------------------------------------------------------------------
	@echo
	@echo You may be prompted for your password in order to proceed.
	@echo
	${RM} -f ${PREFIX}/lib/lib${PROJECT}*.a
	${RM} -f ${PREFIX}/lib/lib${PROJECT}*.so
	${RM} -f ${PREFIX}/include/${PUBLIC_API}.h
	${RM} -f ${PREFIX}/include/kinetic_types.h
	${RM} -f ${PREFIX}/include/kinetic_proto.h
	${RM} -f ${PREFIX}/include/protobuf-c/protobuf-c.h
	${RM} -f ${PREFIX}/include/protobuf-c.h

# all: uninstall clean test default install run rund
all: uninstall clean test default install run
	@echo
	@echo --------------------------------------------------------------------------------
	@echo $(PROJECT) build completed successfully!
	@echo --------------------------------------------------------------------------------
	@echo $(PROJECT) v$(VERSION) is in working order
	@echo

# Other dependencies
$(BIN_DIR)/lib${PROJECT}.a: Makefile
$(BIN_DIR)/lib${PROJECT}.a: Makefile Rakefile VERSION
# kinetic-lib.o: kinetic_client.h kinetic_connection.h kinetic_hmac.h kinetic_logger.h kinetic_message.h kinetic_nbo.h kinetic_operation.h kinetic_pdu.h kinetic_proto.h kinetic_socket.h protobuf-c.h socket99.h


+28 −10
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ Getting Started

    > git clone --recursive https://github.com/atomicobject/kinetic-c.git
    > cd kinetic-c
    > bundle install # Ensure you have all RubyGems at the proper versions
    > bundle install # ensure you have all RubyGems at the proper versions

**Update to the latest version (previously cloned)**

@@ -49,28 +49,46 @@ Getting Started

    > make all # this is what Travis-CI build does to ensure it all keeps working

**Uninstall, perform a full clean build with test, and validate with utility**

    > make all # this is what Travis CI does

API Documentation
=================
[Kinetic-C API](http://seagate.github.io/kinetic-c/kinetic__api_8h.html) (generated with Doxygen)

Examples
========
[Kinetic-C API Documentation](http://seagate.github.io/kinetic-c) (generated with Doxygen)
* [Kinetic-C API](http://seagate.github.io/kinetic-c/kinetic__client_8h.html)
* [Kinetic-C types](http://seagate.github.io/kinetic-c/kinetic__types_8h.html)

Example Client/Test Utility
===========================

Code examples are included for reference as part of a test utility. The source code for the utility is used to build both a static and dynamically linked verion of the kinetic-c-client library.

* 'kinetic-c-util' builds/links against installed Kinetic C static library (.a)
* 'kinetic-c-util.x.y.z' builds/links against installed Kinetic C dynamic library (.so)

The project Makefile can be used as a reference for developing a Makefile for building for a new custom Kinetic C client.

The following examples are provided for development reference and as utilities to aid development. In order to execute a given example, you must first do:
In order to execute a given example, after building it, you must first do:

    > cd build/artifacts/release
    > cd bin

You can then execute `kinetic-c-client-util` with a valid example name, optionally preceeded with any of the optional arguments.

**Options**
Options
-------
* `--host [HostName/IP]` or `-h [HostName/IP]` - Set the Kinetic Device host
* `--tls` - Use the TLS port to execute the specified operation(s)

**Operations**
Operations
----------
* `kinetic-c-client [--host|-h hostname|123.253.253.23] noop put get`
    * `kinetic-c-client-util noop`
        * Execute a NoOp (ping) operation to verify the Kinetic Device is ready
    * `kinetic-c-client-util put`
        * Execute a Put operation to store a key/value
        * Execute a Put operation to store a key/value entry
    * `kinetic-c-client-util get`
        * Execute a Get operation to retrieve a key/value
        * Execute a Get operation to retrieve a key/value entry
    * `kinetic-c-client-util delete`
        * Execute a Delete operation to destroy a key/value entry
+3 −2
Original line number Diff line number Diff line
v0.6.0
------
* Added Makefile build option.
* Added GET operation.
* Added GET and DELETE operations.
* Added Makefile build implementing standard (make; sudo make install) interface.
* Added creation/installation of static (.a) and dynamic (.so) libraries
* Added ByteArray type for buffer management.
* Added Kinetic_KeyValue type for key/value pair handling.
+1 −1
Original line number Diff line number Diff line
0.6.0-beta-1
0.6.0-beta-2
+5 −7
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ PROJECT_NAME = protobuf-c
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER           = "v0.6.0-beta"
PROJECT_NUMBER           = "v0.6.0-beta-2"

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
@@ -754,9 +754,7 @@ WARN_LOGFILE =
# spaces.
# Note: If this tag is empty the current directory is searched.

INPUT                  = ./include \
                         ./src \
                         ./README.md
INPUT                  = ./include ./src ./README.md ./DEVELOP.md

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@@ -1349,7 +1347,7 @@ ECLIPSE_DOC_ID = com.seagate.kinetic-c
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.

DISABLE_INDEX          = YES
DISABLE_INDEX          = NO

# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
# structure should be generated to display hierarchical information. If the tag
@@ -1366,7 +1364,7 @@ DISABLE_INDEX = YES
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.

GENERATE_TREEVIEW      = YES
GENERATE_TREEVIEW      = NO

# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that
# doxygen will group on one line in the generated HTML documentation.
@@ -2058,7 +2056,7 @@ HIDE_UNDOC_RELATIONS = YES
# set to NO
# The default value is: NO.

HAVE_DOT               = YES
HAVE_DOT               = NO

# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed
# to run in parallel. When set to 0 doxygen will base this on the number of
Loading