Commit Graph

291 Commits

Author SHA1 Message Date
Eric Anderson 9bc5d93e4a Mark generated abstract class as Experimental 2016-04-19 12:35:04 -07:00
Carl Mastrangelo faaaa160df Fix compilation nags for generated code 2016-04-18 15:47:44 -07:00
Lukasz Strzalkowski 363e0f6cfc Print compiler version number in generated files 2016-04-11 19:35:19 -07:00
Lukasz Strzalkowski 2fbf142a41 Provide base methods for Abstract stub
Default implementation returns status UNIMPLEMENTED. This allows adding
new methods to services without breaking existing code.
2016-04-11 16:38:23 +02:00
Łukasz Strzałkowski 90fbf9b274 Adapt BindableService in ServerBuilder#addService
Makes binding services to server as simple as it can get.
2016-04-08 11:14:26 -07:00
Lukasz Strzalkowski f8b71e72b3 Add Abstract{ServiceName} class in compiled service class 2016-04-07 17:39:17 -07:00
Eric Anderson 0a01b3cf42 Simplify nano flag to codegen to just 'nano' from 'nano=true'
'nano=true' still works, but any value is now ignored. This is to align
with our lite flag, but also just because It's Cleaner.

Note that this is counter to what javanano does. Javanano requires all
flags have a value and uses true/false for many values.
2016-03-30 09:34:22 -07:00
Eric Anderson b22bcdfd18 Use lite argument in codegen instead of LITE_RUNTIME
This allows using the same proto file for both client and server without
forcing the server to use lite.
2016-03-29 16:19:56 -07:00
Eric Anderson 99a6d8de27 Add native support for Protobuf Lite
Lite already worked by using the protobuf project, but would bring in
extra dependencies that are not intended to work with lite. Although
protobuf is not yet providing a lite package on Maven Central, we will
be able to swap to it once it is available.

There isn't any new original code in the Java portion, except for a new
overload in ProtoUtils that accepts Message instead of MessageLite.
Depending on Message in ProtoUtils allows us to support extra features
out-of-the-box without any changes to the generated code. For example,
JSON encoding could be supported in this way if Marshaller is enhanced.

However, now codegen must be aware of Lite in order to choose with Util
class to use. That is new code.
2016-03-22 15:40:51 -07:00
Eric Anderson 7c6c045d92 Remove support for Nano's deprecated package names
This requires that all nano protos have .nano in their package name. The
support is expected to be removed from protobuf soon, since using the
deprecated package name causes problems.
2016-03-10 11:00:32 -08:00
Carl Mastrangelo ffe0dce85f Add missing override annotation to generated protos 2016-03-04 14:15:02 -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 daf920d4b4 Pass -j to correct command
Passing -j to ./configure produces an error
2016-02-17 11:44:28 -08:00
Eric Anderson bf42913c23 Fix artifact upload for compiler
check-artifact.sh was broken by the update to Gradle 2.10. We think the
update to Gradle 2.8 caused the POM to start being generated, but this
now fixes it to have the correct contents.

Using addFilter _disables_ the normal POM, so we use setFilter instead.

Fixes #1360
2016-01-29 17:16:58 -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
Kun Zhang 29784d1afb Fix grpc-compiler build. 2016-01-26 15:30:35 -08:00
Eric Anderson 46ce4098c5 Update gradle to 2.10
Gets us past some minor DSL changes and should get increased build
performance. Will make it easier to update to 2.11 and other future
versions.
2016-01-26 13:38:04 -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 1d8af602f7 Run make with as many cores as available 2016-01-25 09:35:42 -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
Xudong Ma 5667f0e3a6 Add "using std::to_string" to java_generator.cpp, it is needed by internal version. 2015-10-16 09:32:36 -07:00
Eric Anderson a62db8f283 Update comment; Parser was replaced with NanoFactory 2015-10-14 13:54:23 -07:00
Eric Anderson 1ee336d244 Use one codegen class for all Nano factories
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 degration because the
contiguous switch uses tableswitch bytecode.

ARG_IN_ and ARG_OUT_ are prefixes as otherwise there could be a name
collision with an oddly-named method. Since the other fields are
prefixed with METHOD_ they can't collide.
2015-10-14 13:53:22 -07:00
Xudong Ma f7f57b79c9 Put nano generated code into nano package, unless option javanano_use_deprecated_package is set.
Also fix the behaior while java_package is set to empty.
2015-09-28 09:49:02 -07:00
Eric Anderson d04994f044 Update Windows building instructions for proto3b1 2015-09-24 15:50:28 -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 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
Eric Anderson d42559c6af Swap nano from Parser to message factory
This reduces the amount of logic built into the generated code. If we
swap to an alternative form of decoding we should have greater ability
to adapt the existing API to make use of the new one. Previously most
changes would require duplicating all the nano marshalling code.
2015-09-03 17:31:16 -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
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 bc347e3f6a Display the required Protobuf version when building codegen 2015-09-01 16:02:12 -07:00
Kun Zhang db0423cf24 Rename CHECK and FAIL macros to avoid conflict with internal macros when syncing back 2015-09-01 12:47:25 -07:00
Kun Zhang c00e15f9a2 Check javanano_use_deprecated_package in the message's FileDescriptor, not the current file's. 2015-08-31 14:55:44 -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
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
Kun Zhang cadc0b2681 Fetch the latest Protobuf sources before checking out the release.
The protoc-artifacts may have been created at previous release, which
may not contain the latest Protobuf release.
2015-08-13 14:30:40 -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
Eric Anderson 74490d5f6b In compiler documentation, use grpc-java as plugin name
grpc-java is the implicit name of our plugin, due to its file name. No
need to use another name for it.
2015-06-24 13:13:03 -07:00
nmittler 483738e8bc Reorganizing the deployment docs. 2015-06-10 13:15:04 -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 7d906c569d Fix minor issues with release scripts/documentation 2015-05-20 15:15:18 -07:00
Kun Zhang 8bc992091c Add Dockerfile for codegen distribution 2015-05-13 07:58:41 -07:00
Kun Zhang 9805e27569 Add property ``protoc=/path/to/protoc``
This allows people who cannot run the pre-compiled ``protoc`` pulled
from Maven Central to use their own ``protoc``.

Upgrade to protobuf-gradle-plugin:0.4.1 to display error messages of
protoc failures.
2015-05-12 17:34:40 -07:00
Kun Zhang 287a27a930 Upgrade to protobuf-gradle-plugin:0.4.0
Use the plugin to compile nano for golden test and get rid of the shell
script.
2015-05-11 16:38:22 -07:00
Kun Zhang 2f7497133d Unify build properties.
- Switch all system properties to project properties.
- Use the ``javaLocalNamingStyle`` instead of the
  ``dot.delimited.style`` for property names, so that it can be directly
  referenced by ``rootProject.propertyName``.
- Recommend users to put GRPC-specific properties in project-level
  ``build.properties`` instead of the user-level.
2015-05-07 14:14:10 -07:00
Kun Zhang c5b94c7525 Use protoc from Maven Central. 2015-05-07 11:18:43 -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 a8ef36af16 Create DEPLOYING.md that documents instructions for deploying artifacts.
Move deployment instructions of compiler/README.md there too.
2015-04-23 13:49:26 -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
Kun Zhang 4bc2d6d9a4 Remove call sites of Os.isFamily(). Use osdetector instead 2015-04-17 16:35:23 -07:00
Kun Zhang 0c2ea1550b Fix Mac build failure introduced by commit da3c3f8
- Add -lprotobuf etc to linker.args if libprotobuf.a etc doesn't exist in
  LDFLAGS
- install does not do architecture and dependency check on the artifacts,
  because it may produce non-publishable artifacts due to the above
  change.
2015-04-17 16:32:13 -07:00
zhangkun83 da3c3f8ced Solution for GRPC codegen deployment. 2015-04-16 15:07:36 -07:00
Eric Anderson 3666de4427 Use more precise names for protobuf and nano
io.grpc.nano sort of seems like a "small" version of grpc-java. And
io.grpc.proto could also mean multiple things. Using "protobuf"
and "protobuf nano" gets us consistent names that are still
understandable, predictable, and more similar to protobuf project
itself.
2015-04-10 16:35:23 -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
Kun Zhang 90706dc48f Rename the codegen binary from java_plugin to protoc-gen-grpc-java 2015-04-09 15:24:46 -07:00
Eric Anderson a0acb9b9a8 Working Travis build, with caching of deps 2015-03-20 14:27:32 -07:00
Louis Ryan c42c8c420d Basic travis configuration 2015-03-20 11:37:30 -07:00
Eric Anderson c5bcbc62fe Handle spaces in shell script 2015-03-13 15:26:45 -07:00
Eric Anderson 76d0955a6e Clean up warnings
-Xlint:-options is not available on some earlier JDK 7s, but won't fail
if unsupported. It prevents the warning wanting bootclasspath specified
since target/source is 1.6.
2015-03-12 17:37:32 -07:00
Eric Anderson 192144eaf9 Add Sonatype OSSRH upload support, with nice POMs
Mockito was upgraded to latest to solve JavaDoc issue with
ArgumentsAreDifferent.

We don't yet publish any artifacts for grpc-compiler.
2015-03-02 15:20:06 -08: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
Xiao Hang 6f0b21ee92 Update compiler/README.md with nano codegen commandline 2015-02-26 11:19:59 -08:00
Eric Anderson ff2a28535a Swap to proto3
Benchmark remains proto2 as the .proto has defaults that will need to be
adjusted.
2015-02-25 21:50:37 -08:00
Jakob Buchgraber df321fed73 Create temporary directory for javanano test if it does not exist.
The gradle task testNanoGolden fails because the temporary folder it tries to use does not exist.
The task tries to write files to temporaryDir which points to ./compiler/build/tmp/testNanoGolden/ on my machine.
The directory does not exist by default and so the run_nano_test.sh fails.
2015-02-25 21:47:28 -08:00
zsurocking 5902c6a3bb Revert "Remove nano codegen test temporarily. Currently I haven't figuired" 2015-02-25 20:54:53 -08:00
Xiao Hang b8f5c90e48 Remove nano codegen test temporarily. Currently I haven't figuired
out how to make it work with "gradle clean build"
Somehow temporaryDir is not created when doing gradle clean build,
so the test complains about path not found
2015-02-25 20:43:33 -08:00
Xiao Hang dcff315dc3 Add nano support to Java codegen. Now the user can specify a flag nano=true
to generate naon related code in grpc service interface

Commandline example:
protoc --plugin=protoc-gen-java_rpc=build/binaries/java_pluginExecutable/java_plugin \
  --java_rpc_out=nano=true:"$OUTPUT_FILE" --javanano_out=ignore_services=true:"$OUTPUT_FILE" \
  --proto_path="$DIR_OF_PROTO_FILE" "$PROTO_FILE
2015-02-25 14:38:03 -08:00
Louis Ryan 95c6f5082c Udate TODOs to use Github user names 2015-02-23 12:46:28 -08:00
nmittler f12996086b Fixing compiler build on OS X (Clang) 2015-01-30 15:03:33 -08:00
Eric Anderson fb28ad235b Improve Gradle build of protoc grpc plugin
A Gradle protoc plugin is used for generating and compiling the grpc
codegen. The code organization was changed to match what Gradle expects.

Proto 3 is now required.
2015-01-30 10:19:32 -08:00
Eric Anderson 2049e0d618 Have Gradle observe LDFLAGS/CXXFLAGS/CPPFLAGS
This allows building with a private proto installation (one in home
directory or elsewhere) by specifying -I and -L.
2015-01-29 13:17:11 -08:00
nmittler f83145865a Removing all references to "stubby" 2015-01-27 11:25:25 -08:00
zhangkun83 03f3f5cd97 Reorder the fields of LogHelper to be consistent with initialization order because blaze would complain about it 2015-01-26 15:56:52 -08:00
zhangkun83 d54a463871 Add README.md in the compiler directory 2015-01-26 11:33:11 -08:00
zhangkun83 5e6078594b Add test target for codegen.
Make all test messages empty since we are not testing protobuf
generator.
2015-01-22 16:04:02 -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
zhangkun 9de8e4b569 Make Java codegen ready for open-source. It can be built with the Github HEAD
of opensource protobuf.

- Moved to third_party under GRPC Java directory
- Using Gradle to build
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=84053803
2015-01-15 13:42:49 -08:00