public class UpdateIndexJob extends GeneratedUpdateIndexJob
The UpdateIndexJob is a Job run every minute that updates the LuceneIndex instances incrementally. Instead
of indexing every single hybris Platform item, the UpdateIndexJob only updates items that have been scheduled for
re-indexing. Basically, the course of action is like this:
Scheduling items for update
scheduleUpdate(Collection, boolean) method, as in: UpdateIndexJob.scheduleUpdate(Collections.singleton(item), false);scheduleUpdate(Collection, boolean) method, as in: Item item = getItem( e );
if( UpdateIndexJob.scheduleUpdate( Collections.singleton( item ), false ) )
{ System.out.println( "update is scheduled" ); }
else
{ System.out.println( "item is not part of any index" ); }
Specifying the number of items to index per single run
An index update potentially contains tens of thousands of hybris Platform items. Therefore, an index update with a very large
number of hybris Platform items to be re-indexed might cause the UpdateIndexJob to use up a large amount of system
resources. As the UpdateIndexJob is a hybris Platform CronJob, it runs within the hybris Platform's
Virtual Machine. An index update with a large number of hybris Platform items might cause the Java Virtual Machine to get slow
or possibly even run out of memory. Therefore, the UpdateIndexJob has a limit of how many items to re-index in one
single pass. This limit is specified in the UpdateIndexJob's GeneratedUpdateIndexJob.MAXUPDATESPERRUN
attribute (factory default is 2400).
If the full set of items to be re-indexed exceeds this limit (that is, if there are more than 2400 items to be re-indexed),
then the first batch of 2400 items is indexed with the first UpdateIndexJob run, the second batch of 2400 items is
indexed with the second UpdateIndexJob run, and so on. As the UpdateIndexJob is run every minute,
indexing a large number of hybris Platform items might take several minutes altogether. Therefore, hybris recommends using the
rebuildIndex() method if you need a fully completed index right away and using an incrementally updated index is
not an option. However, running a full index rebuild is likely to cause heavy load on the server(s) running the hybris Platform
and the database.
Job.JobFileLogContainer, Job.SynchronicityGenericItem.GenericItemImplLocalizableItem.LocalizableItemImplExtensibleItem.ExtensibleItemImplItem.AttributeFilter, Item.AttributeMode, Item.CachedGetter, Item.CachedSetter, Item.ItemAttributeMap, Item.ItemConstraint, Item.ItemImpl, Item.JaloCachedComputationExceptionDEFAULT_INITIAL_ATTRIBUTES, MAXUPDATESPERRUNCTX_CURRENTCRONJOB, CTX_CURRENTJOBACTIVE, ALTERNATIVEDATASOURCEID, CHANGERECORDINGENABLED, CODE, CRONJOBS, CRONJOBSHANDLER, EMAILADDRESS, EMAILNOTIFICATIONTEMPLATE, ERRORMODE, LOGLEVELDATABASE, LOGLEVELFILE, LOGTODATABASE, LOGTOFILE, NODEGROUP, NODEID, PRIORITY, REMOVEONEXIT, REQUESTABORT, REQUESTABORTSTEP, RESTRICTIONS, RESTRICTIONSHANDLER, RETRY, SENDEMAIL, SESSIONCONTEXTVALUES, SESSIONCURRENCY, SESSIONLANGUAGE, SESSIONUSER, SINGLEEXECUTABLE, TRIGGERS, TRIGGERSHANDLERLANGUAGE_FALLBACK_ENABLED_CREATION_TIME_INTERNAL, _MODIFIED_TIME_INTERNAL, accessorLog, CREATION_TIME, DISABLE_ATTRIBUTE_CHECK, DISABLE_ITEMCHECK_BEFORE_REMOVABLE, EVEN, FEATURE_ACCESSMAP_QUALIFIER, INITIAL_CREATION_FLAG, isJaloOnly, MODIFIED_TIME, NEGATIVE, NOT_FOUND, OWNER, PK, POSITIVE, SAVE_FROM_SERVICE_LAYER, staticTransientObjects, TYPEimpl, tenant| Constructor and Description |
|---|
UpdateIndexJob() |
| Modifier and Type | Method and Description |
|---|---|
protected Map<LuceneIndex,Map<IndexConfiguration,Collection<IndexUpdate>>> |
getAndMarkPendingUpdates(CronJob cronjob) |
protected static Map<IndexConfiguration,Set<Item>> |
getIndexConfigurationsUpdateMap(Collection<Item> items)
Matches a collection of items to all existing
index configurations. |
protected static Map<ComposedType,Set<IndexConfiguration>> |
getType2ConfigsMap(Set<ComposedType> filterTypes)
Queries all existing
IndexConfiguration and returns all existing mappings between indexed types and their index
configuration. |
protected static Set<ComposedType> |
getTypeSet(Collection<Item> items)
Extracts all different
ComposedTypes from a given collection of items. |
boolean |
isAbortable(CronJob conJob)
Tells whether this currently executed job is abortable.
|
protected CronJob.CronJobResult |
performCronJob(CronJob cronJob)
You have to implement this method in your
Job. |
static boolean |
scheduleUpdate(Collection<Item> items,
boolean remove)
Schedules updates for the given item set.
|
getDefaultAttributeModes, getMaxUpdatesPerRun, getMaxUpdatesPerRun, getMaxUpdatesPerRunAsPrimitive, getMaxUpdatesPerRunAsPrimitive, setMaxUpdatesPerRun, setMaxUpdatesPerRun, setMaxUpdatesPerRun, setMaxUpdatesPerRuncanPerform, canUndo, checkRemovable, configureCronjob, createItem, createLogContext, debug, error, fatal, getConfigAttributes, getCronJobsByCode, getCronJobsByCode, getCurrentLogContainer, getEffectiveLogLevel, getNonInitialAttributes, info, isDebugEnabled, isEnabledFor, isErrorEnabled, isInfoEnabled, isPerformable, isPerformable, isUndoable, isWarnEnabled, jobIsCurrentlyRunning, log, logToFile, perform, perform, perform, prepareAfterFinishEvent, prepareBeforeStartEvent, remove, saveToLogFile, sendFinishedEvent, sendStartEvent, setCode, setCronJobs, setCurrentLogContainer, setNonInitialAttributes, startOwnSession, stopOwnSession, switchDataSource, undo, undo, undoCronJob, unsetAlternativeDataSource, unsetCurrentLogContainer, warnaddToRestrictions, addToRestrictions, addToTriggers, addToTriggers, getAlternativeDataSourceID, getAlternativeDataSourceID, getCode, getCode, getCronJobs, getCronJobs, getEmailAddress, getEmailAddress, getEmailNotificationTemplate, getEmailNotificationTemplate, getErrorMode, getErrorMode, getLogLevelDatabase, getLogLevelDatabase, getLogLevelFile, getLogLevelFile, getNodeGroup, getNodeGroup, getNodeID, getNodeID, getNodeIDAsPrimitive, getNodeIDAsPrimitive, getPriority, getPriority, getPriorityAsPrimitive, getPriorityAsPrimitive, getRestrictions, getRestrictions, getSessionCurrency, getSessionCurrency, getSessionLanguage, getSessionLanguage, getSessionUser, getSessionUser, getTriggers, getTriggers, isActive, isActive, isActiveAsPrimitive, isActiveAsPrimitive, isChangeRecordingEnabled, isChangeRecordingEnabled, isChangeRecordingEnabledAsPrimitive, isChangeRecordingEnabledAsPrimitive, isLogToDatabase, isLogToDatabase, isLogToDatabaseAsPrimitive, isLogToDatabaseAsPrimitive, isLogToFile, isLogToFile, isLogToFileAsPrimitive, isLogToFileAsPrimitive, isRemoveOnExit, isRemoveOnExit, isRemoveOnExitAsPrimitive, isRemoveOnExitAsPrimitive, isRequestAbort, isRequestAbort, isRequestAbortAsPrimitive, isRequestAbortAsPrimitive, isRequestAbortStep, isRequestAbortStep, isRequestAbortStepAsPrimitive, isRequestAbortStepAsPrimitive, isRetry, isRetry, isRetryAsPrimitive, isRetryAsPrimitive, isSendEmail, isSendEmail, isSendEmailAsPrimitive, isSendEmailAsPrimitive, isSingleExecutable, isSingleExecutable, isSingleExecutableAsPrimitive, isSingleExecutableAsPrimitive, removeFromRestrictions, removeFromRestrictions, removeFromTriggers, removeFromTriggers, setActive, setActive, setActive, setActive, setAlternativeDataSourceID, setAlternativeDataSourceID, setChangeRecordingEnabled, setChangeRecordingEnabled, setChangeRecordingEnabled, setChangeRecordingEnabled, setCode, setEmailAddress, setEmailAddress, setEmailNotificationTemplate, setEmailNotificationTemplate, setErrorMode, setErrorMode, setLogLevelDatabase, setLogLevelDatabase, setLogLevelFile, setLogLevelFile, setLogToDatabase, setLogToDatabase, setLogToDatabase, setLogToDatabase, setLogToFile, setLogToFile, setLogToFile, setLogToFile, setNodeGroup, setNodeGroup, setNodeID, setNodeID, setNodeID, setNodeID, setPriority, setPriority, setPriority, setPriority, setRemoveOnExit, setRemoveOnExit, setRemoveOnExit, setRemoveOnExit, setRequestAbort, setRequestAbort, setRequestAbort, setRequestAbort, setRequestAbortStep, setRequestAbortStep, setRequestAbortStep, setRequestAbortStep, setRestrictions, setRestrictions, setRetry, setRetry, setRetry, setRetry, setSendEmail, setSendEmail, setSendEmail, setSendEmail, setSessionCurrency, setSessionCurrency, setSessionLanguage, setSessionLanguage, setSessionUser, setSessionUser, setSingleExecutable, setSingleExecutable, setSingleExecutable, setSingleExecutable, setTriggers, setTriggersgetInitialPropertiesgetAllLocalizedProperties, getAllLocalizedProperties, getAllLocalizedProperties, getAllLocalizedProperties, getAllValuesSessionContext, getLocalizedProperty, getLocalizedProperty, getLocalizedPropertyInternal, getLocalizedPropertyNames, getLocalizedPropertyNames, hasLanguage, isEmptyValue, isFallbackEnabled, removeLocalizedProperty, removeLocalizedProperty, setAllLocalizedProperties, setAllLocalizedProperties, setLocalizedProperty, setLocalizedPropertycreateNonClassAccessor, getAllProperties, getAllProperties, getProperty, getProperty, getPropertyNames, getPropertyNames, removeProperty, removeProperty, setAllProperties, setAllProperties, setProperty, setPropertyaddLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addNegativePermission, addPermission, addPositivePermission, assureExtensionsLoaded, changeTypeAfterCreation, checkConstraint, checkItemPermission, checkMandatoryAttribute, checkMandatoryAttribute, checkPermission, checkPermission, clearPermission, compareTo, ctx, doAfterRemove, doBeforeRemove, equals, getAccessorFor, getAllAttributes, getAllAttributes, getAllAttributes, getAllAttributes, getAllAttributesInternal, getAllLinkedItems, getAndCheckCacheBoundItem, getAttribute, getAttribute, getCacheBoundItem, getComposedType, getComposedTypePK, getCreationTime, getCurrentlyRemovingCount, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItemsCount, getLinkedItemsCount, getLinkedItemsCount, getModificationTime, getNegativePermissions, getOwner, getPermissionMap, getPermissions, getPersistenceVersion, getPK, getPositivePermissions, getRestrictedPrincipals, getSession, getSyncObject, getTenant, getTransientObject, getTransientObjectMap, hashCode, hasRegisteredClassAccessorFor, internal_registerClassAccessorFor, internal_registerNonClassAccessorFor, invalidateLocalCaches, isAlive, isCacheBound, isCurrentlyRemoving, isCurrentlyRemoving, isEmptyRelationValue, isInCreate, isInstanceOf, isItemCheckBeforeRemoveableDisabled, isRelationLocalizationFallbackEnabled, newInstance, notifyExtensionsAfterItemCreation, notifyExtensionsBeforeItemCreation, notifyItemRemoval, readResolve, refreshRemote, registerAccessFor, registerAccessFor, registerJaloInvalidationListeners, remove, removeItemCollection, removeItemCollection, removeLinkedItems, removeLinkedItems, removeLinkedItems, removeLinkedItems, removeLinks, removePartOfItems, removePartOfItems, setAllAttributes, setAllAttributes, setAllAttributesInternal, setAllLinkedItems, setAllLinkedItems, setAllLinkedItems, setAllLinkedItems, setAttribute, setAttribute, setAttributeFromString, setAttributeFromString, setCacheBound, setComposedType, setCreationTime, setImplementation, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setModificationTime, setOwner, setPermissionsByMap, setTransientObject, setUseTA, toString, useTA, writeReplacegetImplementation, setTenantpublic static boolean scheduleUpdate(Collection<Item> items, boolean remove)
IndexConfiguration instances which
contain these items and create a new IndexUpdate. Items with no matching index configuration are simply ignored.items - the items to be re-indexedremove - if true the update will remove any data associated with these itemstrue if any index covers this item and a update is scheduledprotected static Set<ComposedType> getTypeSet(Collection<Item> items)
ComposedTypes from a given collection of items.protected static Map<IndexConfiguration,Set<Item>> getIndexConfigurationsUpdateMap(Collection<Item> items)
index configurations. Since There may be multiple
configurations covering the same type one item may be mapped multiple times. On the other hand if no matching configuration
is found for a give item type these items are not included in the mapping at all.items - the items to mapprotected static Map<ComposedType,Set<IndexConfiguration>> getType2ConfigsMap(Set<ComposedType> filterTypes)
IndexConfiguration and returns all existing mappings between indexed types and their index
configuration.
filterTypes - optionally limits the amount of possible typespublic boolean isAbortable(CronJob conJob)
JobisAbortable in class JobconJob - the current execution of this job.true if the cronjob is running and the job supports aborting via
GeneratedCronJob.setRequestAbort(boolean)protected CronJob.CronJobResult performCronJob(CronJob cronJob) throws AbortCronJobException
JobJob. Here you can execute the job. You have to return a
CronJobResult that indicates whether the Job was successfully executed or not.performCronJob in class JobcronJob - the CronJob to executeCronJobResult that indicates whether the Job was successfully executed or not.
AbortCronJobExceptionCronJob.getFinishedResult(boolean),
CronJob.getAbortResult()protected Map<LuceneIndex,Map<IndexConfiguration,Collection<IndexUpdate>>> getAndMarkPendingUpdates(CronJob cronjob)
Copyright © 2017 SAP SE. All Rights Reserved.