Skip to content

Commit

Permalink
Merge fa855d3 into 79459fd
Browse files Browse the repository at this point in the history
  • Loading branch information
asgeirn authored Jan 17, 2019
2 parents 79459fd + fa855d3 commit 41f1e5e
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 10 deletions.
7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ USER root
COPY . .
RUN gradle --no-daemon build

FROM openjdk:8-jre-alpine
RUN apk add --no-cache tini
ENTRYPOINT ["/sbin/tini", "--"]
FROM gcr.io/distroless/java
ENV JAVA_TOOL_OPTIONS -XX:+ExitOnOutOfMemoryError
COPY --from=builder /home/gradle/build/deps/external/*.jar /data/
COPY --from=builder /home/gradle/build/deps/fint/*.jar /data/
COPY --from=builder /home/gradle/build/libs/fint-provider-*.jar /data/fint-provider.jar
CMD java $JAVA_OPTS -XX:+ExitOnOutOfMemoryError -jar /data/fint-provider.jar
CMD ["/data/fint-provider.jar"]
4 changes: 4 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ pipeline {
withDockerRegistry([credentialsId: 'dtr-fintlabs-no', url: 'https://dtr.fintlabs.no']) {
sh "docker push dtr.fintlabs.no/beta/provider:${BRANCH_NAME}.${BUILD_NUMBER}"
}
sh "docker tag ${GIT_COMMIT} fintlabs.azurecr.io/provider:${BRANCH_NAME}.${BUILD_NUMBER}"
withDockerRegistry([credentialsId: 'fintlabs.azurecr.io', url: 'https://fintlabs.azurecr.io']) {
sh "docker push fintlabs.azurecr.io/provider:${BRANCH_NAME}.${BUILD_NUMBER}"
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
| fint.provider.ttl-status | How long (in minutes) the provider will wait for an initial status from the adapter (that the event was received and understood) | 2 |
| fint.provider.ttl-response | How long (in minutes) the provider will wait for a response with the data from the adapter | 15 |
| fint.provider.max-number-of-emitters | The max number of emitters one orgId can have | 50 |
| fint.provider.event-state.hazelcast | Use Hazelcast Map for EventState | true |
| fint.provider.event-state.list-name | The name of the list used to store event states stored in redisson | current-corrids |
| fint.provider.swagger-https | Force https in the swagger api-docs request | true (disabled in the test profile) |
| fint.provider.test-mode | Runs the provider in test-mode, enabling a test consumer and adapter. | false |
Expand Down
5 changes: 4 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ dependencies {
compile('no.fint:fint-event-model:3.0.0')
compile('no.fint:fint-springfox-extension:0.0.1')
compile('no.fint:fint-spring-secrets:0.1.0')
compile('no.fint:fint-hazelcast:1.2.0-alpha-2')
compile('com.hazelcast:hazelcast:3.11')
compile('com.hazelcast:hazelcast-kubernetes:1.3.1')

compile('org.projectlombok:lombok:1.18.2')
compile("com.github.springfox.loader:springfox-loader:${springfoxLoaderVersion}")
Expand Down Expand Up @@ -119,4 +122,4 @@ jacocoTestReport {
}
}

apply from: 'https://raw.githubusercontent.com/FINTlibs/fint-buildscripts/v1.5.0/dependencyReport.gradle'
apply from: 'https://raw.githubusercontent.com/FINTlibs/fint-buildscripts/v1.5.0/dependencyReport.gradle'
3 changes: 3 additions & 0 deletions src/main/java/no/fint/provider/events/ProviderProps.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public class ProviderProps {
@Value("${fint.provider.event-state.list-name:current-corrids}")
private String key;

@Value("${fint.provider.event-state.hazelcast:true}")
private boolean useHazelcastForEventState;

@Value("${fint.provider.sse-timeout-minutes:17}")
private int sseTimeoutMinutes;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.stream.Collectors;

@Slf4j
Expand All @@ -28,11 +29,15 @@ public class EventStateService {

@PostConstruct
public void init() {
eventStates = hazelcastInstance.getMap(providerProps.getKey());
if (providerProps.isUseHazelcastForEventState()) {
eventStates = hazelcastInstance.getMap(providerProps.getKey());
} else {
eventStates = new ConcurrentSkipListMap<>();
}
log.info("Event States: {}", eventStates.getClass());
}

public void add(Event event, int timeToLiveInMinutes) {
log.trace("Add {}, ttl={}", event, timeToLiveInMinutes);
eventStates.put(event.getCorrId(), new EventState(event, timeToLiveInMinutes));
}

Expand All @@ -42,7 +47,8 @@ public Optional<EventState> remove(Event event) {

public List<Event> getExpiredEvents() {
List<EventState> expired = eventStates.values().stream().filter(EventState::expired).collect(Collectors.toList());
expired.stream().map(EventState::getCorrId).forEach(eventStates::remove);
long count = expired.stream().map(EventState::getCorrId).peek(eventStates::remove).count();
log.info("Removed {} expired events", count);
return expired.stream().map(EventState::getEvent).collect(Collectors.toList());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class JanitorService {
public void cleanUpEventStates() {
log.debug("Running janitor service");
eventStateService.getExpiredEvents().forEach(event -> {
log.info("Event expired: {}", event);
log.debug("Event expired: {}", event);
event.setResponseStatus(ResponseStatus.ERROR);
event.setStatus(Status.ADAPTER_NOT_CONFIRMED);
event.setMessage("Event expired");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class EventStateServiceSpec extends Specification {
eventStateService.init()

then:
1 * hazelcastInstance.getMap('current-corrids') >> Mock(IMap)
eventStateService.eventStates != null
}

def "Add and get new EventState"() {
Expand Down

0 comments on commit 41f1e5e

Please sign in to comment.