Commit Graph

6496 Commits

Author SHA1 Message Date
zhangkun bb9699e429 Fixes a few issues in netty server transport:
- Creates and passes a transport instance to ServerListener.transportCreated().
- Keeps the "/" prefix of the fully qualified method name when passing it to the handler
registry.
- Adds necessary "this." when accessing a member variable in ServerCalls.
- BlockingResponseStream.buffer should be added with BlockingResponseStream.this as
as the mark of end of data.

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76922440
2015-01-08 14:42:52 -08:00
lryan 53acb1c8f9 Remove the old & new HTTP transports as they are incapable of supporting trailers using their
current implementations. Can be revived later if needed.

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76793542
2015-01-08 14:42:52 -08:00
simonma 52f92d06ee Use our own SerializingExecutor.
Also removed some unused imports and fixed some warnings.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76747713
2015-01-08 14:42:51 -08:00
zhangkun 01c96175fd GRPC server codegen: generates the bindService() method that returns a
ServerServiceDefinition that connects the server with application-provided
service implementation.

Introduces a class Method, that holds the invariables of a method that are
inferred from the proto file, to be reused for creating MethodDescriptor
for client code and ServerServiceDefinition for server code in the generated
class.

Adds ServerCalls that contains the functionalities that is used by the
bindService() method in the generated class. It minimizes the logic in the
generated code.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76741797
2015-01-08 14:42:51 -08:00
wonderfly 1dcc3c77c6 Added SSL support to gRPC java server used for integration tests.
Modification made to the old transport so this is a temporary CL.
Implementation is a bit hacky but given that the old transport is going
away, it is good for now.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76707856
2015-01-08 14:42:50 -08:00
ejona 653ffd98d2 ServerImpl
Interfaces were corrected. ChannelImpl was updated to use same style of
exception handling of ServerImpl.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76702816
2015-01-08 14:42:50 -08:00
lryan eb3fc58ce5 Create an in-process adapter between ClientTransport and HandlerRegistry
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76604751
2015-01-08 14:42:50 -08:00
scottpeterson 8f6e2c2270 Fix UNAUTHENTICATED status to point in Java Status class to point to correct code.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76473036
2015-01-08 14:42:49 -08:00
lryan 71e4a92c10 First steps in reducing dependency on proto from runtime.
- Remove transport.proto and move status codes into Status.java with a little refactoring to make
status easier & more precise to use
- Move DeferredProtoInputStream into a proto subpackage
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76392172
2015-01-08 14:42:49 -08:00
nathanmittler 65be3c72d9 Simple echo client.
I've modified ejona@'s original CL to fix some issues involved with
receiving status in trailers.

Also have a fix that should make the Java client properly flush when
writing.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76361782
2015-01-08 14:42:48 -08:00
simonma f7bbb9734c Removed proto dependency from Buffers.java:
1. Removed ByteSting related code (and copyFrom() method, since no one is using it).
2. Removed BuffersByteStringTest.java
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76308473
2015-01-08 14:42:48 -08:00
lryan 1369ea1d21 Metadata improvements.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76175838
2015-01-08 14:42:48 -08:00
ejona 55794111bd Fix reference counting misaccounting.
The fact that duplicate, slice, et al. don't retain() even though they
hold a reference to the originating ByteBuf seems very bug-prone.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76126682
2015-01-08 14:42:47 -08:00
ejona 6fc356b13d Split out a ClientStreamListener from StreamListener.
Headers and trailers are only received on client-side, so we need a
client-specific listener. Close() also has slightly different semantics
between server-side and client-side.

Most of the changes are simple name changes, but AbstractServerStream does update to the new close() semantics.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76094225
2015-01-08 14:42:47 -08:00
ejona 9d50299a04 Plumb trailer passing through transport streams.
We purposefully avoid going through the (de)framer, since close()
behavior is specific to whether on client or server.
AbstractClientStream and AbstractServerStream handle mapping the events
to appropriate semantics, but require stashing status/trailer for later
use.

It was very interesting getting to a point where we could support the old
and new protocol; that is probably the most detailed-oriented portion of
the CL. There are some interface hacks going on, but those will
naturally be removed when we trash the gRPC v1 framer.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76092186
2015-01-08 14:42:46 -08:00
nathanmittler fc7a052c07 Updating gRPC code to the latest Netty version which supports binary headers.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=75853353
2015-01-08 14:42:46 -08:00
ejona ef2129c7d2 Add halfClose() to StreamListener.
This is required to be able to distinguish between the client having
finished sending and the RPC being complete.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=75819962
2015-01-08 14:42:45 -08:00
ejona 913de47b61 Add support for new gRPC protocol
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=75809789
2015-01-08 14:42:45 -08:00
ejona 029f0d22f8 Don't use switch on string, for Java 6 compatibility
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=75322297
2015-01-08 14:42:45 -08:00
ejona 57bfc6a01d Remove dependency on ByteBuffers.
ByteBuffers is not generally available.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=75321682
2015-01-08 14:42:44 -08:00
nathanmittler 23fbc7cb5e Adding support for manually specifying HTTP/2 :authority and :path headers.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=75316631
2015-01-08 14:42:44 -08:00
lryan a7d735e69b Phase 2 of converting to new Headers mechanism for side-channel.
Remove 'context' from interfaces/tests/framers/...

Next phases
- Switch the wire format (ESF needs to be done in near lock-step)
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=75164642
2015-01-08 14:42:43 -08:00
lryan e4bd1c7d69 Phase 1 of converting to new Headers mechanism for side-channel.
Introduces Header and uses it for propagating text-only header values over existing transports
Leaves Context & wire format otherwise unchanged

Next phases
- Remove context from interfaces
- Switch the wire format (ESF needs to be done in near lock-step)

Interface changes are relatively light
Headers class is functional but not optimal
All serialization is done as string until transports expose interface for binary headers
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=75050265
2015-01-08 14:42:43 -08:00
ejona 23ac15a8ba Use String instead of MethodDescriptor in ServerCallHandler.
Using MethodDescriptor before was abusive, but the alternative was not
clear.

The new gRPC protocol causes things to become more obvious. Headers,
method name, and timeout were the interesting things on the
MethodDescriptor. In the new protocol, headers are no longer going to be
treated differently from context. We are fine with passing the method
name. So that leaves just timeout, which we really will need more
methods for on the ServerCall object anyway.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=74889759
2015-01-08 14:42:42 -08:00
simonma 8f3e9eede7 Remove usage of ImmutableXX collectors from calsses that GRpc Android version will care.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=74880326
2015-01-08 14:42:42 -08:00
simonma 18eb63bc16 Remove dependencies on Google common internal:
1. logging.FormattingLogger, change to use java.util.logging.Logger.
2. util.concurrent.SerializingExecutor, make a copy to our code base.
3. io.ByteBuffers, not needed anymore.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=74803598
2015-01-08 14:42:41 -08:00
ejona 92938d1b06 Mimic MethodDescriptor in ServerMethodDefinition when serializing messages.
There is little use in providing the Marshallers directly from the
Definition.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=74790187
2015-01-08 14:42:41 -08:00
ejona 8b23526c31 Correct tense of ServerCall.Listener.onCompleted().
The rest of the methods are present tense, so onComplete() is more
appropriate than onCompleted().
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=74703245
2015-01-08 14:42:41 -08:00
nathanmittler 43d2fcc664 Adding inbound flow control to Netty client and server transports.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=74444530
2015-01-08 14:42:40 -08:00
zhangkun 048649e5e4 Implements the netty-based server transport.
Interface changes
- Moves halfClose() from Stream to ClientStream, because it's only valid on the
client and ServerStream already has close().

Implementation details
- Splits the cient-specific logic from AbstractStream and forms
AbstractClientStream.
- Creates AbstractServerStream for server-specific logic
- Creates NettyServerHandler which is the server counterpart of NettyClientHandler
- Refactors NettyClientHandlerTest and NettyClientStreamTest to share code with
NettyServerHandlerTest and NettyServerStreamTest
- Updated NettyServer to work with the transport.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=74347890
2015-01-08 14:42:40 -08:00
ejona 4e315e0110 Fix more transport error and shutdown scenarios.
Previously, if the active transport had failed but there were still other running transports, we would claim to be shutdown before we actually were (and would end up calling notifyStopped twice).

Also, if a transport immediately failed during startup, we could end up setting activeTransport to the already-failed transport, which meant we would perpetually try to use that broken transport.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=74339777
2015-01-08 14:42:39 -08:00
ejona 4a3b5d1edd Fix possible NPE when starting a transport fails before startAsync() returns.
transportFailedOrStopped() sets activeTransport to null, but
obtainActiveTransport expected it to be non-null because it just set it.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=74264310
2015-01-08 14:42:39 -08:00
nathanmittler e081a2290b Updates to GRPC code resulting from Netty upgrade.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=74249351
2015-01-08 14:42:39 -08:00
simonma b645b38a6a Fix a NPE, Http20Draft12 requires non-null debugData for FrameWriter.goAway().
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=74143304
2015-01-08 14:42:38 -08:00
ejona 070e308763 Have stricter dependencies and build in modules.
This is useful in making sure we don't have stray dependencies and brings us closer to compiling for platforms like Android. We can now remove unwanted dependencies one module at a time, or get individual modules to build on Android.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=73849551
2015-01-08 14:42:38 -08:00
ejona 7a2d8df753 Move OAuth integration to third_party.
It should have been in third_party to begin with.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=73826831
2015-01-08 14:42:38 -08:00
ejona 603959e640 Remove unused ByteBufDeframer.
It was previously replaced by the new deframer.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=73750795
2015-01-08 14:42:37 -08:00
ejona 3184bb8fec Fix all the generics! (in ServerInterceptorsTest)
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=73670835
2015-01-08 14:42:37 -08:00
ejona 886f40d8b7 Add missing generics for ServerMethodDefinition in ServerServiceDefinition.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=73663037
2015-01-08 14:42:37 -08:00
ejona 290d657dc4 Remove unnecessary Generic parameters from ServerCall.
The client Call needs both parameters because it containts start(), but
ServerCall doesn't actually have that same need.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=73662252
2015-01-08 14:42:37 -08:00
nathanmittler 42af07c64d Upgrade GRPC Java/Netty to HTTP/2 draft 14.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=73648766
2015-01-08 14:42:36 -08:00
ejona 34aede347a Move inner classes out of Server.
This is only a move with appropriate code changes to use the new class
names. The only functional change was changing the visibility of
MethodDefinition's constructor to package-private so ServiceDefinition
could construct it.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=73569974
2015-01-08 14:42:36 -08:00
ejona ba71ee91bf Swap Server from Builder to HandlerRegistry.
The idea is that Server would be provided a HandlerRegistry at construction time.

This has a simplistic implementation of HandlerRegistry. If we like the API, then I can implement a lock-less version as we find need.

Most classes are still under Server so that it is obvious what changes were made. Moving things out of Server would be a separate CL.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=73334671
2015-01-08 14:42:36 -08:00
nathanmittler 64eae04d14 Refactoring Deframing code for Netty.
- New Decompressor interface with NettyDecompressor impl. This is responsible for unpackaging and uncompressing the GRPC compression frame.

- New class GrpcDeframer. This is a transport-agnostic class that uses a Decompressor to unpackage the compression frame, and then reads one complete GRPC frame and notifies the listener.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=73068835
2015-01-08 14:42:35 -08:00
zhangkun e1ae25c8c4 Makes the Status-generated exceptions contain the status code.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=72950983
2015-01-08 14:42:35 -08:00
angusdavis 1a87ab2909 Rollforward of 72928317 with fixes to grpc_java_external.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=72934580
2015-01-08 14:42:35 -08:00
simonma 1966d5b7f3 Make sure Stream.cancel() can be called multiple times.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=72928049
2015-01-08 14:42:34 -08:00
simonma f2c4c8555a Update integration tests.
1. Use okhttp client transport for okhttp tests.
2. Utilize GrpcClient to construct channel according to the transport type.
3. Remove the unused middle layer abstract tests after above changes.

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=72732333
2015-01-08 14:42:34 -08:00
zhangkun c7d33bf3c8 Define threading expectation for Stream
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=72590025
2015-01-08 14:42:34 -08:00
ejona 621706aa03 Add basic OAuth support to gRPC.
The primary functionality is an interceptor that authenticates calls using oauth. However, most of the changes are for an integration test to make sure the code works with ESF.

This is based on work by lryan and simonma.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=72567773
2015-01-08 14:42:33 -08:00