Beispiel #1
0
    private void concludeLossGenerators() {
      if (null == dataLossGenerator) {
        dataLossGenerator(Configuration.createLossGenerator(dataLossRate, dataLossSeed));
      }

      if (null == controlLossGenerator) {
        controlLossGenerator(Configuration.createLossGenerator(controlLossRate, controlLossSeed));
      }
    }
Beispiel #2
0
    private void concludeIdleStrategies() {
      if (null == conductorIdleStrategy) {
        conductorIdleStrategy(Configuration.conductorIdleStrategy());
      }

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

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

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

      if (null == sharedIdleStrategy) {
        sharedIdleStrategy(Configuration.sharedIdleStrategy());
      }
    }
Beispiel #3
0
    public Context() {
      termBufferLength(Configuration.termBufferLength());
      termBufferMaxLength(Configuration.termBufferLengthMax());
      initialWindowLength(Configuration.initialWindowLength());
      statusMessageTimeout(Configuration.statusMessageTimeout());
      dataLossRate(Configuration.dataLossRate());
      dataLossSeed(Configuration.dataLossSeed());
      controlLossRate(Configuration.controlLossRate());
      controlLossSeed(Configuration.controlLossSeed());
      mtuLength(Configuration.MTU_LENGTH);

      eventConsumer = System.out::println;
      eventBufferLength = EventConfiguration.bufferLength();

      warnIfDirectoriesExist = true;

      dirsDeleteOnStart(getBoolean(DIRS_DELETE_ON_START_PROP_NAME));
    }
Beispiel #4
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;
    }