Beispiel #1
0
  public BoltInstance(
      PhysicalPlanHelper helper,
      Communicator<HeronTuples.HeronTupleSet> streamInQueue,
      Communicator<HeronTuples.HeronTupleSet> streamOutQueue,
      SlaveLooper looper) {
    super(helper, streamInQueue, streamOutQueue, looper);
    SystemConfig systemConfig =
        (SystemConfig) SingletonRegistry.INSTANCE.getSingleton(SystemConfig.HERON_SYSTEM_CONFIG);

    this.instanceExecuteBatchTime =
        systemConfig.getInstanceExecuteBatchTimeMs() * Constants.MILLISECONDS_TO_NANOSECONDS;
    this.instanceExecuteBatchSize = systemConfig.getInstanceExecuteBatchSizeBytes();
  }
Beispiel #2
0
  /** Construct a Gateway basing on given arguments */
  public Gateway(
      String topologyName,
      String topologyId,
      PhysicalPlans.Instance instance,
      int streamPort,
      int metricsPort,
      final NIOLooper gatewayLooper,
      final Communicator<HeronTuples.HeronTupleSet> inStreamQueue,
      final Communicator<HeronTuples.HeronTupleSet> outStreamQueue,
      final Communicator<InstanceControlMsg> inControlQueue,
      final List<Communicator<Metrics.MetricPublisherPublishMessage>> outMetricsQueues)
      throws IOException {
    systemConfig =
        (SystemConfig) SingletonRegistry.INSTANCE.getSingleton(SystemConfig.HERON_SYSTEM_CONFIG);

    // New the client
    this.gatewayLooper = gatewayLooper;
    this.gatewayMetricsCollector = new MetricsCollector(gatewayLooper, outMetricsQueues.get(0));

    // JVM Metrics are auto-sample metrics so we do not have to insert it inside singleton
    // since it should not be used in other places
    jvmMetrics = new JVMMetrics();
    jvmMetrics.registerMetrics(gatewayMetricsCollector);

    // since we need to call its methods in a lot of classes
    gatewayMetrics = new GatewayMetrics();
    gatewayMetrics.registerMetrics(gatewayMetricsCollector);

    // Init the ErrorReportHandler
    ErrorReportLoggingHandler.init(
        instance.getInstanceId(),
        gatewayMetricsCollector,
        systemConfig.getHeronMetricsExportIntervalSec(),
        systemConfig.getHeronMetricsMaxExceptionsPerMessageCount());

    // Initialize the corresponding 2 socket clients with corresponding socket options
    HeronSocketOptions socketOptions =
        new HeronSocketOptions(
            systemConfig.getInstanceNetworkWriteBatchSizeBytes(),
            systemConfig.getInstanceNetworkWriteBatchTimeMs(),
            systemConfig.getInstanceNetworkReadBatchSizeBytes(),
            systemConfig.getInstanceNetworkReadBatchTimeMs(),
            systemConfig.getInstanceNetworkOptionsSocketSendBufferSizeBytes(),
            systemConfig.getInstanceNetworkOptionsSocketReceivedBufferSizeBytes());
    this.streamManagerClient =
        new StreamManagerClient(
            gatewayLooper,
            STREAM_MGR_HOST,
            streamPort,
            topologyName,
            topologyId,
            instance,
            inStreamQueue,
            outStreamQueue,
            inControlQueue,
            socketOptions,
            gatewayMetrics);
    this.metricsManagerClient =
        new MetricsManagerClient(
            gatewayLooper,
            METRICS_MGR_HOST,
            metricsPort,
            instance,
            outMetricsQueues,
            socketOptions,
            gatewayMetrics);

    // Attach sample Runnable to gatewayMetricsCollector
    gatewayMetricsCollector.registerMetricSampleRunnable(
        jvmMetrics.getJVMSampleRunnable(),
        systemConfig.getInstanceMetricsSystemSampleIntervalSec());
    Runnable sampleStreamQueuesSize =
        new Runnable() {
          @Override
          public void run() {
            gatewayMetrics.setInStreamQueueSize(inStreamQueue.size());
            gatewayMetrics.setOutStreamQueueSize(outStreamQueue.size());
            gatewayMetrics.setInStreamQueueExpectedCapacity(
                inStreamQueue.getExpectedAvailableCapacity());
            gatewayMetrics.setOutStreamQueueExpectedCapacity(
                outStreamQueue.getExpectedAvailableCapacity());
          }
        };
    gatewayMetricsCollector.registerMetricSampleRunnable(
        sampleStreamQueuesSize, systemConfig.getInstanceMetricsSystemSampleIntervalSec());

    final long instanceTuningIntervalMs =
        systemConfig.getInstanceTuningIntervalMs() * Constants.MILLISECONDS_TO_NANOSECONDS;

    // Attache Runnable to update the expected stream's expected available capacity
    Runnable tuningStreamQueueSize =
        new Runnable() {

          @Override
          public void run() {
            inStreamQueue.updateExpectedAvailableCapacity();
            outStreamQueue.updateExpectedAvailableCapacity();
            gatewayLooper.registerTimerEventInNanoSeconds(instanceTuningIntervalMs, this);
          }
        };
    gatewayLooper.registerTimerEventInSeconds(
        systemConfig.getInstanceMetricsSystemSampleIntervalSec(), tuningStreamQueueSize);
  }