use of org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient in project incubator-skywalking by apache.
the class NetworkAddressRegisterEsDAO method update.
@Override
public void update(String id, int spanLayer, int serverType) {
ElasticSearchClient client = getClient();
Map<String, Object> source = new HashMap<>();
source.put(NetworkAddressTable.COLUMN_SPAN_LAYER, spanLayer);
source.put(NetworkAddressTable.COLUMN_SERVER_TYPE, serverType);
client.prepareUpdate(NetworkAddressTable.TABLE, id).setDoc(source).setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE).get();
}
use of org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient in project incubator-skywalking by apache.
the class ApplicationEsCacheDAO method getApplicationIdByAddressId.
@Override
public int getApplicationIdByAddressId(int addressId) {
ElasticSearchClient client = getClient();
SearchRequestBuilder searchRequestBuilder = client.prepareSearch(ApplicationTable.TABLE);
searchRequestBuilder.setTypes(ApplicationTable.TABLE_TYPE);
searchRequestBuilder.setSearchType(SearchType.QUERY_THEN_FETCH);
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
boolQueryBuilder.must().add(QueryBuilders.termQuery(ApplicationTable.COLUMN_ADDRESS_ID, addressId));
boolQueryBuilder.must().add(QueryBuilders.termQuery(ApplicationTable.COLUMN_IS_ADDRESS, BooleanUtils.TRUE));
searchRequestBuilder.setQuery(boolQueryBuilder);
searchRequestBuilder.setSize(1);
SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
if (searchResponse.getHits().totalHits > 0) {
SearchHit searchHit = searchResponse.getHits().iterator().next();
return (int) searchHit.getSource().get(ApplicationTable.COLUMN_APPLICATION_ID);
}
return 0;
}
use of org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient in project incubator-skywalking by apache.
the class NetworkAddressEsCacheDAO method getAddress.
@Override
public NetworkAddress getAddress(int addressId) {
ElasticSearchClient client = getClient();
GetRequestBuilder getRequestBuilder = client.prepareGet(NetworkAddressTable.TABLE, String.valueOf(addressId));
GetResponse getResponse = getRequestBuilder.get();
if (getResponse.isExists()) {
NetworkAddress address = new NetworkAddress();
address.setId((String) getResponse.getSource().get(NetworkAddressTable.COLUMN_ID));
address.setAddressId(((Number) getResponse.getSource().get(NetworkAddressTable.COLUMN_ADDRESS_ID)).intValue());
address.setSpanLayer(((Number) getResponse.getSource().get(NetworkAddressTable.COLUMN_SPAN_LAYER)).intValue());
address.setServerType(((Number) getResponse.getSource().get(NetworkAddressTable.COLUMN_SERVER_TYPE)).intValue());
address.setNetworkAddress((String) getResponse.getSource().get(NetworkAddressTable.COLUMN_NETWORK_ADDRESS));
return address;
}
return null;
}
use of org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient in project incubator-skywalking by apache.
the class InstanceEsCacheDAO method getInstanceIdByAgentUUID.
@Override
public int getInstanceIdByAgentUUID(int applicationId, String agentUUID) {
ElasticSearchClient client = getClient();
SearchRequestBuilder searchRequestBuilder = client.prepareSearch(InstanceTable.TABLE);
searchRequestBuilder.setTypes(InstanceTable.TABLE_TYPE);
searchRequestBuilder.setSearchType(SearchType.QUERY_THEN_FETCH);
BoolQueryBuilder builder = QueryBuilders.boolQuery();
builder.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_APPLICATION_ID, applicationId));
builder.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_AGENT_UUID, agentUUID));
builder.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_IS_ADDRESS, BooleanUtils.FALSE));
searchRequestBuilder.setQuery(builder);
searchRequestBuilder.setSize(1);
SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
if (searchResponse.getHits().totalHits > 0) {
SearchHit searchHit = searchResponse.getHits().iterator().next();
return (int) searchHit.getSource().get(InstanceTable.COLUMN_INSTANCE_ID);
}
return 0;
}
use of org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient in project incubator-skywalking by apache.
the class InstanceEsCacheDAO method getInstanceIdByAddressId.
@Override
public int getInstanceIdByAddressId(int applicationId, int addressId) {
ElasticSearchClient client = getClient();
SearchRequestBuilder searchRequestBuilder = client.prepareSearch(InstanceTable.TABLE);
searchRequestBuilder.setTypes(InstanceTable.TABLE_TYPE);
searchRequestBuilder.setSearchType(SearchType.QUERY_THEN_FETCH);
BoolQueryBuilder builder = QueryBuilders.boolQuery();
builder.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_APPLICATION_ID, applicationId));
builder.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_ADDRESS_ID, addressId));
builder.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_IS_ADDRESS, BooleanUtils.TRUE));
searchRequestBuilder.setQuery(builder);
searchRequestBuilder.setSize(1);
SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
if (searchResponse.getHits().totalHits > 0) {
SearchHit searchHit = searchResponse.getHits().iterator().next();
return (int) searchHit.getSource().get(InstanceTable.COLUMN_INSTANCE_ID);
}
return 0;
}
Aggregations