use of org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient in project incubator-skywalking by apache.
the class StorageModuleEsProvider method prepare.
@Override
public void prepare(Properties config) throws ServiceNotProvidedException {
String clusterName = config.getProperty(CLUSTER_NAME);
Boolean clusterTransportSniffer = (Boolean) config.get(CLUSTER_TRANSPORT_SNIFFER);
String clusterNodes = config.getProperty(CLUSTER_NODES);
elasticSearchClient = new ElasticSearchClient(clusterName, clusterTransportSniffer, clusterNodes);
this.registerServiceImplementation(IBatchDAO.class, new BatchEsDAO(elasticSearchClient));
registerCacheDAO();
registerRegisterDAO();
registerPersistenceDAO();
registerUiDAO();
registerAlarmDAO();
}
use of org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient in project incubator-skywalking by apache.
the class EsDAO method getMaxId.
protected final int getMaxId(String indexName, String columnName) {
ElasticSearchClient client = getClient();
SearchRequestBuilder searchRequestBuilder = client.prepareSearch(indexName);
searchRequestBuilder.setTypes("type");
searchRequestBuilder.setSize(0);
MaxAggregationBuilder aggregation = AggregationBuilders.max("agg").field(columnName);
searchRequestBuilder.addAggregation(aggregation);
SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
Max agg = searchResponse.getAggregations().get("agg");
int id = (int) agg.getValue();
if (id == Integer.MAX_VALUE || id == Integer.MIN_VALUE) {
return 0;
} else {
return id;
}
}
use of org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient in project incubator-skywalking by apache.
the class ElasticSearchStorageInstaller method createTable.
@Override
protected boolean createTable(Client client, TableDefine tableDefine) {
ElasticSearchClient esClient = (ElasticSearchClient) client;
ElasticSearchTableDefine esTableDefine = (ElasticSearchTableDefine) tableDefine;
// mapping
XContentBuilder mappingBuilder = null;
Settings settings = createSettingBuilder(esTableDefine);
try {
mappingBuilder = createMappingBuilder(esTableDefine);
logger.info("mapping builder str: {}", mappingBuilder.string());
} catch (Exception e) {
logger.error("create {} index mapping builder error", esTableDefine.getName());
}
boolean isAcknowledged = esClient.createIndex(esTableDefine.getName(), esTableDefine.type(), settings, mappingBuilder);
logger.info("create {} index with type of {} finished, isAcknowledged: {}", esTableDefine.getName(), esTableDefine.type(), isAcknowledged);
return isAcknowledged;
}
use of org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient in project incubator-skywalking by apache.
the class InstanceRegisterEsDAO method save.
@Override
public void save(Instance instance) {
logger.debug("save instance register info, application getApplicationId: {}, agentUUID: {}", instance.getApplicationId(), instance.getAgentUUID());
ElasticSearchClient client = getClient();
Map<String, Object> source = new HashMap<>();
source.put(InstanceTable.COLUMN_INSTANCE_ID, instance.getInstanceId());
source.put(InstanceTable.COLUMN_APPLICATION_ID, instance.getApplicationId());
source.put(InstanceTable.COLUMN_APPLICATION_CODE, instance.getApplicationCode());
source.put(InstanceTable.COLUMN_AGENT_UUID, instance.getAgentUUID());
source.put(InstanceTable.COLUMN_REGISTER_TIME, TimeBucketUtils.INSTANCE.getSecondTimeBucket(instance.getRegisterTime()));
source.put(InstanceTable.COLUMN_HEARTBEAT_TIME, TimeBucketUtils.INSTANCE.getSecondTimeBucket(instance.getHeartBeatTime()));
source.put(InstanceTable.COLUMN_OS_INFO, instance.getOsInfo());
source.put(InstanceTable.COLUMN_ADDRESS_ID, instance.getAddressId());
source.put(InstanceTable.COLUMN_IS_ADDRESS, instance.getIsAddress());
IndexResponse response = client.prepareIndex(InstanceTable.TABLE, instance.getId()).setSource(source).setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE).get();
logger.debug("save instance register info, application getApplicationId: {}, agentUUID: {}, status: {}", instance.getApplicationId(), instance.getAgentUUID(), response.status().name());
}
use of org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient in project incubator-skywalking by apache.
the class ServiceNameRegisterEsDAO method save.
@Override
public void save(ServiceName serviceName) {
logger.debug("save service name register info, application getApplicationId: {}, service name: {}", serviceName.getId(), serviceName.getServiceName());
ElasticSearchClient client = getClient();
Map<String, Object> source = new HashMap<>();
source.put(ServiceNameTable.COLUMN_SERVICE_ID, serviceName.getServiceId());
source.put(ServiceNameTable.COLUMN_APPLICATION_ID, serviceName.getApplicationId());
source.put(ServiceNameTable.COLUMN_SERVICE_NAME, serviceName.getServiceName());
source.put(ServiceNameTable.COLUMN_SERVICE_NAME_KEYWORD, serviceName.getServiceName());
source.put(ServiceNameTable.COLUMN_SRC_SPAN_TYPE, serviceName.getSrcSpanType());
IndexResponse response = client.prepareIndex(ServiceNameTable.TABLE, serviceName.getId()).setSource(source).setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE).get();
logger.debug("save service name register info, application getApplicationId: {}, service name: {}, status: {}", serviceName.getId(), serviceName.getServiceName(), response.status().name());
}
Aggregations