Commit Graph

211 Commits

Author SHA1 Message Date
nmittler 3efc61b237 Guard against NPE in Netty handlers
We've seen an NPE as a side-effect of a failure in protocol negotiation:

Oct 27, 2015 9:27:09 PM io.grpc.transport.netty.ProtocolNegotiators$AbstractBufferingHandler fail
SEVERE: Transport failed during protocol negotiation
java.lang.NullPointerException
	at io.grpc.transport.netty.NettyClientHandler$2.visit(NettyClientHandler.java:218)
2015-10-28 08:38:59 -07:00
Kun Zhang edd57c941e Support default port in NameResolver.
- Channel builders decide the default port based on whether TLS is used.
- Channel builders populate the default port via an Attributes object
  passed to NameResolver.Factory#newNameResolver
2015-10-27 13:54:36 -07:00
Carl Mastrangelo db56c2463e Add followup ProtocolNegotiators.tls tests 2015-10-26 12:19:07 -07:00
Carl Mastrangelo dd815bc968 Add initial Protocol Negotiation tests 2015-10-26 11:46:52 -07:00
nmittler 6f64999821 Addressing concurrency issue in MessageFramer.
Fixes (hopefully): #991
2015-10-23 13:00:23 -07:00
Kun Zhang efac679abc NameResolverRegistry and better-defined target string.
- NameResolverRegistry contains all the official NameResolvers. Users
  can also add custom NameResolvers to it. It looks up NameResolver by
  try-and-fail. It is the default NameResolver.Factory for builders.
  DnsNameResolver.
- Pass target as Strings instead of URIs from the channel builder to
  ManagedChannelImpl. A target string is not necessarily a valid URI, in
  which case ManagedChannelImpl will add "dns:///" to the beginning of
  the target and use it as URI.
- DnsNameResolver will require scheme "dns" to be present. It no longer
  allows scheme-absent URIs.
2015-10-23 09:37:22 -07:00
Carl Mastrangelo 74088c4fb4 Allow authority override to be propagated to Protocol Negotiators 2015-10-22 15:27:07 -07:00
Kun Zhang 942f4c99d8 Load-balancing ManagedChannelImpl.
- Add NameResolver and LoadBalancer interfaces.
- ManagedChannelImpl now uses NameResolver and LoadBalancer for
  transport selection, which may return transports to multiple
  addresses.
- Transports are still owned by ManagedChannelImpl, which implements
  TransportManager interface that is provided to LoadBalancer, so that
  LoadBalancer doesn't worry about Transport lifecycles.
- Channel builders can be created by forTarget() that accepts the fully
  qualified target name, which is an URI. (TODO) it's not tested.
- The old address-based construction pattern is supported by using
  AbstractManagedChannelImplBuilder.DirectAddressNameResolver.
- (TODO) DnsNameResolver and SimpleLoadBalancer are currently
  incomplete. They merely work for the single-address scenario.
2015-10-20 17:28:44 -07:00
nmittler 6e04c3100e Adding consistent exception handling for Netty
NettyClientHandler currently handles non-HTTP/2 exceptions properly by forcing a shutdown of the connection.  We need to do the server-side as well.

Fixes #1097
2015-10-05 11:46:50 -07:00
Carl Mastrangelo 2d067edf85 Allow host authority override. 2015-10-02 11:00:43 -07:00
Carl Mastrangelo 70cdf76212 adjust other usages in protocol negotiators 2015-09-29 10:57:23 -07:00
Carl Mastrangelo 75e291f062 docs 2015-09-29 10:48:24 -07:00
Carl Mastrangelo cb317c736c Update to share versions 2015-09-29 10:42:12 -07:00
Carl Mastrangelo ff19d90bb8 Force http2 connection when using tls 2015-09-29 10:38:26 -07:00
Carl Mastrangelo 46c18ea237 Move decompressor setting down into the AbstractStream 2015-09-28 10:25:58 -07:00
Xudong Ma f15f672b79 Correct the order of arguments. 2015-09-25 17:36:06 -07:00
nmittler f0d95798f8 Updating Netty to send a single SETTINGS frame.
Fixes #1059
2015-09-24 10:42:57 -07:00
Carl Mastrangelo 70fbd6735a Remove unused function in netty test 2015-09-23 15:15:31 -07:00
Carl Mastrangelo bfd74506fe Remove Netty test that fails with upstream 2015-09-23 13:47:33 -07:00
Eric Anderson 1e1d53b78f Fix test checking for invalid content type
Previously, if the content type was being ignored the error code would
have been UNKNOWN since there was no grpc-status. That seems very to
accidentally pass, so now if the content type is ignored it would get
OK.
2015-09-16 10:00:08 -07:00
Eric Anderson 1cfba96d17 Enforce sending headers before messages on server
ServerCall already had "headers must be sent before any messages, which
must be sent before closing," but the implementation did not enforce it
and our async server handler didn't obey.

The benefit of forcing sending headers first is that it removes the only
implicit call in our API and interceptors dealing just with metadata
don't need to override sendMessage. The implicit behavior was bug-prone
since it wasn't obvious you were forgetting that headers may not be
sent.
2015-09-11 17:39:40 -07:00
Carl Mastrangelo f6582d822d Add a hook to set TLS 2015-09-11 10:03:30 -07:00
Eric Anderson 538cf215f0 Add usePlaintext to ManagedChannelBuilder 2015-09-11 09:57:42 -07:00
Carl Mastrangelo 41d93cfd59 Use Providers in examples 2015-09-11 09:46:08 -07:00
Eric Anderson 5b2a03a02e Add overrideAuthority to ManagedChannelBuilder
We want to allow overriding authority in the ManagedChannelBuilder for
testing. In doing that, we basically require that all Channels support
authority. In reality, this simplifies things and is already being done
by the C implementation, as their unix domain socket support uses
"localhost" just like our in-process transport now does.

We can debate some whether "localhost" is really the most appropriate
authority for the in-process transport, but that should probably happen
later since "localhost" is "good enough" for now.
2015-09-11 09:37:49 -07:00
Eric Anderson 3ae18eaef1 Add overrideAuthority to NettyChannelBuilder
Although the functionality is currently available by passing a
manually-created InetAddress, that requires that the user do I/O before
calling our API and does not work with naming in the future.
2015-09-11 09:37:43 -07:00
Carl Mastrangelo 416b745d8d Add a Server Provider 2015-09-10 12:23:17 -07:00
Eric Anderson df7bf44687 Enable license header checking in checkstyle 2015-09-10 11:29:00 -07:00
nmittler f80ca40fb9 Add client-side logging for TLS negotiation. 2015-09-09 13:16:24 -07:00
nmittler ccf328f367 Fixing erroneous server log when TLS nego fails
Only adding the server HTTP/2 handler after the TLS negotiation is successful.

Fixes #974
2015-09-09 11:42:41 -07:00
Eric Anderson 31394aa9df Let transports be channel service providers for generic usage
This provides an API for applications to use gRPC without using
ExperimentalApis. It also allows swapping out a transport implementation
in the future.
2015-09-09 11:06:35 -07:00
nmittler 9466eb5014 Adding tc_native to interop test scripts
Also adding better server error log
2015-09-09 07:16:49 -07:00
Carl Mastrangelo 3cf76326a2 Move decompressor setting to Server Impl 2015-09-08 13:03:27 -07:00
Eric Anderson 2a3ae36bd3 Only release event loops when unused
Resolves #926. Transports can still be alive when the Server shuts down,
but they are using the worker event loops. Only release the worker event
loops when all transport's channels are closed.
2015-09-03 18:29:34 -07:00
Carl Mastrangelo 07a7279742 Daemonize OkHttp and Netty 2015-09-03 14:35:04 -07:00
nmittler aefefb50c4 Supporting OpenSSL
- Upgrading to Netty 4.1.0.Beta6
- enabling OpenSSL in negotiation codepaths
2015-09-03 13:14:59 -07:00
nmittler b687bdc742 Refactoring channel API.
Client:
* New ManagedChannel abstract class.
* Adding ping to Channel.
* Moving builders and implementations to internal.

Server:
* Added lifecycle management API to Server (mirroring ManagedChannel).
* Moved ServerImpl, AbstractServerBuilder and handler registries to internal.
* New ServerBuilder abstract class (mirroring ManagedChannelBuilder).

Fixes #545
2015-09-03 11:22:29 -07:00
Eric Anderson 210114d4a2 Ease use of JWT by passing URI to auth library
The URI no longer needs to be provided to the Credential explicitly,
which prevents needing to know a magic string and allows using the same
Credential with multiple services.
2015-09-01 15:42:58 -07:00
nmittler d3ab427fca Enforce content-type on client and server.
Fixes #360
2015-09-01 06:59:46 -07:00
Carl Mastrangelo 396f0606f3 Add test to prove RST closes stream, and remove hack from transport to force closure. 2015-08-31 13:26:49 -07:00
nmittler 15f02ba19c Adding maxMessageSize config option
Fixes #832
2015-08-26 15:32:33 -07:00
nmittler 777e928536 Removing transport shutdown hooks from channel builder
The current process of building a channel is a bit complicated in that transports have to provide a own shutdown hook to the channel builder in order to close shared executors. This somewhat entagled creation pattern makes it difficult to separate the process of channel building from transport building. Better separating these two should make the code more readable and maintainable moving forward.
2015-08-25 08:38:39 -07:00
Carl Mastrangelo 345773504c Quick work around for Rst bug 2015-08-24 11:42:35 -07:00
Carl Mastrangelo a508c1d4f5 Remove Headers 2015-08-24 11:41:10 -07:00
Xudong Ma 13c14df055 Netty: Call ClientTransport.Listener.transportReady() after receiving SETTINGS frame. 2015-08-24 10:57:05 -07:00
nmittler e2f88fa904 Moving a few common utilities to GrpcUtil. 2015-08-24 07:53:32 -07:00
nmittler aeae7a8e74 Rename HttpUtil to GrpcUtil.
It's not really just for HTTP, it has becoming a dumping ground for many internal constants/utilities.
2015-08-21 14:02:26 -07:00
nmittler 9f7cb80108 Adding handling for stream exhaustion in Netty. 2015-08-21 13:01:17 -07:00
Kun Zhang 042b278256 Remove the first MethodDescriptor constructor.
that takes the service name and method name separately.

Also fix tests that are still using the old full qualified method name
format.
2015-08-20 14:19:50 -07:00
Kun Zhang 687a6f4814 Skip io.grpc.internal in javadoc.
Also move ExperimentalApi and Internal to io.grpc, so that they appear
in javadoc.
2015-08-20 08:48:44 -07:00