/** * Has the given leadershipTermId already been appended? * * @param leadershipTermId to check * @return true if term was already appended or false if not. */ public boolean hasTermBeenAppended(final long leadershipTermId) { final int index = (int)indexByLeadershipTermIdMap.get(leadershipTermId); return (NULL_VALUE != index); }
/** * Get the term {@link Entry} for a given leadership term id. * * @param leadershipTermId to get {@link Entry} for. * @return the {@link Entry} if found or throw {@link IllegalArgumentException} if no entry exists for term. */ public Entry getTermEntry(final long leadershipTermId) { final int index = (int)indexByLeadershipTermIdMap.get(leadershipTermId); if (NULL_VALUE == index) { throw new ClusterException("unknown leadershipTermId=" + leadershipTermId); } return entries.get(index); }
/** * Long primitive specialised containsKey. * * @param key the key to check. * @return true if the map contains key as a key, false otherwise. */ public boolean containsKey(final long key) { return get(key) != missingValue; }
/** * Long primitive specialised containsKey. * * @param key the key to check. * @return true if the map contains key as a key, false otherwise. */ public boolean containsKey(final long key) { return get(key) != missingValue; }
/** * Has the given leadershipTermId unknown to the log? * * @param leadershipTermId to check * @return true if term has not yet been appended otherwise false. */ public boolean isUnknown(final long leadershipTermId) { return NULL_VALUE == indexByLeadershipTermIdMap.get(leadershipTermId); }
/** * {@inheritDoc} */ public Long get(final Object key) { return get((long)key); }
/** * {@inheritDoc} */ public boolean contains(final Object o) { final Entry entry = (Entry)o; final Long value = get(entry.getKey()); return value != null && value.equals(entry.getValue()); } }
/** * {@inheritDoc} */ public Long get(final Object key) { return valOrNull(get((long)key)); }
private long completedPosition(final int aeronSessionId) { return completionPosition.positions().get(aeronSessionId); }
/** * Get the term {@link Entry} for a given leadership term id. * * @param leadershipTermId to get {@link Entry} for. * @return the {@link Entry} if found or throw {@link IllegalArgumentException} if no entry exists for term. */ public Entry getTermEntry(final long leadershipTermId) { final int index = (int)indexByLeadershipTermIdMap.get(leadershipTermId); if (NULL_VALUE == index) { throw new ClusterException("unknown leadershipTermId=" + leadershipTermId); } return entries.get(index); }
/** * Primitive specialised version of {@link #replace(Object, Object, Object)} * * @param key key with which the specified value is associated * @param oldValue value expected to be associated with the specified key * @param newValue value to be associated with the specified key * @return {@code true} if the value was replaced */ public boolean replace(final long key, final long oldValue, final long newValue) { final long curValue = get(key); if (curValue != oldValue || curValue == missingValue) { return false; } put(key, newValue); return true; }
/** * Primitive specialised version of {@link #replace(Object, Object)} * * @param key key with which the specified value is associated * @param value value to be associated with the specified key * @return the previous value associated with the specified key, or * {@link #missingValue()} if there was no mapping for the key. */ public long replace(final long key, final long value) { long curValue = get(key); if (curValue != missingValue) { curValue = put(key, value); } return curValue; }
/** * Primitive specialised version of {@link #replace(Object, Object)} * * @param key key with which the specified value is associated * @param value value to be associated with the specified key * @return the previous value associated with the specified key, or * {@link #missingValue()} if there was no mapping for the key. */ public long replace(final long key, final long value) { long curValue = get(key); if (curValue != missingValue) { curValue = put(key, value); } return curValue; }
/** * Primitive specialised version of {@link #replace(Object, Object, Object)} * * @param key key with which the specified value is associated * @param oldValue value expected to be associated with the specified key * @param newValue value to be associated with the specified key * @return {@code true} if the value was replaced */ public boolean replace(final long key, long oldValue, long newValue) { final long curValue = get(key); if (curValue != oldValue || curValue == missingValue) { return false; } put(key, newValue); return true; }
/** * Primitive specialised version of {@link #computeIfAbsent(Object, Function)} * * @param key to search on. * @param mappingFunction to provide a value if the get returns null. * @return the value if found otherwise the missing value. */ public long computeIfAbsent(final long key, final LongUnaryOperator mappingFunction) { long value = get(key); if (value == missingValue) { value = mappingFunction.applyAsLong(key); if (value != missingValue) { put(key, value); } } return value; }
/** * Primitive specialised version of {@link #computeIfAbsent(Object, Function)} * * @param key to search on. * @param mappingFunction to provide a value if the get returns null. * @return the value if found otherwise the missing value. */ public long computeIfAbsent(final long key, final LongUnaryOperator mappingFunction) { long value = get(key); if (value == missingValue) { value = mappingFunction.applyAsLong(key); if (value != missingValue) { put(key, value); } } return value; }
long getRecordingId(final int aeronSessionId) { long recordingId = aeronSessionIdToRecordingId.get(aeronSessionId); while (recordingId == NULL_RECORDING_ID) { final int counterId = RecordingPos.findCounterIdBySession(counters, aeronSessionId); if (counterId != NULL_COUNTER_ID) { recordingId = RecordingPos.getRecordingId(counters, counterId); if (recordingId != NULL_RECORDING_ID) { aeronSessionIdToRecordingId.put(aeronSessionId, recordingId); } } archiverIdleStrategy.idle(); } archiverIdleStrategy.reset(); return recordingId; }
private void saveRecord(final int newSequenceNumber, final long sessionId) int position = (int)recordOffsets.get(sessionId); if (position == MISSING_RECORD)
private int resendSaveNotifications(final Long2LongHashMap resend, final SlowStatus status) { int actions = 0; if (!resend.isEmpty()) { final KeyIterator keyIterator = resend.keySet().iterator(); while (keyIterator.hasNext()) { final long connectionId = keyIterator.nextValue(); final int libraryId = (int)resend.get(connectionId); final long position = inboundPublication.saveSlowStatusNotification( libraryId, connectionId, status); if (position > 0) { actions++; keyIterator.remove(); } } } return actions; }