Exemplo n.º 1
0
    private void concludeCounters() {
      if (countersManager() == null) {
        if (counterLabelsBuffer() == null) {
          counterLabelsBuffer(
              CncFileDescriptor.createCounterLabelsBuffer(cncByteBuffer, cncMetaDataBuffer));
        }

        if (counterValuesBuffer() == null) {
          counterValuesBuffer(
              CncFileDescriptor.createCounterValuesBuffer(cncByteBuffer, cncMetaDataBuffer));
        }

        countersManager(new CountersManager(counterLabelsBuffer(), counterValuesBuffer()));
      }

      if (null == systemCounters) {
        systemCounters = new SystemCounters(countersManager);
      }
    }
Exemplo n.º 2
0
    public Context conclude() {
      super.conclude();

      try {
        if (null == epochClock) {
          epochClock = new SystemEpochClock();
        }

        if (null == nanoClock) {
          nanoClock = new SystemNanoClock();
        }

        if (threadingMode == null) {
          threadingMode = Configuration.threadingMode();
        }

        final ByteBuffer eventByteBuffer = ByteBuffer.allocateDirect(eventBufferLength);

        if (null == eventLogger) {
          eventLogger = new EventLogger(eventByteBuffer);
        }

        if (null == unicastSenderFlowControlSupplier) {
          unicastSenderFlowControlSupplier = Configuration::unicastFlowControlStrategy;
        }

        if (null == multicastSenderFlowControlSupplier) {
          multicastSenderFlowControlSupplier = Configuration::multicastFlowControlStrategy;
        }

        if (0 == ipcPublicationTermBufferLength) {
          ipcPublicationTermBufferLength = Configuration.ipcTermBufferLength(termBufferLength());
        }

        toEventReader(new ManyToOneRingBuffer(new UnsafeBuffer(eventByteBuffer)));

        receiverTransportPoller(new DataTransportPoller());
        senderTransportPoller(new ControlTransportPoller());

        Configuration.validateTermBufferLength(termBufferLength());
        Configuration.validateInitialWindowLength(initialWindowLength(), mtuLength());

        cncByteBuffer =
            mapNewFile(
                cncFile(),
                CncFileDescriptor.computeCncFileLength(
                    CONDUCTOR_BUFFER_LENGTH
                        + TO_CLIENTS_BUFFER_LENGTH
                        + COUNTER_LABELS_BUFFER_LENGTH
                        + COUNTER_VALUES_BUFFER_LENGTH));

        cncMetaDataBuffer = CncFileDescriptor.createMetaDataBuffer(cncByteBuffer);
        CncFileDescriptor.fillMetaData(
            cncMetaDataBuffer,
            CONDUCTOR_BUFFER_LENGTH,
            TO_CLIENTS_BUFFER_LENGTH,
            COUNTER_LABELS_BUFFER_LENGTH,
            COUNTER_VALUES_BUFFER_LENGTH);

        final BroadcastTransmitter transmitter =
            new BroadcastTransmitter(
                CncFileDescriptor.createToClientsBuffer(cncByteBuffer, cncMetaDataBuffer));

        clientProxy(new ClientProxy(transmitter, eventLogger));

        toDriverCommands(
            new ManyToOneRingBuffer(
                CncFileDescriptor.createToDriverBuffer(cncByteBuffer, cncMetaDataBuffer)));

        concludeCounters();

        receiverProxy(
            new ReceiverProxy(
                threadingMode, receiverCommandQueue(), systemCounters.receiverProxyFails()));
        senderProxy(
            new SenderProxy(
                threadingMode, senderCommandQueue(), systemCounters.senderProxyFails()));
        fromReceiverDriverConductorProxy(
            new DriverConductorProxy(
                threadingMode,
                toConductorFromReceiverCommandQueue,
                systemCounters.conductorProxyFails()));
        fromSenderDriverConductorProxy(
            new DriverConductorProxy(
                threadingMode,
                toConductorFromSenderCommandQueue,
                systemCounters.conductorProxyFails()));

        rawLogBuffersFactory(
            new RawLogFactory(
                dirName(),
                publicationTermBufferLength,
                maxImageTermBufferLength,
                ipcPublicationTermBufferLength,
                eventLogger));

        concludeIdleStrategies();
        concludeLossGenerators();
      } catch (final Exception ex) {
        LangUtil.rethrowUnchecked(ex);
      }

      return this;
    }