wu-sheng commented on a change in pull request #6499:
URL: https://github.com/apache/skywalking/pull/6499#discussion_r589048060
##########
File path:
oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/StorageEsInstaller.java
##########
@@ -38,68 +42,165 @@
@Slf4j
public class StorageEsInstaller extends ModelInstaller {
private final Gson gson = new Gson();
-
private final StorageModuleElasticsearchConfig config;
protected final ColumnTypeEsMapping columnTypeEsMapping;
+ /**
+ * The mappings of the template .
+ */
+ private final Map<String, Map<String, Object>> tables;
+
public StorageEsInstaller(Client client,
ModuleManager moduleManager,
- final StorageModuleElasticsearchConfig config) {
+ StorageModuleElasticsearchConfig config) throws
StorageException {
super(client, moduleManager);
this.columnTypeEsMapping = new ColumnTypeEsMapping();
this.config = config;
+ this.tables = new HashMap<>();
}
@Override
protected boolean isExists(Model model) throws StorageException {
ElasticSearchClient esClient = (ElasticSearchClient) client;
+ String tableName = IndexController.INSTANCE.getTableName(model);
+ IndexController.LogicIndicesRegister.registerRelation(model.getName(),
tableName);
try {
- if (model.isTimeSeries()) {
- return esClient.isExistsTemplate(model.getName()) &&
esClient.isExistsIndex(
- TimeSeriesUtils.latestWriteIndexName(model));
- } else {
- return esClient.isExistsIndex(model.getName());
+ if (!model.isTimeSeries()) {
+ return esClient.isExistsIndex(tableName);
}
+ boolean exist = esClient.isExistsTemplate(tableName)
+ &&
esClient.isExistsIndex(TimeSeriesUtils.latestWriteIndexName(model));
+ if (RunningMode.isInitMode() &&
IndexController.INSTANCE.isAggregationMode(model)) {
+ appendTemplateMapping(tableName, (Map<String, Object>)
esClient.getTemplate(tableName).get("mappings"));
Review comment:
Got it. Then `appendTemplateMapping` should be renamed.
----------------------------------------------------------------
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]