use of io.zulia.message.ZuliaServiceOuterClass.FetchResponse in project zuliasearch by zuliaio.
the class Fetch method execute.
@Override
public FetchResult execute(ZuliaConnection zuliaConnection) {
ZuliaServiceBlockingStub service = zuliaConnection.getService();
FetchResponse fetchResponse = service.fetch(getRequest());
return new FetchResult(fetchResponse);
}
use of io.zulia.message.ZuliaServiceOuterClass.FetchResponse in project zuliasearch by zuliaio.
the class BatchFetch method execute.
@Override
public BatchFetchResult execute(ZuliaConnection zuliaConnection) {
ZuliaServiceBlockingStub service = zuliaConnection.getService();
Iterator<FetchResponse> batchFetchResponse = service.batchFetch(getRequest());
return new BatchFetchResult(batchFetchResponse);
}
use of io.zulia.message.ZuliaServiceOuterClass.FetchResponse in project zuliasearch by zuliaio.
the class FetchController method get.
@Get
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public HttpResponse<?> get(@QueryValue(ZuliaConstants.ID) final String uniqueId, @QueryValue(ZuliaConstants.INDEX) final String indexName, @QueryValue(value = ZuliaConstants.PRETTY, defaultValue = "true") Boolean pretty) {
ZuliaIndexManager indexManager = ZuliaNodeProvider.getZuliaNode().getIndexManager();
FetchRequest.Builder fetchRequest = FetchRequest.newBuilder();
fetchRequest.setIndexName(indexName);
fetchRequest.setUniqueId(uniqueId);
FetchResponse fetchResponse;
try {
fetchResponse = indexManager.fetch(fetchRequest.build());
if (fetchResponse.hasResultDocument()) {
Document document = ResultHelper.getDocumentFromResultDocument(fetchResponse.getResultDocument());
if (document != null) {
String docString;
if (pretty) {
docString = document.toJson(JsonWriterSettings.builder().indent(true).build());
} else {
docString = document.toJson();
}
if (pretty) {
docString = JsonWriter.formatJson(docString);
}
return HttpResponse.ok(docString).status(ZuliaConstants.SUCCESS);
}
return HttpResponse.ok("Failed to fetch uniqueId <" + uniqueId + "> for index <" + indexName + ">").status(ZuliaConstants.NOT_FOUND);
} else {
return HttpResponse.ok("Failed to fetch uniqueId <" + uniqueId + "> for index <" + indexName + ">").status(ZuliaConstants.NOT_FOUND);
}
} catch (Exception e) {
return HttpResponse.serverError("Failed to fetch uniqueId <" + uniqueId + "> for index <" + indexName + ">: " + e.getMessage()).status(ZuliaConstants.INTERNAL_ERROR);
}
}
use of io.zulia.message.ZuliaServiceOuterClass.FetchResponse in project zuliasearch by zuliaio.
the class BatchFetchServerRequest method handleRequest.
public void handleRequest(BatchFetchRequest request, StreamObserver<FetchResponse> responseObserver) {
try {
for (FetchRequest fetchRequest : request.getFetchRequestList()) {
FetchResponse fetchResponse = indexManager.fetch(fetchRequest);
responseObserver.onNext(fetchResponse);
}
responseObserver.onCompleted();
} catch (Exception e) {
responseObserver.onError(e);
onError(e);
}
}
Aggregations