Class MultiNodesEventsDbImpl
- java.lang.Object
-
- jetbrains.buildServer.serverSide.impl.MultiNodesEventsDbImpl
-
- All Implemented Interfaces:
MultiNodesEvents
public class MultiNodesEventsDbImpl extends Object implements MultiNodesEvents
Very simple implementation ofMultiNodesEventsworking using TeamCity database.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jetbrains.buildServer.serverSide.MultiNodesEvents
MultiNodesEvents.Event, MultiNodesEvents.EventData
-
-
Field Summary
Fields Modifier and Type Field Description static StringCLEANUP_PERIODstatic LoggerLOGGERstatic LoggerLOGGER_DIAGstatic intMAX_STRING_ARG_LENGTHstatic StringPENDING_COUNT_UPDATE_PERIODstatic StringPOLL_PERIODstatic StringTEAMCITY_GROUP_EVENTS_FEATURE_TOGGLE
-
Constructor Summary
Constructors Constructor Description MultiNodesEventsDbImpl(SQLRunnerEx sqlRunner, Supplier<Boolean> secondaryNodesPresenceSupplier, String nodeId, boolean secondaryNode, ServerMetrics serverMetrics)MultiNodesEventsDbImpl(SQLRunnerEx sqlRunner, Supplier<Boolean> secondaryNodesPresenceSupplier, String nodeId, boolean secondaryNode, ServerMetrics serverMetrics, TimeService timeService)MultiNodesEventsDbImpl(SQLRunnerEx sqlRunner, EventDispatcher<BuildServerListener> serverEventDispatcher, Heartbeat heartbeat, ServerMetrics serverMetrics)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcleanupOldEvents()voidensureEventsProcessed()Loads and processes all fresh eventsvoidensureEventsProcessed(Filter<MultiNodesEvents.EventData> eventsFilter)Ensure that all events which have been published by other nodes and match the filter are processed.booleaneventsPublishingEnabled()DategetStoppedDueToDataUpgradeTime()The time when the current node stopped processing new events because the data upgrade was detected.intgetUnprocessedEventsEstimate()booleanhasUnpublishedEvent(MultiNodesEvents.EventData event)booleanhasUnpublishedEvents()booleanhasUnpublishedEvents(Filter<MultiNodesEvents.EventData> eventsFilter)voidpublish(String eventName)voidpublish(String eventName, Long longArg)voidpublish(String eventName, String strArg)voidpublish(MultiNodesEvents.EventData eventData)voidsetPublishingEnabled(boolean enabled)voidstart()voidstop()voidsubscribe(String eventName, Consumer<MultiNodesEvents.Event> eventConsumer)Adds an "events consumer" which will process events with the given name.voidsubscribeOnEvents(String eventName, Consumer<List<MultiNodesEvents.Event>> eventConsumer)Adds an "events consumer" which will process a pack of consequitive events with the same name at once.voidunsubscribe(String eventName)unregister consumer for specified event name
-
-
-
Field Detail
-
MAX_STRING_ARG_LENGTH
public static final int MAX_STRING_ARG_LENGTH
- See Also:
- Constant Field Values
-
LOGGER
public static final Logger LOGGER
-
LOGGER_DIAG
public static final Logger LOGGER_DIAG
-
POLL_PERIOD
public static final String POLL_PERIOD
- See Also:
- Constant Field Values
-
PENDING_COUNT_UPDATE_PERIOD
public static final String PENDING_COUNT_UPDATE_PERIOD
- See Also:
- Constant Field Values
-
TEAMCITY_GROUP_EVENTS_FEATURE_TOGGLE
public static final String TEAMCITY_GROUP_EVENTS_FEATURE_TOGGLE
- See Also:
- Constant Field Values
-
CLEANUP_PERIOD
public static final String CLEANUP_PERIOD
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MultiNodesEventsDbImpl
@Autowired public MultiNodesEventsDbImpl(@NotNull SQLRunnerEx sqlRunner, @NotNull EventDispatcher<BuildServerListener> serverEventDispatcher, @NotNull Heartbeat heartbeat, @NotNull ServerMetrics serverMetrics)
-
MultiNodesEventsDbImpl
@TestOnly public MultiNodesEventsDbImpl(@NotNull SQLRunnerEx sqlRunner, @NotNull Supplier<Boolean> secondaryNodesPresenceSupplier, @NotNull String nodeId, boolean secondaryNode, @NotNull ServerMetrics serverMetrics)
-
MultiNodesEventsDbImpl
@TestOnly public MultiNodesEventsDbImpl(@NotNull SQLRunnerEx sqlRunner, @NotNull Supplier<Boolean> secondaryNodesPresenceSupplier, @NotNull String nodeId, boolean secondaryNode, @NotNull ServerMetrics serverMetrics, @NotNull TimeService timeService)
-
-
Method Detail
-
start
public void start()
-
stop
public void stop()
-
publish
public void publish(@NotNull String eventName)- Specified by:
publishin interfaceMultiNodesEvents
-
publish
public void publish(@NotNull String eventName, @NotNull Long longArg)- Specified by:
publishin interfaceMultiNodesEvents
-
publish
public void publish(@NotNull String eventName, @NotNull String strArg)- Specified by:
publishin interfaceMultiNodesEvents
-
publish
public void publish(@NotNull MultiNodesEvents.EventData eventData)- Specified by:
publishin interfaceMultiNodesEvents
-
getStoppedDueToDataUpgradeTime
@Nullable public Date getStoppedDueToDataUpgradeTime()
The time when the current node stopped processing new events because the data upgrade was detected.
-
eventsPublishingEnabled
public boolean eventsPublishingEnabled()
- Specified by:
eventsPublishingEnabledin interfaceMultiNodesEvents
-
setPublishingEnabled
public void setPublishingEnabled(boolean enabled)
-
subscribe
public void subscribe(@NotNull String eventName, @NotNull Consumer<MultiNodesEvents.Event> eventConsumer)Description copied from interface:MultiNodesEventsAdds an "events consumer" which will process events with the given name. There can be only one consumer per each event name.- Specified by:
subscribein interfaceMultiNodesEvents
-
subscribeOnEvents
public void subscribeOnEvents(@NotNull String eventName, @NotNull Consumer<List<MultiNodesEvents.Event>> eventConsumer)Description copied from interface:MultiNodesEventsAdds an "events consumer" which will process a pack of consequitive events with the same name at once. There can be only one consumer per each event name.- Specified by:
subscribeOnEventsin interfaceMultiNodesEvents
-
unsubscribe
public void unsubscribe(@NotNull String eventName)Description copied from interface:MultiNodesEventsunregister consumer for specified event name- Specified by:
unsubscribein interfaceMultiNodesEvents
-
getUnprocessedEventsEstimate
public int getUnprocessedEventsEstimate()
-
ensureEventsProcessed
public void ensureEventsProcessed()
Description copied from interface:MultiNodesEventsLoads and processes all fresh events- Specified by:
ensureEventsProcessedin interfaceMultiNodesEvents
-
cleanupOldEvents
protected void cleanupOldEvents()
-
hasUnpublishedEvents
@TestOnly public boolean hasUnpublishedEvents()
-
hasUnpublishedEvent
public boolean hasUnpublishedEvent(@NotNull MultiNodesEvents.EventData event)- Specified by:
hasUnpublishedEventin interfaceMultiNodesEvents- Returns:
- true if event is still not published and other nodes can't see it
-
hasUnpublishedEvents
public boolean hasUnpublishedEvents(@NotNull Filter<MultiNodesEvents.EventData> eventsFilter)- Specified by:
hasUnpublishedEventsin interfaceMultiNodesEvents- Returns:
- true if at least one event that match specified filter is still not published and other nodes can't see it
-
ensureEventsProcessed
public void ensureEventsProcessed(@NotNull Filter<MultiNodesEvents.EventData> eventsFilter)Description copied from interface:MultiNodesEventsEnsure that all events which have been published by other nodes and match the filter are processed.- Specified by:
ensureEventsProcessedin interfaceMultiNodesEvents
-
-