Skip to content

Commit

Permalink
the protocol correctly version
Browse files Browse the repository at this point in the history
  • Loading branch information
baotiao committed Aug 9, 2017
2 parents 057a0fa + 00efc05 commit 1a97aa9
Show file tree
Hide file tree
Showing 47 changed files with 12,994 additions and 2,386 deletions.
3 changes: 0 additions & 3 deletions floyd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,6 @@ all: $(LIBRARY)

static_lib: $(LIBRARY)

shared_lib: $(SHARED)
for f in $(notdir $(SHARED)); do mv "$$f" $(LIBOUTPUT); done

dbg: $(LIBRARY)

$(LIBRARY): $(LIBOBJECTS)
Expand Down
120 changes: 78 additions & 42 deletions floyd/example/simple/Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
CC=cc
CXX=g++
LDFLAGS= -lsnappy -lz -lbz2 -lprotobuf -lpthread -lrt $(EXTRA_LDFLAGS)
CFLAGS= -DOS_LINUX -fno-builtin-memcmp -msse -msse4.2 ${EXTRA_CFLAGS}
CXXFLAGS=-std=c++11 -DOS_LINUX -fno-builtin-memcmp -msse -msse4.2 ${EXTRA_CXXFLAGS}
# OPT = -O0 -g
OPT = -O2 -DNDEBUG

# for rocksdb
CXXFLAGS+= -DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX -DOS_LINUX

.PHONY: clean all

all: t t1 t2 cpt read_rock read_floyd

ifndef SLASH_PATH
$(warning Warning: missing slash path, using default)
SLASH_PATH=$(CURDIR)/../third/slash
CXX = g++
ifeq ($(__PERF), 1)
CXXFLAGS = -O0 -g -pipe -fPIC -DNDEBUG -DLOG_LEVEL=LEVEL_INFO -W -Wwrite-strings -Wpointer-arith -Wreorder -Wswitch -Wsign-promo -Wredundant-decls -Wformat -Wall -D_GNU_SOURCE -std=c++11 -D__STDC_FORMAT_MACROS -std=c++11 -gdwarf-2 -Wno-redundant-decls -Wno-unused-variable -DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX -DOS_LINUX
else
CXXFLAGS = -pg -g -O2 -ggdb3 -pipe -fPIC -W -Wwrite-strings -Wpointer-arith -Wreorder -Wswitch -Wsign-promo -Wredundant-decls -Wformat -D_GNU_SOURCE -D__STDC_FORMAT_MACROS -std=c++11 -gdwarf-2 -Wno-redundant-decls -Wno-unused-variable -DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX -DOS_LINUX
endif
SLASH_INCLUDE_DIR=$(SLASH_PATH)
SLASH_LIBRARY=$(SLASH_PATH)/slash/lib/libslash.a
Expand All @@ -41,27 +28,76 @@ CXXFLAGS+=-I../../.. \
-I$(PINK_INCLUDE_DIR) \
-I$(ROCKSDB_INCLUDE_DIR)

t: t.cc $(FLOYD_LIBRARY) $(ROCKSDB_LIBRARY) $(PINK_LIBRARY) $(SLASH_LIBRARY)
$(CXX) $(CXXFLAGS) $^ -o$@ $(LDFLAGS)

t1: t1.cc $(FLOYD_LIBRARY) $(ROCKSDB_LIBRARY) $(PINK_LIBRARY) $(SLASH_LIBRARY)
$(CXX) $(CXXFLAGS) $^ -o$@ $(LDFLAGS)

t2: t2.cc $(FLOYD_LIBRARY) $(ROCKSDB_LIBRARY) $(PINK_LIBRARY) $(SLASH_LIBRARY)
$(CXX) $(CXXFLAGS) $^ -o$@ $(LDFLAGS)

cpt: cpt.cc $(FLOYD_LIBRARY) $(ROCKSDB_LIBRARY) $(PINK_LIBRARY) $(SLASH_LIBRARY)
$(CXX) $(CXXFLAGS) $^ -o$@ $(LDFLAGS)

read_floyd: read_floyd.cc $(FLOYD_LIBRARY) $(ROCKSDB_LIBRARY) $(PINK_LIBRARY) $(SLASH_LIBRARY)
$(CXX) $(CXXFLAGS) $^ -o$@ $(LDFLAGS)

read_rock: read_rock.cc $(FLOYD_LIBRARY) $(ROCKSDB_LIBRARY) $(PINK_LIBRARY) $(SLASH_LIBRARY)
$(CXX) $(CXXFLAGS) $^ -o$@ $(LDFLAGS)

clean:
find . -name "*.[oda]" -exec rm -f {} \;
rm -rf ./t ./t1 ./t2 ./cpt ./read_rock ./read_floyd

$(FLOYD_LIBRARY):
cd ../.. && $(MAKE) static_lib
OBJECT = t t1 t2 t3 t4 t5 t6 t7
SRC_DIR = ./
THIRD_PATH = ../../third
OUTPUT = ./output

LIB_PATH = -L../../lib/ \
-L$(THIRD_PATH)/slash/slash/lib/ \
-L$(THIRD_PATH)/rocksdb/ \
-L$(THIRD_PATH)/pink/pink/lib/


LIBS = -lfloyd \
-lpink \
-lslash \
-lrocksdb \
-lsnappy \
-lprotobuf \
-lz \
-lbz2 \
-lrt \
-lssl \
-lcrypto \
-lprofiler \
-lpthread

INCLUDE_PATH = -I../../../ \
-I$(THIRD_PATH)/rocksdb/include \
-I$(THIRD_PATH)/slash/ \
-I$(THIRD_PATH)/pink/

.PHONY: all clean version


BASE_BOJS := $(wildcard $(SRC_DIR)/*.cc)
BASE_BOJS += $(wildcard $(SRC_DIR)/*.c)
BASE_BOJS += $(wildcard $(SRC_DIR)/*.cpp)
OBJS = $(patsubst %.cc,%.o,$(BASE_BOJS))

all: $(OBJECT)
rm -rf $(OUTPUT)
mkdir -p $(OUTPUT)
mkdir -p $(OUTPUT)/bin
cp $(OBJECT) $(OUTPUT)/bin/
rm -rf $(OBJECT)
@echo "Success, go, go, go..."

t: t.o
$(CXX) $(CXXFLAGS) -o $@ $^ $(INCLUDE_PATH) $(LIB_PATH) $(LIBS)

t1: t1.cc
$(CXX) $(CXXFLAGS) -o $@ $^ $(INCLUDE_PATH) $(LIB_PATH) $(LIBS)

t2: t2.cc
$(CXX) $(CXXFLAGS) -o $@ $^ $(INCLUDE_PATH) $(LIB_PATH) $(LIBS)
t3: t3.cc
$(CXX) $(CXXFLAGS) -o $@ $^ $(INCLUDE_PATH) $(LIB_PATH) $(LIBS)
t4: t4.cc
$(CXX) $(CXXFLAGS) -o $@ $^ $(INCLUDE_PATH) $(LIB_PATH) $(LIBS)
t5: t5.cc
$(CXX) $(CXXFLAGS) -o $@ $^ $(INCLUDE_PATH) $(LIB_PATH) $(LIBS)
t6: t6.cc
$(CXX) $(CXXFLAGS) -o $@ $^ $(INCLUDE_PATH) $(LIB_PATH) $(LIBS)
t7: t7.cc
$(CXX) $(CXXFLAGS) -o $@ $^ $(INCLUDE_PATH) $(LIB_PATH) $(LIBS)
$(OBJS): %.o : %.cc
$(CXX) $(CXXFLAGS) -c $< -o $@ $(INCLUDE_PATH)

clean:
rm -rf $(OUTPUT)
rm -rf $(SRC_DIR)/log
rm -rf ./data*
rm -f $(SRC_DIR)/*.o
rm -rf $(OBJECT)
9 changes: 5 additions & 4 deletions floyd/example/simple/README
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ the simple example will run the Floyd:write the get performance of floyd in a si


t is a single thread wirte tool to get performance
t1 is multi thread program to get performance
t1 is multi thread program to get performance, in this case, all the writes is from the leader node
t2 is an example test node join and leave

read_floyd is the tool to read floyd log
read_rock is the tool to read rocksdb data
cpt is a tool to compare two rocksdb, if they have the same data return true, else return false
t4 is an example used to see the message passing by each node in a stable situation
t5 used to test single mode floyd, including starting a node and writing data
t6 is the same as t1 except that all the writes is from the follower node
49 changes: 0 additions & 49 deletions floyd/example/simple/read_floyd.cc

This file was deleted.

32 changes: 19 additions & 13 deletions floyd/example/simple/t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,37 +43,38 @@ int main()
printf("%s\n", s.ToString().c_str());

std::string msg;
int i = 100;
int cnt = 100;
uint64_t st = NowMicros(), ed;

sleep(10);
while (1) {
if (f1->HasLeader()) {
break;
}
printf("electing leader... sleep 2s\n");
sleep(2);
}

while (i--) {
std::string mystr[100100];
for (int i = 0; i < 100000; i++) {
mystr[i] = slash::RandomString(100);
}
// f1->GetServerStatus(msg);
// printf("%s\n", msg.c_str());
while (cnt--) {
std::string mystr[100100];
for (int i = 0; i < 100000; i++) {
mystr[i] = slash::RandomString(10);
}
f1->GetServerStatus(msg);
printf("%s\n", msg.c_str());
st = NowMicros();
for (int j = 0; j < 100000; j++) {
f1->Write(mystr[j], mystr[j]);
// f1->Write("zz", "zz");
}
ed = NowMicros();
printf("write 10000 cost time microsecond(us) %ld, qps %llu\n", ed - st, 100000 * 1000000LL / (ed - st));
printf("write 100000 cost time microsecond(us) %ld, qps %llu\n", ed - st, 100000 * 1000000LL / (ed - st));
}

delete f1;

i = 5;
while (i--) {
cnt = 5;
while (cnt--) {
f2->GetServerStatus(msg);
for (int j = 0; j < 100; j++) {
f2->Write("zz2" + char(j), "value2" + char(j));
Expand All @@ -85,8 +86,8 @@ int main()
if (!s.ok()) {
printf("floyd reoptn failed\n");
}
i = 5;
while (i--) {
cnt = 5;
while (cnt--) {
f2->GetServerStatus(msg);
for (int j = 0; j < 100; j++) {
f1->Write("zz3" + char(j), "value3" + char(j));
Expand All @@ -95,5 +96,10 @@ int main()
}

getchar();
delete f2;
delete f3;
delete f4;
delete f5;
delete f1;
return 0;
}
Loading

0 comments on commit 1a97aa9

Please sign in to comment.