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. A 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
    • 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 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