Search in sources :

Example 61 with NamedList

use of org.apache.solr.common.util.NamedList in project lucene-solr by apache.

the class SolrSnapshotsTool method listSnapshots.

@SuppressWarnings("rawtypes")
public void listSnapshots(String collectionName) {
    CollectionAdminRequest.ListSnapshots listSnaps = new CollectionAdminRequest.ListSnapshots(collectionName);
    CollectionAdminResponse resp;
    try {
        resp = listSnaps.process(solrClient);
        Preconditions.checkState(resp.getStatus() == 0, "The LISTSNAPSHOTS request failed. The status code is " + resp.getStatus());
        NamedList apiResult = (NamedList) resp.getResponse().get(SolrSnapshotManager.SNAPSHOTS_INFO);
        for (int i = 0; i < apiResult.size(); i++) {
            System.out.println(apiResult.getName(i));
        }
    } catch (Exception e) {
        log.error("Failed to list snapshots for collection " + collectionName, e);
        System.out.println("Failed to list snapshots for collection " + collectionName + " due to following error : " + e.getLocalizedMessage());
    }
}
Also used : CollectionAdminResponse(org.apache.solr.client.solrj.response.CollectionAdminResponse) NamedList(org.apache.solr.common.util.NamedList) CollectionAdminRequest(org.apache.solr.client.solrj.request.CollectionAdminRequest) URISyntaxException(java.net.URISyntaxException) SolrServerException(org.apache.solr.client.solrj.SolrServerException) IOException(java.io.IOException) ParseException(org.apache.commons.cli.ParseException)

Example 62 with NamedList

use of org.apache.solr.common.util.NamedList in project lucene-solr by apache.

the class CdcrReplicatorManager method getCheckpoint.

private long getCheckpoint(CdcrReplicatorState state) throws IOException, SolrServerException {
    ModifiableSolrParams params = new ModifiableSolrParams();
    params.set(CommonParams.ACTION, CdcrParams.CdcrAction.COLLECTIONCHECKPOINT.toString());
    SolrRequest request = new QueryRequest(params);
    request.setPath(path);
    NamedList response = state.getClient().request(request);
    return (Long) response.get(CdcrParams.CHECKPOINT);
}
Also used : QueryRequest(org.apache.solr.client.solrj.request.QueryRequest) NamedList(org.apache.solr.common.util.NamedList) SolrRequest(org.apache.solr.client.solrj.SolrRequest) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams)

Example 63 with NamedList

use of org.apache.solr.common.util.NamedList in project lucene-solr by apache.

the class CdcrRequestHandler method handleOpsAction.

private void handleOpsAction(SolrQueryRequest req, SolrQueryResponse rsp) {
    NamedList hosts = new NamedList();
    for (CdcrReplicatorState state : replicatorManager.getReplicatorStates()) {
        NamedList ops = new NamedList();
        ops.add(CdcrParams.COUNTER_ALL, state.getBenchmarkTimer().getOperationsPerSecond());
        ops.add(CdcrParams.COUNTER_ADDS, state.getBenchmarkTimer().getAddsPerSecond());
        ops.add(CdcrParams.COUNTER_DELETES, state.getBenchmarkTimer().getDeletesPerSecond());
        if (hosts.get(state.getZkHost()) == null) {
            hosts.add(state.getZkHost(), new NamedList());
        }
        ((NamedList) hosts.get(state.getZkHost())).add(state.getTargetCollection(), ops);
    }
    rsp.add(CdcrParams.OPERATIONS_PER_SECOND, hosts);
}
Also used : NamedList(org.apache.solr.common.util.NamedList)

Example 64 with NamedList

use of org.apache.solr.common.util.NamedList in project lucene-solr by apache.

the class CdcrRequestHandler method init.

@Override
public void init(NamedList args) {
    super.init(args);
    if (args != null) {
        // Configuration of the Update Log Synchronizer
        Object updateLogSynchonizerParam = args.get(CdcrParams.UPDATE_LOG_SYNCHRONIZER_PARAM);
        if (updateLogSynchonizerParam != null && updateLogSynchonizerParam instanceof NamedList) {
            updateLogSynchronizerConfiguration = SolrParams.toSolrParams((NamedList) updateLogSynchonizerParam);
        }
        // Configuration of the Replicator
        Object replicatorParam = args.get(CdcrParams.REPLICATOR_PARAM);
        if (replicatorParam != null && replicatorParam instanceof NamedList) {
            replicatorConfiguration = SolrParams.toSolrParams((NamedList) replicatorParam);
        }
        // Configuration of the Buffer
        Object bufferParam = args.get(CdcrParams.BUFFER_PARAM);
        if (bufferParam != null && bufferParam instanceof NamedList) {
            bufferConfiguration = SolrParams.toSolrParams((NamedList) bufferParam);
        }
        // Configuration of the Replicas
        replicasConfiguration = new HashMap<>();
        List replicas = args.getAll(CdcrParams.REPLICA_PARAM);
        for (Object replica : replicas) {
            if (replica != null && replica instanceof NamedList) {
                SolrParams params = SolrParams.toSolrParams((NamedList) replica);
                if (!replicasConfiguration.containsKey(params.get(CdcrParams.SOURCE_COLLECTION_PARAM))) {
                    replicasConfiguration.put(params.get(CdcrParams.SOURCE_COLLECTION_PARAM), new ArrayList<>());
                }
                replicasConfiguration.get(params.get(CdcrParams.SOURCE_COLLECTION_PARAM)).add(params);
            }
        }
    }
}
Also used : NamedList(org.apache.solr.common.util.NamedList) SolrParams(org.apache.solr.common.params.SolrParams) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) List(java.util.List) ArrayList(java.util.ArrayList) NamedList(org.apache.solr.common.util.NamedList)

Example 65 with NamedList

use of org.apache.solr.common.util.NamedList in project lucene-solr by apache.

the class CdcrRequestHandler method handleErrorsAction.

private void handleErrorsAction(SolrQueryRequest req, SolrQueryResponse rsp) {
    NamedList hosts = new NamedList();
    for (CdcrReplicatorState state : replicatorManager.getReplicatorStates()) {
        NamedList errors = new NamedList();
        errors.add(CdcrParams.CONSECUTIVE_ERRORS, state.getConsecutiveErrors());
        errors.add(CdcrReplicatorState.ErrorType.BAD_REQUEST.toLower(), state.getErrorCount(CdcrReplicatorState.ErrorType.BAD_REQUEST));
        errors.add(CdcrReplicatorState.ErrorType.INTERNAL.toLower(), state.getErrorCount(CdcrReplicatorState.ErrorType.INTERNAL));
        NamedList lastErrors = new NamedList();
        for (String[] lastError : state.getLastErrors()) {
            lastErrors.add(lastError[0], lastError[1]);
        }
        errors.add(CdcrParams.LAST, lastErrors);
        if (hosts.get(state.getZkHost()) == null) {
            hosts.add(state.getZkHost(), new NamedList());
        }
        ((NamedList) hosts.get(state.getZkHost())).add(state.getTargetCollection(), errors);
    }
    rsp.add(CdcrParams.ERRORS, hosts);
}
Also used : NamedList(org.apache.solr.common.util.NamedList)

Aggregations

NamedList (org.apache.solr.common.util.NamedList)440 Test (org.junit.Test)125 ArrayList (java.util.ArrayList)111 Map (java.util.Map)83 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)83 SolrException (org.apache.solr.common.SolrException)80 SimpleOrderedMap (org.apache.solr.common.util.SimpleOrderedMap)79 List (java.util.List)76 HashMap (java.util.HashMap)65 SolrQueryResponse (org.apache.solr.response.SolrQueryResponse)55 IOException (java.io.IOException)53 SolrDocumentList (org.apache.solr.common.SolrDocumentList)45 QueryRequest (org.apache.solr.client.solrj.request.QueryRequest)35 SolrQueryRequest (org.apache.solr.request.SolrQueryRequest)35 SolrParams (org.apache.solr.common.params.SolrParams)31 LocalSolrQueryRequest (org.apache.solr.request.LocalSolrQueryRequest)31 QueryResponse (org.apache.solr.client.solrj.response.QueryResponse)30 SolrCore (org.apache.solr.core.SolrCore)30 HttpSolrClient (org.apache.solr.client.solrj.impl.HttpSolrClient)27 SolrIndexSearcher (org.apache.solr.search.SolrIndexSearcher)27