Commit a9eaa2ee authored by peng-yongsheng's avatar peng-yongsheng
Browse files

1. The collectors provider vote about leader which collector execute the delete operation.

2. Delete the history data before the setting that you can find the property name of history_delete_before_days in the application.yml file.
parent b4b9835a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -37,3 +37,4 @@ ui:
#    cluster_nodes: localhost:9300
#    index_shards_number: 2
#    index_replicas_number: 0
#    history_delete_before_days: 3
 No newline at end of file
+6 −0
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@ import org.elasticsearch.client.IndicesAdminClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.index.reindex.DeleteByQueryAction;
import org.elasticsearch.index.reindex.DeleteByQueryRequestBuilder;
import org.elasticsearch.transport.client.PreBuiltTransportClient;
import org.skywalking.apm.collector.client.Client;
import org.skywalking.apm.collector.client.ClientException;
@@ -146,6 +148,10 @@ public class ElasticSearchClient implements Client {
        return client.prepareGet(indexName, "type", id);
    }

    public DeleteByQueryRequestBuilder prepareDelete() {
        return DeleteByQueryAction.INSTANCE.newRequestBuilder(client);
    }

    public MultiGetRequestBuilder prepareMultiGet() {
        return client.prepareMultiGet();
    }
+9 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ package org.skywalking.apm.collector.core.util;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @author peng-yongsheng
@@ -34,10 +35,18 @@ public class CollectionUtils {
        return list == null || list.size() == 0;
    }

    public static boolean isEmpty(Set set) {
        return set == null || set.size() == 0;
    }

    public static boolean isNotEmpty(List list) {
        return !isEmpty(list);
    }

    public static boolean isNotEmpty(Set set) {
        return !isEmpty(set);
    }

    public static boolean isNotEmpty(Map map) {
        return !isEmpty(map);
    }
+2 −0
Original line number Diff line number Diff line
@@ -29,4 +29,6 @@ public interface IPersistenceDAO<Insert, Update, DataImpl extends Data> extends
    Insert prepareBatchInsert(DataImpl data);

    Update prepareBatchUpdate(DataImpl data);

    void deleteHistory(Long startTimestamp, Long endTimestamp);
}
+5 −0
Original line number Diff line number Diff line
@@ -36,5 +36,10 @@
            <artifactId>collector-storage-define</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.skywalking</groupId>
            <artifactId>collector-cluster-define</artifactId>
            <version>${project.version}</version>
        </dependency>
    </dependencies>
</project>
Loading