Class IndexGenerator
java.lang.Object
edu.ucsb.nceas.metacat.shared.BaseService
edu.ucsb.nceas.metacat.index.queue.IndexGenerator
The IndexGenerator class will publish (send) the index information
to a RabbitMQ queue. A index worker will consume the information.
- Author:
- tao
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
static final int
static final int
static final int
static final int
static final int
static final String
Fields inherited from class edu.ucsb.nceas.metacat.shared.BaseService
_serviceName
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
protected static String
getFilePath
(org.dataone.service.types.v1.Identifier id) Get the relative file path for the identifier.static IndexGenerator
Implement a Singleton pattern using "double checked locking" pattern.protected static String
getLastSubdir
(String path) Get the last sub-directory in the path.void
Publish the given information to the index queueboolean
This service is not refreshablestatic void
This method sets the instance to null and forces the getInstance method to create a new instance.int
size()
Get the number of messages in the index queuevoid
stop()
Stop the serviceMethods inherited from class edu.ucsb.nceas.metacat.shared.BaseService
refresh
-
Field Details
-
CREATE_INDEX_TYPE
- See Also:
-
DELETE_INDEX_TYPE
- See Also:
-
SYSMETA_CHANGE_TYPE
- See Also:
-
HIGHEST_PRIORITY
public static final int HIGHEST_PRIORITY- See Also:
-
HIGH_PRIORITY
public static final int HIGH_PRIORITY- See Also:
-
MEDIUM_PRIORITY
public static final int MEDIUM_PRIORITY- See Also:
-
MEDIUM_RESOURCEMAP_PRIORITY
public static final int MEDIUM_RESOURCEMAP_PRIORITY- See Also:
-
LOW_PRIORITY
public static final int LOW_PRIORITY- See Also:
-
-
Method Details
-
getLastSubdir
Get the last sub-directory in the path. If the path is /var/data, data will be returned.- Parameters:
path
- the path will be analyzed.- Returns:
- the last part of path
-
getInstance
Implement a Singleton pattern using "double checked locking" pattern.- Returns:
- a singleton instance of the RabbitMQService class.
- Throws:
ServiceException
-
refreshInstance
public static void refreshInstance()This method sets the instance to null and forces the getInstance method to create a new instance. This method is only used for a testing purpose! -
publish
public void publish(org.dataone.service.types.v1.Identifier id, String index_type, int priority) throws ServiceException, org.dataone.service.exceptions.InvalidRequest Publish the given information to the index queue- Parameters:
id
- the identifier of the object which will be indexedindex_type
- the type of indexing, it can be delete, create or sysmetapriority
- the priority of the index task- Throws:
ServiceException
org.dataone.service.exceptions.InvalidRequest
-
getFilePath
protected static String getFilePath(org.dataone.service.types.v1.Identifier id) throws ServiceException Get the relative file path for the identifier. This relative path is based on application.datafilepath (for data files) or application.documentfilepath (for document files) For example, autogen.1.1 is the docid for guid foo.1 and it is a metadata object. The metadata objects are stored in the path /var/metacat/document/autogen.1.1. Since the application.documentfilepath is "/var/metacat/document", the relative file path will be autogen.1.1. Note, the value can be null since cn doesn't store data objects.- Parameters:
id
- the guid of object- Returns:
- the relative file path
- Throws:
ServiceException
-
refreshable
public boolean refreshable()This service is not refreshable- Specified by:
refreshable
in classBaseService
-
doRefresh
- Specified by:
doRefresh
in classBaseService
- Throws:
ServiceException
-
stop
Stop the service- Specified by:
stop
in classBaseService
- Throws:
ServiceException
-
size
public int size()Get the number of messages in the index queue- Returns:
- the number of messages
-