diff --git a/.gitmodules b/.gitmodules index e6ef001..b462a6c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,18 +1,21 @@ [submodule "third_party/colib"] path = third_party/colib - url = https://github.com/tencent-wechat/libco -[submodule "third_party/phxrpc"] - path = third_party/phxrpc - url = https://github.com/tencent-wechat/phxrpc -[submodule "third_party/phxpaxos"] - path = third_party/phxpaxos - url = https://github.com/tencent-wechat/phxpaxos -[submodule "third_party/leveldb"] - path = third_party/leveldb - url = https://github.com/google/leveldb -[submodule "third_party/protobuf"] - path = third_party/protobuf - url = https://github.com/google/protobuf + url = https://github.com/Tencent/libco +[submodule "third_party/gflags"] + path = third_party/gflags + url = https://github.com/gflags/gflags [submodule "third_party/glog"] path = third_party/glog url = https://github.com/google/glog +[submodule "third_party/protobuf"] + path = third_party/protobuf + url = https://github.com/google/protobuf +[submodule "third_party/leveldb"] + path = third_party/leveldb + url = https://github.com/google/leveldb +[submodule "third_party/phxpaxos"] + path = third_party/phxpaxos + url = https://github.com/Tencent/phxpaxos +[submodule "third_party/phxrpc"] + path = third_party/phxrpc + url = https://github.com/Tencent/phxrpc diff --git a/.travis.yml b/.travis.yml index 2ff64c1..1416b09 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,3 +12,7 @@ script: - docker build -t phxsql/phxsql:latest . && ./test-with-docker.sh notifications: email: true +branches: + only: + - /.*/ + diff --git a/README.md b/README.md index 64b7b48..3e0305a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[简体中文README](https://github.com/tencent-wechat/phxsql/blob/master/README.zh_cn.md) +[简体中文README](https://github.com/Tencent/phxsql/blob/master/README.zh_cn.md) **PhxSQL is a high-availability and strong-consistency MySQL cluster built on Paxos and Percona.** @@ -6,12 +6,12 @@ Authors: Junchao Chen, Haochuan Cui, Duokai Huang, Ming Chen and Sifan Liu Contact us: phxteam@tencent.com -[![Build Status](https://travis-ci.org/tencent-wechat/phxsql.svg?branch=master)](https://travis-ci.org/tencent-wechat/phxsql) +[![Build Status](https://travis-ci.org/Tencent/phxsql.svg?branch=master)](https://travis-ci.org/Tencent/phxsql) #PhxSQL features: - high availability by automatic failovers: the cluster works well when more than half of cluster nodes work and are interconnected. - guarantee of data consistency among cluster nodes: replacing loss-less semi-sync between MySQL master and MySQL slaves with Paxos, PhxSQL ensures zero-loss binlogs between master and slaves and supports linearizable consistency, which is as strong as that of Zookeeper. - - complete compliance with MySQL for and MySQL client: PhxSQL supports up to serializable isolation level of transaction. + - complete compliance with MySQL and MySQL client: PhxSQL supports up to serializable isolation level of transaction. - easy deployment and easy maintenance: PhxSQL, powered by in-house implementation of Paxos, has only 4 components including MySQL and doesn't depend on zookeeper or etcd for anything. PhxSql supports automated cluster membership hot reconfiguration. @@ -21,14 +21,14 @@ This project includes * Third party submodules * Pre-compiled binaries for Ubuntu 64bit system. -Projects on which this project depends are also published by tencent-wechat( phxpaxos, phxrpc, libco ). +Projects on which this project depends are also published by Tencent( phxpaxos, phxrpc, libco ). You can download or clone them with --recurse-submodule. -**phxpaxos:** [http://github.com/tencent-wechat/phxpaxos](http://github.com/tencent-wechat/phxpaxos "http://github.com/tencent-wechat/phxpaxos") +**phxpaxos:** [http://github.com/Tencent/phxpaxos](http://github.com/Tencent/phxpaxos "http://github.com/Tencent/phxpaxos") -**phxrpc:** [http://github.com/tencent-wechat/phxrpc](http://github.com/tencent-wechat/phxrpc "http://github.com/tencent-wechat/phxrpc") +**phxrpc:** [http://github.com/Tencent/phxrpc](http://github.com/Tencent/phxrpc "http://github.com/Tencent/phxrpc") -**libco:** [http://github.com/tencent-wechat/libco](http://github.com/tencent-wechat/libco "http://github.com/tencent-wechat/libco") +**libco:** [http://github.com/Tencent/libco](http://github.com/Tencent/libco "http://github.com/Tencent/libco") # Compilation of PhxSQL diff --git a/README.zh_cn.md b/README.zh_cn.md index 46cb865..031adcf 100644 --- a/README.zh_cn.md +++ b/README.zh_cn.md @@ -6,7 +6,7 @@ 联系我们:phxteam@tencent.com -想了解更多, 以及更详细的编译手册,请进入[中文WIKI](https://github.com/tencent-wechat/phxsql/wiki),和扫描右侧二维码关注我们的公众号 +想了解更多, 以及更详细的编译手册,请进入[中文WIKI](https://github.com/Tencent/phxsql/wiki),和扫描右侧二维码关注我们的公众号 方案说明:[微信开源PhxSQL:高可用、强一致的MySQL集群](http://mp.weixin.qq.com/s?__biz=MzI4NDMyNTU2Mw==&mid=2247483783&idx=1&sn=a2d6e589f1f591ded7703eb74aefccbe&scene=0#wechat_redirect) @@ -22,11 +22,11 @@ PhxSQL设计和实现哲学:[上篇](https://zhuanlan.zhihu.com/p/22345242), 项目中包含PhxSQL源代码,源代码编译时所需要的一些第三方库,及可直接在Linux环境下运行的二进制包。其中代码使用到了微信团队自研的另外三个开源项目(phxpaxos,phxrpc,colib)。若需编译源代码,需额外下载,也可以在clone时通过--recurse-submodule获得代码。 -**phxpaxos项目地址:** [http://github.com/tencent-wechat/phxpaxos](http://github.com/tencent-wechat/phxpaxos "http://github.com/tencent-wechat/phxpaxos") +**phxpaxos项目地址:** [http://github.com/Tencent/phxpaxos](http://github.com/Tencent/phxpaxos "http://github.com/Tencent/phxpaxos") -**phxrpc项目地址:** [http://github.com/tencent-wechat/phxrpc](http://github.com/tencent-wechat/phxrpc "http://github.com/tencent-wechat/phxrpc") +**phxrpc项目地址:** [http://github.com/Tencent/phxrpc](http://github.com/Tencent/phxrpc "http://github.com/Tencent/phxrpc") -**colib项目地址:** [http://github.com/tencent-wechat/libco](http://github.com/tencent-wechat/libco "http://github.com/tencent-wechat/libco") +**colib项目地址:** [http://github.com/Tencent/libco](http://github.com/Tencent/libco "http://github.com/Tencent/libco") # PhxSQL编译 @@ -88,7 +88,7 @@ PhxSQL需要用到一些第三方库(glog, leveldb, protobuf, phxpaxos, colib, 2. 若想打包二进制运行包(集群运行时所需要的所有文件和配置)`make package` 3. `install`完成后,二进制会生成到`PhxSQL`目录下的`sbin`目录,运行所需要的相关文件和配置会安装到PhxSQL目录下的`install_package`目录。打包二进制运行包会把`install_package`进行tar格式的打包,并生成`phxsql.tar.gz`。若想更改`install`的安装目录,可在`sh autoinstall.sh` 后加入`-prefix=`路径 -> 详细的编译步骤请参阅WIKI [中文编译手册](https://github.com/tencent-wechat/phxsql/wiki/%E4%B8%AD%E6%96%87%E8%AF%A6%E7%BB%86%E7%BC%96%E8%AF%91%E6%89%8B%E5%86%8C) +> 详细的编译步骤请参阅WIKI [中文编译手册](https://github.com/Tencent/phxsql/wiki/%E4%B8%AD%E6%96%87%E8%AF%A6%E7%BB%86%E7%BC%96%E8%AF%91%E6%89%8B%E5%86%8C) # PhxSQL部署和运行 diff --git a/makefile.mk b/makefile.mk index c9c3251..54529b4 100644 --- a/makefile.mk +++ b/makefile.mk @@ -11,6 +11,7 @@ NANOPBPATH=$(SRC_BASE_PATH)/third_party/nanopb/ PROTOBUF_INCLUDE_PATH=$(SRC_BASE_PATH)/third_party/protobuf/include LEVELDB_INCLUDE_PATH=$(SRC_BASE_PATH)/third_party/leveldb/include +GFLAGS_INCLUDE_PATH=$(SRC_BASE_PATH)/third_party/gflags/include GLOG_INCLUDE_PATH=$(SRC_BASE_PATH)/third_party/glog/include PHXPAXOS_INCLUDE_PATH=$(SRC_BASE_PATH)/third_party/phxpaxos/include PHXPAXOS_PLUGIN_PATH=$(SRC_BASE_PATH)/third_party/phxpaxos/plugin/include @@ -20,6 +21,7 @@ PHXRPC_INCLUDE_PATH=$(SRC_BASE_PATH)/third_party/phxrpc PROTOBUF_LIB_PATH=$(SRC_BASE_PATH)/third_party/protobuf/lib LEVELDB_LIB_PATH=$(SRC_BASE_PATH)/third_party/leveldb/lib/ +GFLAGS_LIB_PATH=$(SRC_BASE_PATH)/third_party/gflags/lib GLOG_LIB_PATH=$(SRC_BASE_PATH)/third_party/glog/lib MYSQL_LIB_PATH=$(SRC_BASE_PATH)/percona/libmysql PHXPAXOS_LIB_PATH=$(SRC_BASE_PATH)/third_party/phxpaxos/lib @@ -30,12 +32,12 @@ PHXRPC_LIB_PATH=$(SRC_BASE_PATH)/third_party/phxrpc/lib CXX=g++ CXXFLAGS+=-std=c++11 CPPFLAGS+=-I$(SRC_BASE_PATH) -I$(PROTOBUF_INCLUDE_PATH) -I$(LEVELDB_INCLUDE_PATH) -CPPFLAGS+=-I$(GLOG_INCLUDE_PATH) -CPPFLAGS+=-Wall -g -fPIC -m64 +CPPFLAGS+=-I$(GFLAGS_INCLUDE_PATH) -I$(GLOG_INCLUDE_PATH) +CPPFLAGS+=-Wall -g -fPIC -m64 -LDFLAGS += -L$(PHXPAXOS_LIB_PATH) -L$(PHXSQL_LIB_PATH) -L$(PROTOBUF_LIB_PATH) -L$(LEVELDB_LIB_PATH) -LDFLAGS += -L$(GLOG_LIB_PATH) -L$(GRPC_LIBE_PATH) -L$(OPEN_SSL_LIB_PATH) -L$(MYSQL_LIB_PATH) -LDFLAGS += -L$(COLIB_LIB_PATH) +LDFLAGS += -L$(PHXPAXOS_LIB_PATH) -L$(PHXSQL_LIB_PATH) -L$(PROTOBUF_LIB_PATH) -L$(LEVELDB_LIB_PATH) +LDFLAGS += -L$(GFLAGS_LIB_PATH) -L$(GLOG_LIB_PATH) -L$(GRPC_LIBE_PATH) -L$(OPEN_SSL_LIB_PATH) -L$(MYSQL_LIB_PATH) +LDFLAGS += -L$(COLIB_LIB_PATH) LDFLAGS += -static-libgcc -static-libstdc++ LDFLAGS += -Wl,--no-as-needed @@ -58,6 +60,7 @@ vpath %.proto $(PROTOS_PATH) %.pb.cc: %.proto $(PROTOC) -I$(PROTOBUF_INCLUDE_PATH) -I $(PROTOS_PATH) --cpp_out=. $< +.PHONY: install install: make install -C percona @mkdir $(PREFIX)/lib -p;\ diff --git a/phx_percona/percona/plugin/phxsync_phxrpc/CMakeLists.txt b/phx_percona/percona/plugin/phxsync_phxrpc/CMakeLists.txt index 0039e09..6ad4609 100644 --- a/phx_percona/percona/plugin/phxsync_phxrpc/CMakeLists.txt +++ b/phx_percona/percona/plugin/phxsync_phxrpc/CMakeLists.txt @@ -1,14 +1,14 @@ # Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. -# +# # 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; version 2 of the License. -# +# # 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 St, Fifth Floor, Boston, MA 02110-1301 USA @@ -19,16 +19,17 @@ ADD_DEFINITIONS(-std=gnu++0x -DNO_USE_PAXOS_PLUGIN -DMYSQL_SERVER ) EXEC_PROGRAM(g++ ARGS -print-file-name=libstdc++.a OUTPUT_VARIABLE STDCLIBPATH) EXEC_PROGRAM(cp ARGS ${STDCLIBPATH} ${BASE_PATH}/.lib/extlib/libstdcxx.a) -INCLUDE_DIRECTORIES( +INCLUDE_DIRECTORIES( ${BASE_PATH}/include ${BASE_PATH}/third_party/phxpaxos/include ${BASE_PATH}/third_party/phxpaxos/plugin/include/ ) -SET( PHXCLIENTLIB_SRC +SET( PHXCLIENTLIB_SRC ${BASE_PATH}/.lib/extlib/libphxbinlogsvrclient_phxrpc.a ${BASE_PATH}/.lib/extlib/libphxglog.a ${BASE_PATH}/third_party/glog/lib/libglog.a + ${BASE_PATH}/third_party/gflags/lib/libgflags.a ${BASE_PATH}/third_party/phxrpc/lib/libphxrpc.a ${BASE_PATH}/third_party/protobuf/lib/libprotobuf.a ${BASE_PATH}/.lib/extlib/libstdcxx.a diff --git a/phxbinlogsvr/core/paxos/event_executer.cpp b/phxbinlogsvr/core/paxos/event_executer.cpp index e68a011..88b8fa1 100644 --- a/phxbinlogsvr/core/paxos/event_executer.cpp +++ b/phxbinlogsvr/core/paxos/event_executer.cpp @@ -99,9 +99,9 @@ int EventExecuter::SMExecute(const uint64_t &instance_id, const string &paxos_va return ret; } - //LogVerbose("%s current gtid %s event gtid %s sm gtid %s old checksum %llu run %u ms", __func__, - // data.current_gtid().c_str(), data.event_gtid().c_str(), newest_gtid.c_str(), old_checksum, - // timer.GetTime() / 1000); + LogVerbose("%s current gtid %s event gtid %s sm gtid %s old checksum %llu run %u ms", __func__, + data.current_gtid().c_str(), data.event_gtid().c_str(), newest_gtid.c_str(), old_checksum, + timer.GetTime() / 1000); uint64_t new_checksum = Utils::GetCheckSum(old_checksum, data.buffer().c_str(), data.buffer().size()); if (new_checksum != data.checksum()) { diff --git a/phxbinlogsvr/framework/phxrpc/client/phxbinlog_stub_phxrpc.cpp b/phxbinlogsvr/framework/phxrpc/client/phxbinlog_stub_phxrpc.cpp index dbca854..8f36d9e 100644 --- a/phxbinlogsvr/framework/phxrpc/client/phxbinlog_stub_phxrpc.cpp +++ b/phxbinlogsvr/framework/phxrpc/client/phxbinlog_stub_phxrpc.cpp @@ -2,9 +2,9 @@ Tencent is pleased to support the open source community by making PhxSQL available. Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. Licensed under the GNU General Public License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + https://opensource.org/licenses/GPL-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ @@ -12,6 +12,7 @@ #include "phxrpc_phxbinlog_stub.h" #include "phxcomm/phx_log.h" +#include "phxrpc/http.h" #include "phxrpc/rpc.h" #include @@ -80,7 +81,8 @@ int PhxBinlogStub_PhxRPC::RpcCallWithIPList(const FuncName &func, const vectorGetServerConfig(), Server::HttpDispatch, &service_args); + phxrpc::HshaServer server(config_->GetServerConfig(), Server::Dispatch, &service_args); server.RunForever(); @@ -107,16 +107,17 @@ PhxBinLogSvrHandler *Server::GetSvrHandler() { return svr_handler_; } -void Server::HttpDispatch(const phxrpc::HttpRequest & request, phxrpc::HttpResponse * response, - phxrpc::DispatcherArgs_t * args) { - ServiceArgs_t * service_args = (ServiceArgs_t *) (args->service_args); +void Server::Dispatch(const phxrpc::BaseRequest &req, + phxrpc::BaseResponse *const resp, + phxrpc::DispatcherArgs_t *const args) { + ServiceArgs_t *service_args = (ServiceArgs_t *)(args->service_args); PhxbinlogServiceImpl service(service_args); PhxbinlogDispatcher dispatcher(service, args); - phxrpc::HttpDispatcher < PhxbinlogDispatcher > http_dispatcher(dispatcher, PhxbinlogDispatcher::GetURIFuncMap()); - if (!http_dispatcher.Dispatch(request, response)) { - response->SetStatusCode(404); - response->SetReasonPhrase("Not Found"); + phxrpc::BaseDispatcher + base_dispatcher(dispatcher, PhxbinlogDispatcher::GetURIFuncMap()); + if (!base_dispatcher.Dispatch(req, resp)) { + resp->SetFake(phxrpc::BaseResponse::FakeReason::DISPATCH_ERROR); } } diff --git a/phxbinlogsvr/framework/phxrpc/svr/phxbinlog_server.h b/phxbinlogsvr/framework/phxrpc/svr/phxbinlog_server.h index 1148ea0..0eb96a8 100644 --- a/phxbinlogsvr/framework/phxrpc/svr/phxbinlog_server.h +++ b/phxbinlogsvr/framework/phxrpc/svr/phxbinlog_server.h @@ -2,9 +2,9 @@ Tencent is pleased to support the open source community by making PhxSQL available. Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. Licensed under the GNU General Public License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + https://opensource.org/licenses/GPL-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ @@ -13,29 +13,46 @@ #include #include "phxrpc/rpc.h" + namespace phxbinlog { + + class Option; + + } + namespace phxbinlogsvr { + + class PhxBinLogSvrHandler; class PhxBinLogClientFactoryInterface; + + } + namespace phxrpc { + + class BaseTcpStream; -class HttpRequest; -class HttpResponse; +class BaseRequest; +class BaseResponse; + + } + class PhxbinlogServerConfig; + class Server { - public: + public: Server(); virtual ~Server(); void Run(); - private: + private: virtual void InitMonitor(); virtual phxbinlogsvr::PhxBinLogClientFactoryInterface * GetPhxBinLogClientFactory(); void InitConfig(); @@ -46,17 +63,19 @@ class Server { PhxbinlogServerConfig *GetServerConfig(); phxbinlogsvr::PhxBinLogSvrHandler *GetSvrHandler(); - static void HttpDispatch(const phxrpc::HttpRequest & request, phxrpc::HttpResponse * response, - phxrpc::DispatcherArgs_t * args); + static void Dispatch(const phxrpc::BaseRequest &req, + phxrpc::BaseResponse *const resp, + phxrpc::DispatcherArgs_t *const args); - protected: - typedef void (*OpenLogFunc)(const char *, const int &log_level, const char * log_path, + protected: + typedef void (*OpenLogFunc)(const char *, const int &log_level, const char *log_path, const uint32_t &log_file_max_size); typedef void (*LogFunc)(int log_level, const char *format, va_list args); void InitLog(LogFunc log_func, OpenLogFunc openlog_func); - protected: + PhxbinlogServerConfig *config_; phxbinlogsvr::PhxBinLogSvrHandler *svr_handler_; phxbinlog::Option *phxbin_option_; }; + diff --git a/phxbinlogsvr/framework/phxrpc/svr/phxbinlog_service_impl.cpp b/phxbinlogsvr/framework/phxrpc/svr/phxbinlog_service_impl.cpp index e7fc23f..f716c8f 100644 --- a/phxbinlogsvr/framework/phxrpc/svr/phxbinlog_service_impl.cpp +++ b/phxbinlogsvr/framework/phxrpc/svr/phxbinlog_service_impl.cpp @@ -2,9 +2,9 @@ Tencent is pleased to support the open source community by making PhxSQL available. Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. Licensed under the GNU General Public License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + https://opensource.org/licenses/GPL-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ @@ -23,7 +23,7 @@ PhxbinlogServiceImpl::PhxbinlogServiceImpl(ServiceArgs_t * service_args) : PhxbinlogServiceImpl::~PhxbinlogServiceImpl() { } -int PhxbinlogServiceImpl::PHXEcho(const google::protobuf::StringValue &req, google::protobuf::StringValue *resp) { +int PhxbinlogServiceImpl::PhxEcho(const google::protobuf::StringValue &req, google::protobuf::StringValue *resp) { resp->set_value(req.value()); return 0; } diff --git a/phxbinlogsvr/framework/phxrpc/svr/phxbinlog_service_impl.h b/phxbinlogsvr/framework/phxrpc/svr/phxbinlog_service_impl.h index 7698abb..3de6009 100644 --- a/phxbinlogsvr/framework/phxrpc/svr/phxbinlog_service_impl.h +++ b/phxbinlogsvr/framework/phxrpc/svr/phxbinlog_service_impl.h @@ -2,9 +2,9 @@ Tencent is pleased to support the open source community by making PhxSQL available. Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. Licensed under the GNU General Public License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + https://opensource.org/licenses/GPL-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ @@ -28,7 +28,7 @@ class PhxbinlogServiceImpl : public PhxbinlogService { PhxbinlogServiceImpl(ServiceArgs_t * service_args); virtual ~PhxbinlogServiceImpl(); - virtual int PHXEcho(const google::protobuf::StringValue & req, google::protobuf::StringValue *resp); + virtual int PhxEcho(const google::protobuf::StringValue & req, google::protobuf::StringValue *resp); virtual int SendBinLog(const google::protobuf::BytesValue & req, google::protobuf::Empty *resp); diff --git a/phxbinlogsvr/framework/phxrpc/tools/phxbinlog_tool_impl.cpp b/phxbinlogsvr/framework/phxrpc/tools/phxbinlog_tool_impl.cpp index 91521a0..a54f4e3 100644 --- a/phxbinlogsvr/framework/phxrpc/tools/phxbinlog_tool_impl.cpp +++ b/phxbinlogsvr/framework/phxrpc/tools/phxbinlog_tool_impl.cpp @@ -2,9 +2,9 @@ Tencent is pleased to support the open source community by making PhxSQL available. Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. Licensed under the GNU General Public License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + https://opensource.org/licenses/GPL-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ @@ -29,7 +29,7 @@ PhxbinlogToolImpl::PhxbinlogToolImpl() { PhxbinlogToolImpl::~PhxbinlogToolImpl() { } -int PhxbinlogToolImpl::PHXEcho(phxrpc::OptMap & optMap) { +int PhxbinlogToolImpl::PhxEcho(phxrpc::OptMap & optMap) { google::protobuf::StringValue req; google::protobuf::StringValue resp; diff --git a/phxbinlogsvr/framework/phxrpc/tools/phxbinlog_tool_impl.h b/phxbinlogsvr/framework/phxrpc/tools/phxbinlog_tool_impl.h index 7d691f2..c6bfaa3 100644 --- a/phxbinlogsvr/framework/phxrpc/tools/phxbinlog_tool_impl.h +++ b/phxbinlogsvr/framework/phxrpc/tools/phxbinlog_tool_impl.h @@ -2,9 +2,9 @@ Tencent is pleased to support the open source community by making PhxSQL available. Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. Licensed under the GNU General Public License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + https://opensource.org/licenses/GPL-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ @@ -24,7 +24,7 @@ class PhxbinlogToolImpl : public PhxbinlogTool { PhxbinlogToolImpl(); virtual ~PhxbinlogToolImpl(); - virtual int PHXEcho(phxrpc::OptMap & opt_map); + virtual int PhxEcho(phxrpc::OptMap & opt_map); virtual int SendBinLog(phxrpc::OptMap & opt_map); diff --git a/phxcomm/log/phxglog/Makefile.define b/phxcomm/log/phxglog/Makefile.define index db2c73b..3d70ed0 100644 --- a/phxcomm/log/phxglog/Makefile.define +++ b/phxcomm/log/phxglog/Makefile.define @@ -1,31 +1,31 @@ -# Copyright (c) 2016 Tencent. See the AUTHORS file for names +# Copyright (c) 2016 Tencent. See the AUTHORS file for names # of contributors. -# +# # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. -# +# # This library 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 # Library General Public License for more details. -# +# # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, # Boston, MA 02110-1301, USA. -# +# -allobject=elibphxglog.a +allobject=elibphxglog.a PHXGLOG_OBJ=phx_glog.o PHXGLOG_LIB=phxglog include:phxcomm_include -PHXGLOG_SYS_LIB=$(GLOG_LIB_PATH)/libglog.a -lpthread +PHXGLOG_SYS_LIB=$(GLOG_LIB_PATH)/libglog.a $(GFLAGS_LIB_PATH)/libgflags.a -lpthread -PHXGLOG_INCS=$(SRC_BASE_PATH)/phxcomm/log/phxglog +PHXGLOG_INCS=$(SRC_BASE_PATH)/phxcomm/log/phxglog PHXGLOG_EXTRA_CPPFLAGS=-Wall diff --git a/third_party/autoinstall.sh b/third_party/autoinstall.sh index 59998da..94c2452 100755 --- a/third_party/autoinstall.sh +++ b/third_party/autoinstall.sh @@ -16,7 +16,7 @@ function go_back() cd $current_path; } -function check_dir_exist() +function check_dir_exist() { dir_path=$current_path"/$1"; if [ ! -d $dir_path ]; then @@ -25,7 +25,7 @@ function check_dir_exist() fi } -function check_file_exist() +function check_file_exist() { if [ ! -f $1 ]; then return 1; @@ -114,7 +114,7 @@ function install_protobuf() exist_gmock_dir="../phxpaxos/third_party/gmock"; if [ -d $exist_gmock_dir ]; then if [ ! -d gmock ]; then - cp -r $exist_gmock_dir gmock; + cp -r $exist_gmock_dir gmock; fi fi @@ -145,7 +145,40 @@ function install_glog() go_back; cd $lib_name; - ./configure CXXFLAGS=-fPIC --prefix=$(pwd); + ./autogen.sh + exist_gflags_dir="../gflags"; + if [ -d $exist_gflags_dir ]; then + # use local gflags + ./configure CXXFLAGS=-fPIC --prefix=$(pwd) --with-gflags=$exist_gflags_dir; + else + # use system gflags + ./configure CXXFLAGS=-fPIC --prefix=$(pwd); + fi + make && make install; + + check_lib_exist $lib_name; + if [ $? -eq 1 ]; then + perror "$lib_name install fail. please check compile error info." + exit 1; + fi + psucc "install $lib_name ok." +} + +function install_gflags() +{ + lib_name="gflags"; + check_dir_exist $lib_name; + + # check if aready install. + check_lib_exist $lib_name; + if [ $? -eq 0 ]; then + psucc "$lib_name already installed." + return; + fi + # end check. + go_back; + cd $lib_name; + CXXFLAGS=-fPIC cmake . -DCMAKE_INSTALL_PREFIX=$(pwd); make && make install; check_lib_exist $lib_name; @@ -212,7 +245,8 @@ function install_phxpaxos() go_back; cd $lib_name; cd third_party; - rm -rf glog leveldb protobuf; + rm -rf gflags glog leveldb protobuf; + ln -s ../../gflags gflags; ln -s ../../glog glog; ln -s ../../leveldb leveldb ln -s ../../protobuf protobuf; @@ -257,9 +291,10 @@ function install_phxrpc() psucc "install $lib_name ok." } +install_gflags; +install_glog; install_leveldb; install_protobuf; -install_glog; install_colib; install_phxpaxos; install_phxrpc; diff --git a/third_party/colib b/third_party/colib index 44c4ae9..7e8d001 160000 --- a/third_party/colib +++ b/third_party/colib @@ -1 +1 @@ -Subproject commit 44c4ae9d059f72d051fe25b032b554016c896080 +Subproject commit 7e8d001a250018cff859db5f6f4a6edf4a38bc24 diff --git a/third_party/gflags b/third_party/gflags new file mode 160000 index 0000000..46f73f8 --- /dev/null +++ b/third_party/gflags @@ -0,0 +1 @@ +Subproject commit 46f73f88b18aee341538c0dfc22b1710a6abedef diff --git a/third_party/glog b/third_party/glog index 0b0b022..a6a166d 160000 --- a/third_party/glog +++ b/third_party/glog @@ -1 +1 @@ -Subproject commit 0b0b022be1c9c9139955af578fe477529d4b7b3c +Subproject commit a6a166db069520dbbd653c97c2e5b12e08a8bb26 diff --git a/third_party/leveldb b/third_party/leveldb index 3080a45..a53934a 160000 --- a/third_party/leveldb +++ b/third_party/leveldb @@ -1 +1 @@ -Subproject commit 3080a45b626f8ddb474bc5e860796a48b51b3cf0 +Subproject commit a53934a3ae1244679f812d998a4f16f2c7f309a6 diff --git a/third_party/phxpaxos b/third_party/phxpaxos index f851064..c6c8806 160000 --- a/third_party/phxpaxos +++ b/third_party/phxpaxos @@ -1 +1 @@ -Subproject commit f851064bb23192b2f6f866de091799580fa5b086 +Subproject commit c6c8806c3497cabe6e74dc09aa4487b6fd2057f7 diff --git a/third_party/phxrpc b/third_party/phxrpc index 1e7914e..180bc75 160000 --- a/third_party/phxrpc +++ b/third_party/phxrpc @@ -1 +1 @@ -Subproject commit 1e7914eeca71551446c978a43b1d4240ec40b1dc +Subproject commit 180bc75198131c5749e71ed0d0f00ed31596d619 diff --git a/tools/check_install.py b/tools/check_install.py index ca99e10..1af0664 100644 --- a/tools/check_install.py +++ b/tools/check_install.py @@ -6,7 +6,7 @@ lib_dir="" bin_dir="" -third_party_list=["PROTOBUF", "LEVELDB", "GLOG", "PHXPAXOS", "PHXPAXOS_PLUGIN", "COLIB"] +third_party_list=["PROTOBUF", "LEVELDB", "GFLAGS", "GLOG", "PHXPAXOS", "PHXPAXOS_PLUGIN", "COLIB"] def GetPath(key): makefile_def=open("makefile.mk") @@ -40,30 +40,30 @@ def GetPathPrefix(key): def CheckMySql(): if( not os.path.exists( base_dir+"/percona") ): print "percona directory(%s) not found" % (base_dir + "/percona") - print "please make sure percona 5.6 has been placed on the source directory and named \"percona\"," + print "please make sure percona 5.6 has been placed on the source directory and named \"percona\"," print "you can download percona 5.6 from https://github.com/percona/percona-server.git." exit(1) - + def CheckBasePath(): global lib_dir, sbin_dir - lib_dir=GetPath("PHXSQL_LIB_PATH") + lib_dir=GetPath("PHXSQL_LIB_PATH") if( not os.path.exists( lib_dir ) ): os.mkdir( lib_dir ) - sbin_dir=GetPath("PHXSQL_SBIN_PATH") + sbin_dir=GetPath("PHXSQL_SBIN_PATH") if( not os.path.exists( sbin_dir ) ): os.mkdir( sbin_dir ) - extlib_dir=GetPath("PHXSQL_EXTLIB_PATH") + extlib_dir=GetPath("PHXSQL_EXTLIB_PATH") if( not os.path.exists( extlib_dir ) ): os.mkdir( extlib_dir ) def Check3rdPath(): for lib in third_party_list: - path_list=GetPathPrefix(lib) + path_list=GetPathPrefix(lib) for path in path_list: if( not os.path.exists( path[1] ) ): print "%s not found" % path[1] @@ -73,7 +73,7 @@ def Check3rdPath(): def CheckProtobufVersion(): protobuf_bin_path = base_dir + "/third_party/protobuf/bin" if( not os.path.exists( protobuf_bin_path ) ): - print "please make sure protobuf 3.0+ has been installed on the third party directory" + print "please make sure protobuf 3.0+ has been installed on the third party directory" print "and %s/protoc can be detected" % protobuf_bin_path exit(1) @@ -83,7 +83,7 @@ def CheckProtobufVersion(): cmd_res.close() if( res == '' ): print "protobuf %s has beed found",res - print "please make sure protobuf 3.0+ has been installed on the third party directory" + print "please make sure protobuf 3.0+ has been installed on the third party directory" exit(1) if(__name__ == '__main__'):