Search in sources :

Example 36 with ModifiableSolrParams

use of org.apache.solr.common.params.ModifiableSolrParams in project lucene-solr by apache.

the class CdcrBootstrapTest method testConvertClusterToCdcrAndBootstrap.

/**
   * Starts a source cluster with no CDCR configuration, indexes enough documents such that
   * the at least one old tlog is closed and thrown away so that the source cluster does not have
   * all updates available in tlogs only.
   * <p>
   * Then we start a target cluster with CDCR configuration and we change the source cluster configuration
   * to use CDCR (i.e. CdcrUpdateLog, CdcrRequestHandler and CdcrUpdateProcessor) and restart it.
   * <p>
   * We test that all updates eventually make it to the target cluster and that the collectioncheckpoint
   * call returns the same version as the last update indexed on the source.
   */
@Test
public void testConvertClusterToCdcrAndBootstrap() throws Exception {
    // start the target first so that we know its zkhost
    MiniSolrCloudCluster target = new MiniSolrCloudCluster(1, createTempDir("cdcr-target"), buildJettyConfig("/solr"));
    try {
        target.waitForAllNodes(30);
        System.out.println("Target zkHost = " + target.getZkServer().getZkAddress());
        System.setProperty("cdcr.target.zkHost", target.getZkServer().getZkAddress());
        // start a cluster with no cdcr
        MiniSolrCloudCluster source = new MiniSolrCloudCluster(1, createTempDir("cdcr-source"), buildJettyConfig("/solr"));
        try {
            source.waitForAllNodes(30);
            source.uploadConfigSet(configset("cdcr-source-disabled"), "cdcr-source");
            // create a collection with the cdcr-source-disabled configset
            CollectionAdminRequest.createCollection("cdcr-source", "cdcr-source", 1, 1).withProperty("solr.directoryFactory", "solr.StandardDirectoryFactory").process(source.getSolrClient());
            CloudSolrClient sourceSolrClient = source.getSolrClient();
            sourceSolrClient.setDefaultCollection("cdcr-source");
            int docs = (TEST_NIGHTLY ? 100 : 10);
            int numDocs = 0;
            for (int k = 0; k < docs; k++) {
                UpdateRequest req = new UpdateRequest();
                for (; numDocs < (k + 1) * 100; numDocs++) {
                    SolrInputDocument doc = new SolrInputDocument();
                    doc.addField("id", "source_" + numDocs);
                    doc.addField("xyz", numDocs);
                    req.add(doc);
                }
                req.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
                System.out.println("Adding " + docs + " docs with commit=true, numDocs=" + numDocs);
                req.process(sourceSolrClient);
            }
            QueryResponse response = sourceSolrClient.query(new SolrQuery("*:*"));
            assertEquals("", numDocs, response.getResults().getNumFound());
            // lets find and keep the maximum version assigned by source cluster across all our updates
            long maxVersion = Long.MIN_VALUE;
            ModifiableSolrParams params = new ModifiableSolrParams();
            params.set(CommonParams.QT, "/get");
            params.set("getVersions", numDocs);
            response = sourceSolrClient.query(params);
            List<Long> versions = (List<Long>) response.getResponse().get("versions");
            for (Long version : versions) {
                maxVersion = Math.max(maxVersion, version);
            }
            //       upload the cdcr-enabled config and restart source cluster
            source.uploadConfigSet(configset("cdcr-source"), "cdcr-source");
            JettySolrRunner runner = source.stopJettySolrRunner(0);
            source.startJettySolrRunner(runner);
            assertTrue(runner.isRunning());
            AbstractDistribZkTestBase.waitForRecoveriesToFinish("cdcr-source", source.getSolrClient().getZkStateReader(), true, true, 330);
            response = sourceSolrClient.query(new SolrQuery("*:*"));
            assertEquals("Document mismatch on source after restart", numDocs, response.getResults().getNumFound());
            // setup the target cluster
            target.uploadConfigSet(configset("cdcr-target"), "cdcr-target");
            CollectionAdminRequest.createCollection("cdcr-target", "cdcr-target", 1, 1).process(target.getSolrClient());
            CloudSolrClient targetSolrClient = target.getSolrClient();
            targetSolrClient.setDefaultCollection("cdcr-target");
            Thread.sleep(1000);
            cdcrStart(targetSolrClient);
            cdcrStart(sourceSolrClient);
            response = getCdcrQueue(sourceSolrClient);
            System.out.println("Cdcr queue response: " + response.getResponse());
            long foundDocs = waitForTargetToSync(numDocs, targetSolrClient);
            assertEquals("Document mismatch on target after sync", numDocs, foundDocs);
            params = new ModifiableSolrParams();
            params.set(CommonParams.ACTION, CdcrParams.CdcrAction.COLLECTIONCHECKPOINT.toString());
            params.set(CommonParams.QT, "/cdcr");
            response = targetSolrClient.query(params);
            Long checkpoint = (Long) response.getResponse().get(CdcrParams.CHECKPOINT);
            assertNotNull(checkpoint);
            assertEquals("COLLECTIONCHECKPOINT from target cluster should have returned the maximum " + "version across all updates made to source", maxVersion, checkpoint.longValue());
        } finally {
            source.shutdown();
        }
    } finally {
        target.shutdown();
    }
}
Also used : AbstractUpdateRequest(org.apache.solr.client.solrj.request.AbstractUpdateRequest) UpdateRequest(org.apache.solr.client.solrj.request.UpdateRequest) JettySolrRunner(org.apache.solr.client.solrj.embedded.JettySolrRunner) SolrQuery(org.apache.solr.client.solrj.SolrQuery) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) CloudSolrClient(org.apache.solr.client.solrj.impl.CloudSolrClient) SolrInputDocument(org.apache.solr.common.SolrInputDocument) QueryResponse(org.apache.solr.client.solrj.response.QueryResponse) NamedList(org.apache.solr.common.util.NamedList) List(java.util.List) Test(org.junit.Test)

Example 37 with ModifiableSolrParams

use of org.apache.solr.common.params.ModifiableSolrParams in project lucene-solr by apache.

the class CdcrBootstrapTest method invokeCdcrAction.

private QueryResponse invokeCdcrAction(CloudSolrClient client, CdcrParams.CdcrAction action) throws IOException, SolrServerException {
    ModifiableSolrParams params = new ModifiableSolrParams();
    params.set(CommonParams.QT, "/cdcr");
    params.set(CommonParams.ACTION, action.toLower());
    return client.query(params);
}
Also used : ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams)

Example 38 with ModifiableSolrParams

use of org.apache.solr.common.params.ModifiableSolrParams in project lucene-solr by apache.

the class DataImportHandler method handleRequestBody.

@Override
@SuppressWarnings("unchecked")
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
    rsp.setHttpCaching(false);
    //TODO: figure out why just the first one is OK...
    ContentStream contentStream = null;
    Iterable<ContentStream> streams = req.getContentStreams();
    if (streams != null) {
        for (ContentStream stream : streams) {
            contentStream = stream;
            break;
        }
    }
    SolrParams params = req.getParams();
    NamedList defaultParams = (NamedList) initArgs.get("defaults");
    RequestInfo requestParams = new RequestInfo(req, getParamsMap(params), contentStream);
    String command = requestParams.getCommand();
    if (DataImporter.SHOW_CONF_CMD.equals(command)) {
        String dataConfigFile = params.get("config");
        String dataConfig = params.get("dataConfig");
        if (dataConfigFile != null) {
            dataConfig = SolrWriter.getResourceAsString(req.getCore().getResourceLoader().openResource(dataConfigFile));
        }
        if (dataConfig == null) {
            rsp.add("status", DataImporter.MSG.NO_CONFIG_FOUND);
        } else {
            // Modify incoming request params to add wt=raw
            ModifiableSolrParams rawParams = new ModifiableSolrParams(req.getParams());
            rawParams.set(CommonParams.WT, "raw");
            req.setParams(rawParams);
            ContentStreamBase content = new ContentStreamBase.StringStream(dataConfig);
            rsp.add(RawResponseWriter.CONTENT, content);
        }
        return;
    }
    rsp.add("initArgs", initArgs);
    String message = "";
    if (command != null) {
        rsp.add("command", command);
    }
    // If importer is still null
    if (importer == null) {
        rsp.add("status", DataImporter.MSG.NO_INIT);
        return;
    }
    if (command != null && DataImporter.ABORT_CMD.equals(command)) {
        importer.runCmd(requestParams, null);
    } else if (importer.isBusy()) {
        message = DataImporter.MSG.CMD_RUNNING;
    } else if (command != null) {
        if (DataImporter.FULL_IMPORT_CMD.equals(command) || DataImporter.DELTA_IMPORT_CMD.equals(command) || IMPORT_CMD.equals(command)) {
            importer.maybeReloadConfiguration(requestParams, defaultParams);
            UpdateRequestProcessorChain processorChain = req.getCore().getUpdateProcessorChain(params);
            UpdateRequestProcessor processor = processorChain.createProcessor(req, rsp);
            SolrResourceLoader loader = req.getCore().getResourceLoader();
            DIHWriter sw = getSolrWriter(processor, loader, requestParams, req);
            if (requestParams.isDebug()) {
                if (debugEnabled) {
                    // Synchronous request for the debug mode
                    importer.runCmd(requestParams, sw);
                    rsp.add("mode", "debug");
                    rsp.add("documents", requestParams.getDebugInfo().debugDocuments);
                    if (requestParams.getDebugInfo().debugVerboseOutput != null) {
                        rsp.add("verbose-output", requestParams.getDebugInfo().debugVerboseOutput);
                    }
                } else {
                    message = DataImporter.MSG.DEBUG_NOT_ENABLED;
                }
            } else {
                // Asynchronous request for normal mode
                if (requestParams.getContentStream() == null && !requestParams.isSyncMode()) {
                    importer.runAsync(requestParams, sw);
                } else {
                    importer.runCmd(requestParams, sw);
                }
            }
        } else if (DataImporter.RELOAD_CONF_CMD.equals(command)) {
            if (importer.maybeReloadConfiguration(requestParams, defaultParams)) {
                message = DataImporter.MSG.CONFIG_RELOADED;
            } else {
                message = DataImporter.MSG.CONFIG_NOT_RELOADED;
            }
        }
    }
    rsp.add("status", importer.isBusy() ? "busy" : "idle");
    rsp.add("importResponse", message);
    rsp.add("statusMessages", importer.getStatusMessages());
}
Also used : NamedList(org.apache.solr.common.util.NamedList) UpdateRequestProcessorChain(org.apache.solr.update.processor.UpdateRequestProcessorChain) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) SolrResourceLoader(org.apache.solr.core.SolrResourceLoader) ContentStream(org.apache.solr.common.util.ContentStream) SolrParams(org.apache.solr.common.params.SolrParams) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) MapSolrParams(org.apache.solr.common.params.MapSolrParams) UpdateRequestProcessor(org.apache.solr.update.processor.UpdateRequestProcessor) ContentStreamBase(org.apache.solr.common.util.ContentStreamBase)

Example 39 with ModifiableSolrParams

use of org.apache.solr.common.params.ModifiableSolrParams in project lucene-solr by apache.

the class BackupCmd method copyIndexFiles.

private void copyIndexFiles(URI backupPath, ZkNodeProps request, NamedList results) throws Exception {
    String collectionName = request.getStr(COLLECTION_PROP);
    String backupName = request.getStr(NAME);
    String asyncId = request.getStr(ASYNC);
    String repoName = request.getStr(CoreAdminParams.BACKUP_REPOSITORY);
    ShardHandler shardHandler = ocmh.shardHandlerFactory.getShardHandler();
    Map<String, String> requestMap = new HashMap<>();
    String commitName = request.getStr(CoreAdminParams.COMMIT_NAME);
    Optional<CollectionSnapshotMetaData> snapshotMeta = Optional.empty();
    if (commitName != null) {
        SolrZkClient zkClient = ocmh.overseer.getZkController().getZkClient();
        snapshotMeta = SolrSnapshotManager.getCollectionLevelSnapshot(zkClient, collectionName, commitName);
        if (!snapshotMeta.isPresent()) {
            throw new SolrException(ErrorCode.BAD_REQUEST, "Snapshot with name " + commitName + " does not exist for collection " + collectionName);
        }
        if (snapshotMeta.get().getStatus() != SnapshotStatus.Successful) {
            throw new SolrException(ErrorCode.BAD_REQUEST, "Snapshot with name " + commitName + " for collection " + collectionName + " has not completed successfully. The status is " + snapshotMeta.get().getStatus());
        }
    }
    log.info("Starting backup of collection={} with backupName={} at location={}", collectionName, backupName, backupPath);
    Collection<String> shardsToConsider = Collections.emptySet();
    if (snapshotMeta.isPresent()) {
        shardsToConsider = snapshotMeta.get().getShards();
    }
    for (Slice slice : ocmh.zkStateReader.getClusterState().getCollection(collectionName).getActiveSlices()) {
        Replica replica = null;
        if (snapshotMeta.isPresent()) {
            if (!shardsToConsider.contains(slice.getName())) {
                log.warn("Skipping the backup for shard {} since it wasn't part of the collection {} when snapshot {} was created.", slice.getName(), collectionName, snapshotMeta.get().getName());
                continue;
            }
            replica = selectReplicaWithSnapshot(snapshotMeta.get(), slice);
        } else {
            // Note - Actually this can return a null value when there is no leader for this shard.
            replica = slice.getLeader();
            if (replica == null) {
                throw new SolrException(ErrorCode.SERVER_ERROR, "No 'leader' replica available for shard " + slice.getName() + " of collection " + collectionName);
            }
        }
        String coreName = replica.getStr(CORE_NAME_PROP);
        ModifiableSolrParams params = new ModifiableSolrParams();
        params.set(CoreAdminParams.ACTION, CoreAdminParams.CoreAdminAction.BACKUPCORE.toString());
        params.set(NAME, slice.getName());
        params.set(CoreAdminParams.BACKUP_REPOSITORY, repoName);
        // note: index dir will be here then the "snapshot." + slice name
        params.set(CoreAdminParams.BACKUP_LOCATION, backupPath.toASCIIString());
        params.set(CORE_NAME_PROP, coreName);
        if (snapshotMeta.isPresent()) {
            params.set(CoreAdminParams.COMMIT_NAME, snapshotMeta.get().getName());
        }
        ocmh.sendShardRequest(replica.getNodeName(), params, shardHandler, asyncId, requestMap);
        log.debug("Sent backup request to core={} for backupName={}", coreName, backupName);
    }
    log.debug("Sent backup requests to all shard leaders for backupName={}", backupName);
    ocmh.processResponses(results, shardHandler, true, "Could not backup all replicas", asyncId, requestMap);
}
Also used : HashMap(java.util.HashMap) Slice(org.apache.solr.common.cloud.Slice) ShardHandler(org.apache.solr.handler.component.ShardHandler) SolrZkClient(org.apache.solr.common.cloud.SolrZkClient) Replica(org.apache.solr.common.cloud.Replica) SolrException(org.apache.solr.common.SolrException) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) CollectionSnapshotMetaData(org.apache.solr.core.snapshots.CollectionSnapshotMetaData)

Example 40 with ModifiableSolrParams

use of org.apache.solr.common.params.ModifiableSolrParams in project lucene-solr by apache.

the class CreateCollectionCmd method call.

@Override
public void call(ClusterState clusterState, ZkNodeProps message, NamedList results) throws Exception {
    final String collectionName = message.getStr(NAME);
    log.info("Create collection {}", collectionName);
    if (clusterState.hasCollection(collectionName)) {
        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "collection already exists: " + collectionName);
    }
    String configName = getConfigName(collectionName, message);
    if (configName == null) {
        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "No config set found to associate with the collection.");
    }
    ocmh.validateConfigOrThrowSolrException(configName);
    try {
        // look at the replication factor and see if it matches reality
        // if it does not, find best nodes to create more cores
        int numTlogReplicas = message.getInt(TLOG_REPLICAS, 0);
        int numNrtReplicas = message.getInt(NRT_REPLICAS, message.getInt(REPLICATION_FACTOR, numTlogReplicas > 0 ? 0 : 1));
        int numPullReplicas = message.getInt(PULL_REPLICAS, 0);
        ShardHandler shardHandler = ocmh.shardHandlerFactory.getShardHandler();
        final String async = message.getStr(ASYNC);
        Integer numSlices = message.getInt(NUM_SLICES, null);
        String router = message.getStr("router.name", DocRouter.DEFAULT_NAME);
        List<String> shardNames = new ArrayList<>();
        if (ImplicitDocRouter.NAME.equals(router)) {
            ClusterStateMutator.getShardNames(shardNames, message.getStr("shards", null));
            numSlices = shardNames.size();
        } else {
            if (numSlices == null) {
                throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, NUM_SLICES + " is a required param (when using CompositeId router).");
            }
            ClusterStateMutator.getShardNames(numSlices, shardNames);
        }
        int maxShardsPerNode = message.getInt(MAX_SHARDS_PER_NODE, 1);
        if (numNrtReplicas + numTlogReplicas <= 0) {
            throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, NRT_REPLICAS + " + " + TLOG_REPLICAS + " must be greater than 0");
        }
        if (numSlices <= 0) {
            throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, NUM_SLICES + " must be > 0");
        }
        // we need to look at every node and see how many cores it serves
        // add our new cores to existing nodes serving the least number of cores
        // but (for now) require that each core goes on a distinct node.
        final List<String> nodeList = OverseerCollectionMessageHandler.getLiveOrLiveAndCreateNodeSetList(clusterState.getLiveNodes(), message, RANDOM);
        Map<ReplicaAssigner.Position, String> positionVsNodes;
        if (nodeList.isEmpty()) {
            log.warn("It is unusual to create a collection (" + collectionName + ") without cores.");
            positionVsNodes = new HashMap<>();
        } else {
            int totalNumReplicas = numNrtReplicas + numTlogReplicas + numPullReplicas;
            if (totalNumReplicas > nodeList.size()) {
                log.warn("Specified number of replicas of " + totalNumReplicas + " on collection " + collectionName + " is higher than the number of Solr instances currently live or live and part of your " + CREATE_NODE_SET + "(" + nodeList.size() + "). It's unusual to run two replica of the same slice on the same Solr-instance.");
            }
            int maxShardsAllowedToCreate = maxShardsPerNode * nodeList.size();
            int requestedShardsToCreate = numSlices * totalNumReplicas;
            if (maxShardsAllowedToCreate < requestedShardsToCreate) {
                throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Cannot create collection " + collectionName + ". Value of " + MAX_SHARDS_PER_NODE + " is " + maxShardsPerNode + ", and the number of nodes currently live or live and part of your " + CREATE_NODE_SET + " is " + nodeList.size() + ". This allows a maximum of " + maxShardsAllowedToCreate + " to be created. Value of " + NUM_SLICES + " is " + numSlices + ", value of " + NRT_REPLICAS + " is " + numNrtReplicas + ", value of " + TLOG_REPLICAS + " is " + numTlogReplicas + " and value of " + PULL_REPLICAS + " is " + numPullReplicas + ". This requires " + requestedShardsToCreate + " shards to be created (higher than the allowed number)");
            }
            positionVsNodes = ocmh.identifyNodes(clusterState, nodeList, message, shardNames, numNrtReplicas, numTlogReplicas, numPullReplicas);
        }
        ZkStateReader zkStateReader = ocmh.zkStateReader;
        boolean isLegacyCloud = Overseer.isLegacy(zkStateReader);
        ocmh.createConfNode(configName, collectionName, isLegacyCloud);
        Map<String, String> collectionParams = new HashMap<>();
        Map<String, Object> collectionProps = message.getProperties();
        for (String propName : collectionProps.keySet()) {
            if (propName.startsWith(ZkController.COLLECTION_PARAM_PREFIX)) {
                collectionParams.put(propName.substring(ZkController.COLLECTION_PARAM_PREFIX.length()), (String) collectionProps.get(propName));
            }
        }
        createCollectionZkNode(zkClient, collectionName, collectionParams);
        Overseer.getStateUpdateQueue(zkStateReader.getZkClient()).offer(Utils.toJSON(message));
        // wait for a while until we don't see the collection
        TimeOut waitUntil = new TimeOut(30, TimeUnit.SECONDS);
        boolean created = false;
        while (!waitUntil.hasTimedOut()) {
            Thread.sleep(100);
            created = zkStateReader.getClusterState().hasCollection(collectionName);
            if (created)
                break;
        }
        if (!created)
            throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Could not fully create collection: " + collectionName);
        if (nodeList.isEmpty()) {
            log.debug("Finished create command for collection: {}", collectionName);
            return;
        }
        // For tracking async calls.
        Map<String, String> requestMap = new HashMap<>();
        log.debug(formatString("Creating SolrCores for new collection {0}, shardNames {1} , nrtReplicas : {2}, tlogReplicas: {3}, pullReplicas: {4}", collectionName, shardNames, numNrtReplicas, numTlogReplicas, numPullReplicas));
        Map<String, ShardRequest> coresToCreate = new LinkedHashMap<>();
        for (Map.Entry<ReplicaAssigner.Position, String> e : positionVsNodes.entrySet()) {
            ReplicaAssigner.Position position = e.getKey();
            String nodeName = e.getValue();
            String coreName = Assign.buildCoreName(collectionName, position.shard, position.type, position.index + 1);
            log.debug(formatString("Creating core {0} as part of shard {1} of collection {2} on {3}", coreName, position.shard, collectionName, nodeName));
            String baseUrl = zkStateReader.getBaseUrlForNodeName(nodeName);
            // Otherwise the core creation fails
            if (!isLegacyCloud) {
                ZkNodeProps props = new ZkNodeProps(Overseer.QUEUE_OPERATION, ADDREPLICA.toString(), ZkStateReader.COLLECTION_PROP, collectionName, ZkStateReader.SHARD_ID_PROP, position.shard, ZkStateReader.CORE_NAME_PROP, coreName, ZkStateReader.STATE_PROP, Replica.State.DOWN.toString(), ZkStateReader.BASE_URL_PROP, baseUrl, ZkStateReader.REPLICA_TYPE, position.type.name());
                Overseer.getStateUpdateQueue(zkStateReader.getZkClient()).offer(Utils.toJSON(props));
            }
            // Need to create new params for each request
            ModifiableSolrParams params = new ModifiableSolrParams();
            params.set(CoreAdminParams.ACTION, CoreAdminParams.CoreAdminAction.CREATE.toString());
            params.set(CoreAdminParams.NAME, coreName);
            params.set(COLL_CONF, configName);
            params.set(CoreAdminParams.COLLECTION, collectionName);
            params.set(CoreAdminParams.SHARD, position.shard);
            params.set(ZkStateReader.NUM_SHARDS_PROP, numSlices);
            params.set(CoreAdminParams.NEW_COLLECTION, "true");
            params.set(CoreAdminParams.REPLICA_TYPE, position.type.name());
            if (async != null) {
                String coreAdminAsyncId = async + Math.abs(System.nanoTime());
                params.add(ASYNC, coreAdminAsyncId);
                requestMap.put(nodeName, coreAdminAsyncId);
            }
            ocmh.addPropertyParams(message, params);
            ShardRequest sreq = new ShardRequest();
            sreq.nodeName = nodeName;
            params.set("qt", ocmh.adminPath);
            sreq.purpose = 1;
            sreq.shards = new String[] { baseUrl };
            sreq.actualShards = sreq.shards;
            sreq.params = params;
            if (isLegacyCloud) {
                shardHandler.submit(sreq, sreq.shards[0], sreq.params);
            } else {
                coresToCreate.put(coreName, sreq);
            }
        }
        if (!isLegacyCloud) {
            // wait for all replica entries to be created
            Map<String, Replica> replicas = ocmh.waitToSeeReplicasInState(collectionName, coresToCreate.keySet());
            for (Map.Entry<String, ShardRequest> e : coresToCreate.entrySet()) {
                ShardRequest sreq = e.getValue();
                sreq.params.set(CoreAdminParams.CORE_NODE_NAME, replicas.get(e.getKey()).getName());
                shardHandler.submit(sreq, sreq.shards[0], sreq.params);
            }
        }
        ocmh.processResponses(results, shardHandler, false, null, async, requestMap, Collections.emptySet());
        if (results.get("failure") != null && ((SimpleOrderedMap) results.get("failure")).size() > 0) {
            // Let's cleanup as we hit an exception
            // We shouldn't be passing 'results' here for the cleanup as the response would then contain 'success'
            // element, which may be interpreted by the user as a positive ack
            ocmh.cleanupCollection(collectionName, new NamedList());
            log.info("Cleaned up artifacts for failed create collection for [{}]", collectionName);
        } else {
            log.debug("Finished create command on all shards for collection: {}", collectionName);
        }
    } catch (SolrException ex) {
        throw ex;
    } catch (Exception ex) {
        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, null, ex);
    }
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) TimeOut(org.apache.solr.util.TimeOut) ZkNodeProps(org.apache.solr.common.cloud.ZkNodeProps) ArrayList(java.util.ArrayList) StrUtils.formatString(org.apache.solr.common.util.StrUtils.formatString) SimpleOrderedMap(org.apache.solr.common.util.SimpleOrderedMap) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) LinkedHashMap(java.util.LinkedHashMap) ZkStateReader(org.apache.solr.common.cloud.ZkStateReader) SolrException(org.apache.solr.common.SolrException) NamedList(org.apache.solr.common.util.NamedList) ReplicaAssigner(org.apache.solr.cloud.rule.ReplicaAssigner) ShardHandler(org.apache.solr.handler.component.ShardHandler) Replica(org.apache.solr.common.cloud.Replica) SolrException(org.apache.solr.common.SolrException) KeeperException(org.apache.zookeeper.KeeperException) ZooKeeperException(org.apache.solr.common.cloud.ZooKeeperException) NoNodeException(org.apache.zookeeper.KeeperException.NoNodeException) ShardRequest(org.apache.solr.handler.component.ShardRequest) SimpleOrderedMap(org.apache.solr.common.util.SimpleOrderedMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)524 Test (org.junit.Test)168 ArrayList (java.util.ArrayList)87 NamedList (org.apache.solr.common.util.NamedList)76 QueryRequest (org.apache.solr.client.solrj.request.QueryRequest)74 SolrException (org.apache.solr.common.SolrException)68 UpdateRequest (org.apache.solr.client.solrj.request.UpdateRequest)66 HashMap (java.util.HashMap)61 HttpSolrClient (org.apache.solr.client.solrj.impl.HttpSolrClient)58 SolrQueryRequest (org.apache.solr.request.SolrQueryRequest)57 List (java.util.List)56 IOException (java.io.IOException)55 Map (java.util.Map)52 LocalSolrQueryRequest (org.apache.solr.request.LocalSolrQueryRequest)52 SolrInputDocument (org.apache.solr.common.SolrInputDocument)51 QueryResponse (org.apache.solr.client.solrj.response.QueryResponse)48 Tuple (org.apache.solr.client.solrj.io.Tuple)47 SolrParams (org.apache.solr.common.params.SolrParams)42 SolrQueryResponse (org.apache.solr.response.SolrQueryResponse)41 SolrRequest (org.apache.solr.client.solrj.SolrRequest)36