Commit Graph

279 Commits

Author SHA1 Message Date
Carl Mastrangelo 89bc2cd3b2 all: update to latest import ordering 2017-01-26 13:43:06 -08:00
Carl Mastrangelo efbcd1f1b9 core: change method descriptor to be builder based 2017-01-23 12:29:35 -08:00
ZHANG Dapeng 018e2d5307 all: make some api non-experimental for 1.1 2017-01-20 16:34:56 -08:00
Carl Mastrangelo 8e463ce1a8 core,stub: remove deprecated deadline methods 2017-01-10 15:54:38 -08:00
Carl Mastrangelo 8d49df28ee all: add max message size to client calls 2017-01-05 17:23:34 -08:00
Carl Mastrangelo f15ed05260 stub: remove a reference to internal 2016-12-02 09:13:37 -08:00
ZHANG Dapeng 6dc4633bdd stub: add withWaitForReady 2016-11-28 18:13:22 -08:00
Carl Mastrangelo 893ef44b4c all/tests: add a ClientCall and ServerCall suitable for use in tests 2016-09-02 17:09:49 -07:00
Carl Mastrangelo 48c6b3d398 all/tests: unmock ClientCall and ServerCall 2016-08-30 09:58:02 -07:00
Carl Mastrangelo 8894769cdf stub: make more classes final 2016-08-26 15:39:43 -07:00
Carl Mastrangelo 1285477133 all: add parameter name to checkNotNull
After debugging #2153, it would have been nice to know what the exact
parameter was that was null. This change adds a name for each
checkNotNull (and tries to normalized on static imports in order to
shorten lines)
2016-08-12 14:55:00 -07:00
Eric Anderson fb8402fcb1 stub: Avoid double-wrapping status
780b2696 caused all failures for blocked unary stubs to have a
StatusRuntimeException as the cause of the StatusRuntimeException, with
the two exceptions having almost the same status.
2016-08-01 09:53:57 -07:00
Carl Mastrangelo 297af4425e netty: always flush at least once, even if there were no writes 2016-07-19 11:18:54 -07:00
nmittler 780b2696c1 Ensure that trailers are not lost when making blocking calls.
Fixes #2036
2016-07-18 15:47:57 -07:00
Eric Anderson 32fd329e1c core: Rename withCredentials to withCallCredentials on CallOptions
It was withCallCredentials on the stub to avoid confusion with channel
credentials (which don't exist in Java at this time, but do in other
languages), and having the method names be different doesn't add value.
2016-07-01 11:18:38 -07:00
Eric Anderson 29776ca947 core: Fix onReady race by adding DelayedStreamListener
onReady/isReady previously could disagree causing a sort of deadlock
where the application isn't sending because grpc said not to, but won't
be informed to send via onReady later.

This is a stack trace from inprocessTransportOutboundFlowControl. The
line numbers are from this commit but with the changes to DelayedStream
disabled:

at io.grpc.internal.DelayedStream.isReady(DelayedStream.java:306)
  (That is isReady returning false because fallThrough == false)
at io.grpc.internal.ClientCallImpl.isReady(ClientCallImpl.java:382)
at io.grpc.stub.ClientCalls$CallToStreamObserverAdapter.isReady(ClientCalls.java:289)
at io.grpc.stub.ClientCallsTest$8$1.run(ClientCallsTest.java:403)
  (And yet that was the onReady callback, and it won't be called again)
at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onReady(ClientCalls.java:377)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$4.runInContext(ClientCallImpl.java:481)
at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:52)
at io.grpc.internal.SerializeReentrantCallsDirectExecutor.execute(SerializeReentrantCallsDirectExecutor.java:65)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.onReady(ClientCallImpl.java:478)
at io.grpc.internal.DelayedStream$DelayedStreamListener.onReady(DelayedStream.java:366)
at io.grpc.inprocess.InProcessTransport$InProcessStream$InProcessServerStream.request(InProcessTransport.java:284)
at io.grpc.internal.ServerCallImpl.request(ServerCallImpl.java:99)
at io.grpc.stub.ServerCalls$ServerCallStreamObserverImpl.request(ServerCalls.java:345)
at io.grpc.stub.ClientCallsTest.inprocessTransportOutboundFlowControl(ClientCallsTest.java:432)

Fixes #1932
2016-06-27 13:35:52 -07:00
Carl Mastrangelo b55a2bfb3f core: clarify StreamObserver documentation
Fixes #986
2016-06-27 08:20:21 -07:00
Eric Anderson 5487ea8f54 Remove unused variables
This fixed a threading issue in ServerImpl because the unused variable
should have been used.
2016-06-24 12:11:03 -07:00
Eric Anderson 66ab956f9e Reapply "Eliminate MethodDescriptor from startCall and interceptCall for servers"
This reverts commit ef178304cb, which
itself was a revert.
2016-06-23 09:27:47 -07:00
Eric Anderson ef178304cb Revert "Eliminate MethodDescriptor from startCall and interceptCall for servers"
This reverts commit 3df1446deb.

The commit was adding to the difficulty of integration for testing. By
itself it isn't bad, so this is a temporary revert until the many other
commits are absorbed and then it will be reapplied.

This does have a manual edit for ClientCallsTest.
2016-06-20 15:18:18 -07:00
Eric Anderson 26fb347f40 stub: Disable flaky test in ClientCallsTest (#1938)
The test has found a legitimate flake caused by a race in DelayedStream
related to onReady. Disable it until the fix arrives to prevent CI
failure noise.
2016-06-15 21:30:26 -07:00
Eric Anderson 93c34ef008 stub: Improve ClientCall test to fail more obviously
If the timoutout expires, the test will almost certainly fail now due to
responses not matching expected responses, but it isn't as obvious why
the test fails. Swapping to ArrayList prints the entire list when they
don't match, which also makes it easier to diagnose.

This is, in part, to help diagnose #1932
2016-06-15 17:03:20 -07:00
Louis Ryan b681a07f6c Introduce ClientResponseObsever to capture call initiation and to allow
for capture of the CallStreamObserver
2016-06-14 10:18:48 -07:00
Louis Ryan 3df1446deb Eliminate MethodDescriptor from startCall and interceptCall for servers
Make the MethodDescriptor a property of ServerCall
Move ServerMethodDefinition into ServerServiceDefinition
2016-06-13 14:39:58 -07:00
Kun Zhang 432cec7973 core: CallCredentials
Introduce CallCredentials as a first-class option to allow applications
to set per-call credentials into headers for outgoing RPCs. This will
supersede ClientAuthInterceptor. It has access to more
information (e.g., transport attributes, MethodDescriptor) and allow
results to be returned asynchronously, e.g., from a blocking I/O, which
was problemantic with ClientAuthInterceptor.
2016-06-09 17:46:15 -07:00
elandau 90323ad5d4 core: add custom CallOptions 2016-06-02 09:14:48 -07:00
Eric Anderson 7052d8b5e9 core: Promote Deadline API to stable
Fixes #1706
2016-05-26 13:33:48 -07:00
nmittler c102dd4e4f Add trailers to Status for BlockingResponseStream
Fixes #1861
2016-05-25 12:04:55 -07:00
nmittler 6e40edbc21 Add trailers to Status for BlockingResponseStream 2016-05-25 06:54:31 -07:00
Carl Mastrangelo e19848092d core, interop-testing: always set message encoding, and use it in interop tests
This change updates the behavior of the core compression semantics.  Previously,
if the codec was "identity", nothing was set on the wire.  This is allowed by
the spec, but doesn't match what wrapped languages do.

Additionally, the interop tests will now attempt to honor the requested
compression.
2016-05-18 12:04:25 -07:00
Carl Mastrangelo 2825361767 stub: use correct javadoc link for Guava 2016-05-16 10:25:03 -07:00
nmittler 951b5a4ca2 Adding metadata to Status exceptions.
Fixes #681
2016-05-13 15:52:06 -07:00
nmittler d9d4d8b70f Updating status codes to match the spec.
Fixes #1605
2016-05-09 13:55:50 -07:00
Carl Mastrangelo bc661e7fbb all: Finish adding tracking issues for ExperimentalApi 2016-05-03 16:15:57 -07:00
Carl Mastrangelo 0f9e3fa2ea all: Add issues for many of the experimental API annotations 2016-05-03 13:24:28 -07:00
Eric Anderson b0ed77ad81 Specify Status*Exception is to be used in StreamObserver.onError 2016-04-27 16:45:05 -07:00
Kun Zhang 16e168951a Allow application to pass cancellation details.
Resolves #1221

Add ClientCall.cancel(String, Throwable) and deprecate
ClientCall.cancel(). Will delete cancel() after all known third-party
overriders have switched to overriding the new one.
2016-04-27 09:38:18 -07:00
Lukasz Strzalkowski 2fbf142a41 Provide base methods for Abstract stub
Default implementation returns status UNIMPLEMENTED. This allows adding
new methods to services without breaking existing code.
2016-04-11 16:38:23 +02:00
Łukasz Strzałkowski 90fbf9b274 Adapt BindableService in ServerBuilder#addService
Makes binding services to server as simple as it can get.
2016-04-08 11:14:26 -07:00
Lukasz Strzalkowski f8b71e72b3 Add Abstract{ServiceName} class in compiled service class 2016-04-07 17:39:17 -07:00
Steven Parkes 385d61ac4e add a little detail about thread safety / fix typo (#1643) 2016-04-07 17:29:43 -07:00
Kun Zhang 7d49990783 Add RunWith annotation to AbstractStubTest.
It got an error when built internally.
2016-03-28 11:19:03 -07:00
buchgr 32ddf9f381 Make CallOptions and AbstractStub use Deadline.
- Made CallOptions use the Deadline type instead of a
  long to represent a deadline.
- Added new methods CallOptions.withDeadline(Deadline) and
  AbstractStub.withDeadline(Deadline). The methods are
  marked experimental, as the Deadline class is marked
  experimental. These methods are meant to replace
  CallOptions.withDeadlineNanoTime(Long) and
  AbstractStub.withDeadlineNanoTime(Long), which have
  been deprecated.
- Updated CallOptions.toString() to include all fields.
2016-03-25 22:15:22 +01:00
Carl Mastrangelo 65d3847d14 Remove references to Throwable.propagate 2016-03-22 15:47:52 -07:00
buchgr fcda0bb9f7 Fix javadoc in MetadataUtils 2016-03-21 13:59:07 +01:00
buchgr 8e3f375e95 Add null check for channel and calloptions when creating stub. Fixes #1438 2016-03-16 15:33:30 +01:00
Louis Ryan 7902017b07 Add CallStreamObserver and ServerCallStreamObserver which allow for application level interaction with flow control
while still allowing stubs to be used.
Currently these APIs are only useful on the server side, a separate proposal will be made for adding client support
An example of usage is in TestServiceImpl.streamingOutputCallManualFlowControl which listens for flow-control 'onReady' events and produces messages to the client.
Added some unit testing for ServerCalls
2016-03-15 16:45:45 -07: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
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 a3c79e87ae Add a simple compression API 2016-02-01 12:56:21 -08:00
Eric Anderson 4168f67e38 Optimize blocking calls to avoid app thread pool
This reduces the necessary number of threads in the application executor
and provides a small improvement in latency (~15μs, which is normally in
the noise, but would be a 5% improvement).

Benchmark                         (direct)  (transport)  Mode  Cnt       Score        Error  Units
Before:
TransportBenchmark.unaryCall1024      true    INPROCESS  avgt   10    1566.168 ±     13.677  ns/op
TransportBenchmark.unaryCall1024     false    INPROCESS  avgt   10   35769.532 ±   2358.967  ns/op
After:
TransportBenchmark.unaryCall1024      true    INPROCESS  avgt   10    1813.778 ±     19.995  ns/op
TransportBenchmark.unaryCall1024     false    INPROCESS  avgt   10   18568.223 ±   1679.306  ns/op

The benchmark results are exactly what we would expect, assuming that
half of the benefit of direct is on server and half on client:
1566 + (35769 - 1566) / 2 = 18668 ns --vs-- 18568 ns

It is expected that direct=true would get worse, because
SerializingExecutor is now used instead of
SerializeReentrantCallsDirectExecutor plus the additional cost of
ThreadlessExecutor.

In the future we could try to detect the ThreadlessExecutor and ellide
Serializ*Executor completely (as is possible for any single-threaded
executor). We could also optimize the queue used in ThreadlessExecutor
to be single-producer, single-consumer. I don't expect to do those
optimizations soon, however.
2016-01-26 12:41:50 -08:00
Carl Mastrangelo 4b18f49330 Move ServerCall unary check and add tests 2015-12-10 13:01:48 -08:00
Carl Mastrangelo 529b14c07b Add compressor registry, and auto negotiate compression 2015-12-07 10:56:16 -08:00
Louis Ryan 7f2678a332 Switch from INTERNAL to CANCELLED for InterruptedException 2015-12-03 14:33:39 -08:00
Xudong Ma 47ad6f81bf Fix the double-closure of server call for interop tests. 2015-09-15 16:40:59 -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
Eric Anderson 701f9cd7ee Remove stray request() in server-sending path 2015-09-11 17:37:22 -07:00
Eric Anderson 9cb36c6e20 Mark some APIs codegen uses experimental to allow for optimizations
Fixes #975
2015-09-11 11:13:27 -07:00
Eric Anderson be0d7e911a Prevent construction of container classes and reduce API 2015-09-10 10:09:13 -07:00
Eric Anderson 23e6318156 Reduce API surface of AbstractStub 2015-09-10 08:36:08 -07:00
Carl Mastrangelo 399be9ac73 Use stub call options for compression 2015-09-09 13:21:04 -07:00
Xudong Ma 0a51f0fbd9 Move StreamRecorder to testing package. 2015-09-01 09:15:03 -07:00
Louis Ryan a4c821d94e Rename onValue to onNext in StreamObserver to align with the naming in Rx & the proposed Flow API in
Java9
2015-08-26 17:38:22 -07:00
nmittler d5977c4552 Fixing the benchmarks
Fixes #873
2015-08-26 13:55:39 -07:00
Carl Mastrangelo a508c1d4f5 Remove Headers 2015-08-24 11:41:10 -07:00
Carl Mastrangelo 572f4332a7 Remove Trailers 2015-08-13 17:11:29 -07:00
Carl Mastrangelo b141093b3b Make serverInterceptor use MethodDescriptor 2015-08-07 09:28:29 -07:00
Carl Mastrangelo e76b8e7ee8 Renamed Server payload to message 2015-08-05 17:10:37 -07:00
Carl Mastrangelo 67fc45d036 Rename Duplex to Bidi 2015-08-05 17:05:47 -07:00
Carl Mastrangelo 89db769d2d Rename sendPayload to sendMessage 2015-07-31 15:28:06 -07:00
Carl Mastrangelo 14e774130d Rename onPayload to onMessage 2015-07-31 15:11:18 -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
Kun Zhang eb92967a7e Get rid of AbstractServiceDescriptor as it is no longer useful 2015-07-17 17:03:36 -07:00
Kun Zhang b80abef13f Optimize for flow-control: only request for 2 responses in unary-response cases 2015-07-17 09:09:29 -07:00
Kun Zhang d28535bb20 Fail call if more than responses received while only one is expected 2015-07-16 18:17:07 -07:00
Kun Zhang 686dcff217 Rename unaryFutureCall to futureUnaryCall 2015-07-16 12:34:37 -07:00
Kun Zhang 690b26eb93 Sanitize ClientCalls.
- Remove blockingClientStreamingCall() which is not used, and we don't
  actually want that API.
- Rename duplexStreamingCall() to asyncDuplexStreamingCall() to align
  with other async methods.
- In unary call and client streaming call, do not request for additional
  response after the first response.
2015-07-15 17:35:36 -07:00
Kun Zhang 867c76d185 Separate ServerCall binding utilities per method type.
This gives us more flexibility in API changes in the future.

Unary call and server streaming call should call the flow-control method
call.request() only once. Previously it was called whenever a request
arrives, which is wrong. Now it's fixed.

Resolves #436
2015-07-14 13:36:16 -07:00
Kun Zhang c73b75e477 Change AbstractServiceDescriptor.methods() to Collection. Resolves #573 2015-07-09 14:24:51 -07:00
Kun Zhang 73acc73dbf Remove Method and switch its users to MethodDescriptor.
Resolves #511.

- In generated code, make CONFIG private and METHOD_* fields public.
  METHOD_* fields are MethodDescriptors now, users of the CONFIG field
  should switch to using the METHOD_* fields.
- Move MethodType into MethodDescriptor (#529).
- Unify the fully qualified method name. It is fully qualified service
  name + slash + short method name. It doesn't have the leading slash.
- HandlerRegistry switches the key from short method name to fully
  qualified method name.
2015-07-09 09:29:03 -07:00
Eric Anderson d27cbc8aa3 Improve docs to describe close as being last method called
This isn't changing any of the semantics we already had, but more
informing users of the guarantees we provide.
2015-07-08 15:08:26 -07:00
Kun Zhang d3c5b00827 Add CallOptions.
- Pass CallOptions to Channel.newCall() and
  ClientInterceptor.interceptCall().
- Remove timeout from AbstractStub.StubConfigBuilder and add deadline,
  which is stored in a CallOptions inside the stub.
- Deadline is in nanoseconds in the clock defined by System.nanoTime().
  It is converted to timeout before transmitting on the wire. Fail the
  call with DEADLINE_EXCEEDED if it's already expired.
2015-07-07 14:28:38 -07:00
Eric Anderson 68efade3f5 Set hard-coded deadline to just under 1 year
10 years exceeds the maximum for some systems at the moment. Change to 1
year to workaround such systems while they get changed. And since "have
the default be a large number instead of not present" is a temporary fix
anyway.
2015-07-06 12:48:26 -07:00
Eric Anderson 74b5d29c8a Improve Exception backtrace for blocked streaming
Delaying creating the exception produces a much more useful exception.
The status code, description, and exception type are all identical. The
only difference in the backtrace.
2015-07-01 16:39:15 -07:00
Eric Anderson 7233077cdf Fake infinite timeout; 1s is not a good hard-coded timeout
Stubs don't have any timeout. However, MethodDescriptor does and
requires a timeout. We really want "no timeout," which is infinite, but
we use 10 years as the next best thing. CallOptions will end up fixing
this hack as MethodDescriptor will no longer have timeout.

Before, the hard-coded 1s didn't matter, because nobody was observing
it. Since 77878a0 it is now being sent to servers, and some servers
enforce it. Oops.
2015-07-01 16:24:39 -07:00
Eric Anderson fd52a765ed Blocking calls should error with StatusRuntimeException
Previously, it always threw a RuntimeExecutionException with a
StatusRuntimeException within (since the only callers of setException()
provide a StatusRuntimeException).

Resolves #507
2015-06-18 17:59:32 -07:00
Kun Zhang 2ee4d0228d Rename Call to ClientCalls.
Other classes are already following the convention that ClientFoo for
client-side, and ServerFoo for server-side. Call has been the black
sheep of the family.

- Call -> ClientCall
- Calls -> ClientCalls
- ForwardingCall* -> ForwardingClientCall*
2015-06-04 16:39:25 -07:00
Eric Anderson 10fb20650d Produce combined JavaDoc, add links, exclude internals 2015-05-05 11:32:15 -07:00
nmittler 64176d5560 Adding outbound flow control for Netty. 2015-05-04 12:19:57 -07:00
nmittler 7779b4fddf Cleaning up some warnings. 2015-04-30 13:57:38 -07:00
Kun Zhang 0d89d3d1bc Fix the issue where the intecepting call fails in start(), does not
call super.start(), and makes the subsequent use of other methods on the
call throw IllegalStateException.

Create ClientInterceptors.CheckedForwardingCall that handles exception
in start logic.

Create Forwarding[Server]Call[Listener] for generic decoration use
cases, with an abstract delegate() for flexibility.

Create SimpleForwarding[Server]Call[Listener] to replace now deprecated
forwarding classes.
2015-04-09 15:56:03 -07:00
Xudong Ma 2cad9e6000 Add "unsed import" check. 2015-04-03 16:55:01 +08: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
zhangkun83 abd4eec055 Implement cancellation for the Future interface. 2015-03-02 10:33:59 -08:00
zhangkun83 c01af90d18 Polish javadoc for stub/* 2015-02-25 15:20:36 -08:00
Louis Ryan 95c6f5082c Udate TODOs to use Github user names 2015-02-23 12:46:28 -08:00
Eric Anderson 746eccaced Fix inbound flow control for Calls.blockingServerStreamingCall
asyncServerStreamingCall provides the initial request(1).

Fixes #93
2015-02-19 09:37:09 -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
nmittler 02c953e5e0 Migrating run scripts to gradle. 2015-01-26 15:26:11 -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 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
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
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
zhangkun 776ff86687 Eliminate ForwardingChannel and switch all use cases to client interceptors.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=79360027
2015-01-08 14:43:04 -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
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
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
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
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
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
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
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
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
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
nathanmittler 23fbc7cb5e Adding support for manually specifying HTTP/2 :authority and :path headers.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=75316631
2015-01-08 14:42:44 -08:00
lryan a7d735e69b Phase 2 of converting to new Headers mechanism for side-channel.
Remove 'context' from interfaces/tests/framers/...

Next phases
- Switch the wire format (ESF needs to be done in near lock-step)
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=75164642
2015-01-08 14:42:43 -08:00
lryan e4bd1c7d69 Phase 1 of converting to new Headers mechanism for side-channel.
Introduces Header and uses it for propagating text-only header values over existing transports
Leaves Context & wire format otherwise unchanged

Next phases
- Remove context from interfaces
- Switch the wire format (ESF needs to be done in near lock-step)

Interface changes are relatively light
Headers class is functional but not optimal
All serialization is done as string until transports expose interface for binary headers
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=75050265
2015-01-08 14:42:43 -08:00
ejona 621706aa03 Add basic OAuth support to gRPC.
The primary functionality is an interceptor that authenticates calls using oauth. However, most of the changes are for an integration test to make sure the code works with ESF.

This is based on work by lryan and simonma.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=72567773
2015-01-08 14:42:33 -08:00
lryan 34650408aa Add ability to bind HTTP style headers to stubs and have them propagate over
transports that can deliver them.

This unblocks sending OAuth2 headers natively
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=71118741
2015-01-08 14:42:29 -08:00
nathanmittler f4694f57f9 A couple minor fixes to Channel for bugs exposed while integration testing with Netty transport.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=69939586
2015-01-08 14:42:26 -08:00
ejona 4d642200e7 [2/2] Swap Operation wrapping from Channel to Transport.
Session is now (properly) implementing transport API, so ChannelImpl has some
testing.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=69074094
2015-01-08 14:42:23 -08:00
ejona 35cabd0b82 [1/2] Split Channel and Stub APIs, implement Channel.
Call does not accept InputStream length because Marshaller makes it too hard
for the Stub to determine the length.

SessionCall is updated to implement changes to Call, but it is replaced in the
next CL.

You can see what glue is necessary to join the Transport and Stub APIs. The
ugliest pain is dealing with flow control callback. Some of that code is
unrelated and necessary because the Channel uses a separate thread to run
Call.Listener. Other parts will be necessary because Channel must intervene
during Transport callbacks to handle retry logic.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=69020275
2015-01-08 14:42:23 -08:00
ejona 2af35d9bd3 Improve JavaDoc, including style fixes
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=68555036
2015-01-08 14:42:22 -08:00
ejona 8be938ee25 Move newstub to third_party and rename to stub.
It was an oversight that newstub was not in third_party when committed.

Renaming of package was preformed via a script.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=68416211
2015-01-08 14:42:20 -08:00