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 |
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.Listrepeated .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 extends io.grpc.examples.routeguide.FeatureOrBuilder>
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 | 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
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 Should be implemented by generated code.
40 | */
41 | public interface MessageNanoFactory The subclasses of this interface usually want to include the log ID in their {@link
44 | * #toString} results.
45 | */
46 | String getLogId();
47 | }
48 |
--------------------------------------------------------------------------------
/core/src/test/java/io/grpc/inprocess/InProcessClientTransportFactoryTest.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 io.grpc.internal.ClientTransportFactory;
35 | import io.grpc.internal.testing.AbstractClientTransportFactoryTest;
36 | import org.junit.runner.RunWith;
37 | import org.junit.runners.JUnit4;
38 |
39 | @RunWith(JUnit4.class)
40 | public class InProcessClientTransportFactoryTest extends AbstractClientTransportFactoryTest {
41 |
42 | @Override
43 | protected ClientTransportFactory newClientTransportFactory() {
44 | return InProcessChannelBuilder.forName("test-transport").buildTransportFactory();
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/netty/src/main/java/io/grpc/netty/NettyServerProvider.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.netty;
33 |
34 | import io.grpc.Internal;
35 | import io.grpc.ServerProvider;
36 |
37 |
38 | /** Provider for {@link NettyChannelBuilder} instances. */
39 | @Internal
40 | public final class NettyServerProvider extends ServerProvider {
41 |
42 | @Override
43 | protected boolean isAvailable() {
44 | return true;
45 | }
46 |
47 | @Override
48 | protected int priority() {
49 | return 5;
50 | }
51 |
52 | @Override
53 | protected NettyServerBuilder builderForPort(int port) {
54 | return NettyServerBuilder.forPort(port);
55 | }
56 | }
57 |
58 |
--------------------------------------------------------------------------------
/okhttp/third_party/okhttp/java/io/grpc/okhttp/internal/framed/Header.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Forked from OkHttp 2.5.0
3 | */
4 |
5 | package io.grpc.okhttp.internal.framed;
6 |
7 | import okio.ByteString;
8 |
9 | /** HTTP header: the name is an ASCII string, but the value can be UTF-8. */
10 | public final class Header {
11 | // Special header names defined in the SPDY and HTTP/2 specs.
12 | public static final ByteString RESPONSE_STATUS = ByteString.encodeUtf8(":status");
13 | public static final ByteString TARGET_METHOD = ByteString.encodeUtf8(":method");
14 | public static final ByteString TARGET_PATH = ByteString.encodeUtf8(":path");
15 | public static final ByteString TARGET_SCHEME = ByteString.encodeUtf8(":scheme");
16 | public static final ByteString TARGET_AUTHORITY = ByteString.encodeUtf8(":authority"); // HTTP/2
17 | public static final ByteString TARGET_HOST = ByteString.encodeUtf8(":host"); // spdy/3
18 | public static final ByteString VERSION = ByteString.encodeUtf8(":version"); // spdy/3
19 |
20 | /** Name in case-insensitive ASCII encoding. */
21 | public final ByteString name;
22 | /** Value in UTF-8 encoding. */
23 | public final ByteString value;
24 | final int hpackSize;
25 |
26 | // TODO: search for toLowerCase and consider moving logic here.
27 | public Header(String name, String value) {
28 | this(ByteString.encodeUtf8(name), ByteString.encodeUtf8(value));
29 | }
30 |
31 | public Header(ByteString name, String value) {
32 | this(name, ByteString.encodeUtf8(value));
33 | }
34 |
35 | public Header(ByteString name, ByteString value) {
36 | this.name = name;
37 | this.value = value;
38 | this.hpackSize = 32 + name.size() + value.size();
39 | }
40 |
41 | @Override public boolean equals(Object other) {
42 | if (other instanceof Header) {
43 | Header that = (Header) other;
44 | return this.name.equals(that.name)
45 | && this.value.equals(that.value);
46 | }
47 | return false;
48 | }
49 |
50 | @Override public int hashCode() {
51 | int result = 17;
52 | result = 31 * result + name.hashCode();
53 | result = 31 * result + value.hashCode();
54 | return result;
55 | }
56 |
57 | @Override public String toString() {
58 | return String.format("%s: %s", name.utf8(), value.utf8());
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/android-interop-testing/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.integrationtest"
10 | minSdkVersion 9
11 | targetSdkVersion 22
12 | versionCode 1
13 | versionName "1.0"
14 | }
15 | buildTypes {
16 | debug {
17 | minifyEnabled false
18 | }
19 | release {
20 | minifyEnabled true
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 | lintOptions {
25 | disable 'InvalidPackage', 'HardcodedText'
26 | }
27 | }
28 |
29 | protobuf {
30 | protoc {
31 | artifact = 'com.google.protobuf:protoc:3.0.0-beta-2'
32 | }
33 | plugins {
34 | grpc {
35 | artifact = 'io.grpc:protoc-gen-grpc-java:0.14.0-SNAPSHOT' // CURRENT_GRPC_VERSION
36 | }
37 | }
38 | generateProtoTasks {
39 | all().each { task ->
40 | task.builtins {
41 | javanano {
42 | // Options added to --javanano_out
43 | option 'ignore_services=true'
44 | }
45 | }
46 |
47 | task.plugins {
48 | grpc {
49 | // Options added to --grpc_out
50 | option 'nano'
51 | }
52 | }
53 | }
54 | }
55 | }
56 |
57 | dependencies {
58 | compile 'com.android.support:appcompat-v7:22.1.1'
59 | compile 'com.google.android.gms:play-services-base:7.3.0'
60 | compile 'com.google.code.findbugs:jsr305:3.0.0'
61 | compile 'com.google.guava:guava:18.0'
62 | compile 'com.squareup.okhttp:okhttp:2.2.0'
63 | // You need to build grpc-java to obtain these libraries below.
64 | compile 'io.grpc:grpc-protobuf-nano:0.14.0-SNAPSHOT' // CURRENT_GRPC_VERSION
65 | compile 'io.grpc:grpc-okhttp:0.14.0-SNAPSHOT' // CURRENT_GRPC_VERSION
66 | compile 'io.grpc:grpc-stub:0.14.0-SNAPSHOT' // CURRENT_GRPC_VERSION
67 | compile 'io.grpc:grpc-testing:0.14.0-SNAPSHOT' // CURRENT_GRPC_VERSION
68 | compile 'javax.annotation:javax.annotation-api:1.2'
69 | }
70 |
--------------------------------------------------------------------------------
/core/src/main/java/io/grpc/StatusRuntimeException.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;
33 |
34 | /**
35 | * {@link Status} in RuntimeException form, for propagating Status information via exceptions.
36 | *
37 | * @see StatusException
38 | */
39 | public class StatusRuntimeException extends RuntimeException {
40 |
41 | private static final long serialVersionUID = 1950934672280720624L;
42 | private final Status status;
43 |
44 | public StatusRuntimeException(Status status) {
45 | super(Status.formatThrowableMessage(status), status.getCause());
46 | this.status = status;
47 | }
48 |
49 | public final Status getStatus() {
50 | return status;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/core/src/test/java/io/grpc/internal/ByteWritableBufferTest.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 | import org.junit.Before;
35 |
36 | import java.util.Arrays;
37 |
38 | public class ByteWritableBufferTest extends WritableBufferTestBase {
39 |
40 | private MessageFramerTest.ByteWritableBuffer buffer;
41 |
42 | @Before
43 | public void setup() {
44 | buffer = new MessageFramerTest.ByteWritableBuffer(100);
45 | }
46 |
47 | @Override
48 | protected WritableBuffer buffer() {
49 | return buffer;
50 | }
51 |
52 | @Override
53 | protected byte[] writtenBytes() {
54 | return Arrays.copyOf(buffer.data, buffer.readableBytes());
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/examples/src/main/proto/helloworld.proto:
--------------------------------------------------------------------------------
1 | // Copyright 2015, Google Inc.
2 | // 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 | // * 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 | syntax = "proto3";
31 |
32 | option java_multiple_files = true;
33 | option java_package = "io.grpc.examples.helloworld";
34 | option java_outer_classname = "HelloWorldProto";
35 | option objc_class_prefix = "HLW";
36 |
37 | package helloworld;
38 |
39 | // The greeting service definition.
40 | service Greeter {
41 | // Sends a greeting
42 | rpc SayHello (HelloRequest) returns (HelloReply) {}
43 | }
44 |
45 | // The request message containing the user's name.
46 | message HelloRequest {
47 | string name = 1;
48 | }
49 |
50 | // The response message containing the greetings
51 | message HelloReply {
52 | string message = 1;
53 | }
54 |
--------------------------------------------------------------------------------
/examples/android/app/src/main/proto/helloworld.proto:
--------------------------------------------------------------------------------
1 | // Copyright 2015, Google Inc.
2 | // 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 | // * 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 | syntax = "proto3";
31 |
32 | option java_multiple_files = true;
33 | option java_package = "io.grpc.examples.helloworld";
34 | option java_outer_classname = "HelloWorldProto";
35 | option objc_class_prefix = "HLW";
36 |
37 | package helloworld;
38 |
39 | // The greeting service definition.
40 | service Greeter {
41 | // Sends a greeting
42 | rpc SayHello (HelloRequest) returns (HelloReply) {}
43 | }
44 |
45 | // The request message containing the user's name.
46 | message HelloRequest {
47 | string name = 1;
48 | }
49 |
50 | // The response message containing the greetings
51 | message HelloReply {
52 | string message = 1;
53 | }
54 |
--------------------------------------------------------------------------------
/core/src/main/java/io/grpc/StatusException.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;
33 |
34 | import static io.grpc.Status.formatThrowableMessage;
35 |
36 | /**
37 | * {@link Status} in Exception form, for propagating Status information via exceptions.
38 | *
39 | * @see StatusRuntimeException
40 | */
41 | public class StatusException extends Exception {
42 | private static final long serialVersionUID = -660954903976144640L;
43 | private final Status status;
44 |
45 | public StatusException(Status status) {
46 | super(formatThrowableMessage(status), status.getCause());
47 | this.status = status;
48 | }
49 |
50 | public final Status getStatus() {
51 | return status;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/netty/src/test/java/io/grpc/netty/NettyClientTransportFactoryTest.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.internal.ClientTransportFactory;
35 | import io.grpc.internal.testing.AbstractClientTransportFactoryTest;
36 | import io.grpc.testing.TestUtils;
37 | import org.junit.runner.RunWith;
38 | import org.junit.runners.JUnit4;
39 |
40 | @RunWith(JUnit4.class)
41 | public class NettyClientTransportFactoryTest extends AbstractClientTransportFactoryTest {
42 | @Override protected ClientTransportFactory newClientTransportFactory() {
43 | return NettyChannelBuilder
44 | .forAddress("localhost", TestUtils.pickUnusedPort())
45 | .buildTransportFactory();
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/okhttp/src/test/java/io/grpc/okhttp/OkHttpClientTransportFactoryTest.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.okhttp;
33 |
34 | import io.grpc.internal.ClientTransportFactory;
35 | import io.grpc.internal.testing.AbstractClientTransportFactoryTest;
36 | import io.grpc.testing.TestUtils;
37 | import org.junit.runner.RunWith;
38 | import org.junit.runners.JUnit4;
39 |
40 | @RunWith(JUnit4.class)
41 | public class OkHttpClientTransportFactoryTest extends AbstractClientTransportFactoryTest {
42 | @Override
43 | protected ClientTransportFactory newClientTransportFactory() {
44 | return OkHttpChannelBuilder.forAddress("localhost", TestUtils.pickUnusedPort())
45 | .buildTransportFactory();
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/netty/src/main/java/io/grpc/netty/SendPingCommand.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.netty;
33 |
34 | import io.grpc.internal.ClientTransport.PingCallback;
35 |
36 | import java.util.concurrent.Executor;
37 |
38 | /**
39 | * Command sent from the transport to the Netty channel to send a PING frame.
40 | */
41 | class SendPingCommand {
42 | private final PingCallback callback;
43 | private final Executor executor;
44 |
45 | SendPingCommand(PingCallback callback, Executor executor) {
46 | this.callback = callback;
47 | this.executor = executor;
48 | }
49 |
50 | PingCallback callback() {
51 | return callback;
52 | }
53 |
54 | Executor executor() {
55 | return executor;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/core/src/main/java/io/grpc/KnownLength.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;
33 |
34 | import java.io.IOException;
35 |
36 | /**
37 | * An {@link java.io.InputStream} or alike whose total number of bytes that can be read is known
38 | * upfront.
39 | *
40 | * Usually it's a {@link java.io.InputStream} that also implements this interface, in which case
41 | * {@link java.io.InputStream#available()} has a stronger semantic by returning an accurate number
42 | * instead of an estimation.
43 | */
44 | public interface KnownLength {
45 | /**
46 | * Returns the total number of bytes that can be read (or skipped over) from this object until all
47 | * bytes have been read out.
48 | */
49 | int available() throws IOException;
50 | }
51 |
--------------------------------------------------------------------------------
/netty/src/main/java/io/grpc/netty/NegotiationType.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.netty;
33 |
34 | import io.grpc.ExperimentalApi;
35 |
36 | /**
37 | * Identifies the negotiation used for starting up HTTP/2.
38 | */
39 | @ExperimentalApi("Only used by experimental builders")
40 | public enum NegotiationType {
41 | /**
42 | * Uses TLS ALPN/NPN negotiation, assumes an SSL connection.
43 | */
44 | TLS,
45 |
46 | /**
47 | * Use the HTTP UPGRADE protocol for a plaintext (non-SSL) upgrade from HTTP/1.1 to HTTP/2.
48 | */
49 | PLAINTEXT_UPGRADE,
50 |
51 | /**
52 | * Just assume the connection is plaintext (non-SSL) and the remote endpoint supports HTTP/2
53 | * directly without an upgrade.
54 | */
55 | PLAINTEXT
56 | }
57 |
--------------------------------------------------------------------------------
/benchmarks/src/main/proto/payloads.proto:
--------------------------------------------------------------------------------
1 | // Copyright 2015, Google Inc.
2 | // 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 | // * 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 | syntax = "proto3";
31 |
32 | package grpc.benchmarks;
33 |
34 | option java_package = "io.grpc.benchmarks.proto";
35 | option java_outer_classname = "Payloads";
36 |
37 | message ByteBufferParams {
38 | int32 req_size = 1;
39 | int32 resp_size = 2;
40 | }
41 |
42 | message SimpleProtoParams {
43 | int32 req_size = 1;
44 | int32 resp_size = 2;
45 | }
46 |
47 | message ComplexProtoParams {
48 | // TODO (vpai): Fill this in once the details of complex, representative
49 | // protos are decided
50 | }
51 |
52 | message PayloadConfig {
53 | oneof payload {
54 | ByteBufferParams bytebuf_params = 1;
55 | SimpleProtoParams simple_params = 2;
56 | ComplexProtoParams complex_params = 3;
57 | }
58 | }
--------------------------------------------------------------------------------
/core/src/main/java/io/grpc/Compressor.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;
33 |
34 | import java.io.IOException;
35 | import java.io.OutputStream;
36 |
37 | /**
38 | * Represents a message compressor.
39 | */
40 | @ExperimentalApi("https://github.com/grpc/grpc-java/issues/492")
41 | public interface Compressor {
42 | /**
43 | * Returns the message encoding that this compressor uses.
44 | *
45 | * This can be values such as "gzip", "deflate", "snappy", etc.
46 | */
47 | String getMessageEncoding();
48 |
49 | /**
50 | * Wraps an existing output stream with a compressing output stream.
51 | * @param os The output stream of uncompressed data
52 | * @return An output stream that compresses
53 | */
54 | OutputStream compress(OutputStream os) throws IOException;
55 | }
56 |
57 |
--------------------------------------------------------------------------------
/okhttp/src/main/java/io/grpc/okhttp/OkHttpSettingsUtil.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.okhttp;
33 |
34 | import io.grpc.okhttp.internal.framed.Settings;
35 |
36 | /**
37 | * A utility class help gRPC get/set the necessary fields of OkHttp's Settings.
38 | */
39 | class OkHttpSettingsUtil {
40 | public static final int MAX_CONCURRENT_STREAMS = Settings.MAX_CONCURRENT_STREAMS;
41 | public static final int INITIAL_WINDOW_SIZE = Settings.INITIAL_WINDOW_SIZE;
42 |
43 | public static boolean isSet(Settings settings, int id) {
44 | return settings.isSet(id);
45 | }
46 |
47 | public static int get(Settings settings, int id) {
48 | return settings.get(id);
49 | }
50 |
51 | public static void set(Settings settings, int id, int value) {
52 | settings.set(id, 0, value);
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/core/src/main/java/io/grpc/Decompressor.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;
33 |
34 | import java.io.IOException;
35 | import java.io.InputStream;
36 |
37 | /**
38 | * Represents a message decompressor.
39 | */
40 | @ExperimentalApi("https://github.com/grpc/grpc-java/issues/492")
41 | public interface Decompressor {
42 | /**
43 | * Returns the message encoding that this compressor uses.
44 | *
45 | * This can be values such as "gzip", "deflate", "snappy", etc.
46 | */
47 | String getMessageEncoding();
48 |
49 | /**
50 | * Wraps an existing input stream with a decompressing input stream.
51 | * @param is The input stream of uncompressed data
52 | * @return An input stream that decompresses
53 | */
54 | InputStream decompress(InputStream is) throws IOException;
55 | }
56 |
57 |
--------------------------------------------------------------------------------
/netty/src/main/java/io/grpc/netty/NettyChannelProvider.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.netty;
33 |
34 | import io.grpc.Internal;
35 | import io.grpc.ManagedChannelProvider;
36 |
37 | /** Provider for {@link NettyChannelBuilder} instances. */
38 | @Internal
39 | public final class NettyChannelProvider extends ManagedChannelProvider {
40 | @Override
41 | public boolean isAvailable() {
42 | return true;
43 | }
44 |
45 | @Override
46 | public int priority() {
47 | return 5;
48 | }
49 |
50 | @Override
51 | public NettyChannelBuilder builderForAddress(String name, int port) {
52 | return NettyChannelBuilder.forAddress(name, port);
53 | }
54 |
55 | @Override
56 | public NettyChannelBuilder builderForTarget(String target) {
57 | return NettyChannelBuilder.forTarget(target);
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/core/src/test/java/io/grpc/internal/WritableBufferAllocatorTestBase.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 | import static org.junit.Assert.assertNotSame;
35 |
36 | import org.junit.Test;
37 | import org.junit.runner.RunWith;
38 | import org.junit.runners.JUnit4;
39 |
40 | /**
41 | * Abstract base class for tests of {@link WritableBufferAllocator} subclasses.
42 | */
43 | @RunWith(JUnit4.class)
44 | public abstract class WritableBufferAllocatorTestBase {
45 |
46 | protected abstract WritableBufferAllocator allocator();
47 |
48 | @Test
49 | public void testBuffersAreDifferent() {
50 | WritableBuffer buffer1 = allocator().allocate(100);
51 | WritableBuffer buffer2 = allocator().allocate(100);
52 |
53 | assertNotSame(buffer1, buffer2);
54 |
55 | buffer1.release();
56 | buffer2.release();
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/benchmarks/src/main/java/io/grpc/benchmarks/qps/Configuration.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.benchmarks.qps;
33 |
34 | /**
35 | * Configuration for a benchmark application.
36 | */
37 | public interface Configuration {
38 | /**
39 | * Builder for the {@link Configuration}.
40 | * @param It is used by service's abstract class generated by compiler (eg.:
38 | * RouteGuideGrpc.AbstractRouteGuide for RouteGuide service) and lets implementation classes to be
39 | * bind to server.
40 | *
41 | * After this method has been called, it's no longer valid to call
51 | * {@link #newClientTransport(SocketAddress, String)}. No guarantees about thread-safety are made.
52 | */
53 | @Override
54 | void close();
55 | }
56 |
--------------------------------------------------------------------------------
/core/src/main/java/io/grpc/internal/ServerTransportListener.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 io.grpc.Metadata;
35 |
36 | /**
37 | * A observer of a server-side transport for stream creation events. Notifications must occur from
38 | * the transport thread.
39 | */
40 | public interface ServerTransportListener {
41 |
42 | /**
43 | * Called when a new stream was created by the remote client.
44 | *
45 | * @param stream the newly created stream.
46 | * @param method the fully qualified method name being called on the server.
47 | * @param headers containing metadata for the call.
48 | * @return a listener for events on the new stream.
49 | */
50 | ServerStreamListener streamCreated(ServerStream stream, String method,
51 | Metadata headers);
52 |
53 | /**
54 | * The transport completed shutting down. All resources have been released.
55 | */
56 | void transportTerminated();
57 | }
58 |
--------------------------------------------------------------------------------
/core/src/main/java/io/grpc/PartialForwardingServerCallListener.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;
33 |
34 | /**
35 | * A {@link ServerCall.Listener} which forwards all of its methods to another {@link
36 | * ServerCall.Listener} which may have a different parameterized type than the
37 | * onMessage() message type.
38 | */
39 | abstract class PartialForwardingServerCallListener This can be used for optimizing for the case where the content of the input stream will be
42 | * written to an {@link OutputStream} eventually. Instead of copying the content to a byte array
43 | * through {@code read()}, then writing the the {@code OutputStream}, the implementation can write
44 | * the content directly to the {@code OutputStream}.
45 | */
46 | public interface Drainable {
47 |
48 | /**
49 | * Transfers the entire contents of this stream to the specified target.
50 | *
51 | * @param target to write to.
52 | * @return number of bytes written.
53 | */
54 | int drainTo(OutputStream target) throws IOException;
55 | }
56 |
--------------------------------------------------------------------------------
/core/src/main/java/io/grpc/MutableHandlerRegistry.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;
33 |
34 | import javax.annotation.Nullable;
35 | import javax.annotation.concurrent.ThreadSafe;
36 |
37 | /**
38 | * Mutable base class of {@link HandlerRegistry}. Used by server implementations
39 | * that need to bind and unbind services that are exposed to remote clients.
40 | *
41 | * @see MutableHandlerRegistryImpl
42 | */
43 | @ThreadSafe
44 | @ExperimentalApi("https://github.com/grpc/grpc-java/issues/933")
45 | public abstract class MutableHandlerRegistry extends HandlerRegistry {
46 | /**
47 | * Returns {@code null}, or previous service if {@code service} replaced an existing service.
48 | */
49 | @Nullable
50 | public abstract ServerServiceDefinition addService(ServerServiceDefinition service);
51 |
52 | /**
53 | * Returns {@code false} if {@code service} was not registered.
54 | */
55 | public abstract boolean removeService(ServerServiceDefinition service);
56 | }
57 |
--------------------------------------------------------------------------------
42 | * class RouteGuideService extends RouteGuideGrpc.AbstractRouteGuide {
43 | * // ...
44 | * }
45 | *
46 | * Server server = ServerBuilder.forPort(1234).addService(new RouteGuideService()).build();
47 | *