Skip to content

Commit

Permalink
feat: apm ttl (#781)
Browse files Browse the repository at this point in the history
  • Loading branch information
sw1136562366 authored Jan 24, 2024
1 parent 6884cf1 commit 64da119
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,10 @@
public @interface ModelAnnotation {
String name();

long ttl() default 60000L * 60 * 24 * 3;
/**
* unit: day
*
* @return
*/
long ttl() default 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class HoloinsightEsConfiguration {
private String password;
private int shards = 5;
private int replicas = 1;
private int ttl = 7; // unit: day

@Bean("elasticsearchClient")
@Primary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io.holoinsight.server.apm.common.constants.Const;
import io.holoinsight.server.apm.common.model.storage.Model;
import io.holoinsight.server.apm.core.ttl.DataCleaner;
import io.holoinsight.server.apm.engine.elasticsearch.HoloinsightEsConfiguration;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -30,13 +31,15 @@ public class EsDataCleaner implements DataCleaner {

@Autowired
private RestHighLevelClient esClient;
@Autowired
private HoloinsightEsConfiguration esConfiguration;

protected RestHighLevelClient client() {
return esClient;
}

protected long ttl(Model model) {
return model.getTtl();
return model.getTtl() != 0 ? model.getTtl() : esConfiguration.getTtl() * 60000L * 60 * 24;
}

@Override
Expand Down

0 comments on commit 64da119

Please sign in to comment.