Commit Graph

233 Commits

Author SHA1 Message Date
Eric Anderson a479c9116a Move timeout marshaller tests to ChannelImplTest
Now that ChannelImplTest exists, it makes more sense for them to be
there, since the implementation is in ChannelImpl.
2015-06-26 12:19:42 -07:00
Eric Anderson 45da9c5766 Add a few ChannelImpl tests and improve error status 2015-06-26 12:19:41 -07:00
Eric Anderson 9a2db9d7d9 Make ChannelImpl.obtainActiveTransport's fast path lock-free
Resolves #479
2015-06-26 12:19:41 -07:00
Eric Anderson c7403127ea Revert swapping to the "canonical HTTP mapping"
The mapping is poorly suited for gRPC. C and Go don't even do any
mapping. We can improve the mapping in the future, but it is very
important that users don't start depending on the current mapping.

This change is "inspired by" the original code, but is even more
conservative.

Fixes #477
2015-06-25 12:15:34 -07:00
Jack Coughlin 77878a04ee Pass timeout header in ChannelImpl 2015-06-17 16:03:13 -07:00
David Connelly 15104cdc69 Make sure we enter terminated state when transport server has been shut down and all server transports have been closed. Previously, we had only been checking if server transports were closed. Also, make sure termination cleanup is performed at most once with an AssertionError if checkForTermination() called when server has already been terminated 2015-06-15 13:04:11 -07:00
Josh Humphries 0d03f89467 add ping 2015-06-10 12:20:08 -04: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
Louis Ryan 641fc288fc Add support for indeterminate length messages. This will make using GRPC easier for non-proto payload types.
Sync to head
2015-05-26 15:44:46 -07:00
Xudong Ma 0d480879e5 okhttp: outbound flow control.
Fixes #371
2015-05-21 23:05:54 -07:00
Eric Anderson eb85d697c7 Set likely final size of array in toHttp2Headers
We know the size won't be more than serializedHeaders.length, is
unlikely to be fewer, and very unlikely to be substantially fewer. This
prevents us from needing to resize the array in all cases.

Resolves #321
2015-05-19 09:58:17 -07:00
Eric Anderson b69c59ce5f Decrease ArrayDeque memory in SerializingExecutor
By default, ArrayDeque will be of size 16, which is an overkill for most
calls. "4" is not a magical number itself, but seems a better guess than
16 since we do have some knowledge of how much it will contain.

Resolves #320
2015-05-19 09:55:25 -07:00
Eric Anderson 1787106cc7 isReady() should return false until stream allocated
isReady() can provide pushback while the call is in progress, but it
can also provide the pushback necessary when the client creates more
streams than permitted by MAX_CONCURRENT_STREAMS.

As part of this commit, OkHttp is now calling onReady() after call
creation (it previously never called onReady()).
2015-05-12 16:41:50 -07:00
nmittler 518b7dbf7c Slight performance improvment for MutableHandlerRegistryImpl 2015-05-12 09:56:45 -07:00
Eric Anderson 3462eb0e72 Handle OkHttp throwing exception during start()
Ideally OKHttp wouldn't do blocking I/O during start(), but it does and
fixing it is non-trivial. OkHttp can either throw an exception when it
encounters an error during start or it can shut itself down. Both
require changes in ChannelImpl, so we just choose to keep OkHttp's
current behavior and deal with it in ChannelImpl.
2015-05-07 18:52:21 -07:00
Eric Anderson 4e82a11311 Make Channel/Server abstract classes
Abstract classes allow us greater ability to change them over time. They
previously were interfaces to allow us to use Guava's AbstractService.
2015-05-07 16:41:52 -07:00
nmittler 1fa11cea1f Adding default implementation of onReady in Call and ServerCall 2015-05-07 10:52:07 -07:00
nmittler 64176d5560 Adding outbound flow control for Netty. 2015-05-04 12:19:57 -07:00
Louis Ryan f2cba89e48 Update Netty to 9d70cf3 to pick up https://github.com/netty/netty/commit/8271c8a which eliminates
explicit flushing from Nettys HTTP2 codec.
2015-05-01 13:00:04 -07:00
Eric Anderson 4a05869db7 Replace Operation*Exception with Status*Exception
Operation is a term no longer used in gRPC. StatusException seems clear
and is concise. Moved out of Status class to remove stuttering.

The return types of as*Exception() is now explicitly the
Status.*Exception type.
2015-05-01 08:43:37 -07:00
nmittler 7779b4fddf Cleaning up some warnings. 2015-04-30 13:57:38 -07:00
Eric Anderson 2b33598ec4 Don't overwrite error message if bad headers
If we notice something wrong with the headers, then we choose a nice
error message. But we are accidentally overwriting that message with
additional error details.
2015-04-30 09:59:24 -07:00
Louis Ryan d8d7908109 Avoid flushing CreateStreamCommand for calls where the client is known to send a payload immediately afterward.
Added simple JMH benchmark for Netty so improvements can be measured
2015-04-29 13:41:15 -07:00
Eric Anderson 2fb03b07dd Fix style violations added in 986d221
The unused AtomicInteger is caught by checkstyle so causes Travis-CI
to fail.
2015-04-29 08:49:28 -07:00
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