Search in sources :

Example 1 with UnsafeBufferPosition

use of org.agrona.concurrent.status.UnsafeBufferPosition in project aeron by real-logic.

the class ClientConductor method onNewPublication.

public void onNewPublication(final long correlationId, final long registrationId, final int streamId, final int sessionId, final int publicationLimitId, final int statusIndicatorId, final String logFileName) {
    final ConcurrentPublication publication = new ConcurrentPublication(this, stashedChannel, streamId, sessionId, new UnsafeBufferPosition(counterValuesBuffer, publicationLimitId), statusIndicatorId, logBuffers(registrationId, logFileName), registrationId, correlationId);
    resourceByRegIdMap.put(correlationId, publication);
}
Also used : UnsafeBufferPosition(org.agrona.concurrent.status.UnsafeBufferPosition)

Example 2 with UnsafeBufferPosition

use of org.agrona.concurrent.status.UnsafeBufferPosition in project aeron by real-logic.

the class ClientConductor method onNewExclusivePublication.

public void onNewExclusivePublication(final long correlationId, final long registrationId, final int streamId, final int sessionId, final int publicationLimitId, final int statusIndicatorId, final String logFileName) {
    final ExclusivePublication publication = new ExclusivePublication(this, stashedChannel, streamId, sessionId, new UnsafeBufferPosition(counterValuesBuffer, publicationLimitId), statusIndicatorId, logBuffers(registrationId, logFileName), registrationId, correlationId);
    resourceByRegIdMap.put(correlationId, publication);
}
Also used : UnsafeBufferPosition(org.agrona.concurrent.status.UnsafeBufferPosition)

Example 3 with UnsafeBufferPosition

use of org.agrona.concurrent.status.UnsafeBufferPosition in project aeron by real-logic.

the class IpcPublicationTest method setUp.

@SuppressWarnings("unchecked")
@Before
public void setUp() {
    final RingBuffer fromClientCommands = new ManyToOneRingBuffer(new UnsafeBuffer(ByteBuffer.allocateDirect(Configuration.CONDUCTOR_BUFFER_LENGTH)));
    final RawLogFactory mockRawLogFactory = mock(RawLogFactory.class);
    final UnsafeBuffer counterBuffer = new UnsafeBuffer(ByteBuffer.allocateDirect(BUFFER_LENGTH));
    final CountersManager countersManager = new CountersManager(new UnsafeBuffer(ByteBuffer.allocateDirect(BUFFER_LENGTH * 2)), counterBuffer, StandardCharsets.US_ASCII);
    when(mockRawLogFactory.newIpcPublication(anyInt(), anyInt(), anyLong(), anyInt())).thenReturn(LogBufferHelper.newTestLogBuffers(TERM_BUFFER_LENGTH));
    final MediaDriver.Context ctx = new MediaDriver.Context().tempBuffer(new UnsafeBuffer(new byte[METADATA_LENGTH])).ipcTermBufferLength(TERM_BUFFER_LENGTH).toDriverCommands(fromClientCommands).rawLogBuffersFactory(mockRawLogFactory).clientProxy(mock(ClientProxy.class)).driverCommandQueue(mock(ManyToOneConcurrentArrayQueue.class)).epochClock(new SystemEpochClock()).cachedEpochClock(new CachedEpochClock()).cachedNanoClock(new CachedNanoClock()).countersManager(countersManager).systemCounters(mock(SystemCounters.class)).nanoClock(nanoClock);
    ctx.countersValuesBuffer(counterBuffer);
    driverProxy = new DriverProxy(fromClientCommands, CLIENT_ID);
    driverConductor = new DriverConductor(ctx);
    driverProxy.addPublication(CommonContext.IPC_CHANNEL, STREAM_ID);
    driverConductor.doWork();
    ipcPublication = driverConductor.getSharedIpcPublication(STREAM_ID);
    publisherLimit = new UnsafeBufferPosition(counterBuffer, ipcPublication.publisherLimitId());
}
Also used : CommonContext(io.aeron.CommonContext) RawLogFactory(io.aeron.driver.buffer.RawLogFactory) ManyToOneRingBuffer(org.agrona.concurrent.ringbuffer.ManyToOneRingBuffer) RingBuffer(org.agrona.concurrent.ringbuffer.RingBuffer) ManyToOneRingBuffer(org.agrona.concurrent.ringbuffer.ManyToOneRingBuffer) DriverProxy(io.aeron.DriverProxy) UnsafeBufferPosition(org.agrona.concurrent.status.UnsafeBufferPosition) CountersManager(org.agrona.concurrent.status.CountersManager) Before(org.junit.Before)

Example 4 with UnsafeBufferPosition

use of org.agrona.concurrent.status.UnsafeBufferPosition in project Aeron by real-logic.

the class ClientConductor method onNewPublication.

void onNewPublication(final long correlationId, final long registrationId, final int streamId, final int sessionId, final int publicationLimitId, final int statusIndicatorId, final String logFileName) {
    final String stashedChannel = stashedChannelByRegistrationId.remove(correlationId);
    final ConcurrentPublication publication = new ConcurrentPublication(this, stashedChannel, streamId, sessionId, new UnsafeBufferPosition(counterValuesBuffer, publicationLimitId), statusIndicatorId, logBuffers(registrationId, logFileName, stashedChannel), registrationId, correlationId);
    resourceByRegIdMap.put(correlationId, publication);
}
Also used : UnsafeBufferPosition(org.agrona.concurrent.status.UnsafeBufferPosition)

Example 5 with UnsafeBufferPosition

use of org.agrona.concurrent.status.UnsafeBufferPosition in project Aeron by real-logic.

the class ClientConductor method onAvailableImage.

void onAvailableImage(final long correlationId, final int sessionId, final long subscriptionRegistrationId, final int subscriberPositionId, final String logFileName, final String sourceIdentity) {
    final Subscription subscription = (Subscription) resourceByRegIdMap.get(subscriptionRegistrationId);
    if (null != subscription) {
        final Image image = new Image(subscription, sessionId, new UnsafeBufferPosition(counterValuesBuffer, subscriberPositionId), logBuffers(correlationId, logFileName, subscription.channel()), ctx.subscriberErrorHandler(), sourceIdentity, correlationId);
        final AvailableImageHandler handler = subscription.availableImageHandler();
        if (null != handler) {
            isInCallback = true;
            try {
                handler.onAvailableImage(image);
            } catch (final Exception ex) {
                handleError(ex);
            } finally {
                isInCallback = false;
            }
        }
        subscription.addImage(image);
    }
}
Also used : UnsafeBufferPosition(org.agrona.concurrent.status.UnsafeBufferPosition)

Aggregations

UnsafeBufferPosition (org.agrona.concurrent.status.UnsafeBufferPosition)15 RawLog (io.aeron.driver.buffer.RawLog)3 InvalidChannelException (io.aeron.driver.exceptions.InvalidChannelException)3 ReceiveChannelEndpoint (io.aeron.driver.media.ReceiveChannelEndpoint)3 SendChannelEndpoint (io.aeron.driver.media.SendChannelEndpoint)3 ControlProtocolException (io.aeron.exceptions.ControlProtocolException)3 RingBuffer (org.agrona.concurrent.ringbuffer.RingBuffer)3 CountersManager (org.agrona.concurrent.status.CountersManager)3 CommonContext (io.aeron.CommonContext)2 DriverProxy (io.aeron.DriverProxy)2 AtomicCounter (org.agrona.concurrent.status.AtomicCounter)2 Aeron (io.aeron.Aeron)1 ChannelUri (io.aeron.ChannelUri)1 SPY_QUALIFIER (io.aeron.ChannelUri.SPY_QUALIFIER)1 FORCE_TRUE (io.aeron.CommonContext.InferableBoolean.FORCE_TRUE)1 INFER (io.aeron.CommonContext.InferableBoolean.INFER)1 ErrorCode (io.aeron.ErrorCode)1 Context (io.aeron.driver.MediaDriver.Context)1 PublicationParams (io.aeron.driver.PublicationParams)1 SubscriptionParams.validateInitialWindowForRcvBuf (io.aeron.driver.SubscriptionParams.validateInitialWindowForRcvBuf)1