Commit Graph

1182 Commits

Author SHA1 Message Date
Louis Ryan 887064d30e Use latching to enforce expected events are received 2016-02-25 17:33:54 -08:00
Louis Ryan 8dad73492a Various naming and documentation clenaups
Remove attachAsCloseable and replace with the immediate run / call methods
Introduce a concrete Deadline type and use it
2016-02-25 16:33:10 -08:00
Eric Anderson b17a249fc4 Create new AbstractTransportTest for Transports
This is lower-level than the existing AbstractTransportTest. It should
be used by all transports, but InProcessTransport is the only one as
part of this commit.
2016-02-25 16:23:17 -08:00
Kun Zhang d86dfc9552 Merge DelayedStream's setError() into cancel()
DelayedClientTransport.PendingStream will override cancel(), which has a
clearer semantic.

Also permitting all status codes except OK in ClientStream.cancel(),
instead of just 4 codes.
2016-02-25 11:28:48 -08:00
Carl Mastrangelo a959126fb3 Bump Guava to 19.0 2016-02-25 08:42:54 -08:00
Eric Anderson 06e3ef5945 Fix bugs and improvements found by static analyser 2016-02-23 17:32:35 -08:00
Kun Zhang 7a29f3993c Pass transports instead of futures of transports for new calls.
This PR finishes the refactoring started by #1395. Resolves #1342.

Major changes:

- All interfaces that return `ListenableFuture<T>` now return `T`
- Stop passing `null` for transports after shut down. Pass
  `FailingClientTransport` instead. This simplifies the interface
  semantics of interfaces that return a transport, as well as their
  callers because they no longer need to check for `null`.
- Add two methods to `TransportManager`:
 - `createInterimTransport()` takes the place of `BlankFutureProvider`
  in `LoadBalancer` implementations.
 - `createFailingTransport()` takes the place of errors in the `Future`
  when `LoadBalancer` implementations propagate errors to the caller.
- `createInterimTransport()` creates a `DelayedClientTransport` tracked
  by `ManagedChannelImpl`, which will not terminate until all
  `DelayedClientTransport`s, in addition to the `TransportSet`s, are
  terminated.
- Removed the transport argument from the ready and shutdown callbacks,
  because if `LoadBalancer` was given a delayed transport earlier, it
  will get the real transport's shutdown event, thus won't be able to
  match the two through identity comparison, which beats the purpose of
  passing the transport.
2016-02-23 09:42:03 -08:00
Eric Anderson 340481859f Update README to reference 0.13.1 2016-02-23 08:38:48 -08:00
Carl Mastrangelo 42d787288e Use default keystore 2016-02-22 17:18:32 -08:00
Xiao Hang 52b3db2c06 Fix a bug ByteReadableBufferWrapper. We should set new buffer's limit before changing the original buffer's position 2016-02-22 16:28:36 -08:00
William Thurston 8d0267fc41 Allow for interceptors to send and receive messages of type InputStream. 2016-02-21 18:01:25 -08:00
Eric Anderson 56dca036db Limit memory during build
When running :grcp-interop-testing:test, Travis has been hanging on OS X
or flaking on Linux with:
> Process 'Gradle Test Executor 4' finished with non-zero exit value 137

Exit code 137 indicates SIGKILL (128 + 9) and is most likely caused by
the JVM being killed by the kernel's OOM killer.

The limit in .travis.yml is 2x what was necessary to do a parallel
build. The main test memory limit in build.gradle is well above 16m
which is necessary for the tests. Interop-testing is well above 64m
which is necessary for interop-testing, but we use 1.5g to help prevent
timeouts on Travis.

Protobuf and protobuf-nano each have one tests that decodes a proto >64M
in size, which prevents them from running with less than 512m and 768m,
respectively.
2016-02-21 16:59:44 -08:00
nmittler 86fd2523ec Update to latest netty and tcnative. 2016-02-20 14:50:06 -08:00
Lukasz Strzalkowski af6a2650af Add simple BINARY_BYTE_MARSHALLER 2016-02-20 12:30:20 -08:00
Kun Zhang ab1bc05f07 Update package name for grpc load balancer proto. 2016-02-19 17:03:33 -08:00
nmittler 5cef321b78 Use Netty's StreamBufferingEncoder
Fixes #1060
2016-02-19 11:29:28 -08:00
Louis Ryan caad0294b9 Revert the cascading test for the moment as its flaky 2016-02-19 10:28:17 -08:00
Eric Anderson 6f1261f288 Decrease log verbosity for transport status changes
Most of the time it is just feeling like logspam.

Fixes #1439
2016-02-19 09:26:30 -08:00
Eric Anderson d95576804e Revert "Update to latest tcnative release"
This reverts commit 1751536410.

It causes an java.lang.AbstractMethodError
2016-02-19 09:15:12 -08:00
nmittler 1751536410 Update to latest tcnative release 2016-02-19 08:45:01 -08:00
Trask Stalnaker c10f5781b9 Fix sporadic NullPointerException
Fixes #1426
2016-02-18 21:43:43 -08:00
Louis Ryan 86ef8e70b5 Fix Intellij syncing for some generated dirs 2016-02-18 20:44:46 -08:00
Eric Anderson 85e68dbe98 Update README to reference 0.13.0 2016-02-18 16:34:23 -08:00
Eric Anderson b824565632 Improve procedure for creating release tag and branch
The flow itself was improved, but also the addition of Bash variables
and sed automation should hopefully make it less error-prone.
2016-02-18 16:31:14 -08:00
Louis Ryan 7fc986e6d0 Fix flakiness in Cascading cancellation tests
Add explicit shutdown for other executors
2016-02-17 16:17:22 -08:00
Eric Anderson 6715f1202c Add support for codecov.io
Codecov.io provides patch-based code coverage, so you can easily know
how many of the added lines are covered. It also has a more useful UI.

Unfortunately, the percentage it reports does not include partially-
covered lines--those with uncovered conditions. Thus the reported
percentage is about 6% lower than the coverage we've been looking at
previously. Because of this alone, I don't expect to remove coveralls
support soon.

Use the bash script instead of python module since pip isn't available
by default on Travis OS X.

jacocoTestReport uses mustRunAfter (contrary to the docs; see
https://issues.gradle.org/browse/GRADLE-2960) to make sure it runs after
all tests, only if testing is taking place. We would like
:grpc-all:jacocoTestReport to behave the same way. Without it, we would
need two separate invocations of gradle (adding ~1m to Travis run) in
order to prevent getting random results depending on what tests just so
happened to have been run.
2016-02-17 12:24:17 -08:00
Eric Anderson daf920d4b4 Pass -j to correct command
Passing -j to ./configure produces an error
2016-02-17 11:44:28 -08:00
Louis Ryan 12a4b21f74 Integration tests for testing cascading cancellation. 2016-02-17 10:35:37 -08:00
Eric Anderson 30b4232060 Start 0.14.0 development cycle 2016-02-16 16:31:59 -08:00
Eric Anderson 41c3f78687 Maven protoc plugin has a new name and is on Maven Central 2016-02-16 15:29:24 -08:00
Eric Anderson 8d43880356 hpack is no longer a direct dependency
It isn't even a dependency of Netty, now that Netty has forked the code.
2016-02-16 14:54:17 -08:00
Eric Anderson b752e76858 Automated readability/efficiency tweaks
Although the changes were determined automatically, they were manually
applied to the codebase.

ClientCalls actually has a bug fix, since the suggestion to add
interrupt() made it obvious that interrupted() was inappropriate.
2016-02-16 14:15:23 -08:00
nmittler 1dce8df077 Switching to netty-tcnative-boringssl-static 2016-02-16 13:11:45 -08:00
Eric Anderson a3303b51ec Delete unused CancelStreamCommand 2016-02-16 11:45:29 -08:00
Eric Anderson 898634f96a In blocking stubs, throw Status.CANCELLED on interruption
This was already being done in one case, but should have been done for
the other occurrances of InterruptedException. Before the
RuntimeException is just asking to be a bug since application code will
commonly only catch StatusRuntimeException.
2016-02-16 11:38:57 -08:00
Carl Mastrangelo 2d2398ce3a d'oh, really raise the visibility 2016-02-16 10:55:24 -08:00
Carl Mastrangelo acdcd5b114 Raise visibility of netty Channel Builder, and provide a way to pass in a custom protocol negotiator per transport 2016-02-16 10:39:20 -08:00
Kun Zhang cf787bddf2 DelayedClientTransport and fix TransportSet.shutdown() semantics.
Always return a completed future from `TransportSet`. If a (real) transport has not been created (e.g., in reconnect back-off), a `DelayedClientTransport` will be returned.

Eventually we will get rid of the transport futures everywhere, and have streams always __owned__ by some transports.

DelayedClientTransport
----------------------

After we get rid of the transport future, this is what `ClientCallImpl` and `LoadBalancer` get when a real transport has not been created yet. It buffers new streams and pings until `setTransport()` is called, after which point all buffered and future streams/pings are transferred to the real transport.

If a buffered stream is cancelled, `DelayedClientTransport` will remove it from the buffer list, thus #1342 will be resolved after the larger refactoring is complete.

This PR only makes `TransportSet` use `DelayedClientTransport`. Follow-up changes will be made to allow `LoadBalancer.pickTransport()` to return null, in which case `ManagedChannelImpl` will give `ClientCallImpl` a `DelayedClientTransport`.

Changes to ClientTransport shutdown semantics
---------------------------------------------

Previously when shutdown() is called, `ClientTransport` should not accept newStream(), and when all existing streams have been closed, `ClientTransport` is terminated. Only when a transport is terminated would a transport owner (e.g., `TransportSet`) remove the reference to it.

`DelayedClientTransport` brings about a new case: when `setTransport()` is called, we switch to the real transport and no longer need the delayed transport. This is achieved by calling `shutdown()` on the delayed transport and letting it terminate. However, as the delayed transport has already been handed out to users, we would like `newStream()` to keep working for them, even though the delayed transport is already shut down and terminated.

In order to make it easy to manage the life-cycle of `DelayedClientTransport`, we redefine the shutdown semantics of transport:
- A transport can own a stream. Typically the transport owns the streams
  it creates, but there may be exceptions. `DelayedClientTransport` DOES
  NOT OWN the streams it returns from `newStream()` after `setTransport()`
  has been called. Instead, the ownership would be transferred to the
  real transport.
- After `shutdown()` has been called, the transport stops owning new
  streams, and `newStream()` may still succeed. With this idea,
  `DelayedClientTransport`, even when terminated, will continue
  passing `newStream()` to the real transport.
- When a transport is in shutdown state, and it doesn't own any stream,
  it then can enter terminated state.

ManagedClientTransport / ClientTransport
----------------------------------------

Remove life-cycle interfaces from `ClientTransport`, and put them in its subclass - `ManagedClientTransport`, with the same idea that we have `Channel` and `ManagedChannel`. Only the one who creates the transport will get `ManagedClientTransport` thus is able to start and shutdown the transport. The users of transport, e.g., `LoadBalancer`, can only get `ClientTransport` thus are not alter its state. This change clarifies the responsibility of transport life-cycle management.

Fix TransportSet shutdown semantics
-----------------------------------

Currently, if `TransportSet.shutdown()` has been called, it no longer create new transports, which is wrong.

The correct semantics of `TransportSet.shutdown()` should be:
- Shutdown all transports, thus stop new streams being created on them
- Stop `obtainActiveTransport()` from returning transports
- Streams that already created, including those buffered in delayed transport, should continue. That means if delayed transport has buffered streams, we should let the existing reconnect task continue.
2016-02-12 09:36:25 -08:00
Carl Mastrangelo 544cd3a33b pause 2016-02-11 15:45:30 -08:00
Eric Anderson ad301c7e4d Make thread-safety ownership of Metadata explicit 2016-02-11 12:40:38 -08:00
Lukasz Strzalkowski 48b30291ee Add Metadata#keys() which returns set of all keys in the store 2016-02-11 17:32:05 +01:00
Eric Anderson 964963ab1a Replace AUTHORITY_KEY with ClientStream.setAuthority 2016-02-10 17:26:51 -08:00
Eric Anderson 64bc830f65 Update Android test build to use current grpc snapshot and support Gradle 2.10
com.android.tools.build:gradle:1.1.0 doesn't work with Gradle 2.10, but
1.5.0 does.

I also bumped the protobuf-gradle-plugin to be the same as the version
used in the README and our primary build.gradle.
2016-02-10 16:05:03 -08:00
Carl Mastrangelo 3f9e486e0d Raise visibility of Netty Channel Builder Ctor 2016-02-10 10:52:18 -08:00
Eric Anderson 86f2c9f224 Fix InProcessTransport to call onReady
Fixes #875
2016-02-10 10:01:15 -08:00
Eric Anderson 5b9726ea7d netty: release buffered objects when failed
Releasing on failure prevents memory leak.

Fixes #1401
2016-02-10 09:36:54 -08:00
Eric Anderson 52bd63f88e Improve test coverage of ProtoUtils
NanoUtilsTest was updated to use an invalid proto instead of an
IOException to match ProtoUtils and to be more realistic.
2016-02-06 17:22:37 -08:00
Eric Anderson 5a5f985d21 Log full Status on Android test failure 2016-02-04 15:26:18 -08:00
Eric Anderson 3d3fd11378 Negotiation Handlers should implement ChannelHandler
Having Handler implement ChannelInboundHandler is overspecifying and
unnecessary, as the code compiles fine just by changing "implements
ChannelInboundHandler" to "implements ChannelHandler".

PlaintextHandler was swapped to ChannelHandlerAdapter instead of
ChannelDuplexHandler because it just needs the ChannelHandler methods.
2016-02-04 14:02:57 -08:00
Carl Mastrangelo 04a6c8395b Remove deprecated call and TODO in Protocol negotiators 2016-02-04 13:39:56 -08:00