/** * Called to indicate a retransmission is received that may obviate the need to send one ourselves. * <p> * NOTE: Currently only called from unit tests. Would be used for retransmitting from receivers for NAK suppression * * @param termId of the data * @param termOffset of the data */ public void onRetransmitReceived(final int termId, final int termOffset) { final RetransmitAction action = activeRetransmitsMap.get(termId, termOffset); if (null != action && DELAYED == action.state) { activeRetransmitsMap.remove(termId, termOffset); action.cancel(); // do not go into linger } }
public void onRttMeasurement( final RttMeasurementFlyweight msg, final UnsafeBuffer buffer, final int length, final InetSocketAddress srcAddress) { final NetworkPublication publication = publicationBySessionAndStreamId.get(msg.sessionId(), msg.streamId()); if (null != publication) { publication.onRttMeasurement(msg, srcAddress); } }
/** * If the specified key is not already associated with a value (or is mapped * to {@code null}), attempts to compute its value using the given mapping * function and enters it into this map unless {@code null}. * * @param keyPartA for the key * @param keyPartB for the key * @param mappingFunction creates values based upon keys if the key pair is missing * @return the newly created or stored value. */ public V computeIfAbsent(final int keyPartA, final int keyPartB, final EntryFunction<? extends V> mappingFunction) { V value = get(keyPartA, keyPartB); if (value == null) { value = mappingFunction.apply(keyPartA, keyPartB); if (value != null) { put(keyPartA, keyPartB, value); } } return value; }
@Test public void shouldReturnNullWhenNotFoundItem() { final int keyPartA = 3; final int keyPartB = 7; assertNull(map.get(keyPartA, keyPartB)); }
public void onNakMessage( final NakFlyweight msg, final UnsafeBuffer buffer, final int length, final InetSocketAddress srcAddress) { final NetworkPublication publication = publicationBySessionAndStreamId.get(msg.sessionId(), msg.streamId()); if (null != publication) { publication.onNak(msg.termId(), msg.termOffset(), msg.length()); nakMessagesReceived.incrementOrdered(); } }
@Test public void shouldPutAndGetKeysOfNegativeValue() { map.put(721632679, 333118496, "a"); assertThat(map.get(721632679, 333118496), is("a")); map.put(721632719, -659033725, "b"); assertThat(map.get(721632719, -659033725), is("b")); map.put(721632767, -235401032, "c"); assertThat(map.get(721632767, -235401032), is("c")); map.put(721632839, 1791470537, "d"); assertThat(map.get(721632839, 1791470537), is("d")); map.put(721633069, -939458690, "e"); assertThat(map.get(721633069, -939458690), is("e")); map.put(721633127, 1620485039, "f"); assertThat(map.get(721633127, 1620485039), is("f")); map.put(721633163, -1503337805, "g"); assertThat(map.get(721633163, -1503337805), is("g")); map.put(721633229, -2073657736, "h"); assertThat(map.get(721633229, -2073657736), is("h")); map.put(721633255, -1278969172, "i"); assertThat(map.get(721633255, -1278969172), is("i")); map.put(721633257, -1230662585, "j"); assertThat(map.get(721633257, -1230662585), is("j")); map.put(721633319, -532637417, "k"); assertThat(map.get(721633319, -532637417), is("k")); }
@Test public void shouldPutAndGetItem() { final String testValue = "Test"; final int keyPartA = 3; final int keyPartB = 7; assertNull(map.put(keyPartA, keyPartB, testValue)); assertThat(map.get(keyPartA, keyPartB), is(testValue)); }
@Test public void shouldRemoveItem() { final String testValue = "Test"; final int keyPartA = 3; final int keyPartB = 7; map.put(keyPartA, keyPartB, testValue); assertThat(map.remove(keyPartA, keyPartB), is(testValue)); assertNull(map.get(keyPartA, keyPartB)); }
if (null == activeRetransmitsMap.get(termId, termOffset) && activeRetransmitsMap.size() < MAX_RETRANSMITS_DEFAULT)
final NetworkPublication publication = publicationBySessionAndStreamId.get(sessionId, streamId);
/** * If the specified key is not already associated with a value (or is mapped * to {@code null}), attempts to compute its value using the given mapping * function and enters it into this map unless {@code null}. * * @param keyPartA for the key * @param keyPartB for the key * @param mappingFunction creates values based upon keys if the key pair is missing * @return the newly created or stored value. */ public V computeIfAbsent(final int keyPartA, final int keyPartB, final EntryFunction<? extends V> mappingFunction) { V value = get(keyPartA, keyPartB); if (value == null) { value = mappingFunction.apply(keyPartA, keyPartB); if (value != null) { put(keyPartA, keyPartB, value); } } return value; }
/** * Called to indicate a retransmission is received that may obviate the need to send one ourselves. * <p> * NOTE: Currently only called from unit tests. Would be used for retransmitting from receivers for NAK suppression * * @param termId of the data * @param termOffset of the data */ public void onRetransmitReceived(final int termId, final int termOffset) { final RetransmitAction action = activeRetransmitsMap.get(termId, termOffset); if (null != action && DELAYED == action.state) { activeRetransmitsMap.remove(termId, termOffset); action.cancel(); // do not go into linger } }
/** * Called to indicate a retransmission is received that may obviate the need to send one ourselves. * <p> * NOTE: Currently only called from unit tests. Would be used for retransmitting from receivers for NAK suppression * * @param termId of the data * @param termOffset of the data */ public void onRetransmitReceived(final int termId, final int termOffset) { final RetransmitAction action = activeRetransmitsMap.get(termId, termOffset); if (null != action && DELAYED == action.state) { activeRetransmitsMap.remove(termId, termOffset); action.cancel(); // do not go into linger } }
/** * If the specified key is not already associated with a value (or is mapped * to {@code null}), attempts to compute its value using the given mapping * function and enters it into this map unless {@code null}. * * @param keyPartA for the key * @param keyPartB for the key * @param mappingFunction creates values based upon keys if the key pair is missing * @return the newly created or stored value. */ public V computeIfAbsent(final int keyPartA, final int keyPartB, final EntryFunction<? extends V> mappingFunction) { V value = get(keyPartA, keyPartB); if (value == null) { value = mappingFunction.apply(keyPartA, keyPartB); if (value != null) { put(keyPartA, keyPartB, value); } } return value; }
public void onRttMeasurement( final RttMeasurementFlyweight msg, final UnsafeBuffer buffer, final int length, final InetSocketAddress srcAddress) { final NetworkPublication publication = publicationBySessionAndStreamId.get(msg.sessionId(), msg.streamId()); if (null != publication) { publication.onRttMeasurement(msg, srcAddress); } }
public void onRttMeasurement( final RttMeasurementFlyweight msg, final UnsafeBuffer buffer, final int length, final InetSocketAddress srcAddress) { final NetworkPublication publication = publicationBySessionAndStreamId.get(msg.sessionId(), msg.streamId()); if (null != publication) { publication.onRttMeasurement(msg, srcAddress); } }
public void onNakMessage( final NakFlyweight msg, final UnsafeBuffer buffer, final int length, final InetSocketAddress srcAddress) { final NetworkPublication publication = publicationBySessionAndStreamId.get(msg.sessionId(), msg.streamId()); if (null != publication) { publication.onNak(msg.termId(), msg.termOffset(), msg.length()); nakMessagesReceived.incrementOrdered(); } }
public void onNakMessage( final NakFlyweight msg, final UnsafeBuffer buffer, final int length, final InetSocketAddress srcAddress) { final NetworkPublication publication = publicationBySessionAndStreamId.get(msg.sessionId(), msg.streamId()); if (null != publication) { publication.onNak(msg.termId(), msg.termOffset(), msg.length()); nakMessagesReceived.incrementOrdered(); } }
final NetworkPublication publication = publicationBySessionAndStreamId.get(sessionId, streamId);
final NetworkPublication publication = publicationBySessionAndStreamId.get(sessionId, streamId);