Commit Graph

448 Commits

Author SHA1 Message Date
Carl Mastrangelo c85e04698f Make Route Guide client and server accept channel and server builers, respectively. 2016-03-02 16:24:31 -08:00
Carl Mastrangelo 8e1fba7c90 Use Protobuf Json formatting for routeguide example 2016-03-02 10:10:15 -08:00
Carl Mastrangelo 72f1e88d78 Inlcude the file that was used to generate service descriptors 2016-03-01 09:22:10 -08:00
Eric Anderson b752e76858 Automated readability/efficiency tweaks
Although the changes were determined automatically, they were manually
applied to the codebase.

ClientCalls actually has a bug fix, since the suggestion to add
interrupt() made it obvious that interrupted() was inappropriate.
2016-02-16 14:15:23 -08:00
Eric Anderson 4ac4d49370 Help steer new users away from copying our build.gradle
The jsonp dependency string is no longer shared because it was only used
in one place and someone trying to compile the examples using a new
build.gradle will need to add that dependency. It was a bit complex to
follow how libraries.jsonp worked and it wasn't really adding any value
in this particular case.
2016-02-03 10:04:12 -08:00
Eric Anderson b11dce8288 Partially synchronize route_guide.proto with main repository 2016-02-03 10:02:05 -08:00
Eric Anderson 9804b67f1a Include Proto in the java_outer_classname for helloworld.proto
Specifying the outer class is a pretty common convention and avoids the
outer classname changing depending on the contents of the proto file (as
can be seen if outer_classname isn't specified in the route guide
example). To avoid colliding, convention has it end in "Proto".
2016-02-03 10:02:05 -08:00
Eric Anderson 2a17d2648c Partially synchronize helloworld.proto with main repository
Mainly HelloResponse is now HelloReply
2016-02-02 12:56:05 -08:00
Kun Zhang e2ed2e8f03 Upgrade to protobuf-3.0.0-beta-2 and protobuf-nano-3.0.0-alpha-5
Update option name that disables protobuf tests.
2016-01-27 23:32:01 -08:00
Eric Anderson 4168f67e38 Optimize blocking calls to avoid app thread pool
This reduces the necessary number of threads in the application executor
and provides a small improvement in latency (~15μs, which is normally in
the noise, but would be a 5% improvement).

Benchmark                         (direct)  (transport)  Mode  Cnt       Score        Error  Units
Before:
TransportBenchmark.unaryCall1024      true    INPROCESS  avgt   10    1566.168 ±     13.677  ns/op
TransportBenchmark.unaryCall1024     false    INPROCESS  avgt   10   35769.532 ±   2358.967  ns/op
After:
TransportBenchmark.unaryCall1024      true    INPROCESS  avgt   10    1813.778 ±     19.995  ns/op
TransportBenchmark.unaryCall1024     false    INPROCESS  avgt   10   18568.223 ±   1679.306  ns/op

The benchmark results are exactly what we would expect, assuming that
half of the benefit of direct is on server and half on client:
1566 + (35769 - 1566) / 2 = 18668 ns --vs-- 18568 ns

It is expected that direct=true would get worse, because
SerializingExecutor is now used instead of
SerializeReentrantCallsDirectExecutor plus the additional cost of
ThreadlessExecutor.

In the future we could try to detect the ThreadlessExecutor and ellide
Serializ*Executor completely (as is possible for any single-threaded
executor). We could also optimize the queue used in ThreadlessExecutor
to be single-producer, single-consumer. I don't expect to do those
optimizations soon, however.
2016-01-26 12:41:50 -08:00
Eric Anderson d52429dffd Reduce number of codegen'd classes needed for Services
This reduces the number of classes defined, which reduces memory usage.
It also reduces the number of methods defined, which is important
because of the dex limit.

This should have virtually zero performance degradation because the
contiguous switch uses tableswitch bytecode.
2016-01-15 16:45:41 -08:00
Eric Anderson df310fe2b5 More precise exception handling in examples
Try to make it clear how failures propagate and provide hints on how to
get more error information.
2016-01-15 14:26:27 -08:00
Carl Mastrangelo 7ac44928be Fix bug where server wouldn't declare the negotiated compression 2015-12-14 15:48:01 -08:00
Carl Mastrangelo 529b14c07b Add compressor registry, and auto negotiate compression 2015-12-07 10:56:16 -08:00
kenji yoshida 8301121db0 fix typo 2015-11-04 14:09:14 +09:00
Xudong Ma 996ea2fc22 Give dependency example for android clients. 2015-10-07 16:08:36 -07:00
Eric Anderson 2a98c2eee9 Replace broken link in example 2015-09-28 14:43:36 -07:00
Xudong Ma 75624bba24 Remove unused protos. 2015-09-18 16:30:42 -07:00
Xudong Ma 2016a88f5c Update the comments in proguard-rules files. 2015-09-17 18:17:32 -07:00
Eric Anderson 9987aa28a3 Remove javatutorial; it duplicates grpc.io website
It is hard to keep the two in sync.
http://www.grpc.io/docs/tutorials/basic/java.html
2015-09-17 14:53:46 -07:00
Xudong Ma 57ebf8aaf3 Update Android example. 2015-09-17 14:18:48 -07:00
Jerjou Cheng 45c75f2c96 Fix broken tutorial link. 2015-09-14 09:18:06 -07:00
Eric Anderson 1cfba96d17 Enforce sending headers before messages on server
ServerCall already had "headers must be sent before any messages, which
must be sent before closing," but the implementation did not enforce it
and our async server handler didn't obey.

The benefit of forcing sending headers first is that it removes the only
implicit call in our API and interceptors dealing just with metadata
don't need to override sendMessage. The implicit behavior was bug-prone
since it wasn't obvious you were forgetting that headers may not be
sent.
2015-09-11 17:39:40 -07:00
Carl Mastrangelo eab74b5053 Update Client Examples to use ManagedChannelBuilder 2015-09-11 10:30:33 -07:00
Carl Mastrangelo 41d93cfd59 Use Providers in examples 2015-09-11 09:46:08 -07:00
Eric Anderson a6621daca2 Private ServerMethodDefinition constructor; avoid create() in codegen
There is no need to use ServerMethodDefinition in codegen. The create()
method itself could be helpful to a dynamic HandlerRegistry
implementation, so we won't remove it.
2015-09-11 09:25:24 -07:00
Eric Anderson 033cdd0993 Discourage users from running the codegen for the example 2015-09-10 10:29:14 -07:00
Eric Anderson be0d7e911a Prevent construction of container classes and reduce API 2015-09-10 10:09:13 -07:00
Eric Anderson 23e6318156 Reduce API surface of AbstractStub 2015-09-10 08:36:08 -07:00
Carl Mastrangelo 399be9ac73 Use stub call options for compression 2015-09-09 13:21:04 -07:00
Carl Mastrangelo f06c7ebd37 Update server to await termination in the main thread 2015-09-08 15:40:37 -07:00
Carl Mastrangelo 091749e4ca Add an example compressing client 2015-09-08 13:06:25 -07:00
Eric Anderson 47a7ccf0cb Avoid Parser for normal protobuf
Eventually, this could avoid allocating Parser, since we can use
newBuilderForType().mergeFrom(). This would primarily benefit Lite
proto.
2015-09-03 17:31:16 -07:00
nmittler b687bdc742 Refactoring channel API.
Client:
* New ManagedChannel abstract class.
* Adding ping to Channel.
* Moving builders and implementations to internal.

Server:
* Added lifecycle management API to Server (mirroring ManagedChannel).
* Moved ServerImpl, AbstractServerBuilder and handler registries to internal.
* New ServerBuilder abstract class (mirroring ManagedChannelBuilder).

Fixes #545
2015-09-03 11:22:29 -07:00
Xudong Ma d5bd33ca1b Fix generated code reference for intellij projects. 2015-09-02 14:18:31 -07:00
David P. Baker 66b984ca9d Extract the fully-qualified service name into a public static final field on the service container type. 2015-09-02 13:42:46 -07:00
Kun Zhang 5bb0ea9899 Annotate method descritpor files in the generated code with ExperimentalApi 2015-08-31 09:56:44 -07:00
Kun Zhang bd23a8d693 Upgrade to protobuf-3.0.0-beta-1 2015-08-31 09:26:20 -07:00
Stanley Cheung 46687fe705 update android example readme 2015-08-27 16:28:38 -07:00
Stanley Cheung 61422d6295 add back protos and update references 2015-08-27 16:24:04 -07:00
Stanley Cheung e4987cd1f2 update reference to grpc-common to examples 2015-08-27 16:10:33 -07:00
Stanley Cheung fe3f964317 move grpc-common stuff to right location 2015-08-27 16:07:41 -07:00
Louis Ryan a4c821d94e Rename onValue to onNext in StreamObserver to align with the naming in Rx & the proposed Flow API in
Java9
2015-08-26 17:38:22 -07:00
Carl Mastrangelo a508c1d4f5 Remove Headers 2015-08-24 11:41:10 -07:00
Kun Zhang 042b278256 Remove the first MethodDescriptor constructor.
that takes the service name and method name separately.

Also fix tests that are still using the old full qualified method name
format.
2015-08-20 14:19:50 -07:00
Carl Mastrangelo 572f4332a7 Remove Trailers 2015-08-13 17:11:29 -07:00
Kun Zhang d2929cd1a3 Reorganize packages.
Reserve io.grpc for public API only, and all internal stuff in core to
io.grpc.internal, including the non-stable transport API.

Raise the netty/okhttp/inprocess subpackages one level up to io.grpc,
because they are public API and entry points for most users.

Details:

- Rename io.grpc.transport to io.grpc.internal;
- Move SharedResourceHolder and SerializingExecutor to io.grpc.internal
- Rename io.grpc.transport.{netty|okhttp|inprocess} to
  io.grpc.{netty|okhttp|inprocess}
2015-08-10 15:04:29 -07:00
Carl Mastrangelo b141093b3b Make serverInterceptor use MethodDescriptor 2015-08-07 09:28:29 -07:00
Carl Mastrangelo aebb58b200 Change awaitTerminated to awaitTermination 2015-08-06 13:52:17 -07:00
Carl Mastrangelo e76b8e7ee8 Renamed Server payload to message 2015-08-05 17:10:37 -07:00
Carl Mastrangelo 67fc45d036 Rename Duplex to Bidi 2015-08-05 17:05:47 -07:00
Kun Zhang eb92967a7e Get rid of AbstractServiceDescriptor as it is no longer useful 2015-07-17 17:03:36 -07:00
Kun Zhang 686dcff217 Rename unaryFutureCall to futureUnaryCall 2015-07-16 12:34:37 -07:00
Kun Zhang 690b26eb93 Sanitize ClientCalls.
- Remove blockingClientStreamingCall() which is not used, and we don't
  actually want that API.
- Rename duplexStreamingCall() to asyncDuplexStreamingCall() to align
  with other async methods.
- In unary call and client streaming call, do not request for additional
  response after the first response.
2015-07-15 17:35:36 -07:00
Kun Zhang 79f3f026f2 Migrate from PARSER to parser() as a way of getting the parser of a protobuf message.
This was done by #587 (commit af9fb6de77)
but was accidentally reverted by commit 73acc73dbf.
2015-07-15 16:55:26 -07:00
Kun Zhang 867c76d185 Separate ServerCall binding utilities per method type.
This gives us more flexibility in API changes in the future.

Unary call and server streaming call should call the flow-control method
call.request() only once. Previously it was called whenever a request
arrives, which is wrong. Now it's fixed.

Resolves #436
2015-07-14 13:36:16 -07:00
Kun Zhang c73b75e477 Change AbstractServiceDescriptor.methods() to Collection. Resolves #573 2015-07-09 14:24:51 -07:00
Kun Zhang 73acc73dbf Remove Method and switch its users to MethodDescriptor.
Resolves #511.

- In generated code, make CONFIG private and METHOD_* fields public.
  METHOD_* fields are MethodDescriptors now, users of the CONFIG field
  should switch to using the METHOD_* fields.
- Move MethodType into MethodDescriptor (#529).
- Unify the fully qualified method name. It is fully qualified service
  name + slash + short method name. It doesn't have the leading slash.
- HandlerRegistry switches the key from short method name to fully
  qualified method name.
2015-07-09 09:29:03 -07:00
Kun Zhang 35f77ee84b Upgrade to protobuf-gradle-plugin 0.5.0 2015-07-08 16:24:59 -07:00
Kun Zhang d3c5b00827 Add CallOptions.
- Pass CallOptions to Channel.newCall() and
  ClientInterceptor.interceptCall().
- Remove timeout from AbstractStub.StubConfigBuilder and add deadline,
  which is stored in a CallOptions inside the stub.
- Deadline is in nanoseconds in the clock defined by System.nanoTime().
  It is converted to timeout before transmitting on the wire. Fail the
  call with DEADLINE_EXCEEDED if it's already expired.
2015-07-07 14:28:38 -07:00
Kun Zhang af9fb6de77 Migrate from PARSER to parser() as a way of getting the parser of a protobuf message.
Upgrade to protobuf-3.0.0-alpha-3.1 that adds parser(). PARSER will go away eventually.
2015-06-30 23:14:21 -07:00
Kun Zhang a251171850 Upgrade to protobuf-3.0.0-alpha-3 2015-06-05 16:27:17 -07:00
Kun Zhang 2ee4d0228d Rename Call to ClientCalls.
Other classes are already following the convention that ClientFoo for
client-side, and ServerFoo for server-side. Call has been the black
sheep of the family.

- Call -> ClientCall
- Calls -> ClientCalls
- ForwardingCall* -> ForwardingClientCall*
2015-06-04 16:39:25 -07:00
Eric Anderson 8c9cc91844 Update generated proto output
The previous output was not generated with proto3-alpha-2. This has been
regenerated using protoc on Maven Central, so it should be the same
output everywhere.
2015-05-07 15:09:26 -07:00
Eric Anderson 1cf4cc81e8 Use CreateStartScripts for examples
This makes it easy to run our test client/server without the "magic" of
executing directly from Gradle. This makes it more obvious what code is
being run and prevents confusion due to Gradle "hanging" when starting
the server.

This also fixes build errors when running 'installDist' at the root
project.
2015-05-07 08:42:34 -07:00
Kun Zhang 111f6dd81e Allow people to skip codegen compilation.
Resolves #357

- Add project property ``grpc.skip.codegen``, which is false by default.
  People who don't change the codegen nor the proto files can set it to
  true so that they don't need to set up C++ compilation.
- Check in all generated files under ``src/generated``.
2015-05-06 09:56:40 -07:00
Kun Zhang 221c534f11 Fix build on Windows/VC++
- Stop defining custom architectures because VisualCpp toolchain doesn't
  allow it. Reference to built-in architectures 'x86' and 'x86_64' since
  they are supported by all toolchains.
- Remove 'local_arch' from platforms. For unsupported platform, we just
  do not specify the target.
- Target no more than one platform at a time. This simplifies the build
  script a lot.
- Remove the TARGET_ARCHS environment variable. Add system property
  ``arch`` to override ``osdetector.arch``.
- Add ``vc.disable`` to override the default choice of VisualCpp on
  Windows.
- Add ``vc.`` prefix to the properties that are only used with VC++
2015-05-04 09:25:49 -07:00
Kun Zhang 41940f7ff7 Upgrade to protobuf plugin 0.3.1
The plugin has been published on plugins.gradle.org

Conforming to the Gradle standard that plugin IDs must be name-spaced,
the plugin ID has been changed to com.google.protobuf.
2015-04-29 16:28:50 -07:00
Kun Zhang af18876713 Upgrade to com.google.protobuf:protobuf-gradle-plugin:0.1.0
Commit 76f0a09 after the previous release
(ws.antonov.gradle.plugins:gradle-plugin-protobuf:0.9.1) defers the
generation of generateProto tasks to post-evaluation of the project,
which make them no longer available in the evaluation phase. We need to
move the manipulation of these tasks to post-evaluation too.
2015-04-20 10:35:11 -07:00
zhangkun83 da3c3f8ced Solution for GRPC codegen deployment. 2015-04-16 15:07:36 -07:00
Eric Anderson 4f4f8e40bf Remove Guava's Service from server transport
ServerImpl.start() now throws IOException to make the error explicit.
This was previously being papered over by wrapping the exception in
RuntimeException.
2015-04-16 11:28:04 -07:00
Eric Anderson e23f899491 Split protobuf into its own project
We don't want core to depend on protobuf.
2015-04-10 15:50:56 -07:00
Eric Anderson d077290c40 Fix warnings (JavaDoc and [deprecated]) 2015-04-09 18:05:31 -07:00
zhaohaifeng 63db06850e Add simple HelloWord example handling custom header 2015-04-08 08:45:06 -07:00
Xudong Ma 9aae6f65fa checkstyle change:
1. Adds <property name="separateLineBetweenGroups" value="true"/> to CustomImportOrder to enfore blank line between imports groups.
2. Uses checkstyle 6.5, which fixed a bug of "CustomImportOrder checks import sorting according to ASCII order instead of case-insensitive alphabetical order".
2015-04-07 08:27:48 +08:00
Xudong Ma c813ec5ad1 Change the package option of example protos to be same as grpc-common 2015-04-02 17:12:37 +08:00
Eric Anderson 26141b445d Allow checkstyle failures fatal, and fix last issues
Failing disabled by default, but setting checkstyle.ignoreFailures=false
in ~/.gradle/gradle.properties enables failing. Travis will always run
with such failing enabled.
2015-03-23 09:10:53 -07:00
Eric Anderson f38c2a06d9 Add missing copyright headers 2015-03-16 22:11:10 -07:00
Eric Anderson c3e8dae6ce Add checkstyle checking
The checkstyle.xml is a slightly modified version of the upstream Google
checkstyle configuration. All changes have comment describing them.

Lots of warnings were corrected. Examples is the only project that has
warnings still, as the necessary changes require some thought.
2015-03-16 10:53:13 -07:00
Louis Ryan a623445b00 Fix IntelliJ project generation by including generated protobuf srcs 2015-03-12 13:46:14 -07:00
Ade Oshineye 9b5575daa1 Correct small grammar error in comment. 2015-03-03 00:11:50 +00:00
Eric Anderson b938ba5106 Support building on Windows
Protoc should be in PATH and the project properties protobuf.include and
protobuf.libs should be set. For example:

gradlew build -Pprotobuf.include=C:\path\to\protobuf-3.0.0-alpha-2\src ^
  -Pprotobuf.libs=C:\path\to\protobuf-3.0.0-alpha-2\vsprojects\Release

When running more than once, it is probably more convenient to create
%HOMEDRIVE%%HOMEPATH%\.gradle\gradle.properties with contents like:

protobuf.include=C:\\path\\to\\protobuf-3.0.0-alpha-2\\src
protobuf.libs=C:\\path\\to\\protobuf-3.0.0-alpha-2\\vsprojects\\Release
2015-03-02 13:34:09 -08:00
nmittler 2c7c32d227 More example changes to match style guide. 2015-02-27 11:04:42 -08:00
nmittler 81cc0daea7 Updating examples to be consistent with proto3 styleguide. 2015-02-27 09:18:19 -08:00
Jayant Kolhe 02a02c3084 Update README.md
Adding link to Java Tutorial from Readme
2015-02-26 05:21:03 -08:00
nmittler 87daf0e0dc Adding HelloWorld example to grpc-java repo. 2015-02-25 10:56:51 -08:00
nmittler b897a89e78 Adding RouteGuide example and deleting others. 2015-02-24 13:58:16 -08:00
Louis Ryan 95c6f5082c Udate TODOs to use Github user names 2015-02-23 12:46:28 -08:00
Eric Anderson 3af5add7b2 Add java_package proto option for portability
Some protoc Java environments have a package to put all proto namespaces
under, since proto namespaces aren't aligned with Java packages.
2015-02-23 10:38:08 -08:00
Jakob Buchgraber 246e8b52bb Add build file and instructions to examples directory. Fixes #43 2015-02-18 15:58:27 -08:00
nmittler 8bc72b8e9f Updating examples based on recent changes. 2015-01-29 09:57:19 -08:00
nmittler f83145865a Removing all references to "stubby" 2015-01-27 11:25:25 -08:00
ejona 4de2026492 Fix TODO attribution
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=84172357
2015-01-16 16:23:05 -08:00
ejona 7235a396b8 Remove Service API from ChannelImpl
This change loses asynchronous notification of channel state-change and
a way to wait until the channel is actually connected. Both of these are
expected to be added back as part of a health API. The important
distinction from Service is that ChannelImpl never permanently fails and
can revert from being started to connecting again.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=83875407
2015-01-15 13:42:49 -08:00
lryan 56e307fcb6 Add BSD license header to all source files
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=81447025
2015-01-08 14:43:17 -08:00
zhangkun b186b377e8 Remove client-streaming and bi-di streaming methods from blocking client interface.
The current signatures are not more useful than the async counterparts,
we'd rather not have them until more sepcific requirement comes up.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=80402647
2015-01-08 14:43:11 -08:00
zhangkun a71d887661 Make all transport factories package-private in favor of channel builders.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=79367593
2015-01-08 14:43:04 -08:00
simonma 8b0b46eff5 Move examples to third_party.
Remove FormattingLogger usage.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78798688
2015-01-08 14:43:02 -08:00