murblanc commented on a change in pull request #1758: URL: https://github.com/apache/lucene-solr/pull/1758#discussion_r496005660
########## File path: solr/core/src/java/org/apache/solr/cluster/events/impl/CollectionsRepairEventListener.java ########## @@ -0,0 +1,186 @@ +/* + * 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.solr.cluster.events.impl; + +import java.io.IOException; +import java.lang.invoke.MethodHandles; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; + +import org.apache.solr.client.solrj.SolrClient; +import org.apache.solr.client.solrj.cloud.SolrCloudManager; +import org.apache.solr.client.solrj.request.CollectionAdminRequest; +import org.apache.solr.cloud.api.collections.Assign; +import org.apache.solr.cluster.events.ClusterEvent; +import org.apache.solr.cluster.events.ClusterEventListener; +import org.apache.solr.cluster.events.NodesDownEvent; +import org.apache.solr.cluster.events.ReplicasDownEvent; +import org.apache.solr.common.cloud.ClusterState; +import org.apache.solr.common.cloud.Replica; +import org.apache.solr.common.cloud.ReplicaPosition; +import org.apache.solr.core.CoreContainer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This is an illustration how to re-implement the combination of 8x + * NodeLostTrigger and AutoAddReplicasPlanAction to maintain the collection's replication factor. + * <p>NOTE: there's no support for 'waitFor' yet.</p> + * <p>NOTE 2: this functionality would be probably more reliable when executed also as a + * periodically scheduled check - both as a reactive (listener) and proactive (scheduled) measure.</p> + */ +public class CollectionsRepairEventListener implements ClusterEventListener { + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + public static final String PLUGIN_NAME = "collectionsRepairListener"; + private static final String ASYNC_ID_PREFIX = "_async_" + PLUGIN_NAME; + private static final AtomicInteger counter = new AtomicInteger(); + + private final SolrClient solrClient; + private final SolrCloudManager solrCloudManager; + + private boolean running = false; Review comment: Likely needs to be volatile (or get proper synchronization). ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org