Class IndexGenerator

java.lang.Object
edu.ucsb.nceas.metacat.shared.BaseService
edu.ucsb.nceas.metacat.index.queue.IndexGenerator

public class IndexGenerator extends BaseService
The IndexGenerator class will publish (send) the index information to a RabbitMQ queue. An index worker will consume the information.
Author:
tao
  • Field Details

  • Method Details

    • getLastSubdir

      protected static String getLastSubdir(String path)
      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

      public static IndexGenerator getInstance() throws ServiceException
      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 indexed
      index_type - the type of indexing, it can be - delete, create or sysmeta
      priority - the priority of the index task
      Throws:
      ServiceException
      org.dataone.service.exceptions.InvalidRequest
    • refreshable

      public boolean refreshable()
      This service is not refreshable
      Specified by:
      refreshable in class BaseService
    • doRefresh

      protected void doRefresh() throws ServiceException
      Specified by:
      doRefresh in class BaseService
      Throws:
      ServiceException
    • stop

      public void stop() throws ServiceException
      Stop the service
      Specified by:
      stop in class BaseService
      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

      protected static Set<Future> getFutures()
      Get the feature set of this object. It is for testing only
      Returns:
      the feature set
    • removeCompleteFuture

      public static void removeCompleteFuture(Set<Future> futures)
      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