use of org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient in project incubator-skywalking by apache.
the class ApplicationRegisterEsDAO method save.
@Override
public void save(Application application) {
logger.debug("save application register info, application getApplicationId: {}, application code: {}", application.getId(), application.getApplicationCode());
ElasticSearchClient client = getClient();
Map<String, Object> source = new HashMap<>();
source.put(ApplicationTable.COLUMN_APPLICATION_CODE, application.getApplicationCode());
source.put(ApplicationTable.COLUMN_APPLICATION_ID, application.getApplicationId());
source.put(ApplicationTable.COLUMN_ADDRESS_ID, application.getAddressId());
source.put(ApplicationTable.COLUMN_IS_ADDRESS, application.getIsAddress());
IndexResponse response = client.prepareIndex(ApplicationTable.TABLE, application.getId()).setSource(source).setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE).get();
logger.debug("save application register info, application getApplicationId: {}, application code: {}, status: {}", application.getApplicationId(), application.getApplicationCode(), response.status().name());
}
use of org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient in project incubator-skywalking by apache.
the class EsDAO method getMinId.
protected final int getMinId(String indexName, String columnName) {
ElasticSearchClient client = getClient();
SearchRequestBuilder searchRequestBuilder = client.prepareSearch(indexName);
searchRequestBuilder.setTypes("type");
searchRequestBuilder.setSize(0);
MinAggregationBuilder aggregation = AggregationBuilders.min("agg").field(columnName);
searchRequestBuilder.addAggregation(aggregation);
SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
Min agg = searchResponse.getAggregations().get("agg");
int id = (int) agg.getValue();
if (id == Integer.MAX_VALUE || id == Integer.MIN_VALUE) {
return 0;
} else {
return id;
}
}
Aggregations