Commit Graph

2009 Commits

Author SHA1 Message Date
Louis Ryan 986d221eaa Fix issue where close can be called in a reentrant fashion by framer writing causing exception to be thrown by transport 2015-04-28 12:46:48 -07:00
Louis Ryan f679edcfcc Fix memeory leak in MessageFramer caused by allocation of 'empty' buffers never being released.
The buffers are not empty in reality as the allocators enforce a minimum size
2015-04-28 10:10:00 -07:00
Xudong Ma d0aad72441 okhttp: Clean up stream when error happens.
Resolves #279
2015-04-27 14:07:43 -07:00
Xudong Ma 2f4aa5a490 Use Status "UNKNOWN" instead of "INTERNAL" when Status.fromThrowable can not find a cause with a status. 2015-04-24 10:52:27 +08:00
Louis Ryan f7010f2eac Use message size as a hint to the allocator for buffer capacity.
Set upper and lower bounds for Netty & OkHttp allocators based on transport limitations and benchmark results.
Fix OkHttp OutboundFlowController to chunk payloads larger than frameWriter.maxDataLength
Allow OkHttp to allocate buffers to FrameWriter larger than max DATA length
2015-04-23 16:58:43 -07:00
Eric Anderson fc3e41674b Propagate explicit flushes through MessageFramer
MessageFramer allows queing of data and explicit flushing. Sinks
generally can benefit from knowing when they are required to flush, so
we now tell them when MessageFramer received a flush so they only have
to flush when required.
2015-04-21 10:29:08 -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
nmittler f920badc5e Upgrading to the latest Netty version. 2015-04-16 08:42:56 -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
Kun Zhang 0d89d3d1bc Fix the issue where the intecepting call fails in start(), does not
call super.start(), and makes the subsequent use of other methods on the
call throw IllegalStateException.

Create ClientInterceptors.CheckedForwardingCall that handles exception
in start logic.

Create Forwarding[Server]Call[Listener] for generic decoration use
cases, with an abstract delegate() for flexibility.

Create SimpleForwarding[Server]Call[Listener] to replace now deprecated
forwarding classes.
2015-04-09 15:56:03 -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
Eric Anderson 45682dbc18 Hold lock while reading isThreadScheduled
isThreadScheduled is @GuardedBy("internalLock").
2015-04-06 14:13:49 -07:00
Eric Anderson d70d91b5d6 Improve JavaDoc for Status 2015-04-03 16:07:46 -07:00
Xudong Ma 2cad9e6000 Add "unsed import" check. 2015-04-03 16:55:01 +08:00
zhangkun83 966e120098 Add precondition to throw more informative exception when calling request() before start() has been called. 2015-03-26 10:54:59 -07:00
Thomas ten Cate 9175d9d79e Fix data corruption issue receiving payloads > 2kB
Also add OkHttpReadableBuffer unit test, and increase the test string
length to expose the bug.

Also use array equality assertions in the base test, instead of
comparisons whose return value is discarded.

Fixes #231.
2015-03-22 13:14:57 +01:00
Eric Anderson a6edc294fc Improve Status exception message
When the description is null, the exception message would be in the form
of "INTERNAL: null", which isn't very attractive, and makes it seem like
an error in itself. If the description is null, just use "INTERNAL".
2015-03-20 10:29:11 -07:00
Eric Anderson 78cde0ddc0 Move Status.toString next to other methods 2015-03-20 09:47:34 -07:00
nmittler 23972a25b9 Adding outbound flow control API for the transport API 2015-03-16 14:17:03 -07:00
nmittler 9f5614501d Adding outbound flow control API for Call/ServerCall 2015-03-16 12:59:15 -07:00
Eric Anderson 040007ec17 Add package statement to HttpUtilTest 2015-03-16 12:38:07 -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
Jakob Buchgraber 0076243063 Add WritableBuffer interface for zero copy data writes. Fixes #8
WritableBuffer is a generic interface that allows to transfer data
from gRPC directly to the native transport's buffer implementation.
2015-03-13 13:00:44 -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 acfe3def6e Stall MessageDeframer pro-actively
This allows sooner delivery of errors. We never needed to stop delivery
for unexpected EOS, but instead the application would have been required
to request() another message before delivering. Stalling MessageDeframer
sooner removes the need for the application to request another message
before noticing that the buffers are empty.
2015-03-12 11:28:19 -07:00
Eric Anderson 238a4cb620 Add two extra cases to make edge case testing more obvious. 2015-03-11 15:14:28 -07:00
Eric Anderson 8986fc3412 Reorganize tests. Tweak Javadoc formatting 2015-03-11 15:10:35 -07:00
Eric Anderson 0e904f08e0 Tweak Http2Error and add tests 2015-03-11 14:45:03 -07:00
nmittler 2a425090d1 Migrating to Netty 4.1
Fixes #164
2015-03-11 13:18:27 -07:00
Jorge Canizales ad5ae259bb Fixes javadoc errors 2015-03-10 09:24:06 -07:00
Nathan Mittler f1b6f623c5 Merge pull request #166 from nmittler/doclint
Tightening up error message for GO_AWAY.
2015-03-09 13:49:03 -07:00
nmittler dfcfb7bca1 Tightening up error message for GO_AWAY.
The attempt here is to identify all causes of GO_AWAY and to ensure
there is a reasonable description to help understand the cause.

Fixes #163
2015-03-09 13:48:15 -07:00
nmittler 4deff027ba Proper buffer closure when receiving DATA with EOS
The Http2ClientStream should not close the buffer in this case since
it's already been given to the deframer and potentially to the user.

Added cleanup code to MessageDeframer and AbstractClientStream to make
sure that we free the Buffer when appropriate.
2015-03-09 13:28:32 -07:00
nmittler 732cfc0d55 Disable Javadoc doclint on Java 8
It breaks the build.
2015-03-03 07:59:13 -08:00
zhangkun83 ef87818758 Polish javadoc for transport/ 2015-03-02 11:10:29 -08:00
Louis Ryan 46dd47f86b Cleanup Javadoc for Channel, ServerCall and their related classes. 2015-02-25 14:22:12 -08:00
Louis Ryan 425e3c0b7f Remove dead GrpcFramingUtil class 2015-02-23 17:44:23 -08:00
Louis Ryan 95c6f5082c Udate TODOs to use Github user names 2015-02-23 12:46:28 -08:00
Eric Anderson ee6c9d7b52 Add scary JavaDoc to Metadata.setAuthority() 2015-02-20 08:54:08 -08:00
Eric Anderson dbf7d529bd Make sure to close InputStream even if cancelled 2015-02-20 08:52:51 -08:00
Jakob Buchgraber 07d0917b94 Add ServerImpl#awaitTerminated() method. Fixes #80 2015-02-18 16:00:34 -08:00
Eric Anderson e26608fe91 Avoid MoreObjects for "old guava" compatibility
Some early grpc users on Android are using a very old Guava. They are
working on upgrading, but it will take time. This alone is not enough
for "old guava" compilibility; expect more to come.
2015-02-13 17:06:46 -08:00
Eric Anderson 74f231a6dd Remove Guava Service from ClientTransport
OkHttp no longer cancels all calls on shutdown, as we want to allow
graceful shutdown. Such cancelling behavior will likely be provided by
Channel in the future.
2015-02-12 15:20:22 -08:00
Eric Anderson db0d8ad8c4 Only run terminationRunnable once 2015-02-12 15:17:12 -08:00
nabeelmian d2e35b0d02 Added utility class, ForwardingServerListener, that forwards calls to
underlying ServerCall.Listener.

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=85910420
2015-02-09 13:09:19 -08:00
Eric Anderson 8aa79b39fc Improve thread safety of newStream()
OkHttp should now have a thread-safe implementation of newStream.
Previously 'lock' was not held when checking goAway and the checking in
AbstractClientTransport was redundant.

Netty was thread-safe, but it was very hard to tell what guarantees were
necessary and what guarantees each piece was providing.
2015-02-06 14:12:01 -08:00
Eric Anderson f3a90cd42b netty: Cancel stream if interrupted during create
Previously streams were being partially orphaned if there was an
interruption during stream creation. To handle cancellation,
AbstractClientStream's cancel() had to be changed remove the
"optimization" otherwise, again, the stream would be orphaned.
2015-02-04 15:46:27 -08:00
nmittler d0e883ac20 Fixing integration tests
Allowing MessageDeframer.request to be called after the deframer has
been closed.  The stub helpers blindly call request after receiving each
message.
2015-01-30 10:15:30 -08:00
nmittler 89b8d7ff47 Moving decompression to the channel thread. 2015-01-29 14:55:40 -08:00
nmittler f83145865a Removing all references to "stubby" 2015-01-27 11:25:25 -08:00
Eric Anderson aeeebb7cdb Remove Service API from ServerImpl
Fixes #21
2015-01-27 09:20:24 -08:00
nmittler 19052499f7 Removing Maven build 2015-01-27 08:57:37 -08:00
nmittler 02c953e5e0 Migrating run scripts to gradle. 2015-01-26 15:26:11 -08:00
Eric Anderson d0adadbc1f Use proto interface instead of concrete class 2015-01-26 10:23:05 -08:00
Eric Anderson ada32b0cb1 Optimize number of DATA frames for unary requests
Resolves #10
2015-01-22 16:45:20 -08:00
nmittler de3a13164f Changing gRPC Java inbound flow control model
The goal is to mirror the token-based approach used by the Reactive
Streams API.
2015-01-22 11:46:16 -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
simonma f589a4acbb Remove traces of gRPC v1 protocol vs gRPC v2 protocol.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=84087425
2015-01-16 11:03:38 -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
ejona 198a756b83 Add toString to Headers and Trailers
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=83856622
2015-01-15 13:42:46 -08:00
simonma 828f941e99 Remove dependency on guava Lists for initializing list.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=83808289
2015-01-15 13:42:43 -08:00
ejona 3a29c98d40 Don't overwrite transportError in DATA processing
There may already be a transportError, in which case we want to augment
it and not overwrite it.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=83807747
2015-01-15 13:37:38 -08:00
nathanmittler 11c363a7ae Disallowing message delivery after status has been delivered to the listener.
Summary of changes:

1) Merged the interfaces MessageDeframer2.Sink and DeframerListener into
MessageDeframer2.Listener. This simplifies the interface of
MessageDeframer2 quite a bit.

2) Added a deliveryPaused() handler to MessageDeframer2.Listener, which
is called by the deframer when there is not enough data to read/deliver
the next message.

3) Modified AbstractStream and AbstractClientStream to manage the timing
of when the closed() event is delivered to the listener. The
transportReportStatus ultimately controls this by creating a task to
close the listener. It either runs this task immediately or when the
next deliveryPaused() event occurs.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=83620903
2015-01-09 17:00:25 -08:00
yangg f8524a17b8 Add package name to the method string.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=83353207
2015-01-08 14:43:24 -08:00
ejona c0f41920bd Remove gRPC v1 support.
No major refactorings/simplifications were done. Only gRPC v1 support
infrastructure was removed.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=82737436
2015-01-08 14:43:23 -08:00
nathanmittler 164b734aa9 Adding gradle build for Java grpc
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=82152044
2015-01-08 14:43:21 -08:00
nathanmittler 66ce6677b2 Updating version of gRPC maven build to 0.1.0-SNAPSHOT.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=82151533
2015-01-08 14:43:20 -08:00
ejona fc30031fd1 Change default gRPC protocol to v2.
Any place that force-sets the protocol to 2 or assumes the old value
is now removed. Unfortunately, it seems InProcessTransportTest has
some non-obvious dependency on gRPC v1.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=81597524
2015-01-08 14:43:18 -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 2b116ef2cd Encode binary headers with Base64 on the wire, and requires all binary headers
have "-bin" suffix in their names.

Split Metadata.Marshaller into BinaryMarshaller and AsciiMarshaller.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=81306135
2015-01-08 14:43:15 -08:00
zhangkun 63fc64761a Inspect content type from trailers when there are no headers.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=81291102
2015-01-08 14:43:14 -08:00
ejona fb09bba456 Don't leak decompressor in gRPC v2.
We don't use the decompressor at all in gRPC v2, but it may still have
resources that should be close()d.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=81271990
2015-01-08 14:43:14 -08:00
zhangkun 8375cd00e8 GRPC Java clients will send the "te: trailers" header, and the server will
check for it, so that we can detect intermediate proxies that do not support
trailers.

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=81084983
2015-01-08 14:43:13 -08:00
zhangkun 4332c2f56e Change the HTTP code -> GRPC Status mapping to comply with http canonical mapping
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=80767939
2015-01-08 14:43:13 -08:00
lryan c5e70c2310 Remove StreamState and use inboundPhase/outboundPhase instead
Remove synchronization on stateLock as we are not required to be thread safe
Add better toString for stream impls
Internal cleanup of various 'status' fields in AbstractClientStream
Remove 'stashTrailers' as we've already extracted status in layer above correctly

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=80678356
2015-01-08 14:43:12 -08:00
ejona f96e7e8c6c Use real TLS security by default.
The client now checks certificates and performs hostname verification.
Tests check certificates, so the server uses a cert that the client
trusts.

Only the client portion of SslContextFactory was previously used.
Applications that want to ignore certificates (i.e., for testing) can
use io.netty.handler.ssl.util.InsecureTrustManagerFactory instead.

The MOE configuration was already failing to work, and so required the
simple mapping for examples in addition to what was needed for the new
certs.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=80434148
2015-01-08 14:43:11 -08:00
zhangkun 054f595eaa Separate the default event loop groups for client and server, to prevent
contention between client and server in the same test process.
Name the threads of default thread pools.

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=80326782
2015-01-08 14:43:10 -08:00
nathanmittler 63271f4729 Fixing a compatibility issue between the GFE and gRPC java client for the V2 protocol.
The GFE should not be sending DATA frames with endOfStream=true.
However to make things work in the short-term, if we receive one we
still need to process the DATA frame.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=80243944
2015-01-08 14:43:09 -08:00
nathanmittler 5d953e840b Updating gRPC code to use the latest Netty with application-level flow control support.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=80230204
2015-01-08 14:43:09 -08:00
ejona 01152e093d Fix workaround in place for GFE's lack of trailers.
A recent refactoring moved code so our previous workaround stopped
producing any effect.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=79965647
2015-01-08 14:43:08 -08:00
ejona 0f56c47ac8 Handle exceptions thrown by the application
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=79895899
2015-01-08 14:43:08 -08:00
lryan 1f2a1869e5 Fix NullPointerException in AbstractServerStream when deframer reports error and fix error message propagation
Improve detail of deframer error reporting to client

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=79799152
2015-01-08 14:43:07 -08:00
zhangkun aa0b7cc9af Forbid calling next more than once in interceptors.
Will throw IllegalStateException.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=79717262
2015-01-08 14:43:07 -08:00
lryan 4073a8a1a7 Remove redundant field from AbstractClientStream
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=79592498
2015-01-08 14:43:07 -08:00
lryan 669724a588 Rationalize the XXXStream classes to reduce code smear and make Netty/OkHTTP behave more consistently.
More cleanups to follow
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=79574504
2015-01-08 14:43:06 -08:00
ejona ff669ac9c2 More precise Builder generics
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=79430607
2015-01-08 14:43:06 -08:00
zhangkun 776ff86687 Eliminate ForwardingChannel and switch all use cases to client interceptors.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=79360027
2015-01-08 14:43:04 -08:00
zhangkun 48e734d7e3 Dedicated ClientInterceptor interface and utilities.
This will replace the channel-wrapping technique as the official
solution of intercepting calls on the client side. It is done in the
same manner as ServerInterceptor.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=79280263
2015-01-08 14:43:04 -08:00
ejona 9a148a5022 Remove outbound flow control interface.
We know we don't like the API, but don't yet have the new one in place.
Remove the old one now instead of waiting further, because we are
getting more users who are more likely to try to start using the API.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=79090165
2015-01-08 14:43:03 -08:00
nathanmittler ffc18f6c57 Adding MOE configuration for grpc_java.
The TestService proto is temporarily supplied as a generated jar (until the open source protoc compiler supports grpc).

Copies of messages.proto, empty.proto, and message_set.proto are scrubbed and included in the source under integration-testing.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78711468
2015-01-08 14:43:02 -08:00
zhangkun 7dc48e2787 SharedResourceHolder is a utility that manages expensive resources (thread
pools etc) that are shared among channels and servers as default values when
the application doesn't provide its own.

It uses reference counting to shut down resources with a delay.

Changed the channel and server builders to use it for default values of
executors and event loop groups.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78629204
2015-01-08 14:43:01 -08:00
nathanmittler 29cbef1f9b Renaming gRPC-java "newtransport" package to just "transport".
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78596663
2015-01-08 14:43:00 -08:00
simonma 3c986bbcdb Move protobuf code dependencies to net/stubby/proto
Remove needless proto dependencies from tests

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78593107
2015-01-08 14:42:59 -08:00
nathanmittler 0304b3d6b2 Cleaning up various compiler warnings in preparation for opensource.
overview:
1) Lots of @SuppressWarnings :)

2) Remove dependencies on StandardCharsets.XXX (which is Java 7)

3) Moved testing/utils/ssl/* to .../stubby/util so that the netty transport doesn't depend directly on the testing module.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78460727
2015-01-08 14:42:59 -08:00
ejona df9867def9 Support early-OK from Server.
The semantics in gRPC changed where server sending OK before client
half-closes is now permitted.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78404390
2015-01-08 14:42:58 -08:00
ejona 0a585333ce Pre-serialize status codes, for efficiency
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78401520
2015-01-08 14:42:58 -08:00
ejona 46118bb195 Add server support for TLS.
Note that we don't yet have plumbing to use a particular certificate for tests, so it isn't integration-test worthy yet.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78369023
2015-01-08 14:42:57 -08:00
simonma 988f219b04 Handle Headers and Trailers in OkHttp client transport.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78313233
2015-01-08 14:42:57 -08:00
simonma 1e55c6e3f1 Remove Deframer and InputStreamDeframer since we are not using them anymore.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78211270
2015-01-08 14:42:57 -08:00
simonma 2ce8215b0c Fix bug 18054433, only register one listener on transport service.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78112905
2015-01-08 14:42:56 -08:00
nathanmittler 28fb46ef49 Updates to migrate to the latest Netty version.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78008410
2015-01-08 14:42:56 -08:00
lryan 28497e3c7e Add support for servers to deliver response headers
Fixes some propagation issues for trailers too
Adds some more testing for metadata exchange

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=77979593
2015-01-08 14:42:56 -08:00
simonma 29d8c03636 Support inbound flow control in okhttp transport, and the first step to support V2 protocol.
Will add the header/trailer support in the following cl.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=77975189
2015-01-08 14:42:55 -08:00
zhangkun b95c094e7f The client and server usage examples based on stock.proto.
Also add forAddress(String host, int port) to NettyChannelBuilder.

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=77909737
2015-01-08 14:42:55 -08:00
simonma fcab51cc16 Don't send 0-length data frame.
In V2 protocol, we don't send endOfStream in data frame, so there is no point to send a 0-length data frame.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=77864520
2015-01-08 14:42:55 -08:00
zhangkun 8d6d12e4c4 Convenient builders for channels and servers.
Right now only netty-based builders are implemented. OkHttp based
builders will be created separately.

Minimal example of creating a stub:
ChannelImpl channel = NettyChannelBuilder
.newBuilder(new InetSocketAddress("localhost", 8980))
.buildAndWaitForRunning();
StockBlockingStub stub = StockGrpc.newStub(channel);

Minimal example of creating and starting a server:
ServerImpl server = NettyServerBuilder.newBuilder(8980)
.addService(StockGrpc.bindService(new StockServer()))
.buildAndWaitForRunning();
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=77787502
2015-01-08 14:42:55 -08:00
ejona 3411fda784 Implement trailer support in Netty transport
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=77365751
2015-01-08 14:42:55 -08:00
ejona 8c76c8a1d0 Remove Java 7isms and fix Maven compilation
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=77353600
2015-01-08 14:42:54 -08:00
nathanmittler c1f4b7303f Adding shutdown logic to NettyServerTransport.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=77349840
2015-01-08 14:42:54 -08:00
ejona de0a16cad3 Use something closer to the appropriate mime-type.
This is necessary for a C client to talk to the Java server.

Technically, we should be using application/grpc+proto, but since the
"proto" portion is marshaller-dependent, we will need more plumbing
before we can use the complete form.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=77271620
2015-01-08 14:42:54 -08:00
ejona dd7ba53cf8 gRPC status is always sent as ASCII.
As discovered during integration testing.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=77271565
2015-01-08 14:42:54 -08:00
simonma 55892febdd Send connection preface and setting when the okhttp client transport starts, this is required for talking to netty server.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=77104268
2015-01-08 14:42:53 -08:00
lryan 125c1cee69 Delete Session, Operation and ALL of its associated cruft.
This CL also:
- Removes the OkHTTP server implementation
- Switches NanoTest and Http2OkHttpTest to use Netty server. These tests are currently @Suppressed as OkHttp is not yet draft 14 compliant. Simon is fixing
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76998151
2015-01-08 14:42:53 -08:00
simonma 7bc12bf50a Upgrade OkHttp to the head (commit 2d6b3770d9ef3424a12c4c243596a34cc07cbef1), for having Http2 draft 14.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76990746
2015-01-08 14:42:53 -08:00
nathanmittler 06ed8ec55c Various updates to properly handle gRPC connection startup and shutdown.
Also updating to latest version of Netty that contains related fixes.  AbstractHttp2ConnectionHandler was renamed.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76977422
2015-01-08 14:42:52 -08:00
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 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
nathanmittler 88efcaf15c Adding CompositeBuffer and a few other utilties related to Buffers.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=72268003
2015-01-08 14:42:33 -08:00
nathanmittler bd56449f47 Adding new interface GrpcMessageListener and refactoring framing classes to use it.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=72157668
2015-01-08 14:42:33 -08:00
ejona a9c6c088f7 Add missing generics in MethodDescriptor
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=72155290
2015-01-08 14:42:33 -08:00
simonma 7bf17dc4d6 Improve okhttp client transport, handles go away and add unit test.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=72155172
2015-01-08 14:42:32 -08:00
nathanmittler 5f334f7c52 Adding support for TLS negotiation to new Netty transport.
This also fixes the ESF test.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=72144581
2015-01-08 14:42:32 -08:00
zhangkun ed85499d63 Renames Stream.close() to Stream.halfClose(), to be consistent with
StreamState.CLOSED and to match with Call.halfClose().

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=72095951
2015-01-08 14:42:32 -08:00
zhangkun 712e9c1201 Adds call type to MethodDescriptor as some transports need to know whether
the call is unary or streaming when starting the call.

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=71867037
2015-01-08 14:42:31 -08:00
ejona f97eb733f7 Add Server API, a.k.a., Channel for incoming requests.
Everything is nested under a single Server class. This may not seem best, but splitting things up basically requires a lot of "Server" prefixes all over the place, even if we use a separate package. I'm expecting to defer the decision, but once we decide the organization we need to update the Channel API to match.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=71838718
2015-01-08 14:42:31 -08:00
lukes edee75fa47 Migrate callers of MoreExecutors.sameThreadExecutor() to use either
MoreExecutors.directExecutor() or MoreExecutors.newDirectExecutorService()
based on whether the code requires an Executor or an ExecutorService instance.

This is being done to resolve some performance issues with the current
sameThreadExecutor() implementation, by allowing users who don’t need
ExecutorService#shutdown semantics to not pay for them, and to make the costs
more obvious for users who do need them.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=71585920
2015-01-08 14:42:31 -08:00
brettmorgan 56f5ec305e Upgrading OKHTTP to v2.0
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=71465711
2015-01-08 14:42:30 -08:00
simonma 77d9706bd3 Add okhttp client transport.
OkHttpSession is temporally kept for server side using.

Test:
java/com/google/net/stubby/testing/integration/grpc_java_server --port=10009 --transport=http2_okhttp

java/com/google/net/stubby/testing/integration/grpc_java_client --serverHost=localhost --serverPort=10009 --transport=http2_okhttp
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=71436060
2015-01-08 14:42:30 -08:00
nathanmittler 14af1cb2e8 Extracting out the Netty negotiation logic into a separate utility class.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=71357187
2015-01-08 14:42:30 -08:00
zhangkun 1e26ae1924 Fixes GRPC third_party TAP breakage due to naming changes on generated interfaces.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=71347520
2015-01-08 14:42:29 -08:00
nathanmittler bf8870ba86 Update GRPC to work with latest Netty version.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=71285057
2015-01-08 14:42:29 -08:00
lryan a3f0180290 Add simple context exchange mechanism by wrapping Channel.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=71139615
2015-01-08 14:42:29 -08:00
lryan 34650408aa Add ability to bind HTTP style headers to stubs and have them propagate over
transports that can deliver them.

This unblocks sending OAuth2 headers natively
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=71118741
2015-01-08 14:42:29 -08:00
nathanmittler c0a06819b7 Adding simple Transport for HTTP. Also creating abstract base classes for common stream/transport code.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=70983246
2015-01-08 14:42:28 -08:00
ejona e7a43e4e38 Workaround error caused by zero-length DATA frames.
The real solution is to not assume gRPC frame/DATA frame alignment, but
that is a much larger piece of work.

The bug was exposed via talking HTTP/2 to GFE which used a separate DATA frame
for closing the stream.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=70982223
2015-01-08 14:42:28 -08:00
nathanmittler cc7cdb1ab4 Implementing Netty-based GRPC Client Transport. Server-side will be implemented in a follow-up CL.
Overview:
- NettyClientTransport - this is the entry point into the client transport. This creates streams as well as the NettyClientHandler

- NettyClientStream - client stream implementation. This sends commands to the NettyClientHandler via commands.  Callbacks on the stream are made directly from the NettyClientHandler in the channel thread context.

- NettyClientHandler - A Netty HTTP/2 handler that acts as a bridge between the NettyClientStreams and Netty's HTTP/2 processing.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=70970028
2015-01-08 14:42:28 -08:00
lryan 0359907f61 Add NPN/ALPN support via Jetty extensions
Resurrect integration tests that pass through GFE for HTTP2+Netty
Misc improvements to hexa environment

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=70683236
2015-01-08 14:42:27 -08:00
nathanmittler ad1ee03104 Clarifying the InputStream ownership contract in Call.Listener and StreamListener.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=70334261
2015-01-08 14:42:27 -08:00
nathanmittler 46fea97a63 Some minor cleanup on the transport API (documentation and such).
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=70109458
2015-01-08 14:42:27 -08:00
nathanmittler 05a2b252ba New Buffer type for transport API.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=70056282
2015-01-08 14:42:26 -08:00
nathanmittler f4694f57f9 A couple minor fixes to Channel for bugs exposed while integration testing with Netty transport.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=69939586
2015-01-08 14:42:26 -08:00
simonma 6933667178 Sync with new error code.
And when write the Code in the MessageFramer, write the field number instead of the index.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=69868712
2015-01-08 14:42:26 -08:00
nathanmittler 56c1d8c245 Fixing gRPC code to work with new Netty jar
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=69768756
2015-01-08 14:42:25 -08:00
ejona cc9ca9620e Update message framing IDs to adhere to gRPC spec
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=69657434
2015-01-08 14:42:25 -08:00
ejona 7f23d5ccac Copy framing classes to newtransport, tweaking some of their APIs
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=69489753
2015-01-08 14:42:25 -08:00
ejona c638f958fc Port client tests to newtransport.
Where possible, I tried to cleanly shutdown the Channel.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=69404518
2015-01-08 14:42:25 -08:00
ejona 82c87abcbf Fix bugs exposed by test_TestServiceBenchmarks.
More bugs were lurking in this section of code. In some unknown way,
code I'm working on triggered frequent (9/10) failures of
test_TestServiceBenchmarks. These were all possible to be triggered on
HEAD, but for some unknown reason are not.

I am pretty certain we have at least one transport that handles
exceptions poorly, such as by throwing away the exception and not
informing the Operation of the error, which causes this test to time out.
Timeouts in this test are thus likely an indicator of a real bug, even
when it doesn't show any exception, because there was likely an exception
and it was eaten without logging.

Bugs fixed (in order of discovery):

1) In Deframer, currentLength and inFrame were not reset after
consuming a context or status message.

2) In consolidate(), if suffix was greater than the buffer and the
buffer contained data, the data would be lost.

3) In Deframer, some (unknown) Operation's addPayload() did not consume
all of the provided InputStream immediately (maybe it does so on
another thread), leaving those bytes in frame.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=69402916
2015-01-08 14:42:24 -08:00
ejona 88a758236a Deframer.deframe returns number of unprocessed bytes.
This is intended to reduce the flakiness of test_TestServiceBenchmarks.
TAP showed some flaky runs where HttpStreamDeframer threw the exception
"GRPC stream not correctly aligned".

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=69166650
2015-01-08 14:42:24 -08:00
nathanmittler 9334b6fa32 Adding first-cut at generic Netty client and servers implementing the Service interface.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=69076530
2015-01-08 14:42:24 -08:00
ejona 4d642200e7 [2/2] Swap Operation wrapping from Channel to Transport.
Session is now (properly) implementing transport API, so ChannelImpl has some
testing.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=69074094
2015-01-08 14:42:23 -08:00
ejona 4fd4845481 Remove fluent-style from newtransport Stream.
The fluent-style wasn't being used, yet made it impossible to
simultaneously implement both ClientStream and ServerStream. Having a
single class that switches between client and server behavior based on a
boolean is helpful to some transports.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=69028356
2015-01-08 14:42:23 -08:00
ejona 5e01cea1ef Change newtransport to use c.g.n.stubby.Status.
c.g.n.stubby.Transport.Status isn't intended to be used (at least at
this point).
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=69027874
2015-01-08 14:42:23 -08:00
ejona 35cabd0b82 [1/2] Split Channel and Stub APIs, implement Channel.
Call does not accept InputStream length because Marshaller makes it too hard
for the Stub to determine the length.

SessionCall is updated to implement changes to Call, but it is replaced in the
next CL.

You can see what glue is necessary to join the Transport and Stub APIs. The
ugliest pain is dealing with flow control callback. Some of that code is
unrelated and necessary because the Channel uses a separate thread to run
Call.Listener. Other parts will be necessary because Channel must intervene
during Transport callbacks to handle retry logic.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=69020275
2015-01-08 14:42:23 -08:00
lryan 0cf7d4c353 Bring netty5 up to head to support HTTP2 draft 12 so we can test with GFE
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=69006100
2015-01-08 14:42:22 -08:00
nathanmittler d784765814 Updating the transport Stream API to allow for callbacks for when a message was accepted by flow control.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=68706844
2015-01-08 14:42:22 -08:00
ejona 2af35d9bd3 Improve JavaDoc, including style fixes
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=68555036
2015-01-08 14:42:22 -08:00
lryan f8bbc12468 Remove SPDY support from GRPC
Will re-create the E2E tests through GFE when we can properly initiate HTTP2 with GFE.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=68488736
2015-01-08 14:42:21 -08:00
nathanmittler ef31a5f2ae First cut at the GRPC Transport interfaces for Java.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=68458345
2015-01-08 14:42:21 -08:00
lryan 2ce8446a0d Large refactor to:
- Introduce 'Channel' & 'Call' interfaces
- Unify the surfaces for the prototype generated stubs
- Lighten dependency on MessageLite outside of generated code (see Marshaller)
- Bridge Channel to Session pending Transport interface rewrite
- Update all tests to new interfaces

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=68407406
2015-01-08 14:42:20 -08:00
zhangkun 347a22dde0 Add toString() to Status.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=67721763
2015-01-08 14:42:20 -08:00
ejona 07d3f6a202 Move gRPC core to third_party
Half our tests still need to be moved, but that will be for a later
time.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=67023748
2015-01-08 14:42:19 -08:00