Commit Graph

6498 Commits

Author SHA1 Message Date
Carl Mastrangelo 2c2c48a592 Implement Transport reconnect 2015-08-04 13:19:35 -07:00
Xudong Ma 512134b095 Android-Interop-test: fix lint errors/warnings, enable proguard. 2015-08-04 10:52:20 -07:00
Eric Anderson 41d875c7e3 Notify transportReady() in Netty 2015-08-03 16:50:05 -07:00
Kun Zhang 137b2ef8c3 Upgrade protobuf-gradle-plugin to 0.6.1 2015-08-03 13:41:48 -07:00
Xudong Ma c55657e3c5 Make new stream call asynchronous when the MAX_CONCURRENT_STREAMS is reached. 2015-08-03 11:38:18 -07:00
Eric Anderson 248f575a59 Make any lib-generated UNKNOWN have description
Note that even more importantly, this translates a RST_STREAM error code
to a gRPC status code. This is generally useful, but also necessary for
DEADLINE_EXCEEDED to be more reliable in 0eae0d9.

Fixes #687
2015-08-03 11:15:02 -07:00
Carl Mastrangelo 384a80593d Remove all support for Payload 2015-08-03 10:04:01 -07:00
Carl Mastrangelo 88945e00f3 Make ServerImpl Use the common Scheduled Executor Service 2015-08-03 08:53:30 -07:00
Carl Mastrangelo 89db769d2d Rename sendPayload to sendMessage 2015-07-31 15:28:06 -07:00
Carl Mastrangelo d2b1b37ed7 Add a transport ready for use with retry 2015-07-31 15:24:44 -07:00
Carl Mastrangelo c86b547dd3 Forcibly cast in interop test 2015-07-31 15:22:09 -07:00
Carl Mastrangelo 14e774130d Rename onPayload to onMessage 2015-07-31 15:11:18 -07:00
Eric Anderson 8fe667676c Remove serializable distinction for Metadata
This does make use of the fact we are no longer using Multimap. Doing
entries() for ArrayListMultimap must create a new Map.Entry for every
entry. Since we are now using HashMap, we are able to use entries() with
no extra cost.

Merging particular Keys no longer needs to deserialize.
2015-07-30 14:09:21 -07:00
Eric Anderson a2292faf43 Optimize Metadata for reduced allocation count
Multimap creates at least one new object for every access, because all
the objects it returns are "live" and when mutated they need to update
the multimap's size. Many common operations thus require at least an
object allocation per key.

Note that previously remove() was non-functional as it removed the wrong
type from the multimap. The type system did not catch this because
remove() is passed an Object for all collection types.

The return type of removeAll() was changed to Iterable to prevent the
need of converting to Key if the caller doesn't consume the return
value.

Although it appears serialize() is now more expensive in terms of
allocations because it first accumulates into an ArrayList, the memory
usage is approximately the same since Multimap.values() makes an
Iterator for each key. The new code would allocate fewer bytes overall
and in fewer allocations, but the older code retained less memory while
processing. If we want to optimize serialize() we can track the number
of entries without needing to do any wrapping like Multimap does. I
didn't bother because the ArrayList is a fraction of the cost compared
to actually serializing the values.
2015-07-30 14:08:48 -07:00
Eric Anderson 50e28c2ca0 Make docs more strict for byte[] methods in Metadata 2015-07-30 14:07:04 -07:00
Eric Anderson 5698ccaee6 Fix invalid data sharing in Metadata.merge() 2015-07-30 14:07:03 -07:00
Carl Mastrangelo bd8987af1a Add a status to Transport shutdown 2015-07-29 15:35:38 -07:00
Xudong Ma abfdbf69e5 OkHttp: sync error map with gRpc spec. 2015-07-29 08:29:31 -07:00
nmittler a36f4af138 Fix flaky test 2015-07-28 16:35:52 -07:00
Xudong Ma dde1e809a7 Adjust @GuardedBy to pass internal GuardedBy Checking.
This is required by our internal sync.
2015-07-28 09:49:18 -07:00
Carl Mastrangelo 4d2b3e3d06 Remove Intrinsic locking in ChannelImpl. 2015-07-28 07:16:03 -07:00
Xudong Ma e36a64e6a6 Correctly handle unknown http2 error code. 2015-07-27 15:49:28 -07:00
Carl Mastrangelo 6f7c5143f1 Stop using intrinsic locks in ServerImpl 2015-07-27 15:40:03 -07:00
Xudong Ma 750f6265e2 Simplify locking model of OkHttp Transport, avoid potential deadlock.
1. Remove the stream lock, use transport lock instead.
2. Protected streams map with the transport lock instead of using synchronized map.
2015-07-27 08:13:19 -07:00
Jack Coughlin 1ac64bd09d Remove ServerDelayInterceptor from AbstractTransportTest 2015-07-27 07:25:41 -07:00
Eric Anderson eba12fb514 Add missing generics to Context internals 2015-07-23 13:25:39 -07:00
Kun Zhang 60cf5eb5da Use mutation methods for stub reconfiguration.
This makes the reconfiguration code more concise.

- Remove configureNewStub().
- Add mutation methods withDeadlineNanoTime(), withChannel() etc that
  returns the reconfigured stub.
2015-07-23 11:17:35 -07:00
Eric Anderson afdbe19937 Minor fixes/improvements
Cancel was the only method for implementing ClientStream that was not
final, even though it isn't really any different from the other methods.
2015-07-23 11:13:50 -07:00
Eric Anderson 5abe321b81 Fix deframing error handling
CANCELLED is certainly not the right status code. Communicating the
exception to the client removes the need for logging, which also makes
it more clear which call experienced the problem.
2015-07-23 11:13:48 -07:00
Eric Anderson 26d77ecd2e Minor readability changes
Improved some consistency. writeHeaders was the only non-final
implementation method of ServerStream, even though it is really no
different than the others.
2015-07-23 10:57:00 -07:00
Carl Mastrangelo 9a5c733ce9 Move CallImpl 2015-07-23 09:33:48 -07:00
Xudong Ma 659c4b1cbf Benchmark: Enable/Disable TLS for okhttp accordingly 2015-07-22 15:56:32 -07:00
Eric Anderson bf53a0e2e4 Add transport benchmark using JMH
The only benchmark method measures latency of a unary call in an
unloaded environment.
2015-07-22 15:54:41 -07:00
Eric Anderson 3059b70283 Optimize protobuf serializer for in-memory transport
In-memory transport provides back the same input stream that was
provided, so if we notice our own object simply avoid serializing.

DeferredProtoInputStream is made package-private because 1) it doesn't
seem we need it to be public and 2) the change depends on it being
package-private so the constructor can be changed.
2015-07-22 15:54:39 -07:00
Eric Anderson d11e9be127 Add in-process transport
Resolves #518
2015-07-22 15:54:37 -07:00
Eric Anderson 0df3d5e72a Add ClientInterceptors "inside" ChannelImpl
Fixes #538
2015-07-22 15:49:06 -07:00
Eric Anderson 3ce15b50b2 Reverse interceptor execution order
The previous order was unintuitive as the following would execute in the
reverse order:

Channel channel;
channel = ClientInterceptors.intercept(channel, interceptor1,
                                                interceptor2);
// vs
channel = ClientInterceptors.intercept(channel, interceptor1);
channel = ClientInterceptors.intercept(channel, interceptor2);

After this change, they have equivalent behavior. With this change,
there are no more per-invocation allocations and so calling 'next' twice
is no longer prohibited.

Resolves #570
2015-07-22 15:45:58 -07:00
Carl Mastrangelo 6ca7eb33c8 Merge pull request #625 from carl-mastrangelo/eggplant
Add basic unit tests to Abstract Stream
2015-07-22 15:34:33 -07:00
Carl Mastrangelo 977c3d1c77 Merge branch 'master' of github.com:carl-mastrangelo/grpc-java 2015-07-22 15:30:30 -07:00
Carl Mastrangelo 24a9f39e46 Added basic unit test and reorg how onready calls are made
Forgot to add this last file

updated method name

Remove unused function

Remove helper function for threshold edge detection

Remove helper function for threshold edge detection

Re make listener abstract

Added copyright

removed unused field
2015-07-22 15:28:16 -07:00
Kun Zhang 8bd8ed879f Fix protobuf plugin usage in README.md
- The version of protoc should be the same as the version of
  protobuf-java that is transitively depended by grpc
- Updated protobuf-gradle-plugin example to use version 0.5.0
2015-07-22 15:25:12 -07:00
Carl Mastrangelo 7b63909caf removed unused field 2015-07-22 15:22:01 -07:00
Carl Mastrangelo fe21e2799a Added copyright 2015-07-22 15:20:30 -07:00
Carl Mastrangelo 2eaeacafe8 Added basic unit test and reorg how onready calls are made
Forgot to add this last file

updated method name

Remove unused function

Remove helper function for threshold edge detection

Remove helper function for threshold edge detection

Re make listener abstract
2015-07-22 14:45:23 -07:00
Eric Anderson f81ed8e87b Clarify/improve transport interface requirements 2015-07-22 09:30:45 -07:00
Eric Anderson 7d22c09b2c Add Call state-checking enforcement to ChannelImpl and ServerImpl
The CallImpls in ChannelImpl and ServerImpl implement the Call
interfaces; they should be the ones ensuring that inappropriate calling
of methods is handled as the interface describes.
2015-07-22 09:30:44 -07:00
Eric Anderson dff29759a7 Fix reentrancy bug in ServerImpl during shutdown
Previously if the transport shut down immediately and during the
shutdown() call, the ServerImpl would never become terminated.
2015-07-22 09:30:42 -07:00
Eric Anderson 0eae0d9264 Make DEADLINE_EXCEEDED more reliable
The client can race with the server in cancelling due to deadline. If
server cancels we don't get DEADLINE_EXCEEDED, so double-check on
client-side to reduce the chances of losing the race.

Generally we expect the client to lose the race because of coarse timer
granularity for timer expirary. This change does little to help if the
server's clock runs noticably "fast" relative to the client.
2015-07-22 09:30:41 -07:00
Eric Anderson f48bc3b3eb Specify locale for toLowerCase in Metadata 2015-07-21 16:56:00 -07:00
Xudong Ma 5cc4e84e6e okhttp: Enable TLS by default. 2015-07-21 16:30:57 -07:00