本文整理汇总了Java中io.vertx.core.impl.NoStackTraceThrowable类的典型用法代码示例。如果您正苦于以下问题:Java NoStackTraceThrowable类的具体用法?Java NoStackTraceThrowable怎么用?Java NoStackTraceThrowable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NoStackTraceThrowable类属于io.vertx.core.impl包,在下文中一共展示了NoStackTraceThrowable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: waitUntilElasticsearchRunning
import io.vertx.core.impl.NoStackTraceThrowable; //导入依赖的package包/类
/**
* Wait 60 seconds or until Elasticsearch is up and running, whatever
* comes first
* @param client the client to use to check if Elasticsearch is running
* @return an observable that emits exactly one item when Elasticsearch
* is running
*/
public Observable<Void> waitUntilElasticsearchRunning(
ElasticsearchClient client) {
final Throwable repeat = new NoStackTraceThrowable("");
return Observable.defer(client::isRunning).flatMap(running -> {
if (!running) {
return Observable.error(repeat);
}
return Observable.just(running);
}).retryWhen(errors -> {
Observable<Throwable> o = errors.flatMap(t -> {
if (t == repeat) {
// Elasticsearch is still not up, retry
return Observable.just(t);
}
// forward error
return Observable.error(t);
});
// retry for 60 seconds
return RxUtils.makeRetry(60, 1000, null).call(o);
}).map(r -> null);
}
示例2: count
import io.vertx.core.impl.NoStackTraceThrowable; //导入依赖的package包/类
@Override
public Observable<Long> count(String type, JsonObject query) {
String uri = "/" + index + "/" + type + "/_count";
JsonObject source = new JsonObject();
if (query != null) {
source.put("query", query);
}
return performRequestRetry(HttpMethod.GET, uri, source.encode())
.flatMap(sr -> {
Long l = sr.getLong("count");
if (l == null) {
return Observable.error(new NoStackTraceThrowable(
"Could not count documents"));
}
return Observable.just(l);
});
}
示例3: ensureIndex
import io.vertx.core.impl.NoStackTraceThrowable; //导入依赖的package包/类
/**
* Ensure the Elasticsearch index exists
* @return an observable that will emit a single item when the index has
* been created or if it already exists
*/
@Override
public Observable<Void> ensureIndex() {
// check if the index exists
return indexExists().flatMap(exists -> {
if (exists) {
return Observable.just(null);
} else {
// index does not exist. create it.
return createIndex().flatMap(ack -> {
if (ack) {
return Observable.just(null);
}
return Observable.error(new NoStackTraceThrowable("Index creation "
+ "was not acknowledged by Elasticsearch"));
});
}
});
}
示例4: ensureMapping
import io.vertx.core.impl.NoStackTraceThrowable; //导入依赖的package包/类
/**
* Ensure the Elasticsearch mapping exists
* @param type the target type for the mapping
* @return an observable that will emit a single item when the mapping has
* been created or if it already exists
*/
@Override
public Observable<Void> ensureMapping(String type, JsonObject mapping) {
// check if the target type exists
return typeExists(type).flatMap(exists -> {
if (exists) {
return Observable.just(null);
} else {
// target type does not exist. create the mapping.
return putMapping(type, mapping).flatMap(ack -> {
if (ack) {
return Observable.just(null);
}
return Observable.error(new NoStackTraceThrowable("Mapping creation "
+ "was not acknowledged by Elasticsearch"));
});
}
});
}
示例5: doRun
import io.vertx.core.impl.NoStackTraceThrowable; //导入依赖的package包/类
@Override
public void doRun(String[] remainingArgs, InputReader in, PrintWriter out,
Handler<Integer> handler) throws OptionParserException, IOException {
GeoRocketClient client = createClient();
client.getStore().setProperties(query, layer, properties, ar -> {
if (ar.failed()) {
client.close();
Throwable t = ar.cause();
error(t.getMessage());
if (!(t instanceof NoStackTraceThrowable)) {
log.error("Could not set properties", t);
}
handler.handle(1);
} else {
handler.handle(0);
}
});
}
示例6: doRun
import io.vertx.core.impl.NoStackTraceThrowable; //导入依赖的package包/类
@Override
public void doRun(String[] remainingArgs, InputReader in, PrintWriter out,
Handler<Integer> handler) throws OptionParserException, IOException {
GeoRocketClient client = createClient();
client.getStore().delete(query, layer, ar -> {
if (ar.failed()) {
client.close();
Throwable t = ar.cause();
error(t.getMessage());
if (!(t instanceof NoStackTraceThrowable)) {
log.error("Could not delete from store", t);
}
handler.handle(1);
} else {
handler.handle(0);
}
});
}
示例7: doRun
import io.vertx.core.impl.NoStackTraceThrowable; //导入依赖的package包/类
@Override
public void doRun(String[] remainingArgs, InputReader in, PrintWriter out,
Handler<Integer> handler) throws OptionParserException, IOException {
GeoRocketClient client = createClient();
client.getStore().appendTags(query, layer, tags, ar -> {
if (ar.failed()) {
client.close();
Throwable t = ar.cause();
error(t.getMessage());
if (!(t instanceof NoStackTraceThrowable)) {
log.error("Could not add the tags", t);
}
handler.handle(1);
} else {
handler.handle(0);
}
});
}
示例8: doRun
import io.vertx.core.impl.NoStackTraceThrowable; //导入依赖的package包/类
@Override
public void doRun(String[] remainingArgs, InputReader in, PrintWriter out,
Handler<Integer> handler) throws OptionParserException, IOException {
GeoRocketClient client = createClient();
client.getStore().removeProperties(query, layer, properties, ar -> {
if (ar.failed()) {
client.close();
Throwable t = ar.cause();
error(t.getMessage());
if (!(t instanceof NoStackTraceThrowable)) {
log.error("Could not remove properties", t);
}
handler.handle(1);
} else {
handler.handle(0);
}
});
}
示例9: doRun
import io.vertx.core.impl.NoStackTraceThrowable; //导入依赖的package包/类
@Override
public void doRun(String[] remainingArgs, InputReader in, PrintWriter out,
Handler<Integer> handler) throws OptionParserException, IOException {
GeoRocketClient client = createClient();
client.getStore().getPropertyValues(property, query, layer, ar -> {
if (ar.failed()) {
Throwable t = ar.cause();
error(t.getMessage());
if (!(t instanceof NoStackTraceThrowable)) {
log.error("Could not get values of property " + property, t);
}
handler.handle(1);
} else {
ar.result().handler(buf -> {
out.write(buf.toString("utf-8"));
});
ar.result().endHandler(v -> {
client.close();
handler.handle(0);
});
}
});
}
示例10: doRun
import io.vertx.core.impl.NoStackTraceThrowable; //导入依赖的package包/类
@Override
public void doRun(String[] remainingArgs, InputReader in, PrintWriter out,
Handler<Integer> handler) throws OptionParserException, IOException {
GeoRocketClient client = createClient();
client.getStore().removeTags(query, layer, tags, ar -> {
if (ar.failed()) {
client.close();
Throwable t = ar.cause();
error(t.getMessage());
if (!(t instanceof NoStackTraceThrowable)) {
log.error("Could not remove the tags", t);
}
handler.handle(1);
} else {
handler.handle(0);
}
});
}
示例11: error
import io.vertx.core.impl.NoStackTraceThrowable; //导入依赖的package包/类
/**
* Write an error and code to the response.
*
* @param exception the exception that caused the error.
*/
default void error(Throwable exception) {
if (exception instanceof CoreException || exception instanceof CoreRuntimeException) {
write(Protocol.response(((CoreExceptionFormat) exception).status(), exception));
} else if (exception instanceof DecodeException || exception instanceof NoStackTraceThrowable) {
write(Protocol.response(ResponseStatus.ERROR, exception));
} else {
write(Protocol.response(ResponseStatus.ERROR, new UnmappedException(exception)));
}
}
示例12: circuitBreakerWrapper
import io.vertx.core.impl.NoStackTraceThrowable; //导入依赖的package包/类
private Future<RpcResponse> circuitBreakerWrapper(String traceId,
Future<RpcResponse> circuitBreakerFuture) {
Future<RpcResponse> future = Future.future();
circuitBreakerFuture.setHandler(ar -> {
if (ar.failed()) {
if (ar.cause() instanceof NoStackTraceThrowable
&& "operation timeout".equals(ar.cause().getMessage())) {
future.fail(SystemException.create(DefaultErrorCode.TIME_OUT)
.set("timeout", config.getLong("timeout", 10000l)));
return;
}
if (ar.cause() instanceof RuntimeException
&& "open circuit".equals(ar.cause().getMessage())) {
Log.create(LOGGER)
.setTraceId(traceId)
.setModule("RPC")
.setEvent("BreakerTripped")
.error();
future.fail(SystemException.create(DefaultErrorCode.BREAKER_TRIPPED)
.set("details", String.format("Please try again after %ds",
config.getLong("resetTimeout",
30000l) / 1000)));
return;
}
future.fail(ar.cause());
} else {
future.complete(ar.result());
}
});
return future;
}
示例13: openChunkToDocument
import io.vertx.core.impl.NoStackTraceThrowable; //导入依赖的package包/类
/**
* Open a chunk and convert it to an Elasticsearch document. Retry operation
* several times before failing.
* @param path the path to the chunk to open
* @param chunkMeta metadata about the chunk
* @param indexMeta metadata used to index the chunk
* @return an observable that emits the document
*/
private Observable<Map<String, Object>> openChunkToDocument(
String path, ChunkMeta chunkMeta, IndexMeta indexMeta) {
return Observable.defer(() -> store.rxGetOne(path)
.flatMapObservable(chunk -> {
List<? extends IndexerFactory> factories;
Operator<? extends StreamEvent, Buffer> parserOperator;
// select indexers and parser depending on the mime type
String mimeType = chunkMeta.getMimeType();
if (belongsTo(mimeType, "application", "xml") ||
belongsTo(mimeType, "text", "xml")) {
factories = xmlIndexerFactories;
parserOperator = new XMLParserOperator();
} else if (belongsTo(mimeType, "application", "json")) {
factories = jsonIndexerFactories;
parserOperator = new JsonParserOperator();
} else {
return Observable.error(new NoStackTraceThrowable(String.format(
"Unexpected mime type '%s' while trying to index "
+ "chunk '%s'", mimeType, path)));
}
// call meta indexers
Map<String, Object> metaResults = new HashMap<>();
for (MetaIndexerFactory metaIndexerFactory : metaIndexerFactories) {
MetaIndexer metaIndexer = metaIndexerFactory.createIndexer();
metaIndexer.onIndexChunk(path, chunkMeta, indexMeta);
metaResults.putAll(metaIndexer.getResult());
}
// convert chunk to document and close it
return chunkToDocument(chunk, indexMeta.getFallbackCRSString(),
parserOperator, factories)
.doAfterTerminate(chunk::close)
// add results from meta indexers to converted document
.doOnNext(doc -> doc.putAll(metaResults));
}))
.retryWhen(makeRetry());
}
示例14: onDelete
import io.vertx.core.impl.NoStackTraceThrowable; //导入依赖的package包/类
/**
* Delete chunks from the index
* @param body the message containing the paths to the chunks to delete
* @return an observable that emits a single item when the chunks have
* been deleted successfully
*/
private Observable<Void> onDelete(JsonObject body) {
JsonArray paths = body.getJsonArray("paths");
long totalChunks = body.getLong("totalChunks", (long)paths.size());
long remainingChunks = body.getLong("remainingChunks", (long)paths.size());
// execute bulk request
long startTimeStamp = System.currentTimeMillis();
onDeletingStarted(startTimeStamp, paths, totalChunks, remainingChunks);
return client.bulkDelete(TYPE_NAME, paths).flatMap(bres -> {
long stopTimeStamp = System.currentTimeMillis();
if (client.bulkResponseHasErrors(bres)) {
String error = client.bulkResponseGetErrorMessage(bres);
log.error("One or more chunks could not be deleted");
log.error(error);
onDeletingFinished(stopTimeStamp - startTimeStamp, paths, totalChunks,
remainingChunks, error);
return Observable.error(new NoStackTraceThrowable(
"One or more chunks could not be deleted"));
} else {
onDeletingFinished(stopTimeStamp - startTimeStamp, paths, totalChunks,
remainingChunks, null);
return Observable.just(null);
}
});
}
示例15: noLayer
import io.vertx.core.impl.NoStackTraceThrowable; //导入依赖的package包/类
/**
* Test no layer
* @param context the test context
*/
@Test
public void noLayer(TestContext context) {
Async async = context.async();
client.getStore().delete(null, null, context.asyncAssertFailure(t -> {
context.assertTrue(t instanceof NoStackTraceThrowable);
async.complete();
}));
}