├── examples ├── android │ ├── app │ │ ├── .gitignore │ │ ├── src │ │ │ └── main │ │ │ │ ├── res │ │ │ │ ├── values │ │ │ │ │ └── strings.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ └── layout │ │ │ │ │ └── activity_helloworld.xml │ │ │ │ ├── AndroidManifest.xml │ │ │ │ └── proto │ │ │ │ └── helloworld.proto │ │ ├── proguard-rules.pro │ │ └── build.gradle │ ├── settings.gradle │ ├── .gitignore │ ├── build.gradle │ └── README.md ├── src │ ├── generated │ │ └── main │ │ │ └── java │ │ │ └── io │ │ │ └── grpc │ │ │ └── examples │ │ │ ├── routeguide │ │ │ ├── PointOrBuilder.java │ │ │ ├── RouteSummaryOrBuilder.java │ │ │ ├── FeatureDatabaseOrBuilder.java │ │ │ ├── FeatureOrBuilder.java │ │ │ ├── RouteNoteOrBuilder.java │ │ │ └── RectangleOrBuilder.java │ │ │ └── helloworld │ │ │ ├── HelloRequestOrBuilder.java │ │ │ └── HelloReplyOrBuilder.java │ └── main │ │ └── proto │ │ └── helloworld.proto └── README.md ├── testing ├── src │ └── main │ │ └── resources │ │ └── certs │ │ ├── index.txt │ │ ├── ca-openssl.cnf │ │ ├── ca.pem │ │ ├── ca.key │ │ ├── server1.key │ │ ├── badclient.key │ │ ├── badserver.key │ │ ├── server0.key │ │ ├── client.key │ │ ├── server1.pem │ │ ├── badclient.pem │ │ ├── badserver.pem │ │ ├── client.pem │ │ └── server0.pem └── build.gradle ├── android-interop-testing ├── settings.gradle ├── app │ ├── src │ │ └── main │ │ │ ├── res │ │ │ ├── values │ │ │ │ └── strings.xml │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ └── raw │ │ │ │ └── ca.pem │ │ │ ├── AndroidManifest.xml │ │ │ └── proto │ │ │ └── io │ │ │ └── grpc │ │ │ └── android │ │ │ └── integrationtest │ │ │ └── empty.proto │ ├── proguard-rules.pro │ └── build.gradle ├── start-emulator.sh ├── wait-for-emulator.sh ├── build.gradle └── README.md ├── netty ├── src │ ├── main │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── services │ │ │ │ ├── io.grpc.ServerProvider │ │ │ │ └── io.grpc.ManagedChannelProvider │ │ └── java │ │ │ └── io │ │ │ └── grpc │ │ │ └── netty │ │ │ ├── package-info.java │ │ │ ├── GracefulCloseCommand.java │ │ │ ├── RequestMessagesCommand.java │ │ │ ├── NettyServerProvider.java │ │ │ ├── SendPingCommand.java │ │ │ ├── NegotiationType.java │ │ │ ├── NettyChannelProvider.java │ │ │ ├── CancelClientStreamCommand.java │ │ │ ├── CreateStreamCommand.java │ │ │ └── ProtocolNegotiator.java │ └── test │ │ └── java │ │ └── io │ │ └── grpc │ │ └── netty │ │ └── NettyClientTransportFactoryTest.java └── build.gradle ├── .gitattributes ├── okhttp ├── src │ ├── main │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── services │ │ │ │ └── io.grpc.ManagedChannelProvider │ │ └── java │ │ │ └── io │ │ │ └── grpc │ │ │ └── okhttp │ │ │ ├── package-info.java │ │ │ ├── NegotiationType.java │ │ │ ├── OkHttpSettingsUtil.java │ │ │ └── OkHttpChannelProvider.java │ └── test │ │ └── java │ │ └── io │ │ └── grpc │ │ └── okhttp │ │ ├── OkHttpClientTransportFactoryTest.java │ │ └── OkHttpWritableBufferTest.java ├── build.gradle └── third_party │ └── okhttp │ └── java │ └── io │ └── grpc │ └── okhttp │ └── internal │ ├── framed │ ├── Variant.java │ ├── HeadersMode.java │ └── Header.java │ └── TlsVersion.java ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── core ├── src │ ├── test │ │ ├── resources │ │ │ └── io │ │ │ │ └── grpc │ │ │ │ ├── ServerProviderTest-unavailableProvider.txt │ │ │ │ ├── ManagedChannelProviderTest-unavailableProvider.txt │ │ │ │ ├── ServerProviderTest-multipleProvider.txt │ │ │ │ └── ManagedChannelProviderTest-multipleProvider.txt │ │ └── java │ │ │ └── io │ │ │ └── grpc │ │ │ ├── inprocess │ │ │ ├── InProcessServerTest.java │ │ │ ├── InProcessClientTransportFactoryTest.java │ │ │ └── InProcessTransportTest.java │ │ │ ├── internal │ │ │ ├── ReadableBuffersByteBufferTest.java │ │ │ ├── ByteWritableBufferTest.java │ │ │ └── WritableBufferAllocatorTestBase.java │ │ │ ├── IntegerMarshaller.java │ │ │ └── StringMarshaller.java │ └── main │ │ └── java │ │ └── io │ │ └── grpc │ │ ├── package-info.java │ │ ├── inprocess │ │ ├── package-info.java │ │ └── InProcessSocketAddress.java │ │ ├── internal │ │ ├── package-info.java │ │ ├── BackoffPolicy.java │ │ ├── ServerTransport.java │ │ ├── WritableBufferAllocator.java │ │ ├── WithLogId.java │ │ ├── ContextRunnable.java │ │ ├── ServerListener.java │ │ ├── ClientTransportFactory.java │ │ └── ServerTransportListener.java │ │ ├── StatusRuntimeException.java │ │ ├── StatusException.java │ │ ├── KnownLength.java │ │ ├── Compressor.java │ │ ├── Decompressor.java │ │ ├── BindableService.java │ │ ├── PartialForwardingServerCallListener.java │ │ ├── Drainable.java │ │ └── MutableHandlerRegistry.java └── build.gradle ├── interop-testing └── src │ └── main │ ├── resources │ └── io │ │ └── grpc │ │ └── testing │ │ └── integration │ │ └── testdata │ │ └── uncompressable.bin │ └── proto │ └── io │ └── grpc │ └── testing │ └── integration │ └── empty.proto ├── .gitignore ├── CHANGES.md ├── auth └── build.gradle ├── protobuf-lite └── build.gradle ├── run-test-client.sh ├── run-test-server.sh ├── stub └── build.gradle ├── protobuf └── build.gradle ├── grpclb ├── build.gradle └── src │ └── generated │ └── main │ └── java │ └── io │ └── grpc │ └── grpclb │ ├── InitialLoadBalanceRequestOrBuilder.java │ ├── ClientStatsOrBuilder.java │ ├── LoadBalanceResponseOrBuilder.java │ ├── LoadBalanceRequestOrBuilder.java │ └── ServerOrBuilder.java ├── compiler ├── Dockerfile ├── src │ ├── java_plugin │ │ └── cpp │ │ │ └── java_generator.h │ ├── test │ │ └── proto │ │ │ └── test.proto │ └── testLite │ │ └── proto │ │ └── test.proto └── README.md ├── protobuf-nano ├── build.gradle └── src │ ├── test │ └── proto │ │ └── messages.proto │ └── main │ └── java │ └── io │ └── grpc │ └── protobuf │ └── nano │ └── MessageNanoFactory.java ├── PATENTS ├── LICENSE ├── checkstyle.license ├── settings.gradle ├── .travis.yml ├── CONTRIBUTING.md ├── NOTICE.txt └── benchmarks └── src ├── jmh └── java │ └── io │ └── grpc │ └── benchmarks │ └── netty │ └── README.md └── main ├── proto └── payloads.proto └── java └── io └── grpc └── benchmarks └── qps └── Configuration.java /examples/android/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /testing/src/main/resources/certs/index.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /android-interop-testing/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /netty/src/main/resources/META-INF/services/io.grpc.ServerProvider: -------------------------------------------------------------------------------- 1 | io.grpc.netty.NettyServerProvider 2 | -------------------------------------------------------------------------------- /netty/src/main/resources/META-INF/services/io.grpc.ManagedChannelProvider: -------------------------------------------------------------------------------- 1 | io.grpc.netty.NettyChannelProvider 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | TestService.java.txt binary 2 | TestServiceLite.java.txt binary 3 | TestServiceNano.java.txt binary 4 | -------------------------------------------------------------------------------- /okhttp/src/main/resources/META-INF/services/io.grpc.ManagedChannelProvider: -------------------------------------------------------------------------------- 1 | io.grpc.okhttp.OkHttpChannelProvider 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/biubiu/grpc-java/master/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /core/src/test/resources/io/grpc/ServerProviderTest-unavailableProvider.txt: -------------------------------------------------------------------------------- 1 | io.grpc.ServerProviderTest$UnavailableProvider 2 | -------------------------------------------------------------------------------- /core/src/test/resources/io/grpc/ManagedChannelProviderTest-unavailableProvider.txt: -------------------------------------------------------------------------------- 1 | io.grpc.ManagedChannelProviderTest$UnavailableProvider 2 | -------------------------------------------------------------------------------- /examples/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | GrpcHelloworldExample 3 | 4 | -------------------------------------------------------------------------------- /android-interop-testing/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | gRPC Integration Test 3 | 4 | -------------------------------------------------------------------------------- /examples/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/biubiu/grpc-java/master/examples/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/biubiu/grpc-java/master/examples/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/biubiu/grpc-java/master/examples/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /examples/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/biubiu/grpc-java/master/examples/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android-interop-testing/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/biubiu/grpc-java/master/android-interop-testing/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android-interop-testing/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/biubiu/grpc-java/master/android-interop-testing/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android-interop-testing/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/biubiu/grpc-java/master/android-interop-testing/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android-interop-testing/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/biubiu/grpc-java/master/android-interop-testing/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /core/src/test/resources/io/grpc/ServerProviderTest-multipleProvider.txt: -------------------------------------------------------------------------------- 1 | io.grpc.ServerProviderTest$Available5Provider 2 | io.grpc.ServerProviderTest$Available7Provider 3 | io.grpc.ServerProviderTest$Available0Provider 4 | -------------------------------------------------------------------------------- /interop-testing/src/main/resources/io/grpc/testing/integration/testdata/uncompressable.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/biubiu/grpc-java/master/interop-testing/src/main/resources/io/grpc/testing/integration/testdata/uncompressable.bin -------------------------------------------------------------------------------- /core/src/test/resources/io/grpc/ManagedChannelProviderTest-multipleProvider.txt: -------------------------------------------------------------------------------- 1 | io.grpc.ManagedChannelProviderTest$Available5Provider 2 | io.grpc.ManagedChannelProviderTest$Available7Provider 3 | io.grpc.ManagedChannelProviderTest$Available0Provider 4 | -------------------------------------------------------------------------------- /testing/build.gradle: -------------------------------------------------------------------------------- 1 | description = "gRPC: Testing" 2 | dependencies { 3 | compile project(':grpc-core'), 4 | project(':grpc-stub'), 5 | libraries.junit, 6 | libraries.mockito, 7 | libraries.truth 8 | } 9 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Mar 02 09:04:21 PST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.11-bin.zip 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Gradle 2 | build 3 | gradle.properties 4 | .gradle 5 | local.properties 6 | 7 | # IntelliJ IDEA 8 | .idea 9 | *.iml 10 | 11 | # Eclipse 12 | .classpath 13 | .project 14 | .settings 15 | .gitignore 16 | bin 17 | 18 | # OS X 19 | .DS_Store 20 | 21 | # Emacs 22 | *~ 23 | \#*\# 24 | -------------------------------------------------------------------------------- /examples/android/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /gradle.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | .idea/ 9 | 10 | *.iml 11 | *.apk 12 | *.ap_ 13 | *.dex 14 | *.class 15 | bin/ 16 | gen/ 17 | .gradle/ 18 | /*/build/ 19 | local.properties 20 | proguard/ 21 | *.log 22 | -------------------------------------------------------------------------------- /CHANGES.md: -------------------------------------------------------------------------------- 1 | Changes between 0.9.0 and 0.10.0: 2 | -------------------------------- 3 | 4 | #### Features 5 | 6 | #### API Changes 7 | * OkHttpChannelBuilder.overrideHostForAuthority is deprecated 8 | 9 | #### Bug Fixes 10 | * ServerCall forces headers to be sent first 11 | * Servers cannot be started after shutting down (#1023) 12 | -------------------------------------------------------------------------------- /auth/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "be.insaneprogramming.gradle.animalsniffer" version "1.4.0" 3 | } 4 | 5 | description = "gRpc: Auth" 6 | dependencies { 7 | compile project(':grpc-core'), 8 | libraries.oauth_client 9 | } 10 | 11 | // Configure the animal sniffer plugin 12 | animalsniffer { 13 | signature = "org.codehaus.mojo.signature:java16:+@signature" 14 | } 15 | -------------------------------------------------------------------------------- /android-interop-testing/start-emulator.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # The only argument is the AVD name. 4 | # Note: This script will hang, you may want to run it in the background. 5 | 6 | if [ $# -eq 0 ] 7 | then 8 | echo "Please specify the AVD name" 9 | exit 1 10 | fi 11 | 12 | echo "[INFO] Starting emulator $1" 13 | emulator64-arm -avd $1 -netfast -no-skin -no-audio -no-window -port 5554 14 | -------------------------------------------------------------------------------- /protobuf-lite/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "be.insaneprogramming.gradle.animalsniffer" version "1.4.0" 3 | } 4 | 5 | description = 'gRPC: Protobuf Lite' 6 | 7 | dependencies { 8 | compile project(':grpc-core'), 9 | libraries.protobuf, 10 | libraries.guava 11 | } 12 | 13 | animalsniffer { 14 | signature = "org.codehaus.mojo.signature:java16:+@signature" 15 | } 16 | -------------------------------------------------------------------------------- /run-test-client.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | cd "$(dirname "$0")" 3 | cat >&2 <&2 <&1` 8 | let "failcounter += 1" 9 | # Timeout after 5 minutes. 10 | if [[ $failcounter -gt 300 ]]; then 11 | echo "Can not find device after 5 minutes..." 12 | exit 1 13 | fi 14 | sleep 1 15 | done 16 | 17 | -------------------------------------------------------------------------------- /netty/build.gradle: -------------------------------------------------------------------------------- 1 | description = "gRPC: Netty" 2 | dependencies { 3 | compile project(':grpc-core'), 4 | libraries.netty 5 | 6 | // Tests depend on base class defined by core module. 7 | testCompile project(':grpc-core').sourceSets.test.output, 8 | project(':grpc-testing') 9 | } 10 | 11 | test { 12 | jvmArgs "-Xbootclasspath/p:" + configurations.alpnboot.asPath 13 | } 14 | 15 | javadoc.options.links 'http://netty.io/4.1/api/' 16 | -------------------------------------------------------------------------------- /core/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "be.insaneprogramming.gradle.animalsniffer" version "1.4.0" 3 | } 4 | 5 | description = 'gRPC: Core' 6 | 7 | dependencies { 8 | compile libraries.guava, 9 | libraries.jsr305 10 | testCompile project(':grpc-testing') 11 | } 12 | 13 | // Configure the animal sniffer plugin 14 | animalsniffer { 15 | signature = "org.codehaus.mojo.signature:java16:+@signature" 16 | } 17 | 18 | javadoc.exclude 'io/grpc/internal/**' 19 | -------------------------------------------------------------------------------- /protobuf/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "be.insaneprogramming.gradle.animalsniffer" version "1.4.0" 3 | } 4 | 5 | description = 'gRPC: Protobuf' 6 | 7 | dependencies { 8 | compile project(':grpc-core'), 9 | project(':grpc-protobuf-lite'), 10 | libraries.protobuf, 11 | libraries.guava, 12 | libraries.protobuf_util 13 | } 14 | 15 | animalsniffer { 16 | signature = "org.codehaus.mojo.signature:java16:+@signature" 17 | } 18 | -------------------------------------------------------------------------------- /examples/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in $ANDROID_HOME/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | -dontwarn com.google.common.** 13 | -dontwarn okio.** -------------------------------------------------------------------------------- /examples/src/generated/main/java/io/grpc/examples/routeguide/PointOrBuilder.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: route_guide.proto 3 | 4 | package io.grpc.examples.routeguide; 5 | 6 | public interface PointOrBuilder extends 7 | // @@protoc_insertion_point(interface_extends:routeguide.Point) 8 | com.google.protobuf.MessageOrBuilder { 9 | 10 | /** 11 | * optional int32 latitude = 1; 12 | */ 13 | int getLatitude(); 14 | 15 | /** 16 | * optional int32 longitude = 2; 17 | */ 18 | int getLongitude(); 19 | } 20 | -------------------------------------------------------------------------------- /examples/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:1.5.0' 9 | classpath "com.google.protobuf:protobuf-gradle-plugin:0.7.4" 10 | 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | jcenter() 19 | mavenLocal() 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /android-interop-testing/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:1.5.0' 9 | classpath "com.google.protobuf:protobuf-gradle-plugin:0.7.4" 10 | 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | mavenLocal() 19 | jcenter() 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /examples/src/generated/main/java/io/grpc/examples/helloworld/HelloRequestOrBuilder.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: helloworld.proto 3 | 4 | package io.grpc.examples.helloworld; 5 | 6 | public interface HelloRequestOrBuilder extends 7 | // @@protoc_insertion_point(interface_extends:helloworld.HelloRequest) 8 | com.google.protobuf.MessageOrBuilder { 9 | 10 | /** 11 | * optional string name = 1; 12 | */ 13 | java.lang.String getName(); 14 | /** 15 | * optional string name = 1; 16 | */ 17 | com.google.protobuf.ByteString 18 | getNameBytes(); 19 | } 20 | -------------------------------------------------------------------------------- /examples/src/generated/main/java/io/grpc/examples/helloworld/HelloReplyOrBuilder.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: helloworld.proto 3 | 4 | package io.grpc.examples.helloworld; 5 | 6 | public interface HelloReplyOrBuilder extends 7 | // @@protoc_insertion_point(interface_extends:helloworld.HelloReply) 8 | com.google.protobuf.MessageOrBuilder { 9 | 10 | /** 11 | * optional string message = 1; 12 | */ 13 | java.lang.String getMessage(); 14 | /** 15 | * optional string message = 1; 16 | */ 17 | com.google.protobuf.ByteString 18 | getMessageBytes(); 19 | } 20 | -------------------------------------------------------------------------------- /testing/src/main/resources/certs/ca-openssl.cnf: -------------------------------------------------------------------------------- 1 | [req] 2 | distinguished_name = req_distinguished_name 3 | req_extensions = v3_req 4 | 5 | [req_distinguished_name] 6 | countryName = Country Name (2 letter code) 7 | countryName_default = AU 8 | stateOrProvinceName = State or Province Name (full name) 9 | stateOrProvinceName_default = Some-State 10 | organizationName = Organization Name (eg, company) 11 | organizationName_default = Internet Widgits Pty Ltd 12 | commonName = Common Name (eg, YOUR name) 13 | commonName_default = testca 14 | 15 | [v3_req] 16 | basicConstraints = CA:true 17 | keyUsage = critical, keyCertSign 18 | 19 | -------------------------------------------------------------------------------- /grpclb/build.gradle: -------------------------------------------------------------------------------- 1 | description = "gRPC: GRPCLB LoadBalancer plugin" 2 | 3 | buildscript { 4 | repositories { 5 | mavenCentral() 6 | } 7 | dependencies { 8 | classpath libraries.protobuf_plugin 9 | } 10 | } 11 | 12 | dependencies { 13 | compile project(':grpc-core'), 14 | project(':grpc-protobuf'), 15 | project(':grpc-stub'), 16 | libraries.protobuf 17 | } 18 | 19 | configureProtoCompilation() 20 | 21 | idea { 22 | module { 23 | sourceDirs += file("${projectDir}/src/generated/main/grpc"); 24 | sourceDirs += file("${projectDir}/src/generated/main/java"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /android-interop-testing/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in $ANDROID_HOME/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | -dontwarn com.google.common.** 13 | -dontwarn okio.** 14 | -dontwarn org.mockito.** 15 | -dontwarn sun.reflect.** 16 | -dontwarn android.test.** 17 | 18 | # Need to create channel through service provider. 19 | -keepnames class io.grpc.ManagedChannelProvider 20 | -keep class io.grpc.okhttp.OkHttpChannelProvider 21 | -------------------------------------------------------------------------------- /grpclb/src/generated/main/java/io/grpc/grpclb/InitialLoadBalanceRequestOrBuilder.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: load_balancer.proto 3 | 4 | package io.grpc.grpclb; 5 | 6 | public interface InitialLoadBalanceRequestOrBuilder extends 7 | // @@protoc_insertion_point(interface_extends:grpc.lb.v1.InitialLoadBalanceRequest) 8 | com.google.protobuf.MessageOrBuilder { 9 | 10 | /** 11 | * optional string name = 1; 12 | * 13 | *
14 |    * Name of load balanced service
15 |    * 
16 | */ 17 | java.lang.String getName(); 18 | /** 19 | * optional string name = 1; 20 | * 21 | *
22 |    * Name of load balanced service
23 |    * 
24 | */ 25 | com.google.protobuf.ByteString 26 | getNameBytes(); 27 | } 28 | -------------------------------------------------------------------------------- /compiler/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM protoc-artifacts:latest 2 | 3 | RUN scl enable devtoolset-1.1 'bash -c "cd /protobuf && \ 4 | git fetch && \ 5 | git checkout v3.0.0-beta-2 && \ 6 | ./autogen.sh && \ 7 | CXXFLAGS=-m32 ./configure --disable-shared --prefix=/protobuf-32 && \ 8 | make clean && make -j$(nproc) && make -j$(nproc) install"' 9 | 10 | RUN scl enable devtoolset-1.1 'bash -c "cd /protobuf && \ 11 | CXXFLAGS=-m64 ./configure --disable-shared --prefix=/protobuf-64 && \ 12 | make clean && make -j$(nproc) && make -j$(nproc) install"' 13 | 14 | ENV CXXFLAGS=-I/protobuf-32/include \ 15 | LDFLAGS="-L/protobuf-32/lib -L/protobuf-64/lib" 16 | 17 | RUN git clone --depth 1 https://github.com/grpc/grpc-java.git 18 | 19 | # Start in devtoolset environment that uses GCC 4.7 20 | CMD ["scl", "enable", "devtoolset-1.1", "bash"] 21 | -------------------------------------------------------------------------------- /examples/android/README.md: -------------------------------------------------------------------------------- 1 | gRPC Hello World Tutorial (Android Java) 2 | ======================== 3 | 4 | PREREQUISITES 5 | ------------- 6 | - [Java gRPC](https://github.com/grpc/grpc-java) 7 | 8 | - [Android Tutorial](https://developer.android.com/training/basics/firstapp/index.html) if you're new to Android development 9 | 10 | - We only have Android gRPC client in this example. Please follow examples in other languages to build and run a gRPC server. 11 | 12 | INSTALL 13 | ------- 14 | **1. Clone the gRPC Java git repo** 15 | ```sh 16 | $ git clone https://github.com/grpc/grpc-java 17 | $ cd grpc-java 18 | ``` 19 | 20 | **2. Install gRPC Java (not necessary for released versions)** 21 | ```sh 22 | $ ./gradlew install -PskipCodegen=true 23 | ``` 24 | 25 | **3. Install the app** 26 | ```sh 27 | $ cd examples/android 28 | $ ../../gradlew installDebug 29 | ``` 30 | -------------------------------------------------------------------------------- /examples/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /testing/src/main/resources/certs/ca.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICSjCCAbOgAwIBAgIJAJHGGR4dGioHMA0GCSqGSIb3DQEBCwUAMFYxCzAJBgNV 3 | BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX 4 | aWRnaXRzIFB0eSBMdGQxDzANBgNVBAMTBnRlc3RjYTAeFw0xNDExMTEyMjMxMjla 5 | Fw0yNDExMDgyMjMxMjlaMFYxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0 6 | YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDzANBgNVBAMT 7 | BnRlc3RjYTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwEDfBV5MYdlHVHJ7 8 | +L4nxrZy7mBfAVXpOc5vMYztssUI7mL2/iYujiIXM+weZYNTEpLdjyJdu7R5gGUu 9 | g1jSVK/EPHfc74O7AyZU34PNIP4Sh33N+/A5YexrNgJlPY+E3GdVYi4ldWJjgkAd 10 | Qah2PH5ACLrIIC6tRka9hcaBlIECAwEAAaMgMB4wDAYDVR0TBAUwAwEB/zAOBgNV 11 | HQ8BAf8EBAMCAgQwDQYJKoZIhvcNAQELBQADgYEAHzC7jdYlzAVmddi/gdAeKPau 12 | sPBG/C2HCWqHzpCUHcKuvMzDVkY/MP2o6JIW2DBbY64bO/FceExhjcykgaYtCH/m 13 | oIU63+CFOTtR7otyQAWHqXa7q4SbCDlG7DyRFxqG0txPtGvy12lgldA2+RgcigQG 14 | Dfcog5wrJytaQ6UA0wE= 15 | -----END CERTIFICATE----- 16 | -------------------------------------------------------------------------------- /okhttp/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "be.insaneprogramming.gradle.animalsniffer" version "1.4.0" 3 | } 4 | 5 | description = "gRPC: OkHttp" 6 | dependencies { 7 | compile project(':grpc-core'), 8 | libraries.okhttp, 9 | libraries.okio 10 | 11 | // Tests depend on base class defined by core module. 12 | testCompile project(':grpc-core').sourceSets.test.output, 13 | project(":grpc-testing") 14 | } 15 | 16 | project.sourceSets { 17 | main { 18 | java { 19 | srcDir "${projectDir}/third_party/okhttp/java" 20 | } 21 | } 22 | } 23 | 24 | checkstyleMain.exclude '**/io/grpc/okhttp/internal/**' 25 | 26 | // Configure the animal sniffer plugin 27 | animalsniffer { 28 | signature = "org.codehaus.mojo.signature:java16:+@signature" 29 | } 30 | 31 | javadoc.exclude 'io/grpc/okhttp/internal/**' 32 | javadoc.options.links 'http://square.github.io/okhttp/2.x/okhttp/' 33 | -------------------------------------------------------------------------------- /android-interop-testing/app/src/main/res/raw/ca.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICSjCCAbOgAwIBAgIJAJHGGR4dGioHMA0GCSqGSIb3DQEBCwUAMFYxCzAJBgNV 3 | BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX 4 | aWRnaXRzIFB0eSBMdGQxDzANBgNVBAMTBnRlc3RjYTAeFw0xNDExMTEyMjMxMjla 5 | Fw0yNDExMDgyMjMxMjlaMFYxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0 6 | YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDzANBgNVBAMT 7 | BnRlc3RjYTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwEDfBV5MYdlHVHJ7 8 | +L4nxrZy7mBfAVXpOc5vMYztssUI7mL2/iYujiIXM+weZYNTEpLdjyJdu7R5gGUu 9 | g1jSVK/EPHfc74O7AyZU34PNIP4Sh33N+/A5YexrNgJlPY+E3GdVYi4ldWJjgkAd 10 | Qah2PH5ACLrIIC6tRka9hcaBlIECAwEAAaMgMB4wDAYDVR0TBAUwAwEB/zAOBgNV 11 | HQ8BAf8EBAMCAgQwDQYJKoZIhvcNAQELBQADgYEAHzC7jdYlzAVmddi/gdAeKPau 12 | sPBG/C2HCWqHzpCUHcKuvMzDVkY/MP2o6JIW2DBbY64bO/FceExhjcykgaYtCH/m 13 | oIU63+CFOTtR7otyQAWHqXa7q4SbCDlG7DyRFxqG0txPtGvy12lgldA2+RgcigQG 14 | Dfcog5wrJytaQ6UA0wE= 15 | -----END CERTIFICATE----- 16 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | grpc Examples 2 | ============================================== 3 | 4 | To build the examples, run in this directory: 5 | 6 | ``` 7 | $ ../gradlew installDist -PskipCodegen=true 8 | ``` 9 | 10 | This creates the scripts `hello-world-server`, `hello-world-client`, 11 | `route-guide-server`, and `route-guide-client` in the 12 | `build/install/grpc-examples/bin/` directory that run the examples. Each 13 | example requires the server to be running before starting the client. 14 | 15 | For example, to try the hello world example first run: 16 | 17 | ``` 18 | $ ./build/install/grpc-examples/bin/hello-world-server 19 | ``` 20 | 21 | And in a different terminal window run: 22 | 23 | ``` 24 | $ ./build/install/grpc-examples/bin/hello-world-client 25 | ``` 26 | 27 | That's it! 28 | 29 | Please refer to gRPC Java's [README](../README.md) and 30 | [tutorial](http://www.grpc.io/docs/tutorials/basic/java.html) for more 31 | information. 32 | -------------------------------------------------------------------------------- /testing/src/main/resources/certs/ca.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAMBA3wVeTGHZR1Ry 3 | e/i+J8a2cu5gXwFV6TnObzGM7bLFCO5i9v4mLo4iFzPsHmWDUxKS3Y8iXbu0eYBl 4 | LoNY0lSvxDx33O+DuwMmVN+DzSD+Eod9zfvwOWHsazYCZT2PhNxnVWIuJXViY4JA 5 | HUGodjx+QAi6yCAurUZGvYXGgZSBAgMBAAECgYAxRi8i9BlFlufGSBVoGmydbJOm 6 | bwLKl9dP3o33ODSP9hok5y6A0w5plWk3AJSF1hPLleK9VcSKYGYnt0clmPVHF35g 7 | bx2rVK8dOT0mn7rz9Zr70jcSz1ETA2QonHZ+Y+niLmcic9At6hRtWiewblUmyFQm 8 | GwggIzi7LOyEUHrEcQJBAOXxyQvnLvtKzXiqcsW/K6rExqVJVk+KF0fzzVyMzTJx 9 | HRBxUVgvGdEJT7j+7P2kcTyafve0BBzDSPIaDyiJ+Y0CQQDWCb7jASFSbu5M3Zcd 10 | Gkr4ZKN1XO3VLQX10b22bQYdF45hrTN2tnzRvVUR4q86VVnXmiGiTqmLkXcA2WWf 11 | pHfFAkAhv9olUBo6MeF0i3frBEMRfm41hk0PwZHnMqZ6pgPcGnQMnMU2rzsXzkkQ 12 | OwJnvAIOxhJKovZTjmofdqmw5odlAkBYVUdRWjsNUTjJwj3GRf6gyq/nFMYWz3EB 13 | RWFdM1ttkDYzu45ctO2IhfHg4sPceDMO1s6AtKQmNI9/azkUjITdAkApNa9yFRzc 14 | TBaDNPd5KVd58LVIzoPQ6i7uMHteLXJUWqSroji6S3s4gKMFJ/dO+ZXIlgQgfJJJ 15 | ZDL4cdrdkeoM 16 | -----END PRIVATE KEY----- 17 | -------------------------------------------------------------------------------- /testing/src/main/resources/certs/server1.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAOHDFScoLCVJpYDD 3 | M4HYtIdV6Ake/sMNaaKdODjDMsux/4tDydlumN+fm+AjPEK5GHhGn1BgzkWF+slf 4 | 3BxhrA/8dNsnunstVA7ZBgA/5qQxMfGAq4wHNVX77fBZOgp9VlSMVfyd9N8YwbBY 5 | AckOeUQadTi2X1S6OgJXgQ0m3MWhAgMBAAECgYAn7qGnM2vbjJNBm0VZCkOkTIWm 6 | V10okw7EPJrdL2mkre9NasghNXbE1y5zDshx5Nt3KsazKOxTT8d0Jwh/3KbaN+YY 7 | tTCbKGW0pXDRBhwUHRcuRzScjli8Rih5UOCiZkhefUTcRb6xIhZJuQy71tjaSy0p 8 | dHZRmYyBYO2YEQ8xoQJBAPrJPhMBkzmEYFtyIEqAxQ/o/A6E+E4w8i+KM7nQCK7q 9 | K4JXzyXVAjLfyBZWHGM2uro/fjqPggGD6QH1qXCkI4MCQQDmdKeb2TrKRh5BY1LR 10 | 81aJGKcJ2XbcDu6wMZK4oqWbTX2KiYn9GB0woM6nSr/Y6iy1u145YzYxEV/iMwff 11 | DJULAkB8B2MnyzOg0pNFJqBJuH29bKCcHa8gHJzqXhNO5lAlEbMK95p/P2Wi+4Hd 12 | aiEIAF1BF326QJcvYKmwSmrORp85AkAlSNxRJ50OWrfMZnBgzVjDx3xG6KsFQVk2 13 | ol6VhqL6dFgKUORFUWBvnKSyhjJxurlPEahV6oo6+A+mPhFY8eUvAkAZQyTdupP3 14 | XEFQKctGz+9+gKkemDp7LBBMEMBXrGTLPhpEfcjv/7KPdnFHYmhYeBTBnuVmTVWe 15 | F98XJ7tIFfJq 16 | -----END PRIVATE KEY----- 17 | -------------------------------------------------------------------------------- /testing/src/main/resources/certs/badclient.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBALJfYnFn4nkj52WF 3 | E5W2qUxCfjsEFyuXYYKS/07UPWsv3gpZhtjXgdeGL+dpwEBC0IRDBfGnkMp6YY5S 4 | O7rnEz0X3r/fvgYy+dEl2jnaA6zgc7RzMGl9U11d56gP9FiDC2190mvP/hpq2xLZ 5 | CTbIximpmaoQyxuuH1bbYunesIG/AgMBAAECgYAdqJCEzMIyZE7oaW0tOpcB0BiP 6 | FYoIvH4BKRH8eHvR476mt+YdDhBP1scGUmYeCT4Ej+RgHv2LPTgVYwT9eciP2+E/ 7 | CBCNRel0Sw9JepwW0r+jWJtDY1pp6YXAgNRGX2UflvUsT+o9lZvagf9moLTMyGvU 8 | uLFnsyfLim1B4vXvWQJBANouZllXGZoSrZLtR3VgV4tzRQvJxu84kLeIk64Ov47X 9 | pHVBMTRBfzPEhbBodjr1m5OLaVLqkFcXftzRCrbWoKsCQQDRSoLLXOiLrtJ3DLJC 10 | rX7Y8wrHZrqk5bMdZLGa/UX8RanhVw3+Xp+urd1711umeNJfzu/MCk4a1KkG/CU0 11 | rqs9AkA4cSx1DD1JSG+yxMNpsAS1xJomFIrsM9vsPt7FdndDwrF+y+CovhDkGYDk 12 | RAHh+svGfZg/pQK2JRPimAmHhzqFAkEAu6Ya70s2FUeB3Mu9aJs2CD6hg3dQEVkB 13 | 53DI7TX48d9kGW58VX1xnqS02LyWqAPcW5qm1kLHFLdndaPNmBaj4QJBAJugl367 14 | 9d9t/QLTSuULLaoYv2vJT3s1y9HN89EoaDDEkPVfQu6GVEXgIBtim1sI/VPSzI8H 15 | aXvaTUwblFWSM70= 16 | -----END PRIVATE KEY----- 17 | -------------------------------------------------------------------------------- /testing/src/main/resources/certs/badserver.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKeZ1e1y29cmBKaW 3 | oIUwJ5neOJUjx+eD/3nRPe+dvLXEd9+db0fG5RYRR0S3mF1Ywuj4PIxlTW2YprUS 4 | oGSw+tcqWNIzxv94HjwYFkkvER3AblXcDBh0P2zAkzg+nf9AcAsMh0QpDTyrXtMl 5 | gqryjq1/vkhFofKMMbY+aXJdG6OBAgMBAAECgYAAgaB51S0A22aMMkxN2rVj6530 6 | JWWHN4jgD1fGj41wZyWNkWYyq1Ep3ed/N6bIMWp1VbqpGe0/9YQba/D8HOTFHGRt 7 | 72YXnP1e/ds8cxU4x4j1vvqSPtXpMmkiXfXijOvCl9mrMH2xjghFAt6/1Nb9xo1m 8 | VdcOB8OdSuOIw6CI+QJBAN5FZUbS+bRXDWII/FaAih1DBpwCxhYEN+TXPJBxSen6 9 | kOzGt5g+mB6YqRMZ/qshshwPq7bsgFGfJ2lIdS2t3GsCQQDBCKifV5AAkOdOUrkK 10 | HvoX3qnVmyIA8CyvWLcIWpfZ76QAYh0q0StedKdOMXaB1jTeSJ2KU1nlss7UD1Yw 11 | VbrDAkAwjMHpbW3jiVw//Kx5jIwehiRscWKpLnSzBJyTBFvbwsJjJai2lX2OuVO8 12 | +2GYKb0Iyhd81j3VFkl6grwtpRtPAkB7+n+yt555fpfRKjhGU9b09cHGu7h/OcK5 13 | bBVCfE0DYHLI/DsXgPiF1g6Onh4rDdUu3xyv9xDKAqnscV099hHZAkEAvcFBfXZs 14 | tk18N+bUcvXTdZjzZbfLCHlJmwPIspZ8G/6Pn63deg4GVYoCvTwGruah+8y734Ph 15 | 7PskfPgUQlB7Ag== 16 | -----END PRIVATE KEY----- 17 | -------------------------------------------------------------------------------- /testing/src/main/resources/certs/server0.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANOmffupIGC8YDau 3 | rOF4eKnHwPszgpkkhWzKsVxhNDBxCVYx4TEjG0XWIO0iyRXupZbUC+7N/8HnEVNa 4 | 8F1jYhng14Iiq99cNQbbnuHHhIztmpocrJTxmnhGzoAnRa1Tb+GnAuRoIHRA/V2c 5 | VUE9tbikQugFx/SPgXAw6tfWB+YvAgMBAAECgYEAoEq9qzUBgoHoVEGiSPiWWe8g 6 | 5p6yUA1qx2QTQyWTAwT4z0DjjfVKmG99bFsl8+hTnJFnoCp/gnjflEOROwkjp5kG 7 | m0drqOPx1jeipJjpXYTBu49h+WpZ1PF+KhVtxsIm3OOCvh67iWaKyyOVb5Og8aiR 8 | jl6dn/TdG/dlGD8AfUECQQDuNMle6p0oU8amC6O9wIMBroxx2nFstzE6O35PLEzG 9 | /tj0kxxn9Jp2TS9mGaLCzSuXmpjlF4+NOWiBPkrLC2TfAkEA43Xg7uEUkaJAz2/W 10 | m1lIBTLt+4rIQY/2emh33bDcA+rv8rwwrMMIv17/xPx7bs49YqGG5xufD+Rwl6TL 11 | qFXYsQJAPrOwagax1aKvwJeBw3oAQhoTKAkLIEXcdGqipe6QSzVcIIz0xjxxyEAr 12 | AOIwoLxnBCISqwMXq2H4K0UdZPMb2wJAdhdYLY1L6YRMk6XjzImg25oidisKZweA 13 | FvMv8DgHMj2CUAqmVrt3SivfLH1M9C09L3zfFhOAFHcsgX58gav4MQJBANSBnrHj 14 | tIq4l8z79CPUIuu3QyeEh+XwY8s5qE5CNTck0U59lzp9NvENHbkx3KO896TTerko 15 | +8bXHMLkJkHPXms= 16 | -----END PRIVATE KEY----- 17 | -------------------------------------------------------------------------------- /testing/src/main/resources/certs/client.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIICeQIBADANBgkqhkiG9w0BAQEFAASCAmMwggJfAgEAAoGBAOxUR9uhvhbeVUIM 3 | s5WbH0px0mehl2+6sZpNjzvE2KimZpHzMJHukVH0Ffkvhs0b8+S5Ut9VNUAqd3IM 4 | JCCAEGtRNoQhM1t9Yr2zAckSvbRacp+FL/Cj9eDmyo00KsVGaeefA4Dh4OW+ZhkT 5 | NKcldXqkSuj1sEf244JZYuqZp6/tAgMBAAECgYEAi2NSVqpZMafE5YYUTcMGe6QS 6 | k2jtpsqYgggI2RnLJ/2tNZwYI5pwP8QVSbnMaiF4gokD5hGdrNDfTnb2v+yIwYEH 7 | 0w8+oG7Z81KodsiZSIDJfTGsAZhVNwOz9y0VD8BBZZ1/274Zh52AUKLjZS/ZwIbS 8 | W2ywya855dPnH/wj+0ECQQD9X8D920kByTNHhBG18biAEZ4pxs9f0OAG8333eVcI 9 | w2lJDLsYDZrCB2ocgA3lUdozlzPC7YDYw8reg0tkiRY5AkEA7sdNzOeQsQRn7++5 10 | 0bP9DtT/iON1gbfxRzCfCfXdoOtfQWIzTePWtURt9X/5D9NofI0Rg5W2oGy/MLe5 11 | /sXHVQJBAIup5XrJDkQywNZyAUU2ecn2bCWBFjwtqd+LBmuMciI9fOKsZtEKZrz/ 12 | U0lkeMRoSwvXE8wmGLjjrAbdfohrXFkCQQDZEx/LtIl6JINJQiswVe0tWr6k+ASP 13 | 1WXoTm+HYpoF/XUvv9LccNF1IazFj34hwRQwhx7w/V52Ieb+p0jUMYGxAkEAjDhd 14 | 9pBO1fKXWiXzi9ZKfoyTNcUq3eBSVKwPG2nItg5ycXengjT5sgcWDnciIzW7BIVI 15 | JiqOszq9GWESErAatg== 16 | -----END PRIVATE KEY----- 17 | -------------------------------------------------------------------------------- /testing/src/main/resources/certs/server1.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICnDCCAgWgAwIBAgIBBzANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJBVTET 3 | MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ 4 | dHkgTHRkMQ8wDQYDVQQDEwZ0ZXN0Y2EwHhcNMTUxMTA0MDIyMDI0WhcNMjUxMTAx 5 | MDIyMDI0WjBlMQswCQYDVQQGEwJVUzERMA8GA1UECBMISWxsaW5vaXMxEDAOBgNV 6 | BAcTB0NoaWNhZ28xFTATBgNVBAoTDEV4YW1wbGUsIENvLjEaMBgGA1UEAxQRKi50 7 | ZXN0Lmdvb2dsZS5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAOHDFSco 8 | LCVJpYDDM4HYtIdV6Ake/sMNaaKdODjDMsux/4tDydlumN+fm+AjPEK5GHhGn1Bg 9 | zkWF+slf3BxhrA/8dNsnunstVA7ZBgA/5qQxMfGAq4wHNVX77fBZOgp9VlSMVfyd 10 | 9N8YwbBYAckOeUQadTi2X1S6OgJXgQ0m3MWhAgMBAAGjazBpMAkGA1UdEwQCMAAw 11 | CwYDVR0PBAQDAgXgME8GA1UdEQRIMEaCECoudGVzdC5nb29nbGUuZnKCGHdhdGVy 12 | em9vaS50ZXN0Lmdvb2dsZS5iZYISKi50ZXN0LnlvdXR1YmUuY29thwTAqAEDMA0G 13 | CSqGSIb3DQEBCwUAA4GBAJFXVifQNub1LUP4JlnX5lXNlo8FxZ2a12AFQs+bzoJ6 14 | hM044EDjqyxUqSbVePK0ni3w1fHQB5rY9yYC5f8G7aqqTY1QOhoUk8ZTSTRpnkTh 15 | y4jjdvTZeLDVBlueZUTDRmy2feY5aZIU18vFDK08dTG0A87pppuv1LNIR3loveU8 16 | -----END CERTIFICATE----- 17 | -------------------------------------------------------------------------------- /grpclb/src/generated/main/java/io/grpc/grpclb/ClientStatsOrBuilder.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: load_balancer.proto 3 | 4 | package io.grpc.grpclb; 5 | 6 | public interface ClientStatsOrBuilder extends 7 | // @@protoc_insertion_point(interface_extends:grpc.lb.v1.ClientStats) 8 | com.google.protobuf.MessageOrBuilder { 9 | 10 | /** 11 | * optional int64 total_requests = 1; 12 | * 13 | *
14 |    * The total number of requests sent by the client since the last report.
15 |    * 
16 | */ 17 | long getTotalRequests(); 18 | 19 | /** 20 | * optional int64 client_rpc_errors = 2; 21 | * 22 | *
23 |    * The number of client rpc errors since the last report.
24 |    * 
25 | */ 26 | long getClientRpcErrors(); 27 | 28 | /** 29 | * optional int64 dropped_requests = 3; 30 | * 31 | *
32 |    * The number of dropped requests since the last report.
33 |    * 
34 | */ 35 | long getDroppedRequests(); 36 | } 37 | -------------------------------------------------------------------------------- /testing/src/main/resources/certs/badclient.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICoDCCAgmgAwIBAgIJANIz2/zoRiapMA0GCSqGSIb3DQEBBQUAMGkxCzAJBgNV 3 | BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX 4 | aWRnaXRzIFB0eSBMdGQxIjAgBgNVBAMMGWJhZGNsaWVudC50ZXN0Lmdvb2dsZS5j 5 | b20wHhcNMTQwNzI4MjAwODI1WhcNMjQwNzI1MjAwODI1WjBpMQswCQYDVQQGEwJB 6 | VTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0 7 | cyBQdHkgTHRkMSIwIAYDVQQDDBliYWRjbGllbnQudGVzdC5nb29nbGUuY29tMIGf 8 | MA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCyX2JxZ+J5I+dlhROVtqlMQn47BBcr 9 | l2GCkv9O1D1rL94KWYbY14HXhi/nacBAQtCEQwXxp5DKemGOUju65xM9F96/374G 10 | MvnRJdo52gOs4HO0czBpfVNdXeeoD/RYgwttfdJrz/4aatsS2Qk2yMYpqZmqEMsb 11 | rh9W22Lp3rCBvwIDAQABo1AwTjAdBgNVHQ4EFgQU523AJMR8Ds9V8fhf7gu1i0MM 12 | UqAwHwYDVR0jBBgwFoAU523AJMR8Ds9V8fhf7gu1i0MMUqAwDAYDVR0TBAUwAwEB 13 | /zANBgkqhkiG9w0BAQUFAAOBgQCI/tvSBYH1iyfLaCTBKwpdj36+MkR9EeJJmImx 14 | X+bjhKWXwsBX4PDMWvdusr++QGUYtyoya+hfYMXRhXua39mD54xgloQNuu9REDwX 15 | Ffto+aOw3BcYducz6ofxicFK/Y2VeXDurSMpRv5TfGf2Qr6eOOdaRhj6ed7BibHk 16 | X1VGZA== 17 | -----END CERTIFICATE----- 18 | -------------------------------------------------------------------------------- /testing/src/main/resources/certs/badserver.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICoDCCAgmgAwIBAgIJAPdqwqsKNy81MA0GCSqGSIb3DQEBBQUAMGkxCzAJBgNV 3 | BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX 4 | aWRnaXRzIFB0eSBMdGQxIjAgBgNVBAMMGWJhZHNlcnZlci50ZXN0Lmdvb2dsZS5j 5 | b20wHhcNMTQwNzI4MjAwODU0WhcNMjQwNzI1MjAwODU0WjBpMQswCQYDVQQGEwJB 6 | VTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0 7 | cyBQdHkgTHRkMSIwIAYDVQQDDBliYWRzZXJ2ZXIudGVzdC5nb29nbGUuY29tMIGf 8 | MA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCnmdXtctvXJgSmlqCFMCeZ3jiVI8fn 9 | g/950T3vnby1xHffnW9HxuUWEUdEt5hdWMLo+DyMZU1tmKa1EqBksPrXKljSM8b/ 10 | eB48GBZJLxEdwG5V3AwYdD9swJM4Pp3/QHALDIdEKQ08q17TJYKq8o6tf75IRaHy 11 | jDG2PmlyXRujgQIDAQABo1AwTjAdBgNVHQ4EFgQU3u/qvHr9knMBeZyAD7mAA/ec 12 | 8cUwHwYDVR0jBBgwFoAU3u/qvHr9knMBeZyAD7mAA/ec8cUwDAYDVR0TBAUwAwEB 13 | /zANBgkqhkiG9w0BAQUFAAOBgQA/FmR1SGLguxCCfhp4CYCbrAePSyPWDi48gTwj 14 | vVZf/OMxdVu/H8sBYFf27BjbrEugAw16DElFtgTZ83pLb2BvkUgb6vBUK5sEkgmh 15 | z88zBsgDp8aCf4STDOLFZMBh/E9ZKkm1zogbEmlTjFp/ceSpa2gNv7OuN4WiorOh 16 | Wvw40g== 17 | -----END CERTIFICATE----- 18 | -------------------------------------------------------------------------------- /protobuf-nano/build.gradle: -------------------------------------------------------------------------------- 1 | // Add dependency on the protobuf plugin 2 | buildscript { 3 | repositories { 4 | mavenCentral() 5 | } 6 | dependencies { 7 | classpath libraries.protobuf_plugin 8 | } 9 | } 10 | 11 | plugins { 12 | id "be.insaneprogramming.gradle.animalsniffer" version "1.4.0" 13 | } 14 | 15 | description = 'gRPC: Protobuf Nano' 16 | 17 | dependencies { 18 | compile project(':grpc-core'), 19 | libraries.protobuf_nano, 20 | libraries.guava 21 | } 22 | 23 | animalsniffer { 24 | signature = "org.codehaus.mojo.signature:java16:+@signature" 25 | } 26 | 27 | configureProtoCompilation() 28 | 29 | if (project.hasProperty('protobuf')) { 30 | protobuf { 31 | generateProtoTasks { 32 | all().each { task -> 33 | task.builtins { 34 | remove java 35 | javanano { 36 | option 'ignore_services=true' 37 | } 38 | } 39 | } 40 | } 41 | } 42 | } 43 | 44 | idea { 45 | module { 46 | sourceDirs += file("${projectDir}/src/generated/test/javanano"); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /testing/src/main/resources/certs/client.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIC6TCCAlKgAwIBAgIBCjANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJBVTET 3 | MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ 4 | dHkgTHRkMQ8wDQYDVQQDEwZ0ZXN0Y2EwHhcNMTUxMTEwMDEwOTU4WhcNMjUxMTA3 5 | MDEwOTU4WjBaMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8G 6 | A1UECgwYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMRMwEQYDVQQDDAp0ZXN0Y2xp 7 | ZW50MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDsVEfbob4W3lVCDLOVmx9K 8 | cdJnoZdvurGaTY87xNiopmaR8zCR7pFR9BX5L4bNG/PkuVLfVTVAKndyDCQggBBr 9 | UTaEITNbfWK9swHJEr20WnKfhS/wo/Xg5sqNNCrFRmnnnwOA4eDlvmYZEzSnJXV6 10 | pEro9bBH9uOCWWLqmaev7QIDAQABo4HCMIG/MAkGA1UdEwQCMAAwCwYDVR0PBAQD 11 | AgXgMB0GA1UdDgQWBBQAdbW5Vml/CnYwqdP3mOHDARU+8zBwBgNVHSMEaTBnoVqk 12 | WDBWMQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMY 13 | SW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMQ8wDQYDVQQDEwZ0ZXN0Y2GCCQCRxhke 14 | HRoqBzAJBgNVHREEAjAAMAkGA1UdEgQCMAAwDQYJKoZIhvcNAQELBQADgYEAf4MM 15 | k+sdzd720DfrQ0PF2gDauR3M9uBubozDuMuF6ufAuQBJSKGQEGibXbUelrwHmnql 16 | UjTyfolVcxEBVaF4VFHmn7u6vP7S1NexIDdNUHcULqxIb7Tzl8JYq8OOHD2rQy4H 17 | s8BXaVIzw4YcaCGAMS0iDX052Sy7e2JhP8Noxvo= 18 | -----END CERTIFICATE----- 19 | -------------------------------------------------------------------------------- /testing/src/main/resources/certs/server0.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIC8zCCAlygAwIBAgIBCzANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJBVTET 3 | MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ 4 | dHkgTHRkMQ8wDQYDVQQDEwZ0ZXN0Y2EwHhcNMTUxMTEwMDExNDU1WhcNMjUxMTA3 5 | MDExNDU1WjBkMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8G 6 | A1UECgwYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMR0wGwYDVQQDDBQqLnRlc3Qu 7 | Z29vZ2xlLmNvbS5hdTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA06Z9+6kg 8 | YLxgNq6s4Xh4qcfA+zOCmSSFbMqxXGE0MHEJVjHhMSMbRdYg7SLJFe6lltQL7s3/ 9 | wecRU1rwXWNiGeDXgiKr31w1Btue4ceEjO2amhyslPGaeEbOgCdFrVNv4acC5Ggg 10 | dED9XZxVQT21uKRC6AXH9I+BcDDq19YH5i8CAwEAAaOBwjCBvzAJBgNVHRMEAjAA 11 | MAsGA1UdDwQEAwIF4DAdBgNVHQ4EFgQUbyZIbUvqmePzv40xa0mMaDxLToYwcAYD 12 | VR0jBGkwZ6FapFgwVjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUx 13 | ITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEPMA0GA1UEAxMGdGVz 14 | dGNhggkAkcYZHh0aKgcwCQYDVR0RBAIwADAJBgNVHRIEAjAAMA0GCSqGSIb3DQEB 15 | CwUAA4GBAJ21MwMf4WwAjafPKn+8Ng7ordtdp6tlkjt+Xub4l4zMr6FCp6dc/Ceh 16 | 6Hj43zYcKpAe5I6eaVcMc9qcYfUb9i4NVX82dMQpAwpNHgqTzqYt6GYEjF3YhKA7 17 | uOFdA0OvOFJa14SNdNRk9E1Cd/tElXnLnSE4DOguMNvXz8mRKfnD 18 | -----END CERTIFICATE----- 19 | -------------------------------------------------------------------------------- /examples/src/generated/main/java/io/grpc/examples/routeguide/RouteSummaryOrBuilder.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: route_guide.proto 3 | 4 | package io.grpc.examples.routeguide; 5 | 6 | public interface RouteSummaryOrBuilder extends 7 | // @@protoc_insertion_point(interface_extends:routeguide.RouteSummary) 8 | com.google.protobuf.MessageOrBuilder { 9 | 10 | /** 11 | * optional int32 point_count = 1; 12 | * 13 | *
14 |    * The number of points received.
15 |    * 
16 | */ 17 | int getPointCount(); 18 | 19 | /** 20 | * optional int32 feature_count = 2; 21 | * 22 | *
23 |    * The number of known features passed while traversing the route.
24 |    * 
25 | */ 26 | int getFeatureCount(); 27 | 28 | /** 29 | * optional int32 distance = 3; 30 | * 31 | *
32 |    * The distance covered in metres.
33 |    * 
34 | */ 35 | int getDistance(); 36 | 37 | /** 38 | * optional int32 elapsed_time = 4; 39 | * 40 | *
41 |    * The duration of the traversal in seconds.
42 |    * 
43 | */ 44 | int getElapsedTime(); 45 | } 46 | -------------------------------------------------------------------------------- /examples/src/generated/main/java/io/grpc/examples/routeguide/FeatureDatabaseOrBuilder.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: route_guide.proto 3 | 4 | package io.grpc.examples.routeguide; 5 | 6 | public interface FeatureDatabaseOrBuilder extends 7 | // @@protoc_insertion_point(interface_extends:routeguide.FeatureDatabase) 8 | com.google.protobuf.MessageOrBuilder { 9 | 10 | /** 11 | * repeated .routeguide.Feature feature = 1; 12 | */ 13 | java.util.List 14 | getFeatureList(); 15 | /** 16 | * repeated .routeguide.Feature feature = 1; 17 | */ 18 | io.grpc.examples.routeguide.Feature getFeature(int index); 19 | /** 20 | * repeated .routeguide.Feature feature = 1; 21 | */ 22 | int getFeatureCount(); 23 | /** 24 | * repeated .routeguide.Feature feature = 1; 25 | */ 26 | java.util.List 27 | getFeatureOrBuilderList(); 28 | /** 29 | * repeated .routeguide.Feature feature = 1; 30 | */ 31 | io.grpc.examples.routeguide.FeatureOrBuilder getFeatureOrBuilder( 32 | int index); 33 | } 34 | -------------------------------------------------------------------------------- /android-interop-testing/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 25 | 26 | 27 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the GRPC project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of GRPC, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of GRPC. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of GRPC or any code incorporated within this 19 | implementation of GRPC constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of GRPC 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /examples/src/generated/main/java/io/grpc/examples/routeguide/FeatureOrBuilder.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: route_guide.proto 3 | 4 | package io.grpc.examples.routeguide; 5 | 6 | public interface FeatureOrBuilder extends 7 | // @@protoc_insertion_point(interface_extends:routeguide.Feature) 8 | com.google.protobuf.MessageOrBuilder { 9 | 10 | /** 11 | * optional string name = 1; 12 | * 13 | *
14 |    * The name of the feature.
15 |    * 
16 | */ 17 | java.lang.String getName(); 18 | /** 19 | * optional string name = 1; 20 | * 21 | *
22 |    * The name of the feature.
23 |    * 
24 | */ 25 | com.google.protobuf.ByteString 26 | getNameBytes(); 27 | 28 | /** 29 | * optional .routeguide.Point location = 2; 30 | * 31 | *
32 |    * The point where the feature is detected.
33 |    * 
34 | */ 35 | boolean hasLocation(); 36 | /** 37 | * optional .routeguide.Point location = 2; 38 | * 39 | *
40 |    * The point where the feature is detected.
41 |    * 
42 | */ 43 | io.grpc.examples.routeguide.Point getLocation(); 44 | /** 45 | * optional .routeguide.Point location = 2; 46 | * 47 | *
48 |    * The point where the feature is detected.
49 |    * 
50 | */ 51 | io.grpc.examples.routeguide.PointOrBuilder getLocationOrBuilder(); 52 | } 53 | -------------------------------------------------------------------------------- /okhttp/third_party/okhttp/java/io/grpc/okhttp/internal/framed/Variant.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Square, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /* 17 | * Forked from OkHttp 2.5.0 18 | */ 19 | 20 | package io.grpc.okhttp.internal.framed; 21 | 22 | import io.grpc.okhttp.internal.Protocol; 23 | import okio.BufferedSink; 24 | import okio.BufferedSource; 25 | 26 | /** A version and dialect of the framed socket protocol. */ 27 | public interface Variant { 28 | 29 | /** The protocol as selected using ALPN. */ 30 | Protocol getProtocol(); 31 | 32 | /** 33 | * @param client true if this is the HTTP client's reader, reading frames from a server. 34 | */ 35 | FrameReader newReader(BufferedSource source, boolean client); 36 | 37 | /** 38 | * @param client true if this is the HTTP client's writer, writing frames to a server. 39 | */ 40 | FrameWriter newWriter(BufferedSink sink, boolean client); 41 | } 42 | -------------------------------------------------------------------------------- /examples/src/generated/main/java/io/grpc/examples/routeguide/RouteNoteOrBuilder.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: route_guide.proto 3 | 4 | package io.grpc.examples.routeguide; 5 | 6 | public interface RouteNoteOrBuilder extends 7 | // @@protoc_insertion_point(interface_extends:routeguide.RouteNote) 8 | com.google.protobuf.MessageOrBuilder { 9 | 10 | /** 11 | * optional .routeguide.Point location = 1; 12 | * 13 | *
14 |    * The location from which the message is sent.
15 |    * 
16 | */ 17 | boolean hasLocation(); 18 | /** 19 | * optional .routeguide.Point location = 1; 20 | * 21 | *
22 |    * The location from which the message is sent.
23 |    * 
24 | */ 25 | io.grpc.examples.routeguide.Point getLocation(); 26 | /** 27 | * optional .routeguide.Point location = 1; 28 | * 29 | *
30 |    * The location from which the message is sent.
31 |    * 
32 | */ 33 | io.grpc.examples.routeguide.PointOrBuilder getLocationOrBuilder(); 34 | 35 | /** 36 | * optional string message = 2; 37 | * 38 | *
39 |    * The message to be sent.
40 |    * 
41 | */ 42 | java.lang.String getMessage(); 43 | /** 44 | * optional string message = 2; 45 | * 46 | *
47 |    * The message to be sent.
48 |    * 
49 | */ 50 | com.google.protobuf.ByteString 51 | getMessageBytes(); 52 | } 53 | -------------------------------------------------------------------------------- /android-interop-testing/README.md: -------------------------------------------------------------------------------- 1 | gRPC Android test App 2 | ======================= 3 | 4 | Implements gRPC integration tests in an Android App. 5 | 6 | TODO(madongfly) integrate this App into the gRPC-Java build system. 7 | 8 | In order to build this app, you need a local.properties file under this directory which specifies 9 | the location of your android sdk: 10 | ``` 11 | sdk.dir=/somepath/somepath/sdk 12 | ``` 13 | 14 | Connect your Android device or start the emulator: 15 | ``` 16 | $ ./start-emulator.sh & ./wait-for-emulator.sh 17 | ``` 18 | 19 | Start test server 20 | ----------------- 21 | 22 | Start the test server by: 23 | ``` 24 | $ ../run-test-server.sh 25 | ``` 26 | 27 | 28 | Manually test 29 | ------------- 30 | 31 | Install the App by: 32 | ``` 33 | $ ../gradlew installDebug 34 | ``` 35 | Then manually test it with the UI. 36 | 37 | 38 | Commandline test 39 | ---------------- 40 | 41 | Run the test with arguments: 42 | ``` 43 | $ adb shell am instrument -w -e server_host -e server_port -e server_host_override foo.test.google.fr -e use_tls true -e use_test_ca true -e test_case all io.grpc.android.integrationtest/.TesterInstrumentation 44 | ``` 45 | 46 | If the test passed successfully, it will output: 47 | ``` 48 | INSTRUMENTATION_RESULT: grpc test result=Succeed!!! 49 | INSTRUMENTATION_CODE: 0 50 | ``` 51 | otherwise, output something like: 52 | ``` 53 | INSTRUMENTATION_RESULT: grpc test result=Failed... : 54 | INSTRUMENTATION_CODE: 1 55 | ``` 56 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2014, Google Inc. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /examples/src/generated/main/java/io/grpc/examples/routeguide/RectangleOrBuilder.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: route_guide.proto 3 | 4 | package io.grpc.examples.routeguide; 5 | 6 | public interface RectangleOrBuilder extends 7 | // @@protoc_insertion_point(interface_extends:routeguide.Rectangle) 8 | com.google.protobuf.MessageOrBuilder { 9 | 10 | /** 11 | * optional .routeguide.Point lo = 1; 12 | * 13 | *
14 |    * One corner of the rectangle.
15 |    * 
16 | */ 17 | boolean hasLo(); 18 | /** 19 | * optional .routeguide.Point lo = 1; 20 | * 21 | *
22 |    * One corner of the rectangle.
23 |    * 
24 | */ 25 | io.grpc.examples.routeguide.Point getLo(); 26 | /** 27 | * optional .routeguide.Point lo = 1; 28 | * 29 | *
30 |    * One corner of the rectangle.
31 |    * 
32 | */ 33 | io.grpc.examples.routeguide.PointOrBuilder getLoOrBuilder(); 34 | 35 | /** 36 | * optional .routeguide.Point hi = 2; 37 | * 38 | *
39 |    * The other corner of the rectangle.
40 |    * 
41 | */ 42 | boolean hasHi(); 43 | /** 44 | * optional .routeguide.Point hi = 2; 45 | * 46 | *
47 |    * The other corner of the rectangle.
48 |    * 
49 | */ 50 | io.grpc.examples.routeguide.Point getHi(); 51 | /** 52 | * optional .routeguide.Point hi = 2; 53 | * 54 | *
55 |    * The other corner of the rectangle.
56 |    * 
57 | */ 58 | io.grpc.examples.routeguide.PointOrBuilder getHiOrBuilder(); 59 | } 60 | -------------------------------------------------------------------------------- /checkstyle.license: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015, Google Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following disclaimer 12 | * in the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * * Neither the name of Google Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = "grpc" 2 | include ":grpc-core" 3 | include ":grpc-stub" 4 | include ":grpc-auth" 5 | include ":grpc-okhttp" 6 | include ":grpc-protobuf" 7 | include ":grpc-protobuf-lite" 8 | include ":grpc-protobuf-nano" 9 | include ":grpc-netty" 10 | include ":grpc-grpclb" 11 | include ":grpc-testing" 12 | include ":grpc-interop-testing" 13 | include ":grpc-all" 14 | include ":grpc-benchmarks" 15 | include ":grpc-examples" 16 | 17 | project(':grpc-core').projectDir = "$rootDir/core" as File 18 | project(':grpc-stub').projectDir = "$rootDir/stub" as File 19 | project(':grpc-auth').projectDir = "$rootDir/auth" as File 20 | project(':grpc-okhttp').projectDir = "$rootDir/okhttp" as File 21 | project(':grpc-protobuf').projectDir = "$rootDir/protobuf" as File 22 | project(':grpc-protobuf-lite').projectDir = "$rootDir/protobuf-lite" as File 23 | project(':grpc-protobuf-nano').projectDir = "$rootDir/protobuf-nano" as File 24 | project(':grpc-netty').projectDir = "$rootDir/netty" as File 25 | project(':grpc-grpclb').projectDir = "$rootDir/grpclb" as File 26 | project(':grpc-testing').projectDir = "$rootDir/testing" as File 27 | project(':grpc-interop-testing').projectDir = "$rootDir/interop-testing" as File 28 | project(':grpc-all').projectDir = "$rootDir/all" as File 29 | project(':grpc-benchmarks').projectDir = "$rootDir/benchmarks" as File 30 | project(':grpc-examples').projectDir = "$rootDir/examples" as File 31 | 32 | if (settings.hasProperty('skipCodegen') && skipCodegen.toBoolean()) { 33 | println '*** Skipping the build of codegen and compilation of proto files because skipCodegen=true' 34 | } else { 35 | include ":grpc-compiler" 36 | project(':grpc-compiler').projectDir = "$rootDir/compiler" as File 37 | } 38 | -------------------------------------------------------------------------------- /core/src/main/java/io/grpc/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015, Google Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following disclaimer 12 | * in the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * * Neither the name of Google Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | /** 33 | * The gRPC core public API. 34 | */ 35 | package io.grpc; 36 | -------------------------------------------------------------------------------- /okhttp/third_party/okhttp/java/io/grpc/okhttp/internal/framed/HeadersMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Square, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /* 17 | * Forked from OkHttp 2.5.0 18 | */ 19 | 20 | package io.grpc.okhttp.internal.framed; 21 | 22 | public enum HeadersMode { 23 | SPDY_SYN_STREAM, 24 | SPDY_REPLY, 25 | SPDY_HEADERS, 26 | HTTP_20_HEADERS; 27 | 28 | /** Returns true if it is an error these headers to create a new stream. */ 29 | public boolean failIfStreamAbsent() { 30 | return this == SPDY_REPLY || this == SPDY_HEADERS; 31 | } 32 | 33 | /** Returns true if it is an error these headers to update an existing stream. */ 34 | public boolean failIfStreamPresent() { 35 | return this == SPDY_SYN_STREAM; 36 | } 37 | 38 | /** 39 | * Returns true if it is an error these headers to be the initial headers of a 40 | * response. 41 | */ 42 | public boolean failIfHeadersAbsent() { 43 | return this == SPDY_HEADERS; 44 | } 45 | 46 | /** 47 | * Returns true if it is an error these headers to be update existing headers 48 | * of a response. 49 | */ 50 | public boolean failIfHeadersPresent() { 51 | return this == SPDY_REPLY; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /grpclb/src/generated/main/java/io/grpc/grpclb/LoadBalanceResponseOrBuilder.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: load_balancer.proto 3 | 4 | package io.grpc.grpclb; 5 | 6 | public interface LoadBalanceResponseOrBuilder extends 7 | // @@protoc_insertion_point(interface_extends:grpc.lb.v1.LoadBalanceResponse) 8 | com.google.protobuf.MessageOrBuilder { 9 | 10 | /** 11 | * optional .grpc.lb.v1.InitialLoadBalanceResponse initial_response = 1; 12 | * 13 | *
14 |    * This message should be sent on the first response to the client.
15 |    * 
16 | */ 17 | io.grpc.grpclb.InitialLoadBalanceResponse getInitialResponse(); 18 | /** 19 | * optional .grpc.lb.v1.InitialLoadBalanceResponse initial_response = 1; 20 | * 21 | *
22 |    * This message should be sent on the first response to the client.
23 |    * 
24 | */ 25 | io.grpc.grpclb.InitialLoadBalanceResponseOrBuilder getInitialResponseOrBuilder(); 26 | 27 | /** 28 | * optional .grpc.lb.v1.ServerList server_list = 2; 29 | * 30 | *
31 |    * Contains the list of servers selected by the load balancer. The client
32 |    * should send requests to these servers in the specified order.
33 |    * 
34 | */ 35 | io.grpc.grpclb.ServerList getServerList(); 36 | /** 37 | * optional .grpc.lb.v1.ServerList server_list = 2; 38 | * 39 | *
40 |    * Contains the list of servers selected by the load balancer. The client
41 |    * should send requests to these servers in the specified order.
42 |    * 
43 | */ 44 | io.grpc.grpclb.ServerListOrBuilder getServerListOrBuilder(); 45 | 46 | public io.grpc.grpclb.LoadBalanceResponse.LoadBalanceResponseTypeCase getLoadBalanceResponseTypeCase(); 47 | } 48 | -------------------------------------------------------------------------------- /grpclb/src/generated/main/java/io/grpc/grpclb/LoadBalanceRequestOrBuilder.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: load_balancer.proto 3 | 4 | package io.grpc.grpclb; 5 | 6 | public interface LoadBalanceRequestOrBuilder extends 7 | // @@protoc_insertion_point(interface_extends:grpc.lb.v1.LoadBalanceRequest) 8 | com.google.protobuf.MessageOrBuilder { 9 | 10 | /** 11 | * optional .grpc.lb.v1.InitialLoadBalanceRequest initial_request = 1; 12 | * 13 | *
14 |    * This message should be sent on the first request to the load balancer.
15 |    * 
16 | */ 17 | io.grpc.grpclb.InitialLoadBalanceRequest getInitialRequest(); 18 | /** 19 | * optional .grpc.lb.v1.InitialLoadBalanceRequest initial_request = 1; 20 | * 21 | *
22 |    * This message should be sent on the first request to the load balancer.
23 |    * 
24 | */ 25 | io.grpc.grpclb.InitialLoadBalanceRequestOrBuilder getInitialRequestOrBuilder(); 26 | 27 | /** 28 | * optional .grpc.lb.v1.ClientStats client_stats = 2; 29 | * 30 | *
31 |    * The client stats should be periodically reported to the load balancer
32 |    * based on the duration defined in the InitialLoadBalanceResponse.
33 |    * 
34 | */ 35 | io.grpc.grpclb.ClientStats getClientStats(); 36 | /** 37 | * optional .grpc.lb.v1.ClientStats client_stats = 2; 38 | * 39 | *
40 |    * The client stats should be periodically reported to the load balancer
41 |    * based on the duration defined in the InitialLoadBalanceResponse.
42 |    * 
43 | */ 44 | io.grpc.grpclb.ClientStatsOrBuilder getClientStatsOrBuilder(); 45 | 46 | public io.grpc.grpclb.LoadBalanceRequest.LoadBalanceRequestTypeCase getLoadBalanceRequestTypeCase(); 47 | } 48 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | 3 | language: java 4 | 5 | env: 6 | global: 7 | - GRADLE_OPTS=-Xmx512m 8 | - PROTOBUF_VERSION=3.0.0-beta-2 9 | - LDFLAGS=-L/tmp/protobuf/lib 10 | - CXXFLAGS=-I/tmp/protobuf/include 11 | - LD_LIBRARY_PATH=/tmp/protobuf/lib 12 | 13 | before_install: 14 | # Work around https://github.com/travis-ci/travis-ci/issues/2317 15 | - if \[ "$TRAVIS_OS_NAME" = linux \]; then jdk_switcher use oraclejdk8; fi 16 | - buildscripts/make_dependencies.sh # build protoc into /tmp/protobuf-${PROTOBUF_VERSION} 17 | - ln -s "/tmp/protobuf-${PROTOBUF_VERSION}/$(uname -s)-$(uname -p)" /tmp/protobuf 18 | - mkdir -p $HOME/.gradle 19 | - echo "checkstyle.ignoreFailures=false" >> $HOME/.gradle/gradle.properties 20 | 21 | install: 22 | - ./gradlew assemble generateTestProto 23 | 24 | before_script: 25 | - test -z "$(git status --porcelain)" || (git status && echo Error Working directory is not clean. Forget to commit generated files? && false) 26 | 27 | script: 28 | - ./gradlew check :grpc-all:jacocoTestReport 29 | 30 | after_success: 31 | - if \[ "$TRAVIS_OS_NAME" = linux \]; then ./gradlew :grpc-all:coveralls; fi 32 | - bash <(curl -s https://codecov.io/bash) 33 | 34 | os: 35 | - linux 36 | - osx 37 | 38 | # This image comes with jdk8 39 | osx_image: xcode7 40 | 41 | notifications: 42 | email: false 43 | 44 | # Caching does not work for public repositories with OS X: 45 | # https://github.com/travis-ci/travis-ci/issues/4011 46 | cache: 47 | directories: 48 | - /tmp/protobuf-${PROTOBUF_VERSION} 49 | - $HOME/.m2/repository/io/netty 50 | - $HOME/.gradle/caches/modules-2 51 | - $HOME/.gradle/wrapper 52 | 53 | before_cache: 54 | - rm $HOME/.gradle/caches/modules-2/modules-2.lock 55 | - find $HOME/.gradle/wrapper -not -name "*-all.zip" -and -not -name "*-bin.zip" -delete 56 | -------------------------------------------------------------------------------- /okhttp/third_party/okhttp/java/io/grpc/okhttp/internal/TlsVersion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Square, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /* 17 | * Forked from OkHttp 2.5.0 18 | */ 19 | 20 | package io.grpc.okhttp.internal; 21 | 22 | import javax.net.ssl.SSLSocket; 23 | 24 | /** 25 | * Versions of TLS that can be offered when negotiating a secure socket. See 26 | * {@link SSLSocket#setEnabledProtocols}. 27 | */ 28 | public enum TlsVersion { 29 | TLS_1_2("TLSv1.2"), // 2008. 30 | TLS_1_1("TLSv1.1"), // 2006. 31 | TLS_1_0("TLSv1"), // 1999. 32 | SSL_3_0("SSLv3"), // 1996. 33 | ; 34 | 35 | final String javaName; 36 | 37 | private TlsVersion(String javaName) { 38 | this.javaName = javaName; 39 | } 40 | 41 | public static TlsVersion forJavaName(String javaName) { 42 | if ("TLSv1.2".equals(javaName)) { 43 | return TLS_1_2; 44 | } else if ("TLSv1.1".equals(javaName)) { 45 | return TLS_1_1; 46 | } else if ("TLSv1".equals(javaName)) { 47 | return TLS_1_0; 48 | } else if ("SSLv3".equals(javaName)) { 49 | return SSL_3_0; 50 | } 51 | throw new IllegalArgumentException("Unexpected TLS version: " + javaName); 52 | } 53 | 54 | public String javaName() { 55 | return javaName; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to submit a bug report 2 | 3 | If you received an error message, please include it and any exceptions. 4 | 5 | We commonly need to know what platform you are on: 6 | * JDK/JRE version (i.e., ```java -version```) 7 | * Operating system (i.e., ```uname -a```) 8 | 9 | # How to contribute 10 | 11 | We definitely welcome patches and contributions to grpc! Here are some 12 | guideline and information about how to do so. 13 | 14 | ## Before getting started 15 | 16 | In order to protect both you and ourselves, you will need to sign the 17 | [Contributor License Agreement](https://cla.developers.google.com/clas). 18 | 19 | We follow the [Google Java Style 20 | Guide](https://google-styleguide.googlecode.com/svn/trunk/javaguide.html). Our 21 | build automatically will provide warnings for style issues. 22 | [Eclipse](https://google-styleguide.googlecode.com/svn/trunk/eclipse-java-google-style.xml) 23 | and 24 | [IntelliJ](https://google-styleguide.googlecode.com/svn/trunk/intellij-java-google-style.xml) 25 | style configurations are commonly useful. For IntelliJ 14, copy the style to 26 | `~/.IdeaIC14/config/codestyles/`, start IntelliJ, go to File > Settings > Code 27 | Style, and set the Scheme to `GoogleStyle`. 28 | 29 | If planning on making a large change, feel free to [create an issue on 30 | GitHub](https://github.com/grpc/grpc-java/issues/new), visit the [#grpc IRC 31 | channel on Freenode](http://webchat.freenode.net/?channels=grpc), or send an 32 | email to [grpc-io@googlegroups.com](grpc-io@googlegroups.com) to discuss 33 | beforehand. 34 | 35 | ## Proposing changes 36 | 37 | Make sure that `./gradlew build` (`gradlew build` on Windows) completes 38 | successfully without any new warnings. Then create a Pull Request with your 39 | changes. When the changes are accepted, they will be merged or cherry-picked by 40 | a gRPC core developer. 41 | -------------------------------------------------------------------------------- /core/src/main/java/io/grpc/inprocess/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015, Google Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following disclaimer 12 | * in the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * * Neither the name of Google Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | /** 33 | * The in-process transport which is for when a server is in the same process as the client. 34 | */ 35 | package io.grpc.inprocess; 36 | -------------------------------------------------------------------------------- /netty/src/main/java/io/grpc/netty/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015, Google Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following disclaimer 12 | * in the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * * Neither the name of Google Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | /** 33 | * The main transport implementation based on Netty, 34 | * for both the client and the server. 35 | */ 36 | package io.grpc.netty; 37 | -------------------------------------------------------------------------------- /grpclb/src/generated/main/java/io/grpc/grpclb/ServerOrBuilder.java: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: load_balancer.proto 3 | 4 | package io.grpc.grpclb; 5 | 6 | public interface ServerOrBuilder extends 7 | // @@protoc_insertion_point(interface_extends:grpc.lb.v1.Server) 8 | com.google.protobuf.MessageOrBuilder { 9 | 10 | /** 11 | * optional bytes ip_address = 1; 12 | * 13 | *
14 |    * A resolved address for the server, serialized in network-byte-order. It may
15 |    * either be an IPv4 or IPv6 address.
16 |    * 
17 | */ 18 | com.google.protobuf.ByteString getIpAddress(); 19 | 20 | /** 21 | * optional int32 port = 2; 22 | * 23 | *
24 |    * A resolved port number for the server.
25 |    * 
26 | */ 27 | int getPort(); 28 | 29 | /** 30 | * optional string load_balance_token = 3; 31 | * 32 | *
33 |    * An opaque token that is passed from the client to the server in metadata.
34 |    * The server may expect this token to indicate that the request from the
35 |    * client was load balanced.
36 |    * 
37 | */ 38 | java.lang.String getLoadBalanceToken(); 39 | /** 40 | * optional string load_balance_token = 3; 41 | * 42 | *
43 |    * An opaque token that is passed from the client to the server in metadata.
44 |    * The server may expect this token to indicate that the request from the
45 |    * client was load balanced.
46 |    * 
47 | */ 48 | com.google.protobuf.ByteString 49 | getLoadBalanceTokenBytes(); 50 | 51 | /** 52 | * optional bool drop_request = 4; 53 | * 54 | *
55 |    * Indicates whether this particular request should be dropped by the client
56 |    * when this server is chosen from the list.
57 |    * 
58 | */ 59 | boolean getDropRequest(); 60 | } 61 | -------------------------------------------------------------------------------- /protobuf-nano/src/test/proto/messages.proto: -------------------------------------------------------------------------------- 1 | 2 | // Copyright 2015, Google Inc. 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package grpc; 34 | 35 | option java_package = "io.grpc.protobuf"; 36 | 37 | message Message { 38 | int32 i = 1; 39 | bool b = 2; 40 | string s = 3; 41 | bytes bs = 4; 42 | } 43 | -------------------------------------------------------------------------------- /okhttp/src/main/java/io/grpc/okhttp/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015, Google Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following disclaimer 12 | * in the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * * Neither the name of Google Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | /** 33 | * A lightweight transport based on 34 | * OkHttp, mainly for use on Android 35 | * (client-only). 36 | */ 37 | package io.grpc.okhttp; 38 | -------------------------------------------------------------------------------- /core/src/main/java/io/grpc/internal/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015, Google Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following disclaimer 12 | * in the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * * Neither the name of Google Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | /** 33 | * Interfaces and implementations that are internal to gRPC. 34 | * 35 | *

All the content under this package and its subpackages are considered annotated with {@link 36 | * io.grpc.Internal}. 37 | */ 38 | @io.grpc.Internal 39 | package io.grpc.internal; 40 | -------------------------------------------------------------------------------- /compiler/src/java_plugin/cpp/java_generator.h: -------------------------------------------------------------------------------- 1 | #ifndef NET_GRPC_COMPILER_JAVA_GENERATOR_H_ 2 | #define NET_GRPC_COMPILER_JAVA_GENERATOR_H_ 3 | 4 | #include // for abort() 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | class LogHelper { 12 | std::ostream* os; 13 | bool abort; 14 | 15 | public: 16 | LogHelper(std::ostream* os, bool abort) : os(os), abort(abort) {} 17 | ~LogHelper() { 18 | *os << std::endl; 19 | if (abort) { 20 | ::abort(); 21 | } 22 | } 23 | std::ostream& get_os() { 24 | return *os; 25 | } 26 | }; 27 | 28 | // Abort the program after logging the mesage if the given condition is not 29 | // true. Otherwise, do nothing. 30 | #define GRPC_CODEGEN_CHECK(x) !(x) && LogHelper(&std::cerr, true).get_os() \ 31 | << "CHECK FAILED: " << __FILE__ << ":" \ 32 | << __LINE__ << ": " 33 | 34 | // Abort the program after logging the mesage. 35 | #define GRPC_CODEGEN_FAIL GRPC_CODEGEN_CHECK(false) 36 | 37 | using namespace std; 38 | 39 | namespace java_grpc_generator { 40 | 41 | enum ProtoFlavor { 42 | NORMAL, LITE, NANO 43 | }; 44 | 45 | // Returns the package name of the gRPC services defined in the given file. 46 | string ServiceJavaPackage(const google::protobuf::FileDescriptor* file, bool nano); 47 | 48 | // Returns the name of the outer class that wraps in all the generated code for 49 | // the given service. 50 | string ServiceClassName(const google::protobuf::ServiceDescriptor* service); 51 | 52 | // Writes the generated service interface into the given ZeroCopyOutputStream 53 | void GenerateService(const google::protobuf::ServiceDescriptor* service, 54 | google::protobuf::io::ZeroCopyOutputStream* out, 55 | ProtoFlavor flavor); 56 | 57 | } // namespace java_grpc_generator 58 | 59 | #endif // NET_GRPC_COMPILER_JAVA_GENERATOR_H_ 60 | -------------------------------------------------------------------------------- /compiler/src/test/proto/test.proto: -------------------------------------------------------------------------------- 1 | // A simple service definition for testing the protoc plugin. 2 | syntax = "proto3"; 3 | 4 | package grpc.testing; 5 | 6 | option java_package = "io.grpc.testing.integration"; 7 | 8 | message SimpleRequest { 9 | } 10 | 11 | message SimpleResponse { 12 | } 13 | 14 | message StreamingInputCallRequest { 15 | } 16 | 17 | message StreamingInputCallResponse { 18 | } 19 | 20 | message StreamingOutputCallRequest { 21 | } 22 | 23 | message StreamingOutputCallResponse { 24 | } 25 | 26 | // Test service that supports all call types. 27 | service TestService { 28 | // One request followed by one response. 29 | // The server returns the client payload as-is. 30 | rpc UnaryCall(SimpleRequest) returns (SimpleResponse); 31 | 32 | // One request followed by a sequence of responses (streamed download). 33 | // The server returns the payload with client desired type and sizes. 34 | rpc StreamingOutputCall(StreamingOutputCallRequest) 35 | returns (stream StreamingOutputCallResponse); 36 | 37 | // A sequence of requests followed by one response (streamed upload). 38 | // The server returns the aggregated size of client payload as the result. 39 | rpc StreamingInputCall(stream StreamingInputCallRequest) 40 | returns (StreamingInputCallResponse); 41 | 42 | // A sequence of requests with each request served by the server immediately. 43 | // As one request could lead to multiple responses, this interface 44 | // demonstrates the idea of full bidirectionality. 45 | rpc FullBidiCall(stream StreamingOutputCallRequest) 46 | returns (stream StreamingOutputCallResponse); 47 | 48 | // A sequence of requests followed by a sequence of responses. 49 | // The server buffers all the client requests and then serves them in order. A 50 | // stream of responses are returned to the client when the server starts with 51 | // first request. 52 | rpc HalfBidiCall(stream StreamingOutputCallRequest) 53 | returns (stream StreamingOutputCallResponse); 54 | } 55 | -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2014, Google Inc. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | ----------------------------------------------------------------------- 31 | 32 | This product contains a modified portion of 'OkHttp', an open source 33 | HTTP & SPDY client for Android and Java applications, which can be obtained 34 | at: 35 | 36 | * LICENSE: 37 | * okhttp/third_party/okhttp/LICENSE (Apache License 2.0) 38 | * HOMEPAGE: 39 | * https://github.com/square/okhttp 40 | * LOCATION_IN_GRPC: 41 | * okhttp/third_party/okhttp -------------------------------------------------------------------------------- /benchmarks/src/jmh/java/io/grpc/benchmarks/netty/README.md: -------------------------------------------------------------------------------- 1 | Benchmarks 2 | ========== 3 | 4 | This directory contains the standard benchmarks used to assess the performance of GRPC. Since these 5 | benchmarks run on localhost over loopback the performance of the underlying network is considerably 6 | different to real networks and their behavior. To address this issue we recommend the use of 7 | a network emulator to make loopback behave more like a real network. To this end the benchmark 8 | code looks for a loopback interface with 'benchmark' in its name and attempts to use the address 9 | bound to that interface when creating the client and server. If it cannot find such an interface it 10 | will print a warning and continue with the default localhost address. 11 | 12 | To attempt to standardize benchmark behavior across machines we attempt to emulate a 10gbit 13 | ethernet interface with a packet delay of 0.1ms. 14 | 15 | 16 | Linux 17 | ===== 18 | 19 | On Linux we can use [netem](http://www.linuxfoundation.org/collaborate/workgroups/networking/netem) to shape the traffic appropriately. 20 | 21 | ```sh 22 | # Remove all traffic shaping from loopback 23 | sudo tc qdisc del dev lo root 24 | # Add a priority traffic class to the root of loopback 25 | sudo tc qdisc add dev lo root handle 1: prio 26 | # Add a qdisc under the new class with the appropriate shaping 27 | sudo tc qdisc add dev lo parent 1:1 handle 2: netem delay 0.1ms rate 10gbit 28 | # Add a filter which selects the new qdisc class for traffic to 127.127.127.127 29 | sudo tc filter add dev lo parent 1:0 protocol ip prio 1 u32 match ip dst 127.127.127.127 flowid 2:1 30 | # Create an interface alias call 'lo:benchmark' that maps 127.127.127.126 to loopback 31 | sudo ip addr add dev lo 127.127.127.127/32 label lo:benchmark 32 | ``` 33 | 34 | to remove this configuration 35 | 36 | ```sh 37 | sudo tc qdisc del dev lo root 38 | sudo ip addr del dev lo 127.127.127.127/32 label lo:benchmark 39 | ``` 40 | 41 | Other Platforms 42 | =============== 43 | 44 | Contributions welcome! 45 | 46 | -------------------------------------------------------------------------------- /compiler/src/testLite/proto/test.proto: -------------------------------------------------------------------------------- 1 | // A simple service definition for testing the protoc plugin. 2 | syntax = "proto2"; 3 | 4 | package grpc.testing; 5 | 6 | option java_package = "io.grpc.testing.integration"; 7 | option optimize_for = LITE_RUNTIME; 8 | 9 | message SimpleRequest { 10 | } 11 | 12 | message SimpleResponse { 13 | } 14 | 15 | message StreamingInputCallRequest { 16 | } 17 | 18 | message StreamingInputCallResponse { 19 | } 20 | 21 | message StreamingOutputCallRequest { 22 | } 23 | 24 | message StreamingOutputCallResponse { 25 | } 26 | 27 | // Test service that supports all call types. 28 | service TestService { 29 | // One request followed by one response. 30 | // The server returns the client payload as-is. 31 | rpc UnaryCall(SimpleRequest) returns (SimpleResponse); 32 | 33 | // One request followed by a sequence of responses (streamed download). 34 | // The server returns the payload with client desired type and sizes. 35 | rpc StreamingOutputCall(StreamingOutputCallRequest) 36 | returns (stream StreamingOutputCallResponse); 37 | 38 | // A sequence of requests followed by one response (streamed upload). 39 | // The server returns the aggregated size of client payload as the result. 40 | rpc StreamingInputCall(stream StreamingInputCallRequest) 41 | returns (StreamingInputCallResponse); 42 | 43 | // A sequence of requests with each request served by the server immediately. 44 | // As one request could lead to multiple responses, this interface 45 | // demonstrates the idea of full bidirectionality. 46 | rpc FullBidiCall(stream StreamingOutputCallRequest) 47 | returns (stream StreamingOutputCallResponse); 48 | 49 | // A sequence of requests followed by a sequence of responses. 50 | // The server buffers all the client requests and then serves them in order. A 51 | // stream of responses are returned to the client when the server starts with 52 | // first request. 53 | rpc HalfBidiCall(stream StreamingOutputCallRequest) 54 | returns (stream StreamingOutputCallResponse); 55 | } 56 | -------------------------------------------------------------------------------- /compiler/README.md: -------------------------------------------------------------------------------- 1 | gRPC Java Codegen Plugin for Protobuf Compiler 2 | ============================================== 3 | 4 | This generates the Java interfaces out of the service definition from a 5 | `.proto` file. It works with the Protobuf Compiler (``protoc``). 6 | 7 | Normally you don't need to compile the codegen by yourself, since pre-compiled 8 | binaries for common platforms are available on Maven Central. However, if the 9 | pre-compiled binaries are not compatible with your system, you may want to 10 | build your own codegen. 11 | 12 | ## System requirement 13 | 14 | * Linux, Mac OS X with Clang, or Windows with MSYS2 15 | * Java 7 or up 16 | * [Protobuf](https://github.com/google/protobuf) 3.0.0-beta-2 or up 17 | 18 | ## Compiling and testing the codegen 19 | Change to the `compiler` directory: 20 | ``` 21 | $ cd $GRPC_JAVA_ROOT/compiler 22 | ``` 23 | 24 | To compile the plugin: 25 | ``` 26 | $ ../gradlew java_pluginExecutable 27 | ``` 28 | 29 | To test the plugin with the compiler: 30 | ``` 31 | $ ../gradlew test 32 | ``` 33 | You will see a `PASS` if the test succeeds. 34 | 35 | To compile a proto file and generate Java interfaces out of the service definitions: 36 | ``` 37 | $ protoc --plugin=protoc-gen-grpc-java=build/binaries/java_pluginExecutable/protoc-gen-grpc-java \ 38 | --grpc-java_out="$OUTPUT_FILE" --proto_path="$DIR_OF_PROTO_FILE" "$PROTO_FILE" 39 | ``` 40 | To generate Java interfaces with protobuf nano: 41 | ``` 42 | $ protoc --plugin=protoc-gen-grpc-java=build/binaries/java_pluginExecutable/protoc-gen-grpc-java \ 43 | --grpc-java_out=nano:"$OUTPUT_FILE" --proto_path="$DIR_OF_PROTO_FILE" "$PROTO_FILE" 44 | ``` 45 | 46 | ## Installing the codegen to Maven local repository 47 | This will compile a codegen and put it under your ``~/.m2/repository``. This 48 | will make it available to any build tool that pulls codegens from Maven 49 | repostiories. 50 | ``` 51 | $ ../gradlew install 52 | ``` 53 | 54 | ## Creating a release of GRPC Java 55 | Please follow the instructions in ``RELEASING.md`` under the root directory for 56 | details on how to create a new release. 57 | -------------------------------------------------------------------------------- /core/src/main/java/io/grpc/internal/BackoffPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015, Google Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following disclaimer 12 | * in the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * * Neither the name of Google Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | package io.grpc.internal; 33 | 34 | /** 35 | * Determines how long to wait before doing some action (typically a retry, or a reconnect). 36 | */ 37 | interface BackoffPolicy { 38 | interface Provider { 39 | BackoffPolicy get(); 40 | } 41 | 42 | /** 43 | * @return The number of milliseconds to wait. 44 | */ 45 | long nextBackoffMillis(); 46 | } 47 | 48 | -------------------------------------------------------------------------------- /protobuf-nano/src/main/java/io/grpc/protobuf/nano/MessageNanoFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014, Google Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following disclaimer 12 | * in the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * * Neither the name of Google Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | package io.grpc.protobuf.nano; 33 | 34 | import com.google.protobuf.nano.MessageNano; 35 | 36 | /** 37 | * Produce new message instances. Used by a marshaller to deserialize incoming messages. 38 | * 39 | *

Should be implemented by generated code. 40 | */ 41 | public interface MessageNanoFactory { 42 | T newInstance(); 43 | } 44 | -------------------------------------------------------------------------------- /core/src/main/java/io/grpc/inprocess/InProcessSocketAddress.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016, Google Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following disclaimer 12 | * in the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * * Neither the name of Google Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | package io.grpc.inprocess; 33 | 34 | import java.net.SocketAddress; 35 | 36 | /** 37 | * Custom SocketAddress class for {@link InProcessTransport}. 38 | */ 39 | public class InProcessSocketAddress extends SocketAddress { 40 | private final String name; 41 | 42 | public InProcessSocketAddress(String name) { 43 | this.name = name; 44 | } 45 | 46 | public String getName() { 47 | return name; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /core/src/main/java/io/grpc/internal/ServerTransport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015, Google Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following disclaimer 12 | * in the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * * Neither the name of Google Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | package io.grpc.internal; 33 | 34 | /** An inbound connection. */ 35 | public interface ServerTransport { 36 | /** 37 | * Initiates an orderly shutdown of the transport. Existing streams continue, but new streams will 38 | * eventually begin failing. New streams "eventually" begin failing because shutdown may need to 39 | * be processed on a separate thread. May only be called once. 40 | */ 41 | void shutdown(); 42 | } 43 | -------------------------------------------------------------------------------- /okhttp/src/main/java/io/grpc/okhttp/NegotiationType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015, Google Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following disclaimer 12 | * in the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * * Neither the name of Google Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | package io.grpc.okhttp; 33 | 34 | /** 35 | * Identifies the negotiation used for starting up HTTP/2. 36 | */ 37 | public enum NegotiationType { 38 | /** 39 | * Uses TLS ALPN/NPN negotiation, assumes an SSL connection. 40 | */ 41 | TLS, 42 | 43 | /** 44 | * Just assume the connection is plaintext (non-SSL) and the remote endpoint supports HTTP/2 45 | * directly without an upgrade. 46 | */ 47 | PLAINTEXT 48 | } 49 | -------------------------------------------------------------------------------- /examples/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'com.google.protobuf' 3 | 4 | android { 5 | compileSdkVersion 22 6 | buildToolsVersion "22.0.1" 7 | 8 | defaultConfig { 9 | applicationId "io.grpc.android.helloworldexample" 10 | minSdkVersion 9 11 | targetSdkVersion 22 12 | versionCode 1 13 | versionName "1.0" 14 | } 15 | buildTypes { 16 | release { 17 | minifyEnabled true 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | lintOptions { 22 | disable 'InvalidPackage', 'HardcodedText' 23 | textReport true 24 | textOutput "stdout" 25 | } 26 | } 27 | 28 | protobuf { 29 | protoc { 30 | artifact = 'com.google.protobuf:protoc:3.0.0-beta-2' 31 | } 32 | plugins { 33 | grpc { 34 | artifact = 'io.grpc:protoc-gen-grpc-java:0.14.0-SNAPSHOT' // CURRENT_GRPC_VERSION 35 | } 36 | } 37 | generateProtoTasks { 38 | all().each { task -> 39 | task.builtins { 40 | javanano { 41 | // Options added to --javanano_out 42 | option 'ignore_services=true' 43 | } 44 | } 45 | 46 | task.plugins { 47 | grpc { 48 | // Options added to --grpc_out 49 | option 'nano' 50 | } 51 | } 52 | } 53 | } 54 | } 55 | 56 | dependencies { 57 | compile 'com.android.support:appcompat-v7:22.1.1' 58 | compile 'com.google.code.findbugs:jsr305:3.0.0' 59 | compile 'com.google.guava:guava:18.0' 60 | compile 'com.squareup.okhttp:okhttp:2.2.0' 61 | // You need to build grpc-java to obtain these libraries below. 62 | compile 'io.grpc:grpc-okhttp:0.14.0-SNAPSHOT' // CURRENT_GRPC_VERSION 63 | compile 'io.grpc:grpc-protobuf-nano:0.14.0-SNAPSHOT' // CURRENT_GRPC_VERSION 64 | compile 'io.grpc:grpc-stub:0.14.0-SNAPSHOT' // CURRENT_GRPC_VERSION 65 | compile 'javax.annotation:javax.annotation-api:1.2' 66 | } 67 | -------------------------------------------------------------------------------- /netty/src/main/java/io/grpc/netty/GracefulCloseCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016, Google Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following disclaimer 12 | * in the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * * Neither the name of Google Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | package io.grpc.netty; 33 | 34 | import io.grpc.Status; 35 | 36 | /** 37 | * A command to trigger close. It is buffered differently than normal close and also includes 38 | * reason for closure. 39 | */ 40 | class GracefulCloseCommand { 41 | private final Status status; 42 | 43 | public GracefulCloseCommand(Status status) { 44 | this.status = status; 45 | } 46 | 47 | public Status getStatus() { 48 | return status; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /core/src/test/java/io/grpc/inprocess/InProcessServerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016, Google Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following disclaimer 12 | * in the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * * Neither the name of Google Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | package io.grpc.inprocess; 33 | 34 | import com.google.common.truth.Truth; 35 | 36 | import org.junit.Test; 37 | import org.junit.runner.RunWith; 38 | import org.junit.runners.JUnit4; 39 | 40 | @RunWith(JUnit4.class) 41 | public class InProcessServerTest { 42 | 43 | @Test 44 | public void getPort_notStarted() throws Exception { 45 | InProcessServer s = new InProcessServer("name"); 46 | 47 | Truth.assertThat(s.getPort()).isEqualTo(-1); 48 | } 49 | } 50 | 51 | -------------------------------------------------------------------------------- /core/src/test/java/io/grpc/internal/ReadableBuffersByteBufferTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014, Google Inc. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are 6 | * met: 7 | * 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above 11 | * copyright notice, this list of conditions and the following disclaimer 12 | * in the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * * Neither the name of Google Inc. nor the names of its 16 | * contributors may be used to endorse or promote products derived from 17 | * this software without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | package io.grpc.internal; 33 | 34 | import static com.google.common.base.Charsets.UTF_8; 35 | 36 | import java.nio.ByteBuffer; 37 | 38 | /** 39 | * Tests for the array-backed {@link ReadableBuffer} returned by {@link 40 | * ReadableBuffers#wrap(ByteBuffer)}. 41 | */ 42 | public class ReadableBuffersByteBufferTest extends ReadableBufferTestBase { 43 | 44 | @Override 45 | protected ReadableBuffer buffer() { 46 | return ReadableBuffers.wrap(ByteBuffer.wrap(msg.getBytes(UTF_8))); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /examples/android/app/src/main/res/layout/activity_helloworld.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 11 | 17 | 24 | 25 | 26 | 27 | 32 | 33 |