Commit 28309bec by Johannes Edmeier

Fix the hazelcast sample

parent e66f115d
......@@ -29,7 +29,7 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
import com.hazelcast.config.Config;
import com.hazelcast.config.EvictionPolicy;
import com.hazelcast.config.ListConfig;
import com.hazelcast.config.InMemoryFormat;
import com.hazelcast.config.MapConfig;
// tag::application-hazelcast[]
......@@ -39,12 +39,10 @@ import com.hazelcast.config.MapConfig;
public class SpringBootAdminApplication {
@Bean
public Config hazelcastConfig() {
return new Config().setProperty("hazelcast.jmx", "true")
.addMapConfig(new MapConfig("spring-boot-admin-application-eventstore").setBackupCount(1)
.setEvictionPolicy(
EvictionPolicy.NONE))
.addListConfig(
new ListConfig("spring-boot-admin-event-eventstore").setBackupCount(1).setMaxSize(1000));
MapConfig mapConfig = new MapConfig("spring-boot-admin-event-store").setInMemoryFormat(InMemoryFormat.OBJECT)
.setBackupCount(1)
.setEvictionPolicy(EvictionPolicy.NONE);
return new Config().setProperty("hazelcast.jmx", "true").addMapConfig(mapConfig);
}
@Profile("insecure")
......
......@@ -19,6 +19,7 @@ package de.codecentric.boot.admin;
import de.codecentric.boot.admin.server.config.AdminServerProperties;
import de.codecentric.boot.admin.server.config.EnableAdminServer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
......@@ -76,4 +77,8 @@ public class SpringBootAdminApplication extends SpringBootServletInitializer {
}
}
public static void main(String[] args) {
SpringApplication.run(SpringBootAdminApplication.class, args);
}
}
......@@ -168,7 +168,8 @@ public class Instance implements Serializable {
private Instance apply(InstanceEvent event, boolean isNewEvent) {
Assert.notNull(event, "'event' must not be null");
Assert.isTrue(this.id.equals(event.getInstance()), "'event' must refer the same instance");
Assert.isTrue(this.nextVersion() == event.getVersion(), "expected event version doesn't match");
Assert.isTrue(this.nextVersion() == event.getVersion(),
() -> "Event " + event.getVersion() + " doesn't match exptected version " + this.nextVersion());
List<InstanceEvent> unsavedEvents = appendToEvents(event, isNewEvent);
......
......@@ -64,7 +64,11 @@ public class SnapshottingInstanceRepository extends EventsourcingInstanceReposit
}
public void start() {
this.subscription = Flux.from(getEventStore()).doOnNext(this::updateSnapshot).retryWhen(retryOnAny).subscribe();
this.subscription = getEventStore().findAll()
.concatWith(getEventStore())
.doOnNext(this::updateSnapshot)
.retryWhen(retryOnAny)
.subscribe();
}
public void stop() {
......
......@@ -102,9 +102,11 @@ public abstract class ConcurrentMapEventStore extends InstanceEventPublisher imp
}
if (eventLog.replace(id, oldEvents, newEvents)) {
log.debug("Events saved {}", events);
log.debug("Events appended to log {}", events);
return true;
}
log.debug("Unsuccessful attempot append the events {} ", events);
return false;
}
......
......@@ -50,7 +50,7 @@ import org.springframework.mail.javamail.JavaMailSenderImpl;
import static org.assertj.core.api.Assertions.assertThat;
public class AdminServerNotifierConfigurationTest {
private static final InstanceEvent APP_DOWN = new InstanceStatusChangedEvent(InstanceId.of("id-2"), 1L,
private static final InstanceEvent APP_DOWN = new InstanceStatusChangedEvent(InstanceId.of("id-2"), 0L,
StatusInfo.ofDown());
private AnnotationConfigApplicationContext context;
......
......@@ -135,7 +135,7 @@ public class InstanceTest {
IllegalArgumentException.class).hasMessage("'event' must refer the same instance");
assertThatThrownBy(() -> instance.apply(new InstanceDeregisteredEvent(InstanceId.of("id"), 1L))).isInstanceOf(
IllegalArgumentException.class).hasMessage("expected event version doesn't match");
IllegalArgumentException.class).hasMessage("Event 1 doesn't match exptected version 0");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment