wu-sheng commented on a change in pull request #6499:
URL: https://github.com/apache/skywalking/pull/6499#discussion_r588899385
##########
File path:
oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/StorageEsInstaller.java
##########
@@ -68,40 +78,87 @@ protected boolean isExists(Model model) throws
StorageException {
@Override
protected void createTable(Model model) throws StorageException {
ElasticSearchClient esClient = (ElasticSearchClient) client;
-
Map<String, Object> settings = createSetting(model);
Map<String, Object> mapping = createMapping(model);
- log.info("index {}'s columnTypeEsMapping builder str: {}",
esClient.formatIndexName(model.getName()), mapping
- .toString());
+ String tableName = PhysicalIndexManager.INSTANCE.getTableName(model);
+ PhysicalIndices.registerRelation(model.getName(), tableName);
+ log.info("index {}'s columnTypeEsMapping builder str: {}",
+ esClient.formatIndexName(tableName), mapping.toString()
+ );
+ String indexName;
try {
- String indexName;
- if (!model.isTimeSeries()) {
- indexName = model.getName();
- } else {
- if (!esClient.isExistsTemplate(model.getName())) {
- boolean isAcknowledged =
esClient.createTemplate(model.getName(), settings, mapping);
- log.info(
- "create {} index template finished, isAcknowledged:
{}", model.getName(), isAcknowledged);
+ if (model.isTimeSeries()) {
+ if (!esClient.isExistsTemplate(tableName) ||
!isTemplateMappingCompatible(tableName, mapping)) {
+ Map<String, Object> templateMapping =
appendTemplateMapping(tableName, mapping);
+ boolean isAcknowledged = esClient.putTemplate(tableName,
settings, templateMapping);
+ log.info("create {} index template finished,
isAcknowledged: {}", tableName, isAcknowledged);
if (!isAcknowledged) {
- throw new StorageException("create " + model.getName()
+ " index template failure, ");
+ throw new StorageException("create " + tableName + "
index template failure, ");
}
}
indexName = TimeSeriesUtils.latestWriteIndexName(model);
+ } else {
+ indexName = tableName;
}
- if (!esClient.isExistsIndex(indexName)) {
- boolean isAcknowledged = esClient.createIndex(indexName);
+
+ if (esClient.isExistsIndex(indexName)) {
Review comment:
The index you created is an empty index, all column related things are
in the template(such as mapping), am I right?
Then why do we need to keep deleting/recreating? Even more for the indices
not time series?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]