Class MultiNodesEventsDbImpl
- java.lang.Object
-
- jetbrains.buildServer.serverSide.impl.MultiNodesEventsDbImpl
-
- All Implemented Interfaces:
MultiNodesEvents
public class MultiNodesEventsDbImpl extends Object implements MultiNodesEvents
Very simple implementation ofMultiNodesEvents
working 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 String
CLEANUP_PERIOD
static Logger
LOGGER
static Logger
LOGGER_DIAG
static int
MAX_STRING_ARG_LENGTH
static String
PENDING_COUNT_UPDATE_PERIOD
static String
POLL_PERIOD
static String
TEAMCITY_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 void
cleanupOldEvents()
void
ensureEventsProcessed()
Loads and processes all fresh eventsvoid
ensureEventsProcessed(Filter<MultiNodesEvents.EventData> eventsFilter)
Ensure that all events which have been published by other nodes and match the filter are processed.boolean
eventsPublishingEnabled()
Date
getStoppedDueToDataUpgradeTime()
The time when the current node stopped processing new events because the data upgrade was detected.int
getUnprocessedEventsEstimate()
boolean
hasUnpublishedEvent(MultiNodesEvents.EventData event)
boolean
hasUnpublishedEvents()
boolean
hasUnpublishedEvents(Filter<MultiNodesEvents.EventData> eventsFilter)
void
publish(String eventName)
void
publish(String eventName, Long longArg)
void
publish(String eventName, String strArg)
void
publish(MultiNodesEvents.EventData eventData)
void
setPublishingEnabled(boolean enabled)
void
start()
void
stop()
void
subscribe(String eventName, Consumer<MultiNodesEvents.Event> eventConsumer)
Adds an "events consumer" which will process events with the given name.void
subscribeOnEvents(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.void
unsubscribe(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:
publish
in interfaceMultiNodesEvents
-
publish
public void publish(@NotNull String eventName, @NotNull Long longArg)
- Specified by:
publish
in interfaceMultiNodesEvents
-
publish
public void publish(@NotNull String eventName, @NotNull String strArg)
- Specified by:
publish
in interfaceMultiNodesEvents
-
publish
public void publish(@NotNull MultiNodesEvents.EventData eventData)
- Specified by:
publish
in 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:
eventsPublishingEnabled
in interfaceMultiNodesEvents
-
setPublishingEnabled
public void setPublishingEnabled(boolean enabled)
-
subscribe
public void subscribe(@NotNull String eventName, @NotNull Consumer<MultiNodesEvents.Event> eventConsumer)
Description copied from interface:MultiNodesEvents
Adds an "events consumer" which will process events with the given name. There can be only one consumer per each event name.- Specified by:
subscribe
in interfaceMultiNodesEvents
-
subscribeOnEvents
public void subscribeOnEvents(@NotNull String eventName, @NotNull Consumer<List<MultiNodesEvents.Event>> eventConsumer)
Description copied from interface:MultiNodesEvents
Adds 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:
subscribeOnEvents
in interfaceMultiNodesEvents
-
unsubscribe
public void unsubscribe(@NotNull String eventName)
Description copied from interface:MultiNodesEvents
unregister consumer for specified event name- Specified by:
unsubscribe
in interfaceMultiNodesEvents
-
getUnprocessedEventsEstimate
public int getUnprocessedEventsEstimate()
-
ensureEventsProcessed
public void ensureEventsProcessed()
Description copied from interface:MultiNodesEvents
Loads and processes all fresh events- Specified by:
ensureEventsProcessed
in interfaceMultiNodesEvents
-
cleanupOldEvents
protected void cleanupOldEvents()
-
hasUnpublishedEvents
@TestOnly public boolean hasUnpublishedEvents()
-
hasUnpublishedEvent
public boolean hasUnpublishedEvent(@NotNull MultiNodesEvents.EventData event)
- Specified by:
hasUnpublishedEvent
in 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:
hasUnpublishedEvents
in 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:MultiNodesEvents
Ensure that all events which have been published by other nodes and match the filter are processed.- Specified by:
ensureEventsProcessed
in interfaceMultiNodesEvents
-
-