Class AnalyticsIndexTypeMigrationUpgradePlugin

java.lang.Object
org.exoplatform.container.component.BaseComponentPlugin
org.exoplatform.commons.upgrade.UpgradeProductPlugin
io.meeds.analytics.elasticsearch.upgrade.AnalyticsIndexTypeMigrationUpgradePlugin
All Implemented Interfaces:
org.exoplatform.container.component.ComponentPlugin

public class AnalyticsIndexTypeMigrationUpgradePlugin extends org.exoplatform.commons.upgrade.UpgradeProductPlugin
Runs, after the platform has started, the migration of the weekly analytics indices that hold as another type a field the index template types keyword, at each start until the migration is complete: a run left no index behind, and the newest index has the types of the index template. The plugin keeps its own record of it, which replaces the version check of the upgrade service: a first run that fails with no change of version is asked again, a platform whose newest index was created by a former template is asked again until an index created by the new one is the newest, and a complete migration is never asked again, at a later upgrade either. A run that follows an incomplete one finds the indices already migrated with the expected types and skips them.

A server stopped while it migrated leaves its lock, which looks held for 600000L ms: a start that finds the lock held tries once more in the same start, once that lock can be taken over, so that an interrupted migration does not wait for the start after. When another node does hold the lock, that second try is refused as the first one.

  • Field Summary

    Fields inherited from class org.exoplatform.commons.upgrade.UpgradeProductPlugin

    asyncUpgradeExecution, executeOnlyOnce, OLD_PRODUCT_GROUP_ID, oldProductGroupId, PRODUCT_GROUP_ID, productGroupId, targetVersion, UPGRADE_COMPLETED_STATUS, UPGRADE_PLUGIN_ASYNC, UPGRADE_PLUGIN_ENABLE, UPGRADE_PLUGIN_EXECUTE_ONCE_PARAMETER, UPGRADE_PLUGIN_EXECUTION_ORDER, UPGRADE_PLUGIN_TARGET_PARAMETER

    Fields inherited from class org.exoplatform.container.component.BaseComponentPlugin

    desc, name
  • Constructor Summary

    Constructors
    Constructor
    Description
    AnalyticsIndexTypeMigrationUpgradePlugin(org.exoplatform.commons.api.settings.SettingService settingService, org.exoplatform.container.xml.InitParams initParams)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Read when the upgrade runs, after the start of the platform, and not as a constructor parameter: the upgrade service builds its plugins while the container starts, before the analytics beans are due.
    void
    processUpgrade(String oldVersion, String newVersion)
     
    protected void
    scheduleRetry(long delayMs, Runnable retry)
    Runs the second try on a thread of its own, which does not keep the server from stopping, with the container and the request life cycle the upgrade service gives to the first one: its thread is given back at once.
    boolean
    shouldProceedToUpgrade(String newVersion, String previousGroupVersion, org.exoplatform.commons.upgrade.UpgradePluginExecutionContext previousUpgradePluginExecution)
     

    Methods inherited from class org.exoplatform.commons.upgrade.UpgradeProductPlugin

    afterUpgrade, beforeUpgrade, equals, getPluginExecutionOrder, getProductGroupId, getTargetVersion, getValue, hashCode, isAsyncUpgradeExecution, isEnabled, isExecuteOnlyOnce, shouldProceedToUpgrade, storeValueForPlugin

    Methods inherited from class org.exoplatform.container.component.BaseComponentPlugin

    getDescription, getName, setDescription, setName

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AnalyticsIndexTypeMigrationUpgradePlugin

      public AnalyticsIndexTypeMigrationUpgradePlugin(org.exoplatform.commons.api.settings.SettingService settingService, org.exoplatform.container.xml.InitParams initParams)
  • Method Details

    • shouldProceedToUpgrade

      public boolean shouldProceedToUpgrade(String newVersion, String previousGroupVersion, org.exoplatform.commons.upgrade.UpgradePluginExecutionContext previousUpgradePluginExecution)
      Overrides:
      shouldProceedToUpgrade in class org.exoplatform.commons.upgrade.UpgradeProductPlugin
    • processUpgrade

      public void processUpgrade(String oldVersion, String newVersion)
      Specified by:
      processUpgrade in class org.exoplatform.commons.upgrade.UpgradeProductPlugin
    • scheduleRetry

      protected void scheduleRetry(long delayMs, Runnable retry)
      Runs the second try on a thread of its own, which does not keep the server from stopping, with the container and the request life cycle the upgrade service gives to the first one: its thread is given back at once.
      Parameters:
      delayMs - the time to wait before the try
      retry - the try
    • getMigrationService

      protected AnalyticsIndexTypeMigrationService getMigrationService()
      Read when the upgrade runs, after the start of the platform, and not as a constructor parameter: the upgrade service builds its plugins while the container starts, before the analytics beans are due.
      Returns:
      the service that migrates the indices