Skip to content

Commit

Permalink
Merge 4ae6f17 into ec8ae7d
Browse files Browse the repository at this point in the history
  • Loading branch information
allanmckenzie committed Jun 5, 2019
2 parents ec8ae7d + 4ae6f17 commit 52bcf09
Show file tree
Hide file tree
Showing 48 changed files with 810 additions and 75 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ on [Keep a CHANGELOG](http://keepachangelog.com/). This project adheres to
[Semantic Versioning](http://semver.org/).

## [Unreleased]
## [2.0.0-M33] - 2019-06-05
### Changed
- Catchup and rebuild now use the new System Command jmx architecture
- Events for catchup and rebuild moved in from framework-api
- Catchup and rebuild moved to a new 'event-store-management' module

## [2.0.0-M32] - 2019-05-30
### Fixed
- Added component column to processed_event table to allow Event Listener and Indexer to create
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import uk.gov.justice.services.jdbc.persistence.JdbcResultSetStreamer;
import uk.gov.justice.services.jdbc.persistence.PreparedStatementWrapper;
import uk.gov.justice.services.jdbc.persistence.PreparedStatementWrapperFactory;
import uk.gov.justice.services.jmx.command.SystemCommandStore;
import uk.gov.justice.services.messaging.DefaultJsonObjectEnvelopeConverter;
import uk.gov.justice.services.messaging.JsonEnvelope;
import uk.gov.justice.services.messaging.JsonObjectEnvelopeConverter;
Expand Down Expand Up @@ -163,7 +164,8 @@ public void initializeDatabase() throws Exception {
PublishedEventRepository.class,
PrePublishRepository.class,
PublishedEventQueries.class,
StopWatchFactory.class
StopWatchFactory.class,
SystemCommandStore.class
})
public WebApp war() {
return new WebApp()
Expand Down
4 changes: 4 additions & 0 deletions event-sourcing/subscription-manager/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
<artifactId>subscription-event-tracking</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>uk.gov.justice.services</groupId>
<artifactId>jmx</artifactId>
</dependency>

<!--Test Dependencies-->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import uk.gov.justice.services.event.sourcing.subscription.catchup.consumer.task.ConsumeEventQueueBean;
import uk.gov.justice.services.event.sourcing.subscription.catchup.consumer.util.DummyTransactionalEventProcessor;
import uk.gov.justice.services.event.sourcing.subscription.catchup.consumer.util.TestCatchupBean;
import uk.gov.justice.services.jmx.command.SystemCommandStore;
import uk.gov.justice.services.messaging.JsonEnvelope;
import uk.gov.justice.services.test.utils.core.messaging.Poller;

Expand Down Expand Up @@ -48,7 +49,8 @@ public class EventStreamCatchupIT {
EventStreamsInProgressList.class,
ConsumeEventQueueBean.class,
EventQueueConsumerFactory.class,
LoggerProducer.class
LoggerProducer.class,
SystemCommandStore.class
})
public WebApp war() {
return new WebApp()
Expand Down
58 changes: 58 additions & 0 deletions event-store-management/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>event-store</artifactId>
<groupId>uk.gov.justice.event-store</groupId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>event-store-management</artifactId>

<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>uk.gov.justice.utils</groupId>
<artifactId>utilities-core</artifactId>
</dependency>
<dependency>
<groupId>uk.gov.justice.event-store</groupId>
<artifactId>published-event-processor</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>uk.gov.justice.services</groupId>
<artifactId>jmx</artifactId>
<version>${framework.version}</version>
</dependency>
<dependency>
<groupId>uk.gov.justice.event-store</groupId>
<artifactId>subscription-manager</artifactId>
<version>${project.version}</version>
</dependency>

<!--Test Dependencies-->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>uk.gov.justice.services</groupId>
<artifactId>test-utils-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package uk.gov.justice.services.eventstore.management.catchup.commands;

import uk.gov.justice.services.jmx.command.BaseSystemCommand;

public class CatchupCommand extends BaseSystemCommand {

public static final String CATCHUP = "CATCHUP";

public CatchupCommand() {
super(CATCHUP);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package uk.gov.justice.services.eventstore.management.catchup.commands;

import static uk.gov.justice.services.eventstore.management.catchup.commands.CatchupCommand.CATCHUP;

import uk.gov.justice.services.common.util.UtcClock;
import uk.gov.justice.services.eventstore.management.catchup.events.CatchupRequestedEvent;
import uk.gov.justice.services.jmx.command.HandlesSystemCommand;

import javax.enterprise.event.Event;
import javax.inject.Inject;

public class CatchupCommandHandler {

@Inject
private UtcClock utcClock;

@Inject
private Event<CatchupRequestedEvent> catchupRequestedEventFirer;

@HandlesSystemCommand(CATCHUP)
public void doCatchup() {
catchupRequestedEventFirer.fire(new CatchupRequestedEvent(new CatchupCommand(), utcClock.now()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package uk.gov.justice.services.eventstore.management.catchup.commands;

import uk.gov.justice.services.jmx.command.BaseSystemCommand;

public class CatchupWithRebuildCommand extends BaseSystemCommand {

public static final String CATCHUP_WITH_REBUILD = "CATCHUP_WITH_REBUILD";

public CatchupWithRebuildCommand() {
super(CATCHUP_WITH_REBUILD);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package uk.gov.justice.services.eventstore.management.catchup.commands;


import static uk.gov.justice.services.eventstore.management.catchup.commands.CatchupWithRebuildCommand.CATCHUP_WITH_REBUILD;

import uk.gov.justice.services.common.util.UtcClock;
import uk.gov.justice.services.jmx.command.HandlesSystemCommand;

import javax.enterprise.event.Event;
import javax.inject.Inject;

public class CatchupWithRebuildHandler {

@Inject
private UtcClock clock;

@Inject
private Event<CatchupWithRebuildRequestedEvent> catchupWithRebuildRequestedEventFirer;


@HandlesSystemCommand(CATCHUP_WITH_REBUILD)
public void doCatchupWithRebuild() {

final CatchupWithRebuildRequestedEvent catchupWithRebuildRequestedEvent = new CatchupWithRebuildRequestedEvent(
new CatchupWithRebuildCommand(),
clock.now()
);

catchupWithRebuildRequestedEventFirer.fire(catchupWithRebuildRequestedEvent);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package uk.gov.justice.services.eventstore.management.catchup.commands;

import static java.lang.String.format;

import javax.enterprise.event.Observes;
import javax.inject.Inject;

import org.slf4j.Logger;

public class CatchupWithRebuildObserver {

@Inject
private Logger logger;

public void onCatchupWithRebuildRequested(@Observes final CatchupWithRebuildRequestedEvent event) {

logger.info(format("%s requested at %tc", event.getSystemCommand(), event.getRequestedAt()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package uk.gov.justice.services.eventstore.management.catchup.commands;

import uk.gov.justice.services.jmx.command.SystemCommand;

import java.time.ZonedDateTime;
import java.util.Objects;

public class CatchupWithRebuildRequestedEvent {

private final SystemCommand systemCommand;
private final ZonedDateTime requestedAt;

public CatchupWithRebuildRequestedEvent(final SystemCommand systemCommand, final ZonedDateTime requestedAt) {
this.systemCommand = systemCommand;
this.requestedAt = requestedAt;
}

public SystemCommand getSystemCommand() {
return systemCommand;
}

public ZonedDateTime getRequestedAt() {
return requestedAt;
}

@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (!(o instanceof CatchupWithRebuildRequestedEvent)) return false;
final CatchupWithRebuildRequestedEvent that = (CatchupWithRebuildRequestedEvent) o;
return Objects.equals(systemCommand, that.systemCommand) &&
Objects.equals(requestedAt, that.requestedAt);
}

@Override
public int hashCode() {
return Objects.hash(systemCommand, requestedAt);
}

@Override
public String toString() {
return "CatchupWithRebuildRequestedEvent{" +
"commandName=" + systemCommand +
", requestedAt=" + requestedAt +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package uk.gov.justice.services.eventstore.management.catchup.events;

import java.time.ZonedDateTime;
import java.util.Objects;

public class CatchupCompletedEvent {

private final ZonedDateTime completedAt;

public CatchupCompletedEvent(final ZonedDateTime completedAt) {
this.completedAt = completedAt;
}

public ZonedDateTime getCompletedAt() {
return completedAt;
}

@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (!(o instanceof CatchupCompletedEvent)) return false;
final CatchupCompletedEvent that = (CatchupCompletedEvent) o;
return Objects.equals(completedAt, that.completedAt);
}

@Override
public int hashCode() {
return Objects.hash(completedAt);
}

@Override
public String toString() {
return "CatchupCompletedEvent{" +
"completedAt=" + completedAt +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package uk.gov.justice.services.eventstore.management.catchup.events;

import java.time.ZonedDateTime;
import java.util.Objects;

public class CatchupCompletedForSubscriptionEvent {

private final String eventSourceName;
private final ZonedDateTime catchupCompletedAt;
private final int totalNumberOfEvents;

public CatchupCompletedForSubscriptionEvent(
final String eventSourceName,
final int totalNumberOfEvents,
final ZonedDateTime catchupCompletedAt) {

this.eventSourceName = eventSourceName;
this.catchupCompletedAt = catchupCompletedAt;
this.totalNumberOfEvents = totalNumberOfEvents;
}

public String getEventSourceName() {
return eventSourceName;
}

public ZonedDateTime getCatchupCompletedAt() {
return catchupCompletedAt;
}

public int getTotalNumberOfEvents() {
return totalNumberOfEvents;
}

@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (!(o instanceof CatchupCompletedForSubscriptionEvent)) return false;
final CatchupCompletedForSubscriptionEvent that = (CatchupCompletedForSubscriptionEvent) o;
return totalNumberOfEvents == that.totalNumberOfEvents &&
Objects.equals(eventSourceName, that.eventSourceName) &&
Objects.equals(catchupCompletedAt, that.catchupCompletedAt);
}

@Override
public int hashCode() {
return Objects.hash(eventSourceName, catchupCompletedAt, totalNumberOfEvents);
}

@Override
public String toString() {
return "CatchupCompletedForSubscriptionEvent{" +
"eventSourceName='" + eventSourceName + '\'' +
", catchupCompletedAt=" + catchupCompletedAt +
", totalNumberOfEvents=" + totalNumberOfEvents +
'}';
}
}
Loading

0 comments on commit 52bcf09

Please sign in to comment.