Package org.apache.solr.handler
Class ReplicationHandler
java.lang.Object
org.apache.solr.handler.RequestHandlerBase
org.apache.solr.handler.ReplicationHandler
- All Implemented Interfaces:
AutoCloseable,ApiSupport,SolrInfoBean,NestedRequestHandler,APIConfigProvider<ReplicationHandler.ReplicationHandlerConfig>,SolrMetricProducer,SolrRequestHandler,PermissionNameProvider,SolrCoreAware
public class ReplicationHandler
extends RequestHandlerBase
implements SolrCoreAware, APIConfigProvider<ReplicationHandler.ReplicationHandlerConfig>
A Handler which provides a REST API for replication and serves replication requests from
Followers.
When running on the leader, it provides the following commands
- Get the current replicable index version (command=indexversion)
- Get the list of files for a given index version (command=filelist&indexversion=<VERSION>)
- Get full or a part (chunk) of a given index or a config file (command=filecontent&file=<FILE_NAME>) You can optionally specify an offset and length to get that chunk of the file. You can request a configuration file by using "cf" parameter instead of the "file" parameter.
- Get status/statistics (command=details)
When running on the follower, it provides the following commands
- Perform an index fetch now (command=snappull)
- Get status/statistics (command=details)
- Abort an index fetch (command=abort)
- Enable/Disable polling the leader for new versions (command=enablepoll or command=disablepoll)
- Since:
- solr 1.4
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic classNested classes/interfaces inherited from class org.apache.solr.handler.RequestHandlerBase
RequestHandlerBase.HandlerMetricsNested classes/interfaces inherited from interface org.apache.solr.jersey.APIConfigProvider
APIConfigProvider.APIConfigNested classes/interfaces inherited from interface org.apache.solr.security.PermissionNameProvider
PermissionNameProvider.NameNested classes/interfaces inherited from interface org.apache.solr.core.SolrInfoBean
SolrInfoBean.Category, SolrInfoBean.Group -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringBoolean param for tests that can be specified when usingCMD_FETCH_INDEXto force the current request to block until the fetch is complete.Fields inherited from class org.apache.solr.handler.RequestHandlerBase
aggregateNodeLevelMetricsEnabled, appends, defaults, httpCaching, initArgs, invariants, metrics, publishCpuTime, REQUEST_CPU_TIMER_CONTEXT, solrMetricsContext, SOURCE_ATTRFields inherited from interface org.apache.solr.security.PermissionNameProvider
ANY, NULL, valuesFields inherited from interface org.apache.solr.metrics.SolrMetricProducer
CATEGORY_ATTR, HANDLER_ATTR, NAME_ATTR, OPERATION_ATTR, PLUGIN_NAME_ATTR, RESULT_ATTR, TYPE_ATTRFields inherited from interface org.apache.solr.request.SolrRequestHandler
TYPE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidclose()Implementations should always callSolrMetricProducer.super.close()to ensure that metrics with the same life-cycle as this component are properly unregistered.doFetch(org.apache.solr.common.params.SolrParams solrParams, boolean forceReplication) static voiddoSnapShoot(int numberToKeep, int numberBackupsToKeep, String location, String repoName, String commitName, String name, SolrCore core, Consumer<org.apache.solr.common.util.NamedList<?>> result) Category of this componentgetConfFileInfoFromCache(org.apache.solr.common.util.NamedList<String> nameAndAlias, Map<String, org.apache.solr.handler.ReplicationHandler.FileInfo> confFileInfoCache) For configuration files, checksum of the file is included because, unlike index files, they may have same content but different timestamps.org.apache.solr.common.util.NamedList<String> Simple one or two line descriptionCollection<Class<? extends JerseyResource>> Returns any JAX-RS annotated v2 APIs associated with this request handler.getPermissionName(AuthorizationContext request) voidvoidvoidinitializeMetrics(SolrMetricsContext parentContext, io.opentelemetry.api.common.Attributes attributes) Implementation should initialize all metrics to aSolrMetricsContextRegistry/MeterProvider withAttributesas the common set of attributes that will be attached to every metric that is initialized for that class/componentbooleanprovide()static LongreadIntervalNs(String interval) Whether this request handler must be made available at the /v2/ pathvoidsetPollListener(ReplicationHandler.PollListener pollListener) voidshutdown()Methods inherited from class org.apache.solr.handler.RequestHandlerBase
getApis, getInitArgs, getMetricsForThisRequest, getName, getPluginInfo, getRequestHandler, getSolrMetricsContext, getSolrParamsFromNamedList, getSubHandler, handleRequest, init, isInternalShardRequest, processErrorMetricsOnException, processReceivedException, setPluginInfoMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.solr.api.ApiSupport
registerV1
-
Field Details
-
PATH
- See Also:
-
EXCEPTION
- See Also:
-
LEADER_URL
- See Also:
-
FETCH_FROM_LEADER
- See Also:
-
SKIP_COMMIT_ON_LEADER_VERSION_ZERO
- See Also:
-
MESSAGE
- See Also:
-
COMMAND
- See Also:
-
CMD_DETAILS
- See Also:
-
CMD_BACKUP
- See Also:
-
CMD_RESTORE
- See Also:
-
CMD_RESTORE_STATUS
- See Also:
-
CMD_FETCH_INDEX
- See Also:
-
CMD_ABORT_FETCH
- See Also:
-
CMD_GET_FILE_LIST
- See Also:
-
CMD_GET_FILE
- See Also:
-
CMD_DISABLE_POLL
- See Also:
-
CMD_DISABLE_REPL
- See Also:
-
CMD_ENABLE_REPL
- See Also:
-
CMD_ENABLE_POLL
- See Also:
-
CMD_INDEX_VERSION
- See Also:
-
CMD_SHOW_COMMITS
- See Also:
-
CMD_DELETE_BACKUP
- See Also:
-
SIZE
- See Also:
-
ALIAS
- See Also:
-
CONF_FILES
- See Also:
-
REPLICATE_AFTER
- See Also:
-
RESERVE
- See Also:
-
EXTERNAL
- See Also:
-
INTERNAL
- See Also:
-
ERR_STATUS
- See Also:
-
OK_STATUS
- See Also:
-
NEXT_EXECUTION_AT
- See Also:
-
NUMBER_BACKUPS_TO_KEEP_REQUEST_PARAM
- See Also:
-
NUMBER_BACKUPS_TO_KEEP_INIT_PARAM
- See Also:
-
WAIT
Boolean param for tests that can be specified when usingCMD_FETCH_INDEXto force the current request to block until the fetch is complete. NOTE: This param is not advised for non-test code, since the duration of the fetch for non-trivial indexes will likely cause the request to time out.- See Also:
- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
-
Constructor Details
-
ReplicationHandler
public ReplicationHandler()
-
-
Method Details
-
getPermissionName
- Specified by:
getPermissionNamein interfacePermissionNameProvider
-
setPollListener
-
isFollower
public boolean isFollower() -
handleRequestBody
- Specified by:
handleRequestBodyin classRequestHandlerBase- Throws:
Exception
-
abortFetch
public boolean abortFetch() -
doFetch
public IndexFetcher.IndexFetchResult doFetch(org.apache.solr.common.params.SolrParams solrParams, boolean forceReplication) -
doSnapShoot
public static void doSnapShoot(int numberToKeep, int numberBackupsToKeep, String location, String repoName, String commitName, String name, SolrCore core, Consumer<org.apache.solr.common.util.NamedList<?>> result) throws IOException - Throws:
IOException
-
getIndexVersionResponse
- Throws:
IOException
-
getConfFileInfoFromCache
public List<FileMetaData> getConfFileInfoFromCache(org.apache.solr.common.util.NamedList<String> nameAndAlias, Map<String, org.apache.solr.handler.ReplicationHandler.FileInfo> confFileInfoCache) For configuration files, checksum of the file is included because, unlike index files, they may have same content but different timestamps.The local conf files information is cached so that everytime it does not have to compute the checksum. The cache is refreshed only if the lastModified of the file changes
-
getCategory
Description copied from interface:SolrInfoBeanCategory of this component- Specified by:
getCategoryin interfaceSolrInfoBean- Overrides:
getCategoryin classRequestHandlerBase
-
getDescription
Description copied from interface:SolrInfoBeanSimple one or two line description- Specified by:
getDescriptionin interfaceSolrInfoBean- Specified by:
getDescriptionin classRequestHandlerBase
-
getConfFileNameAlias
-
getConfFileInfoCache
-
getIncludeConfFiles
-
getReserveCommitDuration
-
initializeMetrics
public void initializeMetrics(SolrMetricsContext parentContext, io.opentelemetry.api.common.Attributes attributes) Description copied from interface:SolrMetricProducerImplementation should initialize all metrics to aSolrMetricsContextRegistry/MeterProvider withAttributesas the common set of attributes that will be attached to every metric that is initialized for that class/component- Specified by:
initializeMetricsin interfaceSolrMetricProducer- Overrides:
initializeMetricsin classRequestHandlerBase- Parameters:
parentContext- The registry that the component will initialize metrics toattributes- Base set of attributes that will be bound to all metrics for that component
-
close
Description copied from interface:SolrMetricProducerImplementations should always callSolrMetricProducer.super.close()to ensure that metrics with the same life-cycle as this component are properly unregistered. This prevents obscure memory leaks.from: https://docs.oracle.com/javase/8/docs/api/java/lang/AutoCloseable.html While this interface method is declared to throw Exception, implementers are strongly encouraged to declare concrete implementations of the close method to throw more specific exceptions, or to throw no exception at all if the close operation cannot fail.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSolrMetricProducer- Throws:
IOException
-
inform
- Specified by:
informin interfaceSolrCoreAware
-
getJerseyResources
Description copied from interface:ApiSupportReturns any JAX-RS annotated v2 APIs associated with this request handler.- Specified by:
getJerseyResourcesin interfaceApiSupport- See Also:
-
registerV2
Description copied from interface:ApiSupportWhether this request handler must be made available at the /v2/ path- Specified by:
registerV2in interfaceApiSupport
-
shutdown
public void shutdown() -
readIntervalNs
-
provide
- Specified by:
providein interfaceAPIConfigProvider<ReplicationHandler.ReplicationHandlerConfig>
-
getConfigClass
- Specified by:
getConfigClassin interfaceAPIConfigProvider<ReplicationHandler.ReplicationHandlerConfig>
-