Java Code Examples for com.couchbase.client.dcp.Client#Environment

The following examples show how to use com.couchbase.client.dcp.Client#Environment . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Conductor.java    From java-dcp-client with Apache License 2.0 6 votes vote down vote up
public Conductor(final Client.Environment env, DcpClientMetrics metrics) {
  this.metrics = requireNonNull(metrics);
  this.env = env;
  this.bucketConfigArbiter = new BucketConfigArbiter(env);

  bucketConfigArbiter.configs()
      .observeOn(Schedulers.from(configUpdateExecutor))
      .forEach(config -> {
        // Couchbase sometimes says a newly created bucket has no partitions.
        // This doesn't affect cluster topology, but it's a problem for code
        // that needs to know the real partition count during startup.
        if (config.numberOfPartitions() == 0 && currentConfig.get() == null) {
          // Skip this config. The server will send another when the bucket is really ready.
          LOGGER.debug("Skipping initial config (rev {}) because it has invalid partition count.", config.rev());
          return;
        }

        LOGGER.trace("Applying new configuration, new rev is {}.", config.rev());
        currentConfig.set(config);
        reconfigure(config);
        configurationApplied.countDown();
      });
}
 
Example 2
Source File: DcpChannel.java    From java-dcp-client with Apache License 2.0 5 votes vote down vote up
public DcpChannel(HostAndPort address, final Client.Environment env, final Conductor conductor) {
  super(LifecycleState.DISCONNECTED);
  this.address = address;
  this.env = env;
  this.conductor = conductor;
  this.controlHandler = new DcpChannelControlHandler(this);
  this.isShutdown = false;
  this.metrics = new DcpChannelMetrics(new MetricsContext("dcp", Tags.of("remote", address.format())));
}
 
Example 3
Source File: ChannelFlowControllerImpl.java    From java-dcp-client with Apache License 2.0 5 votes vote down vote up
public ChannelFlowControllerImpl(Channel channel, Client.Environment environment) {
  this.channel = requireNonNull(channel);
  this.needsBufferAck = environment.dcpControl().bufferAckEnabled();
  if (needsBufferAck) {
    int bufferAckPercent = environment.bufferAckWatermark();
    int bufferSize = Integer.parseInt(environment.dcpControl().get(DcpControl.Names.CONNECTION_BUFFER_SIZE));
    this.bufferAckWatermark = (int) Math.round(bufferSize / 100.0 * bufferAckPercent);
    LOGGER.debug("BufferAckWatermark absolute is {}", bufferAckWatermark);
  } else {
    this.bufferAckWatermark = 0;
  }
  this.bufferAckCounter = 0;
}
 
Example 4
Source File: DcpMessageHandler.java    From java-dcp-client with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new message handler.
 *
 * @param environment data event callback handler.
 * @param controlHandler control event handler.
 */
DcpMessageHandler(final Channel channel, final Client.Environment environment,
                  final DcpChannelControlHandler controlHandler,
                  final DcpChannelMetrics metrics) {
  this.dataEventHandler = environment.dataEventHandler();
  this.controlHandler = controlHandler;
  this.flowController = new ChannelFlowControllerImpl(channel, environment);
  this.metrics = requireNonNull(metrics);
}
 
Example 5
Source File: DcpPipeline.java    From java-dcp-client with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the pipeline.
 *
 * @param environment the stateful environment.
 * @param controlHandler the control event handler.
 */
public DcpPipeline(final Client.Environment environment,
                   final DcpChannelControlHandler controlHandler, BucketConfigArbiter bucketConfigArbiter,
                   DcpChannelMetrics metrics) {
  this.bucketConfigArbiter = requireNonNull(bucketConfigArbiter);
  this.environment = requireNonNull(environment);
  this.controlHandler = requireNonNull(controlHandler);
  this.metrics = requireNonNull(metrics);
  if (environment.sslEnabled()) {
    this.sslEngineFactory = new SSLEngineFactory(environment);
  } else {
    this.sslEngineFactory = null;
  }
}
 
Example 6
Source File: PersistencePollingHandler.java    From java-dcp-client with Apache License 2.0 5 votes vote down vote up
public PersistencePollingHandler(final Client.Environment env,
                                 final BucketConfigSource bucketConfigSource,
                                 final DcpRequestDispatcher dispatcher) {
  this.env = requireNonNull(env);
  this.bucketConfigSource = requireNonNull(bucketConfigSource);
  this.persistedSeqnos = requireNonNull(env.persistedSeqnos());
  this.dcpOps = new DcpOpsImpl(dispatcher);
}
 
Example 7
Source File: BucketConfigArbiter.java    From java-dcp-client with Apache License 2.0 4 votes vote down vote up
public BucketConfigArbiter(Client.Environment environment) {
  this.environment = requireNonNull(environment);
}
 
Example 8
Source File: DcpConnectHandler.java    From java-dcp-client with Apache License 2.0 4 votes vote down vote up
DcpConnectHandler(final Client.Environment env) {
  this.env = requireNonNull(env);
  this.connectionNameGenerator = env.connectionNameGenerator();
  this.bucket = env.bucket();
  this.dcpControl = env.dcpControl();
}