Commit Graph

295 Commits

Author SHA1 Message Date
Eric Anderson 7865b031e1 okhttp: code style fix; handle exception
For code style, we either need a comment describing why an exception is
ignored or to actually handle the exception. In this case there doesn't
seem to be a strong reason to ignore the exception, but it isn't all
that important either, so just log at INFO.
2015-03-21 09:12:30 -07:00
Xudong Ma 79ef04bc91 Fix a race condition in the test, we may nitify MockFrameReader to return before it satrts waiting.
This commit fixes #223
2015-03-21 23:01:06 +08:00
Xudong Ma 7c6b627170 Close frame reader and notify the listener in reader thread, to avoid reading after reader is closed. 2015-03-17 08:04:07 +08:00
nmittler 23972a25b9 Adding outbound flow control API for the transport API 2015-03-16 14:17:03 -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
nmittler fad21aafe7 Test receiving invalid stream IDs in okhttp
Fixes #173
2015-03-09 14:10:10 -07:00
Xiao Hang 62fb1d2c8a Bug fix. frameWriter and frameReader are not initialized when an Exception is thrown in socket creation.
So do not touch them in shutdown path if they are null.
2015-02-26 10:48:14 -08:00
Louis Ryan 95c6f5082c Udate TODOs to use Github user names 2015-02-23 12:46:28 -08:00
Jakob Buchgraber f2f120922d Fix race for stream id in OkHttpClientTransport.
When running benchmarks using the okhttp transport with lots of
streams per channel we would see the occasional GOAWAY frame with
the server logging exceptions of the like "io.netty.handler.codec.http2.Http2Exception: Request stream 575 is behind the next expected stream 583".

As quickly identified by @ejona86, there is a race between creating a new stream id and writing the header on the wire.
Putting both under the same lock ensures that those two always go together.

After this change the errors disappeared. The perf impact should be small as the actual write to
the socket doesn't happen within the lock, but only the scheduling of the write.
2015-02-19 21:29:31 -08:00
Eric Anderson 303482ad3c Fix race in OkHttp test
transportTerminated() is called after closing the streams, so we can't
just wait on the streams and expect it to have been called.
2015-02-13 08:54:50 -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 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
nmittler 89b8d7ff47 Moving decompression to the channel thread. 2015-01-29 14:55:40 -08:00
Jake Wharton 6a93de9c59 Remove explicit Okio dependency.
The version of Okio that we want is dependent on the version of OkHttp. Let it come transitively through the normal dependency resolution mechanism.
2015-01-27 16:33:25 -08:00
nmittler f83145865a Removing all references to "stubby" 2015-01-27 11:25:25 -08:00
nmittler 19052499f7 Removing Maven build 2015-01-27 08:57:37 -08:00
Manik Surtani 0ca6584d19 Move to a non-snapshot version of OkHttp 2015-01-26 15:48:14 -08:00
nmittler 02c953e5e0 Migrating run scripts to gradle. 2015-01-26 15:26:11 -08:00
Eric Anderson 0077e67274 Remove unused imports 2015-01-26 10:23:05 -08:00
nmittler 02cc5217a2 Fixing @GuardedBy annotation to use the correct lock name. 2015-01-22 12:33:24 -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 3df1c33403 Reimplement test "readStatus" since v2 is here.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=84082247
2015-01-16 11:03:36 -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
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
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
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 4523059762 Upgrade OkHttp for Android SNI / NPN fix
https://github.com/square/okhttp/pull/1137
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=82149209
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
rocking 9dd0c944c8 Add SslSocketFactory support to OkHttpTransportFactory.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=81367843
2015-01-08 14:43:15 -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
simonma 751a4df52a Remove JDK1.7 method InetSocketAddress#getHostString since JDK1.7 is only supported by Android after 4.4 KitKat.
Now we pass the host directly into OkHttpClientTranport for 2 reasons:
1. We don't need to call InetAddress/InetSocketAddress.getHostName(), which will do a reverse DNS lookup, may return a different value other than user specified.
2. In some tests, we want to change the host to match TLS cert, in such case, we can use OkHttpChannelBuilder.overrideHostForAuthority(String host) to override the host, then the transport will get the overridden value.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=81169377
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
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
nathanmittler 0d8477c85c Adding crude outbound flow control to OkHttp transport.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=80390743
2015-01-08 14:43:10 -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
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
zhangkun a71d887661 Make all transport factories package-private in favor of channel builders.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=79367593
2015-01-08 14:43:04 -08:00
ejona 9a5a8de65d [1/3] Move AbstractTransportTest to third_party.
This required making it no longer depend on GrpcClient. Instead, we now
use the builders that make using GrpcClient almost completely obsolete.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78860648
2015-01-08 14:43:02 -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
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