long channelStatus(final int channelStatusId) { switch (channelStatusId) { case 0: return ChannelEndpointStatus.INITIALIZING; case ChannelEndpointStatus.NO_ID_ALLOCATED: return ChannelEndpointStatus.ACTIVE; default: return countersReader.getCounterValue(channelStatusId); } }
public void print(final PrintStream out) { counters.forEach( (counterId, typeId, keyBuffer, label) -> { if (filter(typeId, keyBuffer)) { final long value = counters.getCounterValue(counterId); out.format("%3d: %,20d - %s%n", counterId, value, label); } }); }
private void awaitRecordingComplete(final long position) { final CountersReader counters = aeron.countersReader(); final int counterId = RecordingPos.findCounterIdBySession(counters, publicationSessionId); while (counters.getCounterValue(counterId) < position) { Thread.yield(); } }
void pollRecPos() { if (CountersReader.NULL_COUNTER_ID == counterId) { counterId = RecordingPos.findCounterIdBySession(countersReader, image.sessionId()); } else if (RecordingPos.NULL_RECORDING_ID == recordingId) { recordingId = RecordingPos.getRecordingId(countersReader, counterId); } else { recPos = countersReader.getCounterValue(counterId); } }
private void awaitRecordingComplete( final long recordingId, final long position, final CountersReader counters, final int counterId) { idleStrategy.reset(); do { idle(); if (!RecordingPos.isActive(counters, counterId, recordingId)) { throw new ClusterException("recording has stopped unexpectedly: " + recordingId); } } while (counters.getCounterValue(counterId) < position); }
final int counterId = RecordingPos.findCounterIdBySession(counters, publication.sessionId()); while (counters.getCounterValue(counterId) < stopPosition)
/** * Take a snapshot of all the counters and group them by streams. * * @return a snapshot of all the counters and group them by streams. */ public Map<StreamCompositeKey, List<StreamPosition>> snapshot() { final Map<StreamCompositeKey, List<StreamPosition>> streams = new HashMap<>(); counters.forEach( (counterId, typeId, keyBuffer, label) -> { if ((typeId >= PUBLISHER_LIMIT_TYPE_ID && typeId <= RECEIVER_POS_TYPE_ID) || typeId == SENDER_LIMIT_TYPE_ID || typeId == PER_IMAGE_TYPE_ID || typeId == PUBLISHER_POS_TYPE_ID) { final StreamCompositeKey key = new StreamCompositeKey( keyBuffer.getInt(SESSION_ID_OFFSET), keyBuffer.getInt(STREAM_ID_OFFSET), keyBuffer.getStringAscii(CHANNEL_OFFSET)); final StreamPosition position = new StreamPosition( keyBuffer.getLong(REGISTRATION_ID_OFFSET), counters.getCounterValue(counterId), typeId); streams .computeIfAbsent(key, (ignore) -> new ArrayList<>()) .add(position); } }); return streams; }
long errors() { return countersReader().getCounterValue(SystemCounterDescriptor.ERRORS.id()); }
@Test public void shouldCatchErrorOnAddressAlreadyInUseForSubscriptions() { final Subscription subscriptionA = clientA.addSubscription(URI, STREAM_ID); while (subscriptionA.channelStatus() == ChannelEndpointStatus.INITIALIZING) { SystemTest.checkInterruptedStatus(); Thread.yield(); } assertThat(subscriptionA.channelStatus(), is(ChannelEndpointStatus.ACTIVE)); final Subscription subscriptionB = clientB.addSubscription(URI, STREAM_ID); final ArgumentCaptor<Throwable> captor = ArgumentCaptor.forClass(Throwable.class); verify(errorHandlerClientB, timeout(5000)).onError(captor.capture()); assertThat(captor.getValue(), instanceOf(ChannelEndpointException.class)); final ChannelEndpointException channelEndpointException = (ChannelEndpointException)captor.getValue(); final long status = clientB.countersReader().getCounterValue(channelEndpointException.statusIndicatorId()); assertThat(status, is(ChannelEndpointStatus.ERRORED)); assertThat(errorCounter.get(), greaterThan(0)); assertThat(subscriptionB.channelStatusId(), is(channelEndpointException.statusIndicatorId())); assertThat(subscriptionA.channelStatus(), is(ChannelEndpointStatus.ACTIVE)); }
while (counters.getCounterValue(counterId) < publication.position())
@Test public void shouldCatchErrorOnAddressAlreadyInUseForPublications() { final Publication publicationA = clientA.addPublication(URI_WITH_INTERFACE_PORT, STREAM_ID); while (publicationA.channelStatus() == ChannelEndpointStatus.INITIALIZING) { SystemTest.checkInterruptedStatus(); Thread.yield(); } assertThat(publicationA.channelStatus(), is(ChannelEndpointStatus.ACTIVE)); final Publication publicationB = clientB.addPublication(URI_WITH_INTERFACE_PORT, STREAM_ID); final ArgumentCaptor<Throwable> captor = ArgumentCaptor.forClass(Throwable.class); verify(errorHandlerClientB, timeout(5000)).onError(captor.capture()); assertThat(captor.getValue(), instanceOf(ChannelEndpointException.class)); final ChannelEndpointException channelEndpointException = (ChannelEndpointException)captor.getValue(); final long status = clientB.countersReader().getCounterValue(channelEndpointException.statusIndicatorId()); assertThat(status, is(ChannelEndpointStatus.ERRORED)); assertThat(errorCounter.get(), greaterThan(0)); assertThat(publicationB.channelStatusId(), is(channelEndpointException.statusIndicatorId())); assertTrue(publicationB.isClosed()); assertThat(publicationA.channelStatus(), is(ChannelEndpointStatus.ACTIVE)); }
private void awaitRecordingComplete( final long recordingId, final long position, final CountersReader counters, final int counterId, final AeronArchive archive) { idleStrategy.reset(); do { idleStrategy.idle(); checkInterruptedStatus(); if (!RecordingPos.isActive(counters, counterId, recordingId)) { throw new ClusterException("recording has stopped unexpectedly: " + recordingId); } archive.checkForErrorResponse(); } while (counters.getCounterValue(counterId) < position); }
Election.State electionState() { final MutableInteger electionStateValue = new MutableInteger(NULL_VALUE); countersReader().forEach( (counterId, typeId, keyBuffer, label) -> { if (typeId == Election.ELECTION_STATE_TYPE_ID) { electionStateValue.value = (int)countersReader().getCounterValue(counterId); } }); return NULL_VALUE != electionStateValue.value ? Election.State.get(electionStateValue.value) : null; }
while (counters.getCounterValue(counterId) < stopPosition)
while (counters.getCounterValue(counterId) < stopPosition)
while (counters.getCounterValue(counterId) < currentPosition)
while (counters.getCounterValue(counterId) < firstStopPosition) while (counters.getCounterValue(counterId) < secondStopPosition)
long channelStatus(final int channelStatusId) { switch (channelStatusId) { case 0: return ChannelEndpointStatus.INITIALIZING; case ChannelEndpointStatus.NO_ID_ALLOCATED: return ChannelEndpointStatus.ACTIVE; default: return countersReader.getCounterValue(channelStatusId); } }
long channelStatus(final int channelStatusId) { switch (channelStatusId) { case 0: return ChannelEndpointStatus.INITIALIZING; case ChannelEndpointStatus.NO_ID_ALLOCATED: return ChannelEndpointStatus.ACTIVE; default: return countersReader.getCounterValue(channelStatusId); } }
private boolean archivingNotComplete(final long endPosition, final long recordingId) { final int counterId = RecordingPos.findCounterIdByRecording(countersReader, recordingId); // wait if the recording is active - otherwise assume that the recording has complete. if (counterId != CountersReader.NULL_COUNTER_ID) { return countersReader.getCounterValue(counterId) < endPosition; } return false; }