Class CollectionsRepairEventListener
- java.lang.Object
-
- org.apache.solr.cluster.events.impl.CollectionsRepairEventListener
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,ClusterSingleton
,ClusterEventListener
public class CollectionsRepairEventListener extends Object implements ClusterEventListener, ClusterSingleton, Closeable
This is an illustration how to re-implement the combination of Solr 8x NodeLostTrigger and AutoAddReplicasPlanAction to maintain the collection's replicas when nodes are lost.The notion of
waitFor
delay between detection and repair action is implemented as a scheduled execution of the repair method, which is called every 1 sec to check whether there are any lost nodes that exceeded theirwaitFor
period.NOTE: this functionality would be probably more reliable when executed also as a periodically scheduled check - both as a reactive (listener) and proactive (scheduled) measure.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.solr.cloud.ClusterSingleton
ClusterSingleton.State
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_WAIT_FOR_SEC
static String
PLUGIN_NAME
-
Constructor Summary
Constructors Constructor Description CollectionsRepairEventListener(CoreContainer cc)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
String
getName()
Unique name of this singleton.ClusterSingleton.State
getState()
Returns the current state of the component.void
onEvent(ClusterEvent event)
Handle the event.void
setWaitForSecond(int waitForSecond)
void
start()
Start the operation of the component.void
stop()
Stop the operation of the component.
-
-
-
Field Detail
-
PLUGIN_NAME
public static final String PLUGIN_NAME
- See Also:
- Constant Field Values
-
DEFAULT_WAIT_FOR_SEC
public static final int DEFAULT_WAIT_FOR_SEC
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CollectionsRepairEventListener
public CollectionsRepairEventListener(CoreContainer cc)
-
-
Method Detail
-
setWaitForSecond
public void setWaitForSecond(int waitForSecond)
-
getName
public String getName()
Description copied from interface:ClusterSingleton
Unique name of this singleton. Used for registration.- Specified by:
getName
in interfaceClusterSingleton
-
onEvent
public void onEvent(ClusterEvent event)
Description copied from interface:ClusterEventListener
Handle the event. Implementations should be non-blocking - if any long processing is needed it should be performed asynchronously.- Specified by:
onEvent
in interfaceClusterEventListener
- Parameters:
event
- cluster event
-
start
public void start() throws Exception
Description copied from interface:ClusterSingleton
Start the operation of the component. Initially this method should set the state to STARTING, and on success it should set the state to RUNNING.- Specified by:
start
in interfaceClusterSingleton
- Throws:
Exception
- on startup errors. The component should revert to the STOPPED state.
-
getState
public ClusterSingleton.State getState()
Description copied from interface:ClusterSingleton
Returns the current state of the component.- Specified by:
getState
in interfaceClusterSingleton
-
stop
public void stop()
Description copied from interface:ClusterSingleton
Stop the operation of the component. Initially this method should set the state to STOPPING, and on return it should set the state to STOPPED. Components should also avoid holding any resource when in STOPPED state.- Specified by:
stop
in interfaceClusterSingleton
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
-