Octo-rpc integration Thrift 0.11.0
Abstract: OCTO is a service governance framework of Meituan, which is open source in 2019. It mainly includes three modules: OCTO-RPC, OCto-Portal and OCto-MNS. This article describes how to integrate Thrift 0.11.0 version into OTO-PRC.
A, environmental
Mac, homebrew, git, jdk8, maven3
Second, the target
Use ZooKeeper as the registry of the service, do not use OCto-MNS, and do not use CAT as trace
3. Install Thrift 0.11.0
The latest version of Thrift is 0.12.0. Homebrew installs 0.12.0 by default, but does not provide 0.11.0.
- Copy the formula file thrift. Rb locally
class Thrift < Formula
desc "Framework for scalable cross-language services development"
homepage "https://thrift.apache.org/"
url "https://www.apache.org/dyn/closer.cgi?path=/thrift/0.11.0/thrift-0.11.0.tar.gz"
sha256 "c4ad38b6cb4a3498310d405a91fef37b9a8e79a50cd0968148ee2524d2fa60c2"
bottle do
cellar :any
rebuild 1
sha256 "5b99e08e1a69b6b9e39769982efec86fd773753d39439ca89011e180bcdb9249" => :mojave
sha256 "3a0d80b8f12a25fc87a4fe58722357c932c320a5d9a79f27346d21bcb956a337" => :high_sierra
sha256 "85bc8f2f5634985803ae738a548710cb6f0ca71acb0a35b7b2f29631b894820d" => :sierra
end
head do
url "https://github.com/apache/thrift.git"
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
depends_on "pkg-config" => :build
end
depends_on "bison" => :build
depends_on "boost"
depends_on "openssl"
def install
system "./bootstrap.sh" unless build.stable?
args = %W[
--disable-debug
--disable-tests
--prefix=#{prefix}
--libdir=#{lib}
--with-openssl=#{Formula["openssl"].opt_prefix}
--without-erlang
--without-haskell
--without-perl
--without-php
--without-php_extension
--without-ruby
--without-java
--without-python
]
ENV.cxx11 if ENV.compiler == :clang
# Don't install extensions to /usr:
ENV["PY_PREFIX"] = prefix
ENV["PHP_PREFIX"] = prefix
ENV["JAVA_PREFIX"] = buildpath
system "./configure", *args
ENV.deparallelize
system "make"
system "make"."install"
end
test do
system "#{bin}/thrift"."--version"
end
end
Copy the code
-
Brew Uninstall Thrift if other versions are already installed
brew install ./thrift.rb
-
Check whether the installation is successful
thrift –version
4. Octo-rpc integration Thrift 0.11.0
-
The code download
git clone https://github.com/Meituan-Dianping/octo-rpc.git
-
Upgrade Thrift to 0.11.0 and update dorado/pom.xml
< libthrift version > 0.11.0 < / libthrift version >
-
Annotations MNS – Invoker dependency
<! -- <dependency> <groupId>com.meituan.octo</groupId> <artifactId>mns-invoker</artifactId> <exclusions> <exclusion> <artifactId>libthrift</artifactId> <groupId>org.apache.thrift</groupId> </exclusion> </exclusions> </dependency> -->Copy the code
-
Sh script file in the octo-rpc/dorado directory. Run the chmod +x gen_thrift. Sh &./gen_thrift
#! /bin/bash #dorado/dorado-test/dorado-test-api files=$(ls dorado-test/dorado-test-api/src/main/resources/thrift/) for filename in $files do echo $filename thrift --gen java dorado-test/dorado-test-api/src/main/resources/thrift/$filename done cp -rf gen-java/* dorado-test/dorado-test-api/src/main/java/ rm -rf gen-java # dorado-protocol-octo files=$(ls dorado-protocol/dorado-protocol-octo/src/main/resources/idl/) for filename in $files do echo $filename thrift --gen java dorado-protocol/dorado-protocol-octo/src/main/resources/idl/$filename done cp -rf gen-java/* dorado-protocol/dorado-protocol-octo/src/main/java/ rm -rf gen-java Copy the code
-
Update the class com. At meituan. Dorado. Serialize. Thrift. ThriftIDLSerializer. Java, incompatible
TApplicationException.read(protocol) -> TApplicationException.readFrom(protocol) Copy the code
-
Modules compiled
mvn clean install -Dmaven.test.skip=true -pl -dorado-registry/dorado-registry-mns,-dorado-trace/dorado-trace-cat
-
The whole into a JAR package
cd dorado-build && mvn clean install -Dmaven.test.skip=true