Skip to content

Commit

Permalink
Merge f8eed38 into c557640
Browse files Browse the repository at this point in the history
  • Loading branch information
asgeirn committed Jan 25, 2019
2 parents c557640 + f8eed38 commit cc6753f
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 18 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
19 changes: 11 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
apply from: 'https://raw.githubusercontent.com/FINTprosjektet/fint-buildscripts/v1.5.0/dependencies.gradle'
apply from: 'https://raw.githubusercontent.com/FINTprosjektet/fint-buildscripts/v1.6.0/dependencies.gradle'
ext {
springBootVersion = springBootVersion
}
Expand Down Expand Up @@ -47,21 +47,24 @@ dependencies {
compile('no.fint:fint-sse:1.2.0') {
exclude group: 'org.springframework.security.oauth', module: 'spring-security-oauth2'
}
compile('org.glassfish.jersey.core:jersey-client:2.26')
compile('org.glassfish.jersey.core:jersey-common:2.26')
compile('org.glassfish.jersey.core:jersey-client:2.27')
compile('org.glassfish.jersey.core:jersey-common:2.27')

compile('no.fint:fint-audit-mongo-plugin:1.4.1')
compile('no.fint:fint-events:2.2.0-rc-1')
compile('no.fint:fint-events:2.2.0')
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.1')
compile('com.hazelcast:hazelcast-kubernetes:1.3.1')

compile('org.projectlombok:lombok:1.18.2')
compile("org.projectlombok:lombok:${lombokVersion}")
compile("com.github.springfox.loader:springfox-loader:${springfoxLoaderVersion}")
compile('com.github.fakemongo:fongo:2.1.0')
compile('com.github.fakemongo:fongo:2.1.1')
compile('com.jayway.jsonpath:json-path:2.4.0')
compile('org.reflections:reflections:0.9.11')
compile('org.apache.commons:commons-lang3:3.8')
compile('org.apache.commons:commons-lang3:3.8.1')
compile('org.jooq:jool-java-8:0.9.14')

compile('org.springframework.boot:spring-boot-starter-web')
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.6.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 @@ -24,15 +25,19 @@ public class EventStateService {
@Autowired
private ProviderProps providerProps;

private Map<String,EventState> eventStates;
private Map<String, EventState> eventStates;

@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,10 @@ 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();
if (count > 0) {
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 cc6753f

Please sign in to comment.