use of zipkin.storage.elasticsearch.http.ElasticsearchHttpStorage.APPLICATION_JSON in project zipkin by openzipkin.
the class EnsureIndexTemplate method apply.
/**
* This is a blocking call, used inside a lazy. That's because no writes should occur until the
* template is available.
*/
static void apply(HttpCall.Factory callFactory, String name, String indexTemplate) {
HttpUrl templateUrl = callFactory.baseUrl.newBuilder("_template").addPathSegment(name).build();
Request getTemplate = new Request.Builder().url(templateUrl).tag("get-template").build();
try {
callFactory.execute(getTemplate, b -> null);
} catch (IllegalStateException e) {
// TODO: handle 404 slightly more nicely
Request updateTemplate = new Request.Builder().url(templateUrl).put(RequestBody.create(APPLICATION_JSON, indexTemplate)).tag("update-template").build();
callFactory.execute(updateTemplate, b -> null);
}
}
use of zipkin.storage.elasticsearch.http.ElasticsearchHttpStorage.APPLICATION_JSON in project zipkin by openzipkin.
the class HttpBulkIndexer method execute.
/** Creates a bulk request when there is more than one object to store */
void execute(Callback<Void> callback) {
HttpUrl url = pipeline != null ? http.baseUrl.newBuilder("_bulk").addQueryParameter("pipeline", pipeline).build() : http.baseUrl.resolve("_bulk");
Request request = new Request.Builder().url(url).tag(tag).post(RequestBody.create(APPLICATION_JSON, body.readByteString())).build();
http.<Void>newCall(request, b -> {
if (indices.isEmpty())
return null;
ElasticsearchHttpStorage.flush(http, join(indices));
return null;
}).submit(callback);
}
Aggregations