use of io.hops.hopsworks.exceptions.ElasticException in project hopsworks by logicalclocks.
the class ElasticClientController method indexDoc.
public void indexDoc(IndexRequest request) throws ElasticException {
FailableSupplier<IndexResponse> query = () -> client.getClient().index(request, RequestOptions.DEFAULT);
IndexResponse response = executeElasticQuery(query, "elastic index doc", request.toString());
if (response.status().getStatus() != 201) {
String msg = "doc index - bad status response:" + response.status().getStatus();
throw new ElasticException(RESTCodes.ElasticErrorCode.ELASTIC_QUERY_ERROR, Level.INFO, msg);
}
}
use of io.hops.hopsworks.exceptions.ElasticException in project hopsworks by logicalclocks.
the class ElasticClientController method bulkDelete.
public void bulkDelete(BulkRequest request) throws ElasticException {
FailableSupplier<BulkResponse> query = () -> client.getClient().bulk(request, RequestOptions.DEFAULT);
BulkResponse response = executeElasticQuery(query, "elastic bulk delete", request.toString());
if (response.hasFailures()) {
String msg = "failures during bulk delete";
throw new ElasticException(RESTCodes.ElasticErrorCode.ELASTIC_QUERY_ERROR, Level.INFO, msg);
}
}
use of io.hops.hopsworks.exceptions.ElasticException in project hopsworks by logicalclocks.
the class ElasticClientController method clusterHealthGet.
public ClusterHealthResponse clusterHealthGet() throws ElasticException {
ClusterHealthRequest request = new ClusterHealthRequest();
FailableSupplier<ClusterHealthResponse> query = () -> client.getClient().cluster().health(request, RequestOptions.DEFAULT);
ClusterHealthResponse response = executeElasticQuery(query, "elastic get cluster health", request.toString());
if (response.status().equals(RestStatus.OK) || response.status().equals(RestStatus.NOT_FOUND)) {
return response;
} else {
throw new ElasticException(RESTCodes.ElasticErrorCode.ELASTIC_QUERY_ERROR, Level.INFO, "error during elastic get cluster health");
}
}
use of io.hops.hopsworks.exceptions.ElasticException in project hopsworks by logicalclocks.
the class ElasticController method projectSearchHighLevel.
public SearchHit[] projectSearchHighLevel(Integer projectId, String searchTerm) throws ServiceException, ElasticException {
// check if the index are up and running
if (!elasticClientCtrl.mngIndexExists(Settings.META_INDEX)) {
throw new ServiceException(RESTCodes.ServiceErrorCode.ELASTIC_INDEX_NOT_FOUND, Level.SEVERE, "index: " + Settings.META_INDEX);
}
SearchResponse response = executeSearchQuery(projectSearchQuery(projectId, searchTerm.toLowerCase()));
if (response.status().getStatus() == 200) {
SearchHit[] hits = new SearchHit[0];
if (response.getHits().getHits().length > 0) {
hits = response.getHits().getHits();
}
projectSearchInSharedDatasets(projectId, searchTerm, hits);
return hits;
}
// elasticsearch rather than a bad query
throw new ElasticException(RESTCodes.ElasticErrorCode.ELASTIC_QUERY_ERROR, Level.INFO, "Error while executing query, code: " + response.status().getStatus());
}
use of io.hops.hopsworks.exceptions.ElasticException in project hopsworks by logicalclocks.
the class ElasticClient method shutdownClient.
private void shutdownClient() throws ElasticException {
if (elasticClient != null) {
try {
elasticClient.indices().clearCache(new ClearIndicesCacheRequest(Settings.META_INDEX), RequestOptions.DEFAULT);
elasticClient.close();
elasticClient = null;
} catch (IOException e) {
throw new ElasticException(RESTCodes.ElasticErrorCode.ELASTIC_INTERNAL_REQ_ERROR, Level.INFO, "Error while shuting down client", e.getMessage(), e);
}
}
}
Aggregations