Commit Graph

5126 Commits

Author SHA1 Message Date
zhangkun 7dc48e2787 SharedResourceHolder is a utility that manages expensive resources (thread
pools etc) that are shared among channels and servers as default values when
the application doesn't provide its own.

It uses reference counting to shut down resources with a delay.

Changed the channel and server builders to use it for default values of
executors and event loop groups.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78629204
2015-01-08 14:43:01 -08:00
lryan 8fc81f4a37 Fix compile error using new ProtoUtils
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78611659
2015-01-08 14:43:01 -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
simonma 3c986bbcdb Move protobuf code dependencies to net/stubby/proto
Remove needless proto dependencies from tests

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78593107
2015-01-08 14:42:59 -08:00
ejona 2dbae4d4f2 Use zero-filled payload for UNCOMPRESSED.
Previously we were using English text, but this just adds extra effort for all
the other languages that will need to implement servers. The integration test
case descriptions uses zero-filled bytes.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78477356
2015-01-08 14:42:59 -08:00
nathanmittler 0304b3d6b2 Cleaning up various compiler warnings in preparation for opensource.
overview:
1) Lots of @SuppressWarnings :)

2) Remove dependencies on StandardCharsets.XXX (which is Java 7)

3) Moved testing/utils/ssl/* to .../stubby/util so that the netty transport doesn't depend directly on the testing module.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78460727
2015-01-08 14:42:59 -08:00
ejona 96e6ed9c53 Define threading requirements of StreamObserver
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78404413
2015-01-08 14:42:58 -08:00
ejona df9867def9 Support early-OK from Server.
The semantics in gRPC changed where server sending OK before client
half-closes is now permitted.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78404390
2015-01-08 14:42:58 -08:00
ejona 0a585333ce Pre-serialize status codes, for efficiency
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78401520
2015-01-08 14:42:58 -08:00
nathanmittler 905d387e4f Porting GrpcClient and GrpcServer to third_party.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78372524
2015-01-08 14:42:58 -08:00
ejona 46118bb195 Add server support for TLS.
Note that we don't yet have plumbing to use a particular certificate for tests, so it isn't integration-test worthy yet.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78369023
2015-01-08 14:42:57 -08:00
simonma 988f219b04 Handle Headers and Trailers in OkHttp client transport.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78313233
2015-01-08 14:42:57 -08:00
yangg 8b4ecad497 Use "/" instead of "." as the separator between service name and client name.
Change from /Service.method to /Service/method.

quote from the spec:
Method (required): a path identifying the operation to perform on the
specified host, conforming to RFC 3986 sec 3.3. E.g
“/calendar.v1/ListEvents”
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78288091
2015-01-08 14:42:57 -08:00
simonma 1e55c6e3f1 Remove Deframer and InputStreamDeframer since we are not using them anymore.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78211270
2015-01-08 14:42:57 -08:00
simonma 2ce8215b0c Fix bug 18054433, only register one listener on transport service.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78112905
2015-01-08 14:42:56 -08:00
nathanmittler 28fb46ef49 Updates to migrate to the latest Netty version.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78008410
2015-01-08 14:42:56 -08:00
lryan 28497e3c7e Add support for servers to deliver response headers
Fixes some propagation issues for trailers too
Adds some more testing for metadata exchange

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=77979593
2015-01-08 14:42:56 -08:00
simonma 29d8c03636 Support inbound flow control in okhttp transport, and the first step to support V2 protocol.
Will add the header/trailer support in the following cl.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=77975189
2015-01-08 14:42:55 -08:00
zhangkun b95c094e7f The client and server usage examples based on stock.proto.
Also add forAddress(String host, int port) to NettyChannelBuilder.

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=77909737
2015-01-08 14:42:55 -08:00
simonma fcab51cc16 Don't send 0-length data frame.
In V2 protocol, we don't send endOfStream in data frame, so there is no point to send a 0-length data frame.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=77864520
2015-01-08 14:42:55 -08:00
zhangkun 8d6d12e4c4 Convenient builders for channels and servers.
Right now only netty-based builders are implemented. OkHttp based
builders will be created separately.

Minimal example of creating a stub:
ChannelImpl channel = NettyChannelBuilder
.newBuilder(new InetSocketAddress("localhost", 8980))
.buildAndWaitForRunning();
StockBlockingStub stub = StockGrpc.newStub(channel);

Minimal example of creating and starting a server:
ServerImpl server = NettyServerBuilder.newBuilder(8980)
.addService(StockGrpc.bindService(new StockServer()))
.buildAndWaitForRunning();
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=77787502
2015-01-08 14:42:55 -08:00
ejona 3411fda784 Implement trailer support in Netty transport
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=77365751
2015-01-08 14:42:55 -08:00
ejona 8c76c8a1d0 Remove Java 7isms and fix Maven compilation
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=77353600
2015-01-08 14:42:54 -08:00
nathanmittler c1f4b7303f Adding shutdown logic to NettyServerTransport.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=77349840
2015-01-08 14:42:54 -08:00
ejona de0a16cad3 Use something closer to the appropriate mime-type.
This is necessary for a C client to talk to the Java server.

Technically, we should be using application/grpc+proto, but since the
"proto" portion is marshaller-dependent, we will need more plumbing
before we can use the complete form.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=77271620
2015-01-08 14:42:54 -08:00
ejona dd7ba53cf8 gRPC status is always sent as ASCII.
As discovered during integration testing.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=77271565
2015-01-08 14:42:54 -08:00
simonma 55892febdd Send connection preface and setting when the okhttp client transport starts, this is required for talking to netty server.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=77104268
2015-01-08 14:42:53 -08:00
lryan 125c1cee69 Delete Session, Operation and ALL of its associated cruft.
This CL also:
- Removes the OkHTTP server implementation
- Switches NanoTest and Http2OkHttpTest to use Netty server. These tests are currently @Suppressed as OkHttp is not yet draft 14 compliant. Simon is fixing
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76998151
2015-01-08 14:42:53 -08:00
simonma 7bc12bf50a Upgrade OkHttp to the head (commit 2d6b3770d9ef3424a12c4c243596a34cc07cbef1), for having Http2 draft 14.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76990746
2015-01-08 14:42:53 -08:00
nathanmittler 06ed8ec55c Various updates to properly handle gRPC connection startup and shutdown.
Also updating to latest version of Netty that contains related fixes.  AbstractHttp2ConnectionHandler was renamed.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76977422
2015-01-08 14:42:52 -08:00
zhangkun bb9699e429 Fixes a few issues in netty server transport:
- Creates and passes a transport instance to ServerListener.transportCreated().
- Keeps the "/" prefix of the fully qualified method name when passing it to the handler
registry.
- Adds necessary "this." when accessing a member variable in ServerCalls.
- BlockingResponseStream.buffer should be added with BlockingResponseStream.this as
as the mark of end of data.

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76922440
2015-01-08 14:42:52 -08:00
lryan 53acb1c8f9 Remove the old & new HTTP transports as they are incapable of supporting trailers using their
current implementations. Can be revived later if needed.

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76793542
2015-01-08 14:42:52 -08:00
simonma 52f92d06ee Use our own SerializingExecutor.
Also removed some unused imports and fixed some warnings.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76747713
2015-01-08 14:42:51 -08:00
zhangkun 01c96175fd GRPC server codegen: generates the bindService() method that returns a
ServerServiceDefinition that connects the server with application-provided
service implementation.

Introduces a class Method, that holds the invariables of a method that are
inferred from the proto file, to be reused for creating MethodDescriptor
for client code and ServerServiceDefinition for server code in the generated
class.

Adds ServerCalls that contains the functionalities that is used by the
bindService() method in the generated class. It minimizes the logic in the
generated code.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76741797
2015-01-08 14:42:51 -08:00
wonderfly 1dcc3c77c6 Added SSL support to gRPC java server used for integration tests.
Modification made to the old transport so this is a temporary CL.
Implementation is a bit hacky but given that the old transport is going
away, it is good for now.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76707856
2015-01-08 14:42:50 -08:00
ejona 653ffd98d2 ServerImpl
Interfaces were corrected. ChannelImpl was updated to use same style of
exception handling of ServerImpl.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76702816
2015-01-08 14:42:50 -08:00
lryan eb3fc58ce5 Create an in-process adapter between ClientTransport and HandlerRegistry
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76604751
2015-01-08 14:42:50 -08:00
scottpeterson 8f6e2c2270 Fix UNAUTHENTICATED status to point in Java Status class to point to correct code.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76473036
2015-01-08 14:42:49 -08:00
lryan 71e4a92c10 First steps in reducing dependency on proto from runtime.
- Remove transport.proto and move status codes into Status.java with a little refactoring to make
status easier & more precise to use
- Move DeferredProtoInputStream into a proto subpackage
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76392172
2015-01-08 14:42:49 -08:00
nathanmittler 65be3c72d9 Simple echo client.
I've modified ejona@'s original CL to fix some issues involved with
receiving status in trailers.

Also have a fix that should make the Java client properly flush when
writing.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76361782
2015-01-08 14:42:48 -08:00
simonma f7bbb9734c Removed proto dependency from Buffers.java:
1. Removed ByteSting related code (and copyFrom() method, since no one is using it).
2. Removed BuffersByteStringTest.java
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76308473
2015-01-08 14:42:48 -08:00
lryan 1369ea1d21 Metadata improvements.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76175838
2015-01-08 14:42:48 -08:00
ejona 55794111bd Fix reference counting misaccounting.
The fact that duplicate, slice, et al. don't retain() even though they
hold a reference to the originating ByteBuf seems very bug-prone.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76126682
2015-01-08 14:42:47 -08:00
ejona 6fc356b13d Split out a ClientStreamListener from StreamListener.
Headers and trailers are only received on client-side, so we need a
client-specific listener. Close() also has slightly different semantics
between server-side and client-side.

Most of the changes are simple name changes, but AbstractServerStream does update to the new close() semantics.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76094225
2015-01-08 14:42:47 -08:00
ejona 9d50299a04 Plumb trailer passing through transport streams.
We purposefully avoid going through the (de)framer, since close()
behavior is specific to whether on client or server.
AbstractClientStream and AbstractServerStream handle mapping the events
to appropriate semantics, but require stashing status/trailer for later
use.

It was very interesting getting to a point where we could support the old
and new protocol; that is probably the most detailed-oriented portion of
the CL. There are some interface hacks going on, but those will
naturally be removed when we trash the gRPC v1 framer.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76092186
2015-01-08 14:42:46 -08:00
nathanmittler fc7a052c07 Updating gRPC code to the latest Netty version which supports binary headers.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=75853353
2015-01-08 14:42:46 -08:00
ejona ef2129c7d2 Add halfClose() to StreamListener.
This is required to be able to distinguish between the client having
finished sending and the RPC being complete.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=75819962
2015-01-08 14:42:45 -08:00
ejona 913de47b61 Add support for new gRPC protocol
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=75809789
2015-01-08 14:42:45 -08:00
ejona 029f0d22f8 Don't use switch on string, for Java 6 compatibility
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=75322297
2015-01-08 14:42:45 -08:00
ejona 57bfc6a01d Remove dependency on ByteBuffers.
ByteBuffers is not generally available.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=75321682
2015-01-08 14:42:44 -08:00