Commit 594994ff authored by 彭勇升 pengys's avatar 彭勇升 pengys Committed by 吴晟
Browse files

1. Provide InsertRequest and UpdateRequest interface for prepare persistence. (#3131)

2. Implement the ids query for H2 metrics DAO.
parent 3fd1f072
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ public class MetricsPersistentWorker extends PersistenceWorker<Metrics, MergeDat

    private final Model model;
    private final MergeDataCache<Metrics> mergeDataCache;
    private final IMetricsDAO<?, ?> metricsDAO;
    private final IMetricsDAO metricsDAO;
    private final AbstractWorker<Metrics> nextAlarmWorker;
    private final AbstractWorker<ExportEvent> nextExportWorker;
    private final DataCarrier<Metrics> dataCarrier;
+4 −3
Original line number Diff line number Diff line
@@ -22,15 +22,16 @@ import java.io.IOException;
import java.util.Map;
import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
import org.apache.skywalking.oap.server.core.storage.model.Model;
import org.apache.skywalking.oap.server.library.client.request.*;

/**
 * @author peng-yongsheng
 */
public interface IMetricsDAO<INSERT, UPDATE> extends DAO {
public interface IMetricsDAO extends DAO {

    Map<String, Metrics> get(Model model, Metrics[] metrics) throws IOException;

    INSERT prepareBatchInsert(Model model, Metrics metrics) throws IOException;
    InsertRequest prepareBatchInsert(Model model, Metrics metrics) throws IOException;

    UPDATE prepareBatchUpdate(Model model, Metrics metrics) throws IOException;
    UpdateRequest prepareBatchUpdate(Model model, Metrics metrics) throws IOException;
}
+2 −2
Original line number Diff line number Diff line
@@ -26,9 +26,9 @@ import org.apache.skywalking.oap.server.library.module.Service;
/**
 * @author peng-yongsheng
 */
public interface StorageDAO<INSERT, UPDATE> extends Service {
public interface StorageDAO extends Service {

    IMetricsDAO<INSERT, UPDATE> newMetricsDao(StorageBuilder<Metrics> storageBuilder);
    IMetricsDAO newMetricsDao(StorageBuilder<Metrics> storageBuilder);

    IRegisterDAO newRegisterDao(StorageBuilder<RegisterSource> storageBuilder);

+4 −4
Original line number Diff line number Diff line
@@ -254,14 +254,14 @@ public class ElasticSearchClient implements Client {
        client.update(request);
    }

    public IndexRequest prepareInsert(String indexName, String id, XContentBuilder source) {
    public ElasticSearchInsertRequest prepareInsert(String indexName, String id, XContentBuilder source) {
        indexName = formatIndexName(indexName);
        return new IndexRequest(indexName, TYPE, id).source(source);
        return new ElasticSearchInsertRequest(indexName, TYPE, id).source(source);
    }

    public UpdateRequest prepareUpdate(String indexName, String id, XContentBuilder source) {
    public ElasticSearchUpdateRequest prepareUpdate(String indexName, String id, XContentBuilder source) {
        indexName = formatIndexName(indexName);
        return new UpdateRequest(indexName, TYPE, id).doc(source);
        return new ElasticSearchUpdateRequest(indexName, TYPE, id).doc(source);
    }

    public int delete(String indexName, String timeBucketColumnName, long endTimeBucket) throws IOException {
+37 −0
Original line number Diff line number Diff line
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.skywalking.oap.server.library.client.elasticsearch;

import org.apache.skywalking.oap.server.library.client.request.InsertRequest;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.common.xcontent.XContentBuilder;

/**
 * @author peng-yongsheng
 */
public class ElasticSearchInsertRequest extends IndexRequest implements InsertRequest {

    public ElasticSearchInsertRequest(String index, String type, String id) {
        super(index, type, id);
    }

    @Override public ElasticSearchInsertRequest source(XContentBuilder sourceBuilder) {
        super.source(sourceBuilder);
        return this;
    }
}
Loading