All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.o19s.es.ltr.action.TransportCacheStatsAction Maven / Gradle / Ivy

There is a newer version: 6.8.0
Show newest version
/*
 * Copyright [2017] Wikimedia Foundation
 *
 * Licensed 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 com.o19s.es.ltr.action;

import com.o19s.es.ltr.action.CachesStatsAction.CachesStatsNodeResponse;
import com.o19s.es.ltr.action.CachesStatsAction.CachesStatsNodesRequest;
import com.o19s.es.ltr.action.CachesStatsAction.CachesStatsNodesResponse;
import com.o19s.es.ltr.feature.store.index.Caches;
import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.nodes.BaseNodeRequest;
import org.elasticsearch.action.support.nodes.TransportNodesAction;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;

import java.util.List;

public class TransportCacheStatsAction extends TransportNodesAction {
    private final Caches caches;

    @Inject
    public TransportCacheStatsAction(Settings settings, ThreadPool threadPool,
                                        ClusterService clusterService, TransportService transportService,
                                        ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver,
                                        Caches caches) {
        super(settings, CachesStatsAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
                CachesStatsNodesRequest::new, CachesStatsNodeRequest::new, ThreadPool.Names.MANAGEMENT,
                CachesStatsAction.CachesStatsNodeResponse.class);
        this.caches = caches;
    }

    @Override
    protected CachesStatsNodesResponse newResponse(CachesStatsNodesRequest request, List responses,
                                                   List failures) {
        return new CachesStatsNodesResponse(clusterService.getClusterName(), responses, failures);
    }

    @Override
    protected CachesStatsNodeRequest newNodeRequest(String nodeId, CachesStatsNodesRequest request) {
        return new CachesStatsNodeRequest(nodeId);
    }

    @Override
    protected CachesStatsNodeResponse newNodeResponse() {
        return new CachesStatsNodeResponse();
    }

    @Override
    protected CachesStatsNodeResponse nodeOperation(CachesStatsNodeRequest request) {
        return new CachesStatsNodeResponse(clusterService.localNode()).initFromCaches(caches);
    }

    public static class CachesStatsNodeRequest extends BaseNodeRequest {
        public CachesStatsNodeRequest() {
        }

        public CachesStatsNodeRequest(String nodeId) {
            super(nodeId);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy