@Service(value="blDatabaseSystemEventNode") @ManagedResource(objectName="org.broadleafcommerce:name=DatabaseSystemEventNode", description="Database System Event Node", currencyTimeLimit=15) public class DatabaseSystemEventNodeImpl extends Object implements DatabaseSystemEventNode, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>
Modifier and Type | Class and Description |
---|---|
static class |
DatabaseSystemEventNodeImpl.ConsumeJob |
static class |
DatabaseSystemEventNodeImpl.DurableConsumeJob |
static class |
DatabaseSystemEventNodeImpl.KeepAliveJob |
Modifier and Type | Field and Description |
---|---|
protected CacheInvalidationHelper |
cacheInvalidationHelper |
protected org.springframework.context.ApplicationContext |
context |
protected int |
durableEventsPerPoll |
protected org.quartz.Scheduler |
durableScheduler |
protected Map<String,List<SystemEventConsumer>> |
eventConsumers |
protected boolean |
eventConsumptionEnabled |
protected EventLockUtil |
eventLockUtil |
protected int |
eventsPerPoll |
protected EventWorkerType |
eventWorkerType |
protected org.broadleafcommerce.profile.core.service.IdGenerationService |
idGenerationService |
protected long |
jobThreadPoolCount |
protected org.quartz.Scheduler |
keepAliveScheduler |
protected long |
missedDurableEventsPollingThresholdSeconds
The maximum age of a durable events (in seconds) that a node will consume.
|
protected boolean |
pause |
protected long |
pollingIntervalSeconds |
protected ProcessManager |
processManager |
protected org.quartz.Scheduler |
scheduler |
protected DatabaseSystemEventDao |
systemEventDao |
protected SystemEventSender |
systemEventSender |
protected org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor |
taskExecutor |
protected List<ScheduledJobThreadInitializer> |
threadInitializers |
protected org.springframework.transaction.PlatformTransactionManager |
transactionManager |
protected org.broadleafcommerce.common.util.StreamingTransactionCapableUtil |
transUtil |
Constructor and Description |
---|
DatabaseSystemEventNodeImpl() |
Modifier and Type | Method and Description |
---|---|
protected void |
buildEventScheduler() |
void |
consumeLocalEvent(SystemEvent event)
Cause asynchronous consumption of this event to occur in the same JVM, rather than provide to event to the
cluster.
|
EventWorkerType |
determineHostWorkerType()
Determine if this is an ADMIN or SITE node
|
protected void |
executeEvent(SystemEventConsumer consumer,
SystemEvent lockedEvent) |
void |
executeEvents(List<SystemEvent> events,
boolean durable)
Iterate through a list of events and provide those events to the appropriate
SystemEventConsumer
instances. |
int |
getDurableEventsPerPoll()
The number of events of type DURABLE_GLOBAL to retrieve in each poll.
|
Map<String,List<SystemEventConsumer>> |
getEventConsumers()
All the
SystemEventConsumer instances registered in Spring. |
int |
getEventsPerPoll()
The number of events to retrieve in each poll.
|
long |
getJobThreadPoolCount()
The number of threads actively polling for available events.
|
long |
getMissedDurableEventsPollingThresholdSeconds()
The maximum amount of time into the past that durable events should be retrieved.
|
Long |
getNodeId() |
NodeRegistration |
getNodeRegistration()
Get the
NodeRegistration associated. |
long |
getPollingIntervalSeconds()
The wait time between each polling attempt for available events.
|
void |
invalidateCacheElement(String entityClass,
String id) |
void |
invalidateCacheElement(String entityClass,
String property,
String id)
Utility method for initiating a cache invalidation event.
|
void |
invalidateCacheRegion(String region) |
void |
invalidateCategory(String id) |
void |
invalidateCustomer(String id) |
void |
invalidateOffer(String id) |
void |
invalidateProduct(String id) |
boolean |
isCreated() |
boolean |
isPause()
Whether or not this node is paused.
|
void |
onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event) |
protected void |
removeUniversalDuplicates(List<SystemEvent> events) |
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
void |
setDurableEventsPerPoll(int durableEventsPerPoll) |
void |
setEventConsumers(Map<String,List<SystemEventConsumer>> eventConsumers) |
void |
setEventsPerPoll(int eventsPerPoll) |
void |
setJobThreadPoolCount(long jobThreadPoolCount) |
void |
setMissedDurableEventsPollingThresholdSeconds(long missedDurableEventsPollingThresholdSeconds) |
void |
setPause(boolean pause) |
void |
setPollingIntervalSeconds(long pollingIntervalSeconds) |
void |
stop() |
protected org.broadleafcommerce.common.util.StreamingTransactionCapableUtil transUtil
protected org.springframework.transaction.PlatformTransactionManager transactionManager
protected org.broadleafcommerce.profile.core.service.IdGenerationService idGenerationService
protected DatabaseSystemEventDao systemEventDao
protected ProcessManager processManager
@Value(value="${database.event.polling.interval.seconds}") protected long pollingIntervalSeconds
@Value(value="${database.event.quantity.per.poll:5}") protected int eventsPerPoll
@Value(value="${database.durable.event.quantity.per.poll:250}") protected int durableEventsPerPoll
@Value(value="${database.missed.durable.event.polling.threshold.seconds:604800}") protected long missedDurableEventsPollingThresholdSeconds
@Value(value="${database.event.consumption.enabled:true}") protected boolean eventConsumptionEnabled
protected SystemEventSender systemEventSender
protected CacheInvalidationHelper cacheInvalidationHelper
protected org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor taskExecutor
protected EventLockUtil eventLockUtil
protected List<ScheduledJobThreadInitializer> threadInitializers
protected Map<String,List<SystemEventConsumer>> eventConsumers
protected org.quartz.Scheduler scheduler
protected org.quartz.Scheduler durableScheduler
protected org.quartz.Scheduler keepAliveScheduler
protected boolean pause
protected long jobThreadPoolCount
protected EventWorkerType eventWorkerType
protected org.springframework.context.ApplicationContext context
public void onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event)
onApplicationEvent
in interface org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>
protected void buildEventScheduler() throws IOException, org.quartz.SchedulerException
IOException
org.quartz.SchedulerException
public void consumeLocalEvent(SystemEvent event)
DatabaseSystemEventNode
consumeLocalEvent
in interface DatabaseSystemEventNode
@PreDestroy public void stop()
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
org.springframework.beans.BeansException
public EventWorkerType determineHostWorkerType()
DatabaseSystemEventNode
determineHostWorkerType
in interface DatabaseSystemEventNode
public void executeEvents(List<SystemEvent> events, boolean durable)
DatabaseSystemEventNode
SystemEventConsumer
instances.executeEvents
in interface DatabaseSystemEventNode
durable
- Whether or not these events are durable (i.e. GLOBAL_DURABLE)public NodeRegistration getNodeRegistration()
DatabaseSystemEventNode
NodeRegistration
associated. Every instance of DatabaseSystemEventNode
creates a registration in the database.getNodeRegistration
in interface DatabaseSystemEventNode
@ManagedAttribute(description="Whether or not event processing is currently paused.", currencyTimeLimit=15) public boolean isPause()
DatabaseSystemEventNode
isPause
in interface DatabaseSystemEventNode
@ManagedAttribute(description="Whether or not event processing is currently paused.", currencyTimeLimit=15) public void setPause(boolean pause)
setPause
in interface DatabaseSystemEventNode
@ManagedOperation(description="Invalidate the cache for an entity collection property", currencyTimeLimit=15) public void invalidateCacheElement(String entityClass, String property, String id)
DatabaseSystemEventNode
invalidateCacheElement
in interface DatabaseSystemEventNode
@ManagedOperation(description="Invalidate the cache for an entity", currencyTimeLimit=15) public void invalidateCacheElement(String entityClass, String id)
invalidateCacheElement
in interface DatabaseSystemEventNode
@ManagedOperation(description="Invalidate an entire cache region", currencyTimeLimit=15) public void invalidateCacheRegion(String region)
invalidateCacheRegion
in interface DatabaseSystemEventNode
@ManagedOperation(description="Convenience method for invalidating a Product", currencyTimeLimit=15) public void invalidateProduct(String id)
invalidateProduct
in interface DatabaseSystemEventNode
@ManagedOperation(description="Convenience method for invalidating a Category", currencyTimeLimit=15) public void invalidateCategory(String id)
invalidateCategory
in interface DatabaseSystemEventNode
@ManagedOperation(description="Convenience method for invalidating a Offer", currencyTimeLimit=15) public void invalidateOffer(String id)
invalidateOffer
in interface DatabaseSystemEventNode
@ManagedOperation(description="Convenience method for invalidating a Customer", currencyTimeLimit=15) public void invalidateCustomer(String id)
invalidateCustomer
in interface DatabaseSystemEventNode
public long getPollingIntervalSeconds()
DatabaseSystemEventNode
getPollingIntervalSeconds
in interface DatabaseSystemEventNode
public void setPollingIntervalSeconds(long pollingIntervalSeconds)
setPollingIntervalSeconds
in interface DatabaseSystemEventNode
public int getEventsPerPoll()
DatabaseSystemEventNode
SystemEvent.getPriority()
.
The default value is 5. This does not include events of type GLOBAL_DURABLE.getEventsPerPoll
in interface DatabaseSystemEventNode
public void setEventsPerPoll(int eventsPerPoll)
setEventsPerPoll
in interface DatabaseSystemEventNode
public long getJobThreadPoolCount()
DatabaseSystemEventNode
getJobThreadPoolCount
in interface DatabaseSystemEventNode
public void setJobThreadPoolCount(long jobThreadPoolCount)
setJobThreadPoolCount
in interface DatabaseSystemEventNode
public Map<String,List<SystemEventConsumer>> getEventConsumers()
DatabaseSystemEventNode
SystemEventConsumer
instances registered in Spring.getEventConsumers
in interface DatabaseSystemEventNode
public void setEventConsumers(Map<String,List<SystemEventConsumer>> eventConsumers)
setEventConsumers
in interface DatabaseSystemEventNode
public long getMissedDurableEventsPollingThresholdSeconds()
DatabaseSystemEventNode
getMissedDurableEventsPollingThresholdSeconds
in interface DatabaseSystemEventNode
public int getDurableEventsPerPoll()
DatabaseSystemEventNode
SystemEvent.getPriority()
.getDurableEventsPerPoll
in interface DatabaseSystemEventNode
public void setDurableEventsPerPoll(int durableEventsPerPoll)
setDurableEventsPerPoll
in interface DatabaseSystemEventNode
public void setMissedDurableEventsPollingThresholdSeconds(long missedDurableEventsPollingThresholdSeconds)
setMissedDurableEventsPollingThresholdSeconds
in interface DatabaseSystemEventNode
public boolean isCreated()
isCreated
in interface DatabaseSystemEventNode
public Long getNodeId()
getNodeId
in interface DatabaseSystemEventNode
protected void executeEvent(SystemEventConsumer consumer, SystemEvent lockedEvent)
protected void removeUniversalDuplicates(List<SystemEvent> events)
Copyright © 2019. All rights reserved.