Skip to content

Commit

Permalink
add protobuf submodule and pika_inner_message.proto (OpenAtomFoundati…
Browse files Browse the repository at this point in the history
  • Loading branch information
Axlgrep committed May 15, 2019
1 parent f03e71b commit 082b410
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*.lo
*.o
*.obj
*pb.cc
*pb.h

# Precompiled Headers
*.gch
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
[submodule "third/pink"]
path = third/pink
url = https://github.com/Qihoo360/pink.git
[submodule "third/protobuf"]
path = third/protobuf
url = https://github.com/google/protobuf.git
29 changes: 25 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ BLACKWIDOW_PATH = $(THIRD_PATH)/blackwidow
endif
BLACKWIDOW = $(BLACKWIDOW_PATH)/lib/libblackwidow$(DEBUG_SUFFIX).a

ifndef PROTOBUF_PATH
PROTOBUF_PATH = $(THIRD_PATH)/protobuf
endif
PROTOBUF = $(PROTOBUF_PATH)/_install/lib/libprotobuf.a
PROTOC = $(PROTOBUF_PATH)/_install/bin/protoc

ifeq ($(360), 1)
GLOG := $(GLOG_PATH)/.libs/libglog.a
endif
Expand All @@ -90,7 +96,8 @@ INCLUDE_PATH = -I. \
-I$(PINK_PATH) \
-I$(BLACKWIDOW_PATH)/include \
-I$(ROCKSDB_PATH) \
-I$(ROCKSDB_PATH)/include
-I$(ROCKSDB_PATH)/include \
-I$(PROTOBUF_PATH)/_install/include

ifeq ($(360),1)
INCLUDE_PATH += -I$(GLOG_PATH)/src
Expand All @@ -100,7 +107,7 @@ LIB_PATH = -L./ \
-L$(SLASH_PATH)/slash/lib \
-L$(PINK_PATH)/pink/lib \
-L$(BLACKWIDOW_PATH)/lib \
-L$(ROCKSDB_PATH)
-L$(ROCKSDB_PATH) \

ifeq ($(360),1)
LIB_PATH += -L$(GLOG_PATH)/.libs
Expand All @@ -111,14 +118,17 @@ LDFLAGS += $(LIB_PATH) \
-lslash$(DEBUG_SUFFIX) \
-lblackwidow$(DEBUG_SUFFIX) \
-lrocksdb$(DEBUG_SUFFIX) \
-lglog
-lglog \

# ---------------End Dependences----------------

VERSION_CC=$(SRC_PATH)/build_version.cc
LIB_SOURCES := $(VERSION_CC) \
$(filter-out $(VERSION_CC), $(wildcard $(SRC_PATH)/*.cc))

PIKA_PROTO := $(wildcard $(SRC_PATH)/*.proto)
PIKA_PROTO_GENS:= $(PIKA_PROTO:%.proto=%.pb.cc) $(PIKA_PROTO:%.proto=%.pb.h)


#-----------------------------------------------

Expand Down Expand Up @@ -182,6 +192,7 @@ $(SRC_PATH)/build_version.cc: FORCE
FORCE:

LIBOBJECTS = $(LIB_SOURCES:.cc=.o)
PROTOOBJECTS = $(PIKA_PROTO:.proto=.pb.o)

# if user didn't config LIBNAME, set the default
ifeq ($(BINNAME),)
Expand All @@ -192,14 +203,19 @@ BINARY = ${BINNAME}

.PHONY: distclean clean dbg all

%.pb.cc %.pb.h: %.proto $(PROTOC)
$(AM_V_CC)$(PROTOC) -I=$(SRC_PATH) --cpp_out=$(SRC_PATH) $<

%.o: %.cc
$(AM_V_CC)$(CXX) $(CXXFLAGS) -c $< -o $@

proto : $(PIKA_PROTO_GENS)

all: $(BINARY)

dbg: $(BINARY)

$(BINARY): $(SLASH) $(PINK) $(ROCKSDB) $(BLACKWIDOW) $(GLOG) $(LIBOBJECTS)
$(BINARY): $(SLASH) $(PINK) $(ROCKSDB) $(BLACKWIDOW) $(GLOG) $(PROTOOBJECTS) $(PROTOBUF) $(LIBOBJECTS)
$(AM_V_at)rm -f $@
$(AM_V_at)$(AM_LINK)
$(AM_V_at)rm -rf $(OUTPUT)
Expand All @@ -220,12 +236,16 @@ $(ROCKSDB):
$(BLACKWIDOW):
$(AM_V_at)make -C $(BLACKWIDOW_PATH) ROCKSDB_PATH=$(ROCKSDB_PATH) SLASH_PATH=$(SLASH_PATH) DEBUG_LEVEL=$(DEBUG_LEVEL)

$(PROTOBUF) $(PROTOC):
cd $(PROTOBUF_PATH); autoreconf -if; ./configure --prefix=$(PROTOBUF_PATH)/_install; make install

$(GLOG):
cd $(THIRD_PATH)/glog; if [ ! -f ./Makefile ]; then ./configure --disable-shared; fi; make; echo '*' > $(CURDIR)/third/glog/.gitignore;

clean:
rm -rf $(OUTPUT)
rm -rf $(CLEAN_FILES)
rm -rf $(PIKA_PROTO_GENS)
find $(SRC_PATH) -name "*.[oda]*" -exec rm -f {} \;
find $(SRC_PATH) -type f -regex ".*\.\(\(gcda\)\|\(gcno\)\)" -exec rm {} \;

Expand All @@ -234,4 +254,5 @@ distclean: clean
make -C $(SLASH_PATH)/slash/ clean
make -C $(BLACKWIDOW_PATH)/ clean
make -C $(ROCKSDB_PATH)/ clean
make -C $(PROTOBUF_PATH)/ clean
# make -C $(GLOG_PATH)/ clean
60 changes: 60 additions & 0 deletions src/pika_inner_message.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package InnerMessage;

enum Type {
kSyncMeta = 1;
kTrySync = 2;
}

enum StatusCode {
kOk = 1;
kWait = 2;
kError = 3;
}

message SyncOffset {
required int32 filenum = 1;
required int64 offset = 2;
optional bool force = 3;
}

message Node {
required string ip = 1;
required int32 port = 2;
}

message Table {
required string table_name = 1;
required int32 partition_num = 2;
}

message InnerRequst {
message SyncMeta {
required Node node = 1;
}

message TrySync {
required Node node = 1;
required string table_name = 2;
required int32 partition_id = 3;
required SyncOffset sync_offset = 4;
}

required Type type = 1;
optional SyncMeta sync_meta = 2;
optional TrySync try_sync = 3;
}

message InnerResponse {
message SyncMeta {
repeated Table tables = 1;
}

message TrySync {
required StatusCode code = 1;
optional string reply = 2;
}

required Type type = 1;
optional SyncMeta sync_meta = 2;
optional TrySync try_sync = 3;
}
1 change: 1 addition & 0 deletions third/protobuf
Submodule protobuf added at 774d63

0 comments on commit 082b410

Please sign in to comment.