Commit Graph

104 Commits

Author SHA1 Message Date
Carl Mastrangelo 3a39b81cf5
all: remove java6 type args 2019-02-04 10:03:50 -08:00
Eric Anderson 4a3f28f45f context: fix detaching ROOT
If you attach literal ROOT to the thread, if anyone else restores root
it will set the thread local to be null. This broke the "are you
detaching the current context" check, as ROOT != null. This was a
regression introduced in 55b08e67d.
2019-02-01 11:56:20 -08:00
ZHANG Dapeng d0ecc08705
all: fix lint 2019-01-31 09:31:13 -08:00
Eric Anderson 55b08e67d4 context: Avoid leaking ClassLoader through ThreadLocal 2019-01-28 13:54:52 -08:00
Carl Mastrangelo 2d654496ee
context: make Deadline toString() more readable 2018-12-05 17:44:44 -08:00
Rodrigo Queiro 8481943866 Add missing j2objc dependency to Bazel build
This avoids a warning when building artifacts that depend on Guava.

Fixes #5046.
2018-11-13 13:39:35 -08:00
Carl Mastrangelo b0f423295b
all: use Java7 brackets 2018-09-14 13:52:29 -07:00
Eric Gribkoff 79b24709b9
all: update animalsniffer to Java 7 and add Android 14 (#4727) 2018-08-09 09:09:21 -07:00
Eric Anderson 6d7c7dc583 context: Avoid deprecated Truth API
This helps an internal cleanup removing the old failWithRawMessage API.
2018-07-20 14:48:44 -07:00
ZHANG Dapeng bf4a00c6de
context/core/netty: Add @CheckReturnValue to Context
By adding inner class annotations without introducing external dependencies.
2018-05-15 13:14:30 -07:00
Carl Mastrangelo 60a0b0c471
all: normalize copyright header 2018-05-03 14:55:21 -07:00
Carl Mastrangelo a414b91a59
context: remove context profiling 2018-02-15 18:08:19 -08:00
Carl Mastrangelo 6ea8fffa2b
context: add basic context profiling 2018-02-09 19:45:19 -08:00
Bogdan Drutu af936919f3 Update opencensus to 0.11.0 and remove extra dependencies. 2018-01-26 13:04:26 -08:00
Eric Anderson 2d88269965 Update to Truth 0.36
Due to transitive dependencies, this also upgrades Guava to 22. However
Truth is only used in our tests, so our users should be unimpacted.
2017-12-04 13:48:00 -08:00
Eric Anderson 2bde25d2d9 testing: Remove DeadlineSubject
The class is still used internally, so we move it to context's tests for
it to be reused. To avoid a circular dependency with context's tests
depending on core's tests, StaticTestingClassLoader was also moved to
context's tests.

This is driven by a need to modernize DeadlineSubject for newer versions
of Truth, but the newer versions of Truth update Guava. To avoid leaking
the Guava update to all users of grpc-testing, we're removing the
Subject. In our internal tests we can update the Truth dependency with
less issue.
2017-11-22 17:57:46 -08:00
zpencer 255643bed9 context: Make CancellableContext implement Closeable (#3607) 2017-10-25 11:17:44 -07:00
Eric Anderson 5bf4f5b7a6 context: Use .class literal instead of Class.forName
Found via ErrorProne
2017-09-20 09:43:50 -07:00
Eric Anderson bd28b92850 Avoid catching AssertionError in tests
Found via ErrorProne
2017-09-20 09:43:50 -07:00
zpencer 86dec11f7b context: log severe warning if ancestry chain too long (#3459)
If a context has an unreasonable number of ancestors, then
chances are this is an application error. Log the stack trace to
notify the user and aid in debugging.
2017-09-14 11:39:19 -07:00
Eric Anderson 6164b7b2ee Move jmh benchmarks to their respective modules
The benchmarks should be close to the code they're benchmarking, like
we do with tests.

This includes a bugfix to SerializingExecutorBenchmark to let it run.

The io.grpc.benchmarks.netty benchmarks in benchmarks/ depend on
ByteBufOutputMarshaller from benchmarks's main, so they were not moved.
2017-08-28 13:37:39 -07:00
Eric Gribkoff 812e65a5ca context: add RunWith annotation 2017-08-28 12:11:02 -07:00
Eric Anderson 3620931eae context: Use polymorphism instead of canBeCancelled field 2017-08-28 09:41:56 -07:00
Eric Anderson 21cd244734 context: Remove superfluous cascadesCancellation field 2017-08-28 09:41:56 -07:00
Eric Anderson 7cafb6745b context: Store Deadline in CancellableContext directly 2017-08-24 13:21:06 -07:00
zpencer e707d95d77 context: compress cancellation ancestor chain (#3372)
Now that we have the copy of write keyvalue store (#3368), there
is no need to keep the full parent chain. We only need a
reference to the nearest cancellable ancestor. This optimization
should in theory make cancellations more efficient and also make
our data structs more GC friendly.
2017-08-22 09:20:31 -07:00
zpencer 608b95547b context: remove unused fields from removed bloomfilter (#3371)
remove unused fields from removed bloom filter
2017-08-22 08:21:31 -07:00
zpencer b45e354411 context: hashtrie based keyvalue store (#3368)
This is the hashtrie data structure authored by @ejona86

The linked list key value store is known cause problems in
pathological cases where users keep updating the same key(s) over and
over. This copy on write tree will bound reads at O(lgN) where N is
the number of keys in the map, rather than O(lgM) where M is the total
number of put operations.

Also:

- added some unit tests
- ran a test putting random keys into the map and comparing the result
  with a java.util.HashMap to verify sanity. The test passes but I
  won't check it into the repo because it takes a long time to run:
  https://gist.github.com/zpencer/12cb435235d171c1fe09aef18825fad0
2017-08-21 16:35:17 -07:00
zpencer 47ce000464 add bloom filter to Context (#3350)
* This is the bloom filter based context improvement authored by @lukesandberg
2017-08-16 10:38:02 -07:00
Paul Gross 72b9ee22b8 all: Fix mismatch in naming Bazel Maven jars
This commit aligns the naming of the Bazel Maven jars with the names
used by Bazel's migration-tooling project:

https://github.com/bazelbuild/migration-tooling

Unfortunately, we can't fix @com_google_protobuf_java because it's
required by Bazel itself.

Fixes #3328
2017-08-11 16:39:43 -07:00
zpencer e195c1ab76 context: change storage API to return a restoreable context (#3292)
This API change allows storage implementations to put some state
information into the return value, giving it the ability to act
as a cookie. In environments where contexts can be replaced, the
current original context can be stashed there and be restored
when detach is called.
2017-08-10 19:30:53 -07:00
Vladimir Gordiychuk 00fe090ac1 context: Create TimeoutException only when deadline occurs
Use deadline on client calls lead to create TimeoutException even
if deadline not occurs yet. fillStacktrack very expensive operation
that allocate many unnecessary objects in heap. Now exception
creates only when deadline occurs.

Close #3272
2017-07-25 15:53:37 -07:00
ZHANG Dapeng db279eb3c1 context: add test for the scenario that Context's logger itself is using Context
This will break if
7f1ac34d41,
2f6e2c87ab,
a3a5420922
are reverted:

```
io.grpc.ContextTest > initContextWithCustomClassLoaderWithCustomLogger FAILED
    java.lang.ExceptionInInitializerError
        at io.grpc.ContextTest$LoadMeWithStaticTestingClassLoader.run(ContextTest.java:789)
        at io.grpc.ContextTest.initContextWithCustomClassLoaderWithCustomLogger(ContextTest.java:760)

        Caused by:
        java.lang.RuntimeException: Storage override had failed to initialize
            at io.grpc.Context.storage(Context.java:134)
            at io.grpc.Context.current(Context.java:163)
            at io.grpc.ContextTest$LoadMeWithStaticTestingClassLoader$1.publish(ContextTest.java:773)
            at java.util.logging.Logger.log(Logger.java:738)
            at java.util.logging.Logger.doLog(Logger.java:765)
            at java.util.logging.Logger.log(Logger.java:875)
            at io.grpc.Context.<clinit>(Context.java:122)
            ... 2 more
```
2017-07-21 15:20:02 -07:00
Eric Anderson 7f1ac34d41 context: Lazy load storage
Using static initialization is possible, but quite complex to handle
logging and circular loading. Lazy loading prevents an entire class of
circular dependencies.
2017-07-20 16:34:05 -07:00
Kun Zhang 2f6e2c87ab context: stop using logger at all in static initialization. (#3191)
Turns out avoiding log() alone in the static initialization is not
enough. isLoggable() can also be overridden and call back to Context.
We take a another approach, save the exception and log it outside of
the initialization block.
2017-07-06 13:55:44 -07:00
Eric Anderson c436561fc5 all: Use fixed version number for java 6/7 signatures
This is important for stable builds, as if the signature changes the old source
may no longer validate.
2017-06-30 15:25:34 -07:00
Simon Horlick 6d9e149dcb build: Add Bazel java_grpc_library rule
Bazel third party dependencies are specified in repositories.bzl which
gives the consumer the ability to opt-out of any dependencies they use
directly in their own project.

Fixes #2756
2017-06-22 13:06:49 -07:00
Carl Mastrangelo 0622dce925 context: declare that context should not be mocked 2017-06-06 13:04:32 -07:00
Carl Mastrangelo 166108a943 all: fix licence whitespace 2017-06-01 14:28:37 -07:00
Carl Mastrangelo 3bfd630bff all: update to Apache 2 licence
Also, update the authors.
2017-05-31 13:29:01 -07:00
zpencer 347eb09d92 all: Minor updates to expand javadocs (#2991)
all: Minor updates to expand javadocs
2017-05-17 17:12:45 -07:00
Eric Anderson eb6acfe186 Javadoc improvements, especially to Context 2017-05-15 10:12:44 -07:00
ZHANG Dapeng 87c75b3ce7 core: annotate some keys with Immutable; Context.Key final 2017-03-16 17:50:23 -07:00
Eric Anderson 72923dca87 all: prepare for ErrorProne's FutureReturnValueIgnored
Futures almost universally should be handled in some way when being
returned, either to receive the value or to cancel scheduled tasks to
prevent leaks.

Netty is a bit of a special case though, since it constantly returns
futures that you ignore (even adding a listener returns the "this"
future). So we want to suppress the warning for code using Netty instead
of trying to fix it. When we enable ErrorProne in the build, we should
start passing -Xep:FutureReturnValueIgnored:OFF in the compilerArgs.
2017-02-16 07:22:56 -08:00
Eric Anderson 42aa64c647 all: swap to newer animalsniffer plugin
The new plugin uses a newer version of animalsniffer, allows overriding
the animalsniffer version used, and has up-to-date handling. The
up-to-date handling cuts fully incremental parallel build times in half,
from 5.5s to 2.7s.

The previous plugin was supposed to be verifying tests. However, either
it wasn't verifying them or its verification was broken.
2017-02-07 12:49:01 -08:00
Carl Mastrangelo 89bc2cd3b2 all: update to latest import ordering 2017-01-26 13:43:06 -08:00
Kun Zhang 8a4c7bdf7f docs: clarify requirements of detach(). (#2630) 2017-01-20 15:31:04 -08:00
Kun Zhang a3a5420922 context: don't log to logger in static initialization. (#2581) 2017-01-10 11:10:15 -08:00
Kun Zhang ea4390cf5c context: put ContextStorageOverride in io.grpc.override. (#2570)
To make it easier to filter.
2017-01-06 08:55:29 -08:00
Kun Zhang b34d07d058 core: remove a benign data race. (#2546)
This is an alternative to #2543 and it doesn't introduce volatile usage.
2016-12-21 13:21:10 -08:00
Kun Zhang 97b926391b context: add the four-value withValues(). (#2506) 2016-12-13 14:03:23 -08:00
Eric Anderson cfb6bd0fe2 context: Fix ErrorProne ClassNewInstance
http://errorprone.info/bugpattern/ClassNewInstance
2016-12-08 10:33:31 -08:00
Kun Zhang 84862867f7 context: pluggable Storage mechanism. (#2461)
Currently Context propagate in-thread by its own ThreadLocal, and
cross-thread propagation must be done with the mechanisms provied by
gRPC Context.  However, there are frameworks (e.g. what we are using
inside Google) which have already established context-propagation
mechanisms.  If gRPC Context may ride on top of them, it would be
propagated automatically without additional effort from the application.

The Storage API allows gRPC Context to be attached to anything.  The
default implementation still uses its own ThreadLocal.  If an override
implementation is present, gRPC Context will use it.
2016-12-02 09:47:58 -08:00
Kun Zhang c4f7f5c4fd core: split Context into a separate grpc-context artifact.
The Context API is not particularly gRPC-specific, and will be used by
Census as its context propagation mechanism.

Removed all dependencies to make it easy for other libraries to depend
on.
2016-09-02 13:18:35 -07:00