Пример #1
0
  @Test
  public void shouldIncrementPublisherLimitOnSubscription() throws Exception {
    driverProxy.addSubscription(CommonContext.IPC_CHANNEL, STREAM_ID);
    driverConductor.doWork();

    assertThat(publisherLimit.get(), is(greaterThan(0L)));
  }
Пример #2
0
 public void closeResource(final AutoCloseable resource) {
   if (isShared()) {
     driverConductor.onCloseResource(resource);
   } else {
     offer(new CloseResourceCmd(resource));
   }
 }
Пример #3
0
  public void onTimeEvent(final long time, final DriverConductor conductor) {
    switch (status) {
      case INACTIVE:
        if (isDrained() || time > (timeOfLastStatusChange + imageLivenessTimeoutNs)) {
          status(PublicationImage.Status.LINGER);
          conductor.imageTransitionToLinger(this);
        }
        break;

      case LINGER:
        if (time > (timeOfLastStatusChange + imageLivenessTimeoutNs)) {
          reachedEndOfLife = true;
          conductor.cleanupImage(this);
        }
        break;
    }
  }
Пример #4
0
  @SuppressWarnings("unchecked")
  @Before
  public void setUp() throws Exception {
    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)), counterBuffer);

    when(mockRawLogFactory.newDirectPublication(anyInt(), anyInt(), anyLong()))
        .thenReturn(LogBufferHelper.newTestLogBuffers(TERM_BUFFER_LENGTH, TERM_META_DATA_LENGTH));

    final MediaDriver.Context ctx =
        new MediaDriver.Context()
            .toDriverCommands(fromClientCommands)
            .rawLogBuffersFactory(mockRawLogFactory)
            .clientProxy(mock(ClientProxy.class))
            .eventLogger(mock(EventLogger.class))
            .toConductorFromReceiverCommandQueue(mock(OneToOneConcurrentArrayQueue.class))
            .toConductorFromSenderCommandQueue(mock(OneToOneConcurrentArrayQueue.class))
            .toEventReader(mock(ManyToOneRingBuffer.class))
            .epochClock(new SystemEpochClock())
            .countersManager(countersManager)
            .nanoClock(nanoClock);

    ctx.counterValuesBuffer(counterBuffer);

    driverProxy = new DriverProxy(fromClientCommands);
    driverConductor = new DriverConductor(ctx);

    // have a conductor construct one for us
    driverProxy.addPublication(CommonContext.IPC_CHANNEL, STREAM_ID);
    driverConductor.doWork();

    directPublication = driverConductor.getDirectPublication(STREAM_ID);

    publisherLimit = new UnsafeBufferPosition(counterBuffer, directPublication.publisherLimitId());
  }
Пример #5
0
 public void createPublicationImage(
     final int sessionId,
     final int streamId,
     final int initialTermId,
     final int activeTermId,
     final int termOffset,
     final int termLength,
     final int mtuLength,
     final InetSocketAddress controlAddress,
     final InetSocketAddress srcAddress,
     final ReceiveChannelEndpoint channelEndpoint) {
   if (isShared()) {
     driverConductor.onCreatePublicationImage(
         sessionId,
         streamId,
         initialTermId,
         activeTermId,
         termOffset,
         termLength,
         mtuLength,
         controlAddress,
         srcAddress,
         channelEndpoint);
   } else {
     offer(
         new CreatePublicationImageCmd(
             sessionId,
             streamId,
             initialTermId,
             activeTermId,
             termOffset,
             termLength,
             mtuLength,
             controlAddress,
             srcAddress,
             channelEndpoint));
   }
 }
Пример #6
0
 public void onTimeEvent(final long time, final DriverConductor conductor) {
   if (time > (timeOfLastKeepaliveFromClient() + CLIENT_LIVENESS_TIMEOUT_NS)) {
     reachedEndOfLife = true;
     conductor.cleanupSubscriptionLink(SubscriptionLink.this);
   }
 }