-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #122 from openzipkin/async-spanstore
Adds AsyncSpanStore: an SPI to adapt to async composition libraries
- Loading branch information
Showing
23 changed files
with
1,095 additions
and
372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
zipkin-spanstores/elasticsearch/src/main/java/zipkin/elasticsearch/ElasticFutures.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/** | ||
* Copyright 2015-2016 The OpenZipkin Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
package zipkin.elasticsearch; | ||
|
||
import com.google.common.base.Function; | ||
import com.google.common.util.concurrent.FutureCallback; | ||
import com.google.common.util.concurrent.Futures; | ||
import com.google.common.util.concurrent.ListenableFuture; | ||
import com.google.common.util.concurrent.SettableFuture; | ||
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.action.ListenableActionFuture; | ||
import zipkin.async.Callback; | ||
|
||
final class ElasticFutures { | ||
|
||
static <T> ListenableFuture<T> toGuava(ListenableActionFuture<T> elasticFuture) { | ||
final SettableFuture<T> future = SettableFuture.create(); | ||
elasticFuture.addListener(new ActionListener<T>() { | ||
@Override public void onResponse(T t) { | ||
future.set(t); | ||
} | ||
|
||
@Override public void onFailure(Throwable e) { | ||
future.setException(e); | ||
} | ||
}); | ||
return future; | ||
} | ||
|
||
static <A, C> void onComplete( | ||
ListenableActionFuture<A> future, | ||
final Callback<C> callback, | ||
final Function<A, C> successTransformationFn | ||
) { | ||
future.addListener(new ActionListener<A>() { | ||
|
||
@Override public void onResponse(A a) { | ||
try { | ||
callback.onSuccess(successTransformationFn.apply(a)); | ||
} catch (Error | RuntimeException e) { | ||
callback.onError(e); | ||
} | ||
} | ||
|
||
@Override public void onFailure(Throwable e) { | ||
callback.onError(e); | ||
} | ||
}); | ||
} | ||
|
||
static <A, C> void onComplete( | ||
ListenableFuture<A> future, | ||
final Callback<C> callback, | ||
final Function<A, C> successTransformationFn | ||
) { | ||
Futures.addCallback(future, new FutureCallback<A>() { | ||
|
||
@Override public void onSuccess(A result) { | ||
try { | ||
callback.onSuccess(successTransformationFn.apply(result)); | ||
} catch (Error | RuntimeException e) { | ||
callback.onError(e); | ||
} | ||
} | ||
|
||
@Override public void onFailure(Throwable t) { | ||
callback.onError(t); | ||
} | ||
}); | ||
} | ||
} |
37 changes: 0 additions & 37 deletions
37
...-spanstores/elasticsearch/src/main/java/zipkin/elasticsearch/ElasticListenableFuture.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.