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 Classes Modifier and Type Class Description static interface
ReplicationHandler.PollListener
static class
ReplicationHandler.ReplicationHandlerConfig
-
Nested classes/interfaces inherited from class org.apache.solr.handler.RequestHandlerBase
RequestHandlerBase.HandlerMetrics
-
Nested classes/interfaces inherited from interface org.apache.solr.jersey.APIConfigProvider
APIConfigProvider.APIConfig
-
Nested classes/interfaces inherited from interface org.apache.solr.security.PermissionNameProvider
PermissionNameProvider.Name
-
Nested classes/interfaces inherited from interface org.apache.solr.core.SolrInfoBean
SolrInfoBean.Category, SolrInfoBean.Group
-
-
Field Summary
-
Fields inherited from class org.apache.solr.handler.RequestHandlerBase
aggregateNodeLevelMetricsEnabled, appends, defaults, httpCaching, initArgs, invariants, metrics, solrMetricsContext
-
Fields inherited from interface org.apache.solr.security.PermissionNameProvider
ANY, NULL, values
-
Fields inherited from interface org.apache.solr.request.SolrRequestHandler
TYPE
-
-
Constructor Summary
Constructors Constructor Description ReplicationHandler()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
abortFetch()
IndexFetcher.IndexFetchResult
doFetch(org.apache.solr.common.params.SolrParams solrParams, boolean forceReplication)
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)
SolrInfoBean.Category
getCategory()
Category of this componentMap<String,org.apache.solr.handler.ReplicationHandler.FileInfo>
getConfFileInfoCache()
List<CoreReplicationAPI.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.org.apache.solr.common.util.NamedList<String>
getConfFileNameAlias()
Class<ReplicationHandler.ReplicationHandlerConfig>
getConfigClass()
String
getDescription()
Simple one or two line descriptionString
getIncludeConfFiles()
CoreReplicationAPI.IndexVersionResponse
getIndexVersionResponse()
Collection<Class<? extends JerseyResource>>
getJerseyResources()
Returns any JAX-RS annotated v2 APIs associated with this request handler.static <T> T
getObjectWithBackwardCompatibility(org.apache.solr.common.util.NamedList<?> params, String preferredKey, String alternativeKey)
PermissionNameProvider.Name
getPermissionName(AuthorizationContext request)
Long
getReserveCommitDuration()
void
handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp)
void
inform(SolrCore core)
void
initializeMetrics(SolrMetricsContext parentContext, String scope)
Initialize metrics specific to this producer.boolean
isFollower()
ReplicationHandler.ReplicationHandlerConfig
provide()
Boolean
registerV2()
Whether this request handler must be made available at the /v2/ pathvoid
setPollListener(ReplicationHandler.PollListener pollListener)
void
shutdown()
-
Methods inherited from class org.apache.solr.handler.RequestHandlerBase
getApis, getInitArgs, getMetricsForThisRequest, getName, getPluginInfo, getRequestHandler, getSolrMetricsContext, getSolrParamsFromNamedList, getSubHandler, handleRequest, init, isInternalShardRequest, normalizeReceivedException, processErrorMetricsOnException, setPluginInfo
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.solr.api.ApiSupport
registerV1
-
Methods inherited from interface org.apache.solr.metrics.SolrMetricProducer
close
-
-
-
-
Field Detail
-
PATH
public static final String PATH
- See Also:
- Constant Field Values
-
EXCEPTION
public static final String EXCEPTION
- See Also:
- Constant Field Values
-
LEADER_URL
public static final String LEADER_URL
- See Also:
- Constant Field Values
-
LEGACY_LEADER_URL
@Deprecated public static final String LEGACY_LEADER_URL
Deprecated.Only used for backwards compatibility. UseLEADER_URL
- See Also:
- Constant Field Values
-
FETCH_FROM_LEADER
public static final String FETCH_FROM_LEADER
- See Also:
- Constant Field Values
-
SKIP_COMMIT_ON_LEADER_VERSION_ZERO
public static final String SKIP_COMMIT_ON_LEADER_VERSION_ZERO
- See Also:
- Constant Field Values
-
LEGACY_SKIP_COMMIT_ON_LEADER_VERSION_ZERO
@Deprecated public static final String LEGACY_SKIP_COMMIT_ON_LEADER_VERSION_ZERO
Deprecated.Only used for backwards compatibility. UseSKIP_COMMIT_ON_LEADER_VERSION_ZERO
- See Also:
- Constant Field Values
-
STATUS
public static final String STATUS
- See Also:
- Constant Field Values
-
MESSAGE
public static final String MESSAGE
- See Also:
- Constant Field Values
-
COMMAND
public static final String COMMAND
- See Also:
- Constant Field Values
-
CMD_DETAILS
public static final String CMD_DETAILS
- See Also:
- Constant Field Values
-
CMD_BACKUP
public static final String CMD_BACKUP
- See Also:
- Constant Field Values
-
CMD_RESTORE
public static final String CMD_RESTORE
- See Also:
- Constant Field Values
-
CMD_RESTORE_STATUS
public static final String CMD_RESTORE_STATUS
- See Also:
- Constant Field Values
-
CMD_FETCH_INDEX
public static final String CMD_FETCH_INDEX
- See Also:
- Constant Field Values
-
CMD_ABORT_FETCH
public static final String CMD_ABORT_FETCH
- See Also:
- Constant Field Values
-
CMD_GET_FILE_LIST
public static final String CMD_GET_FILE_LIST
- See Also:
- Constant Field Values
-
CMD_GET_FILE
public static final String CMD_GET_FILE
- See Also:
- Constant Field Values
-
CMD_DISABLE_POLL
public static final String CMD_DISABLE_POLL
- See Also:
- Constant Field Values
-
CMD_DISABLE_REPL
public static final String CMD_DISABLE_REPL
- See Also:
- Constant Field Values
-
CMD_ENABLE_REPL
public static final String CMD_ENABLE_REPL
- See Also:
- Constant Field Values
-
CMD_ENABLE_POLL
public static final String CMD_ENABLE_POLL
- See Also:
- Constant Field Values
-
CMD_INDEX_VERSION
public static final String CMD_INDEX_VERSION
- See Also:
- Constant Field Values
-
CMD_SHOW_COMMITS
public static final String CMD_SHOW_COMMITS
- See Also:
- Constant Field Values
-
CMD_DELETE_BACKUP
public static final String CMD_DELETE_BACKUP
- See Also:
- Constant Field Values
-
GENERATION
public static final String GENERATION
- See Also:
- Constant Field Values
-
OFFSET
public static final String OFFSET
- See Also:
- Constant Field Values
-
LEN
public static final String LEN
- See Also:
- Constant Field Values
-
FILE
public static final String FILE
- See Also:
- Constant Field Values
-
SIZE
public static final String SIZE
- See Also:
- Constant Field Values
-
MAX_WRITE_PER_SECOND
public static final String MAX_WRITE_PER_SECOND
- See Also:
- Constant Field Values
-
CONF_FILE_SHORT
public static final String CONF_FILE_SHORT
- See Also:
- Constant Field Values
-
TLOG_FILE
public static final String TLOG_FILE
- See Also:
- Constant Field Values
-
CHECKSUM
public static final String CHECKSUM
- See Also:
- Constant Field Values
-
ALIAS
public static final String ALIAS
- See Also:
- Constant Field Values
-
CONF_CHECKSUM
public static final String CONF_CHECKSUM
- See Also:
- Constant Field Values
-
CONF_FILES
public static final String CONF_FILES
- See Also:
- Constant Field Values
-
REPLICATE_AFTER
public static final String REPLICATE_AFTER
- See Also:
- Constant Field Values
-
FILE_STREAM
public static final String FILE_STREAM
- See Also:
- Constant Field Values
-
POLL_INTERVAL
public static final String POLL_INTERVAL
- See Also:
- Constant Field Values
-
INTERVAL_ERR_MSG
public static final String INTERVAL_ERR_MSG
- See Also:
- Constant Field Values
-
PACKET_SZ
public static final int PACKET_SZ
- See Also:
- Constant Field Values
-
RESERVE
public static final String RESERVE
- See Also:
- Constant Field Values
-
COMPRESSION
public static final String COMPRESSION
- See Also:
- Constant Field Values
-
EXTERNAL
public static final String EXTERNAL
- See Also:
- Constant Field Values
-
INTERNAL
public static final String INTERNAL
- See Also:
- Constant Field Values
-
ERR_STATUS
public static final String ERR_STATUS
- See Also:
- Constant Field Values
-
OK_STATUS
public static final String OK_STATUS
- See Also:
- Constant Field Values
-
NEXT_EXECUTION_AT
public static final String NEXT_EXECUTION_AT
- See Also:
- Constant Field Values
-
NUMBER_BACKUPS_TO_KEEP_REQUEST_PARAM
public static final String NUMBER_BACKUPS_TO_KEEP_REQUEST_PARAM
- See Also:
- Constant Field Values
-
NUMBER_BACKUPS_TO_KEEP_INIT_PARAM
public static final String NUMBER_BACKUPS_TO_KEEP_INIT_PARAM
- See Also:
- Constant Field Values
-
WAIT
public static final String WAIT
Boolean param for tests that can be specified when usingCMD_FETCH_INDEX
to 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 likeley cause the request to time out.- See Also:
- Constant Field Values
- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
-
Method Detail
-
getPermissionName
public PermissionNameProvider.Name getPermissionName(AuthorizationContext request)
- Specified by:
getPermissionName
in interfacePermissionNameProvider
-
setPollListener
public void setPollListener(ReplicationHandler.PollListener pollListener)
-
isFollower
public boolean isFollower()
-
handleRequestBody
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception
- Specified by:
handleRequestBody
in classRequestHandlerBase
- Throws:
Exception
-
getObjectWithBackwardCompatibility
public static <T> T getObjectWithBackwardCompatibility(org.apache.solr.common.util.NamedList<?> params, String preferredKey, String alternativeKey)
-
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
public CoreReplicationAPI.IndexVersionResponse getIndexVersionResponse() throws IOException
- Throws:
IOException
-
getConfFileInfoFromCache
public List<CoreReplicationAPI.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
public SolrInfoBean.Category getCategory()
Description copied from interface:SolrInfoBean
Category of this component- Specified by:
getCategory
in interfaceSolrInfoBean
- Overrides:
getCategory
in classRequestHandlerBase
-
getDescription
public String getDescription()
Description copied from interface:SolrInfoBean
Simple one or two line description- Specified by:
getDescription
in interfaceSolrInfoBean
- Specified by:
getDescription
in classRequestHandlerBase
-
getConfFileNameAlias
public org.apache.solr.common.util.NamedList<String> getConfFileNameAlias()
-
getConfFileInfoCache
public Map<String,org.apache.solr.handler.ReplicationHandler.FileInfo> getConfFileInfoCache()
-
getIncludeConfFiles
public String getIncludeConfFiles()
-
getReserveCommitDuration
public Long getReserveCommitDuration()
-
initializeMetrics
public void initializeMetrics(SolrMetricsContext parentContext, String scope)
Description copied from interface:SolrMetricProducer
Initialize metrics specific to this producer.- Specified by:
initializeMetrics
in interfaceSolrMetricProducer
- Overrides:
initializeMetrics
in classRequestHandlerBase
- Parameters:
parentContext
- parent metrics context. If this component has the same life-cycle as the parent it can simply use the parent context, otherwise it should obtain a child context usingSolrMetricsContext.getChildContext(Object)
passingthis
as the child object.scope
- component scope
-
inform
public void inform(SolrCore core)
- Specified by:
inform
in interfaceSolrCoreAware
-
getJerseyResources
public Collection<Class<? extends JerseyResource>> getJerseyResources()
Description copied from interface:ApiSupport
Returns any JAX-RS annotated v2 APIs associated with this request handler.- Specified by:
getJerseyResources
in interfaceApiSupport
- See Also:
ApiSupport.getApis()
-
registerV2
public Boolean registerV2()
Description copied from interface:ApiSupport
Whether this request handler must be made available at the /v2/ path- Specified by:
registerV2
in interfaceApiSupport
-
shutdown
public void shutdown()
-
provide
public ReplicationHandler.ReplicationHandlerConfig provide()
- Specified by:
provide
in interfaceAPIConfigProvider<ReplicationHandler.ReplicationHandlerConfig>
-
getConfigClass
public Class<ReplicationHandler.ReplicationHandlerConfig> getConfigClass()
- Specified by:
getConfigClass
in interfaceAPIConfigProvider<ReplicationHandler.ReplicationHandlerConfig>
-
-