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. An index worker will consume the information.
- Author:
- tao
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final intstatic final intstatic final intstatic final StringFields inherited from class edu.ucsb.nceas.metacat.shared.BaseService
_serviceName -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected static org.apache.commons.pool2.impl.GenericObjectPool<com.rabbitmq.client.Channel>Get the channel pool of this object.Get the feature set of this object.static IndexGeneratorImplement a Singleton pattern using "double checked locking" pattern.protected static StringgetLastSubdir(String path) Get the last sub-directory in the path.voidPublish the given information to the index queuebooleanThis service is not refreshablestatic voidThis method sets the instance to null and forces the getInstance method to create a new instance.static voidremoveCompleteFuture(Set<Future> futures) This method removes the Future objects from a set which have the done status.protected static voidsetChannelPool(org.apache.commons.pool2.impl.GenericObjectPool<com.rabbitmq.client.Channel> pool) This method is used for testing to replace the channel pool by a mock poolintsize()Get the number of messages in the index queuevoidstop()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:
-
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:
ServiceExceptionorg.dataone.service.exceptions.InvalidRequest
-
refreshable
public boolean refreshable()This service is not refreshable- Specified by:
refreshablein classBaseService
-
doRefresh
- Specified by:
doRefreshin classBaseService- Throws:
ServiceException
-
stop
Stop the service- Specified by:
stopin classBaseService- Throws:
ServiceException
-
size
public int size()Get the number of messages in the index queue- Returns:
- the number of messages
-
setChannelPool
protected static void setChannelPool(org.apache.commons.pool2.impl.GenericObjectPool<com.rabbitmq.client.Channel> pool) This method is used for testing to replace the channel pool by a mock pool- Parameters:
pool-
-
getChannelPool
protected static org.apache.commons.pool2.impl.GenericObjectPool<com.rabbitmq.client.Channel> getChannelPool()Get the channel pool of this object. It is for testing only.- Returns:
- the channel pool object
-
getFutures
Get the feature set of this object. It is for testing only- Returns:
- the feature set
-
removeCompleteFuture
This method removes the Future objects from a set which have the done status. So the free space can be used again. If it cannot remove any one, it will wait and try again until some space was freed up.- Parameters:
futures- the set which hold the futures to be checked
-