com.aliyun.openservices.aliyun.log.producer.ProducerConfig Java Examples

The following examples show how to use com.aliyun.openservices.aliyun.log.producer.ProducerConfig. 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: LogAccumulator.java    From aliyun-log-java-producer with Apache License 2.0 6 votes vote down vote up
public LogAccumulator(
    String producerHash,
    ProducerConfig producerConfig,
    Map<String, Client> clientPool,
    Semaphore memoryController,
    RetryQueue retryQueue,
    BlockingQueue<ProducerBatch> successQueue,
    BlockingQueue<ProducerBatch> failureQueue,
    IOThreadPool ioThreadPool,
    AtomicInteger batchCount) {
  this.producerHash = producerHash;
  this.producerConfig = producerConfig;
  this.clientPool = clientPool;
  this.memoryController = memoryController;
  this.retryQueue = retryQueue;
  this.successQueue = successQueue;
  this.failureQueue = failureQueue;
  this.ioThreadPool = ioThreadPool;
  this.batchCount = batchCount;
  this.batches = new ConcurrentHashMap<GroupKey, ProducerBatchHolder>();
  this.appendsInProgress = new AtomicInteger(0);
  this.closed = false;
}
 
Example #2
Source File: LogAccumulator.java    From aliyun-log-java-producer with Apache License 2.0 6 votes vote down vote up
void transferProducerBatch(
    IOThreadPool ioThreadPool,
    ProducerConfig producerConfig,
    Map<String, Client> clientPool,
    RetryQueue retryQueue,
    BlockingQueue<ProducerBatch> successQueue,
    BlockingQueue<ProducerBatch> failureQueue,
    AtomicInteger batchCount) {
  if (producerBatch == null) {
    return;
  }
  ioThreadPool.submit(
      new SendProducerBatchTask(
          producerBatch,
          producerConfig,
          clientPool,
          retryQueue,
          successQueue,
          failureQueue,
          batchCount));
  producerBatch = null;
}
 
Example #3
Source File: SendProducerBatchTask.java    From aliyun-log-java-producer with Apache License 2.0 6 votes vote down vote up
public SendProducerBatchTask(
    ProducerBatch batch,
    ProducerConfig producerConfig,
    Map<String, Client> clientPool,
    RetryQueue retryQueue,
    BlockingQueue<ProducerBatch> successQueue,
    BlockingQueue<ProducerBatch> failureQueue,
    AtomicInteger batchCount) {
  this.batch = batch;
  this.producerConfig = producerConfig;
  this.clientPool = clientPool;
  this.retryQueue = retryQueue;
  this.successQueue = successQueue;
  this.failureQueue = failureQueue;
  this.batchCount = batchCount;
}
 
Example #4
Source File: FlinkLogProducer.java    From aliyun-log-flink-connector with Apache License 2.0 6 votes vote down vote up
private Producer createProducer(ConfigWrapper configWrapper) {
    ProducerConfig producerConfig = new ProducerConfig();
    producerConfig.setLingerMs(configWrapper.getInt(FLUSH_INTERVAL_MS,
            ProducerConfig.DEFAULT_LINGER_MS));
    producerConfig.setRetries(configWrapper.getInt(MAX_RETRIES,
            ProducerConfig.DEFAULT_RETRIES));
    producerConfig.setBaseRetryBackoffMs(
            configWrapper.getLong(BASE_RETRY_BACK_OFF_TIME_MS,
                    ProducerConfig.DEFAULT_BASE_RETRY_BACKOFF_MS));
    producerConfig.setMaxRetryBackoffMs(
            configWrapper.getLong(MAX_RETRY_BACK_OFF_TIME_MS, ProducerConfig.DEFAULT_MAX_RETRY_BACKOFF_MS));
    producerConfig.setMaxBlockMs(
            configWrapper.getLong(MAX_BLOCK_TIME_MS, ProducerConfig.DEFAULT_MAX_BLOCK_MS));
    producerConfig.setIoThreadCount(
            configWrapper.getInt(IO_THREAD_NUM, ProducerConfig.DEFAULT_IO_THREAD_COUNT));
    Producer producer = new LogProducer(producerConfig);
    ProjectConfig config = new ProjectConfig(project,
            configWrapper.getString(ConfigConstants.LOG_ENDPOINT),
            configWrapper.getString(ConfigConstants.LOG_ACCESSSKEYID),
            configWrapper.getString(ConfigConstants.LOG_ACCESSKEY));
    producer.putProjectConfig(config);
    return producer;
}
 
Example #5
Source File: LogProducerProvider.java    From alibaba-flink-connectors with Apache License 2.0 5 votes vote down vote up
@Override
protected LogProducer produceNormalClient(String accessId, String accessKey) {
	ProjectConfigs projectConfigs = new ProjectConfigs();
	ProjectConfig projectConfig = new ProjectConfig(this.projectName, this.endPoint, accessId, accessKey);
	projectConfigs.put(projectConfig);
	producerConfig = new ProducerConfig(projectConfigs);
	producerConfig.setLingerMs(flushInterval);
	producerConfig.setRetries(maxRetryTimes);
	LogProducer producer = new LogProducer(producerConfig);
	return producer;
}
 
Example #6
Source File: LogProducerProvider.java    From alibaba-flink-connectors with Apache License 2.0 5 votes vote down vote up
@Override
protected LogProducer produceStsClient(String accessId, String accessKey, String securityToken) {
	ProjectConfigs projectConfigs = new ProjectConfigs();
	ProjectConfig projectConfig = new ProjectConfig(this.projectName, this.endPoint, accessId, accessKey, securityToken);
	projectConfigs.put(projectConfig);
	producerConfig = new ProducerConfig(projectConfigs);
	producerConfig.setLingerMs(flushInterval);
	producerConfig.setRetries(maxRetryTimes);
	LogProducer producer = new LogProducer(producerConfig);
	return producer;
}
 
Example #7
Source File: TestAppender.java    From aliyun-log-logback-appender with Apache License 2.0 5 votes vote down vote up
private static void sleep() {
    ProducerConfig producerConfig = new ProducerConfig();
    try {
        Thread.sleep(2 * producerConfig.getLingerMs());
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}
 
Example #8
Source File: LogAccumulator.java    From aliyun-log-java-producer with Apache License 2.0 5 votes vote down vote up
private void ensureValidLogSize(int sizeInBytes) throws LogSizeTooLargeException {
  if (sizeInBytes > ProducerConfig.MAX_BATCH_SIZE_IN_BYTES) {
    throw new LogSizeTooLargeException(
        "the logs is "
            + sizeInBytes
            + " bytes which is larger than MAX_BATCH_SIZE_IN_BYTES "
            + ProducerConfig.MAX_BATCH_SIZE_IN_BYTES);
  }
  if (sizeInBytes > producerConfig.getTotalSizeInBytes()) {
    throw new LogSizeTooLargeException(
        "the logs is "
            + sizeInBytes
            + " bytes which is larger than the totalSizeInBytes you specified");
  }
}
 
Example #9
Source File: LoghubAppenderTest.java    From aliyun-log-log4j2-appender with Apache License 2.0 5 votes vote down vote up
private static void sleep() {
    ProducerConfig producerConfig = new ProducerConfig(new ProjectConfigs());
    try {
        Thread.sleep(2 * producerConfig.getLingerMs());
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}