@Test public void wrapsOverSectorBoundaries() { final int requiredNumberOfWritesToSpanSector = 45; final List<CompositeKey> keys = IntStream .range(0, requiredNumberOfWritesToSpanSector) .mapToObj((i) -> idStrategy.onInitiateLogon("b" + i, null, null, "a" + i, null, null)) .collect(toList()); final List<SessionContext> contexts = keys .stream() .map(compositeKey -> sessionContexts.onLogon(compositeKey, fixDictionary)) .peek(sessionContext -> sessionContext.onSequenceReset(time)) .collect(toList()); final SessionContext firstContext = contexts.get(0); firstContext.onSequenceReset(time); final SessionContexts contextsAfterRestart = newSessionContexts(buffer); IntStream .range(0, requiredNumberOfWritesToSpanSector) .forEach((i) -> assertValuesEqual(contexts.get(i), contextsAfterRestart.onLogon(keys.get(i), fixDictionary))); }
public SessionContext onLogon(final CompositeKey compositeKey, final FixDictionary fixDictionary) { final SessionContext sessionContext = newSessionContext(compositeKey, fixDictionary); if (!currentlyAuthenticatedSessionIds.add(sessionContext.sessionId())) { return DUPLICATE_SESSION; } return sessionContext; }
SessionContexts { public SessionContext onLogon(final CompositeKey compositeKey, final FixDictionary fixDictionary) { final SessionContext sessionContext = newSessionContext(compositeKey, fixDictionary); if (!currentlyAuthenticatedSessionIds.add(sessionContext.sessionId())) { return DUPLICATE_SESSION; } return sessionContext; } }
SessionContexts { public SessionContext onLogon(final CompositeKey compositeKey, final FixDictionary fixDictionary) { final SessionContext sessionContext = newSessionContext(compositeKey, fixDictionary); if (!currentlyAuthenticatedSessionIds.add(sessionContext.sessionId())) { return DUPLICATE_SESSION; } return sessionContext; } SessionContexts(
        final MappedFile mappedFile,
        final SessionIdStrategy idStrategy,
        final int initialSequenceIndex,
        final ErrorHandler errorHandler); }
SessionContexts { public SessionContext onLogon(final CompositeKey compositeKey, final FixDictionary fixDictionary) { final SessionContext sessionContext = newSessionContext(compositeKey, fixDictionary); if (!currentlyAuthenticatedSessionIds.add(sessionContext.sessionId())) { return DUPLICATE_SESSION; } return sessionContext; } SessionContexts(
        final MappedFile mappedFile,
        final SessionIdStrategy idStrategy,
        final int initialSequenceIndex,
        final ErrorHandler errorHandler); SessionContext onLogon(final CompositeKey compositeKey, final FixDictionary fixDictionary); void onDisconnect(final long sessionId); void reset(final File backupLocation); List<SessionInfo> allSessions(); }
SessionContexts { public SessionContext onLogon(final CompositeKey compositeKey, final FixDictionary fixDictionary) { final SessionContext sessionContext = newSessionContext(compositeKey, fixDictionary); if (!currentlyAuthenticatedSessionIds.add(sessionContext.sessionId())) { return DUPLICATE_SESSION; } return sessionContext; } SessionContexts(
        final MappedFile mappedFile,
        final SessionIdStrategy idStrategy,
        final int initialSequenceIndex,
        final ErrorHandler errorHandler); SessionContext onLogon(final CompositeKey compositeKey, final FixDictionary fixDictionary); void onDisconnect(final long sessionId); void reset(final File backupLocation); List<SessionInfo> allSessions();  }