com.ibm.commerce.experimentation.registry

Class ExperimentRegistry

    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String CLASSNAME
      The name of this class.
      static java.lang.String COPYRIGHT
      IBM copyright notice field.
    • Constructor Summary

      Constructors 
      Constructor and Description
      ExperimentRegistry()
      The default constructor for this class.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      java.lang.Object createKey(java.lang.String strKey)
      This method creates a cache key from the string representation of the key.
      java.lang.String createKeyString(TypedProperty prop)
      This method creates a string representation of a cache key based on the input properties.
      ExperimentCache getCachedExperiment(java.lang.Integer experimentId)
      This method returns the cached experiment object with the given experiment ID.
      java.util.ArrayList getCachedExperiments(java.lang.Integer storeElementTypeId, java.lang.Integer storeId, java.sql.Timestamp currentTime)
      This method takes a store element type ID, store ID, and the current time, and according to the experiment schedule, populates the cached experiment object class with the content of the experiments that will be shown to all store elements of the given type in the given store.
      static ExperimentRegistry getInstance()
      This method returns an instance of this registry class.
      int getRandomNumber(int maxLimit)
      This method returns a randomly generated integer value between 0 (inclusive) and the specified value (exclusive).
      void populate(com.ibm.commerce.registry.LRUDynamicHashtable aCache)
      This method populates the given cache object during server start up and refresh of this cache.
      void refresh()
      This method refreshes registry entries from the database.
      void refresh(CommandContext commandContext)
      This method performs a refresh to the entire experiment cache.
      java.lang.Object retrieve(java.lang.Object key)
      This method retrieves an experiment of the given key from the database, populates its data into an experiment cache object and returns it to the caller of this method.
      void update(CommandContext commandContext, java.lang.String actionType, java.lang.Integer experimentId, java.lang.String experimentStatus)
      This method performs an update to the specified experiment in the cache.
      void update(java.lang.String action, java.lang.Object key)
      This method updates an element in the registry.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • COPYRIGHT

        public static final java.lang.String COPYRIGHT
        IBM copyright notice field.
        See Also:
        Constant Field Values
      • CLASSNAME

        public static final java.lang.String CLASSNAME
        The name of this class.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ExperimentRegistry

        public ExperimentRegistry()
        The default constructor for this class.
    • Method Detail

      • createKey

        public java.lang.Object createKey(java.lang.String strKey)
                                   throws java.lang.Exception
        This method creates a cache key from the string representation of the key.
        Specified by:
        createKey in interface ElementUpdate
        Specified by:
        createKey in class AbstractManagedDynamicCacheRegistry
        Parameters:
        strKey - The string representation of a cache key.
        Returns:
        A cache key.
        Throws:
        java.lang.Exception - Thrown whenever an exception is encountered in this method.
      • createKeyString

        public java.lang.String createKeyString(TypedProperty prop)
                                         throws java.lang.Exception
        This method creates a string representation of a cache key based on the input properties.
        Specified by:
        createKeyString in interface ElementUpdate
        Specified by:
        createKeyString in class AbstractManagedDynamicCacheRegistry
        Parameters:
        prop - The input properties.
        Returns:
        The string representation of a cache key.
        Throws:
        java.lang.Exception - Thrown whenever an exception is encountered in this method.
      • getCachedExperiment

        public ExperimentCache getCachedExperiment(java.lang.Integer experimentId)
        This method returns the cached experiment object with the given experiment ID.
        Parameters:
        experimentId - The ID of the experiment.
        Returns:
        The cached experiment.
      • getCachedExperiments

        public java.util.ArrayList getCachedExperiments(java.lang.Integer storeElementTypeId,
                                                        java.lang.Integer storeId,
                                                        java.sql.Timestamp currentTime)
        This method takes a store element type ID, store ID, and the current time, and according to the experiment schedule, populates the cached experiment object class with the content of the experiments that will be shown to all store elements of the given type in the given store.
        Parameters:
        storeElementTypeId - The ID of the store element type.
        storeId - The ID of the store.
        currentTime - The time for the evaluation.
        Returns:
        A list of cached experiments.
      • getInstance

        public static ExperimentRegistry getInstance()
        This method returns an instance of this registry class.
        Returns:
        An instance of this registry class.
      • getRandomNumber

        public int getRandomNumber(int maxLimit)
        This method returns a randomly generated integer value between 0 (inclusive) and the specified value (exclusive).
        Parameters:
        maxLimit - The bound on the random number to be returned.
        Returns:
        A randomly generated integer value between 0 (inclusive) and maxLimit (exclusive).
      • populate

        public void populate(com.ibm.commerce.registry.LRUDynamicHashtable aCache)
                      throws java.lang.Exception
        This method populates the given cache object during server start up and refresh of this cache.
        Specified by:
        populate in class AbstractManagedDynamicCacheRegistry
        Parameters:
        aCache - The cache object.
        Throws:
        java.lang.Exception - Thrown whenever an exception is encountered in this method.
      • refresh

        public void refresh()
                     throws java.lang.Exception
        This method refreshes registry entries from the database.
        Specified by:
        refresh in interface Registry
        Overrides:
        refresh in class AbstractManagedDynamicCacheRegistry
        Throws:
        java.lang.Exception - Thrown whenever an exception is encountered in this method.
      • refresh

        public void refresh(CommandContext commandContext)
                     throws ECException
        This method performs a refresh to the entire experiment cache.
        Parameters:
        commandContext - The command context.
        Throws:
        ECException - Thrown when an error occurs while accessing the runtime command context.
      • retrieve

        public java.lang.Object retrieve(java.lang.Object key)
                                  throws java.lang.Exception
        This method retrieves an experiment of the given key from the database, populates its data into an experiment cache object and returns it to the caller of this method.
        Specified by:
        retrieve in class AbstractManagedDynamicCacheRegistry
        Parameters:
        key - The ID of the experiment which is used as the key to identify an experiment.
        Returns:
        The cache object of the given key.
        Throws:
        java.lang.Exception - Thrown whenever an exception is encountered in this method.
      • update

        public void update(java.lang.String action,
                           java.lang.Object key)
                    throws java.lang.Exception
        This method updates an element in the registry.
        Specified by:
        update in interface ElementUpdate
        Overrides:
        update in class AbstractManagedDynamicCacheRegistry
        Parameters:
        action - The action to be applied to the cached element.
        key - The cache key.
        Throws:
        java.lang.Exception - Thrown whenever an exception is encountered in this method.
      • update

        public void update(CommandContext commandContext,
                           java.lang.String actionType,
                           java.lang.Integer experimentId,
                           java.lang.String experimentStatus)
                    throws ECException
        This method performs an update to the specified experiment in the cache.
        Parameters:
        commandContext - The command context.
        actionType - The type of action to be performed to the experiment cache in the registry.
        experimentId - The ID of the experiment to be added or updated.
        experimentStatus - The new status value of the given experiment, if the status needs to be updated; null otherwise.
        Throws:
        ECException - Thrown when an error occurs while accessing the runtime command context.