• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AmazonKinesisAsyncClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.amazonaws.services.kinesis.AmazonKinesisAsyncClient的典型用法代码示例。如果您正苦于以下问题:Java AmazonKinesisAsyncClient类的具体用法?Java AmazonKinesisAsyncClient怎么用?Java AmazonKinesisAsyncClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AmazonKinesisAsyncClient类属于com.amazonaws.services.kinesis包,在下文中一共展示了AmazonKinesisAsyncClient类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: validateStreamName

import com.amazonaws.services.kinesis.AmazonKinesisAsyncClient; //导入依赖的package包/类
@Override
protected void validateStreamName(AmazonKinesisAsyncClient client, String streamName) {
  DescribeStreamResult describeResult = null;
  try {
    describeResult = getClient().describeStream(streamName);
    String streamStatus = describeResult.getStreamDescription().getStreamStatus();
    if(!StreamStatus.ACTIVE.name().equals(streamStatus) && !StreamStatus.UPDATING.name().equals(streamStatus)) {
      setInitializationFailed(true);
      addError("Stream " + streamName + " is not ready (in active/updating status) for appender: " + name);
    }
  }
  catch(ResourceNotFoundException rnfe) {
    setInitializationFailed(true);
    addError("Stream " + streamName + " doesn't exist for appender: " + name, rnfe);
  }
}
 
开发者ID:guardian,项目名称:kinesis-logback-appender,代码行数:17,代码来源:KinesisAppender.java


示例2: createClient

import com.amazonaws.services.kinesis.AmazonKinesisAsyncClient; //导入依赖的package包/类
private AmazonKinesisAsyncClient createClient() {

        // Building Kinesis configuration
        int connectionTimeout = ClientConfiguration.DEFAULT_CONNECTION_TIMEOUT;
        int maxConnection = ClientConfiguration.DEFAULT_MAX_CONNECTIONS;

        RetryPolicy retryPolicy = ClientConfiguration.DEFAULT_RETRY_POLICY;
        int socketTimeout = ClientConfiguration.DEFAULT_SOCKET_TIMEOUT;
        boolean useReaper = ClientConfiguration.DEFAULT_USE_REAPER;
        String userAgent = ClientConfiguration.DEFAULT_USER_AGENT;

        ClientConfiguration clientConfiguration = new ClientConfiguration();
        clientConfiguration.setConnectionTimeout(connectionTimeout);
        clientConfiguration.setMaxConnections(maxConnection);
        clientConfiguration.setRetryPolicy(retryPolicy);
        clientConfiguration.setSocketTimeout(socketTimeout);
        clientConfiguration.setUseReaper(useReaper);
        clientConfiguration.setUserAgent(userAgent);

        // Reading credentials from ENV-variables
        AWSCredentialsProvider awsCredentialsProvider = new DefaultAWSCredentialsProviderChain();

        // Configuring Kinesis-client with configuration
        AmazonKinesisAsyncClient kinesisAsyncClient = new AmazonKinesisAsyncClient(awsCredentialsProvider, clientConfiguration);
        Regions myRegion = Regions.fromName(AmazonUtil.getInstance().getRegion());
        kinesisAsyncClient.withRegion(Region.getRegion(myRegion));

        return kinesisAsyncClient;
    }
 
开发者ID:SaschaMoellering,项目名称:ingestion-service,代码行数:30,代码来源:KinesisVerticle.java


示例3: AWSKinesisEventStore

import com.amazonaws.services.kinesis.AmazonKinesisAsyncClient; //导入依赖的package包/类
@Inject
public AWSKinesisEventStore(AWSConfig config,
                            Metastore metastore,
                            FieldDependency fieldDependency) {
    kinesis = new AmazonKinesisAsyncClient(config.getCredentials());
    kinesis.setRegion(config.getAWSRegion());
    if (config.getKinesisEndpoint() != null) {
        kinesis.setEndpoint(config.getKinesisEndpoint());
    }
    this.config = config;
    this.bulkClient = new S3BulkEventStore(metastore, config, fieldDependency);

    KinesisProducerConfiguration producerConfiguration = new KinesisProducerConfiguration()
            .setRegion(config.getRegion())
            .setCredentialsProvider(config.getCredentials());
    if (config.getKinesisEndpoint() != null) {
        try {
            URL url = new URL(config.getKinesisEndpoint());
            producerConfiguration.setKinesisEndpoint(url.getHost());
            producerConfiguration.setKinesisPort(url.getPort());
            producerConfiguration.setVerifyCertificate(false);
        } catch (MalformedURLException e) {
            throw new IllegalStateException(String.format("Kinesis endpoint is invalid: %s", config.getKinesisEndpoint()));
        }
    }
    producer = new KinesisProducer(producerConfiguration);
}
 
开发者ID:rakam-io,项目名称:rakam,代码行数:28,代码来源:AWSKinesisEventStore.java


示例4: doStart

import com.amazonaws.services.kinesis.AmazonKinesisAsyncClient; //导入依赖的package包/类
@Override
protected void doStart() {
    kinesis = new AmazonKinesisAsyncClient(
            getCredentials(),
            getClientConfiguration(),
            AppenderExecutors.newExecutor(this, getThreadPoolSize())
    );
    kinesis.setRegion(RegionUtils.getRegion(region));
}
 
开发者ID:trautonen,项目名称:logback-ext,代码行数:10,代码来源:KinesisAppender.java


示例5: open

import com.amazonaws.services.kinesis.AmazonKinesisAsyncClient; //导入依赖的package包/类
@Override
public void open(VDSConfiguration ctx) throws Exception {
    String accessID = ctx.getString(ACCESS_KEY);
    String secretKey = ctx.getString(SECRET_KEY);
    _streamName = ctx.getString(STREAM_NAME);
    int tcount = ctx.optInt(THREAD_COUNT, 5);
    _threadpool = new ThreadPoolExecutor(tcount, tcount, 10, 
        TimeUnit.SECONDS, new ArrayBlockingQueue(100),new ThreadPoolExecutor.CallerRunsPolicy()); // TODO: make the queue length configurable        
    BasicAWSCredentials creds = new BasicAWSCredentials(accessID, secretKey);
    _client = new AmazonKinesisAsyncClient(creds, _threadpool);
    _scheduler.scheduleAtFixedRate(_callback, 10, 10, TimeUnit.SECONDS); // TODO: make this configurable?
    
    _logger.info("Created connection to AWS Kinesis");
    _logger.info("Stream name: " + _streamName);
}
 
开发者ID:InformaticaCorp,项目名称:Surf,代码行数:16,代码来源:KinesisTarget.java


示例6: createClient

import com.amazonaws.services.kinesis.AmazonKinesisAsyncClient; //导入依赖的package包/类
private AmazonKinesisAsync createClient(ClientConfiguration config,
                                         MapWrap configuration) {


    AmazonKinesisAsync kinesisClient = new AmazonKinesisAsyncClient(getAwsCredentialsProvider(
            configuration, config), config, Executors.newFixedThreadPool(config.getMaxConnections(),
            new ThreadFactoryBuilder().setNameFormat("lumbermill-async-kinesis-%d").build()));

    Regions region = Regions.fromName(configuration.asString("region", "eu-west-1"));
    kinesisClient.setRegion(Region.getRegion(region));
    if (configuration.exists("endpoint")) {

        String endpoint = configuration.asString("endpoint");
        if (endpoint.length() > 0) {
            kinesisClient.setEndpoint(endpoint);
        }
    }



    return kinesisClient;
}
 
开发者ID:sonyxperiadev,项目名称:lumber-mill,代码行数:23,代码来源:KinesisClientFactory.java


示例7: createClient

import com.amazonaws.services.kinesis.AmazonKinesisAsyncClient; //导入依赖的package包/类
@Override
protected AmazonKinesisAsyncClient createClient(AWSCredentialsProvider credentials, ClientConfiguration configuration,
    ThreadPoolExecutor executor) {
  return new AmazonKinesisAsyncClient(credentials, configuration, executor);
}
 
开发者ID:guardian,项目名称:kinesis-logback-appender,代码行数:6,代码来源:KinesisAppender.java


示例8: createClient

import com.amazonaws.services.kinesis.AmazonKinesisAsyncClient; //导入依赖的package包/类
private AmazonKinesisAsyncClient createClient() {

		// Building Kinesis configuration
		int connectionTimeout = getOptionalIntConfig(CONNECTION_TIMEOUT, ClientConfiguration.DEFAULT_CONNECTION_TIMEOUT);
		int maxConnection = getOptionalIntConfig(MAX_CONNECTION, ClientConfiguration.DEFAULT_MAX_CONNECTIONS);

		// TODO: replace default retry policy
		RetryPolicy retryPolicy = ClientConfiguration.DEFAULT_RETRY_POLICY;
		int socketTimeout = getOptionalIntConfig(SOCKET_TIMEOUT, ClientConfiguration.DEFAULT_SOCKET_TIMEOUT);
		boolean useReaper = getOptionalBooleanConfig(USE_REAPER, ClientConfiguration.DEFAULT_USE_REAPER);
		String userAgent = getOptionalStringConfig(USER_AGENT, ClientConfiguration.DEFAULT_USER_AGENT);
		String endpoint = getOptionalStringConfig(ENDPOINT, null);


		streamName = getMandatoryStringConfig(STREAM_NAME);
		partitionKey = getMandatoryStringConfig(PARTITION_KEY);
		region = getMandatoryStringConfig(REGION);

		logger.info(" --- Stream name: " + streamName);
		logger.info(" --- Partition key: " + partitionKey);
		logger.info(" --- Region: " + region);
		if(endpoint != null) {
			logger.info(" --- Endpoint: " + endpoint);
		}

		ClientConfiguration clientConfiguration = new ClientConfiguration();
		clientConfiguration.setConnectionTimeout(connectionTimeout);
		clientConfiguration.setMaxConnections(maxConnection);
		clientConfiguration.setRetryPolicy(retryPolicy);
		clientConfiguration.setSocketTimeout(socketTimeout);
		clientConfiguration.setUseReaper(useReaper);
		clientConfiguration.setUserAgent(userAgent);

		/*
		AWS credentials provider chain that looks for credentials in this order:
			Environment Variables - AWS_ACCESS_KEY_ID and AWS_SECRET_KEY
			Java System Properties - aws.accessKeyId and aws.secretKey
			Credential profiles file at the default location (~/.aws/credentials) shared by all AWS SDKs and the AWS CLI
			Instance profile credentials delivered through the Amazon EC2 metadata service
		*/

		AWSCredentialsProvider awsCredentialsProvider = new DefaultAWSCredentialsProviderChain();

		// Configuring Kinesis-client with configuration
		AmazonKinesisAsyncClient kinesisAsyncClient = new AmazonKinesisAsyncClient(awsCredentialsProvider, clientConfiguration);
		Region awsRegion = RegionUtils.getRegion(region);
		kinesisAsyncClient.setRegion(awsRegion);
		if(endpoint != null) {
			kinesisAsyncClient.setEndpoint(endpoint);
		}

		return kinesisAsyncClient;
	}
 
开发者ID:awin,项目名称:mod-kinesis,代码行数:54,代码来源:KinesisMessageProcessor.java


示例9: activateOptions

import com.amazonaws.services.kinesis.AmazonKinesisAsyncClient; //导入依赖的package包/类
/**
  * Configures this appender instance and makes it ready for use by the
  * consumers. It validates mandatory parameters and confirms if the configured
  * stream is ready for publishing data yet.
  * 
  * Error details are made available through the fallback handler for this
  * appender
  * 
  * @throws IllegalStateException
  *           if we encounter issues configuring this appender instance
  */
 @Override
 public void activateOptions() {
   if (streamName == null) {
     initializationFailed = true;
     error("Invalid configuration - streamName cannot be null for appender: " + name);
   }

   if (layout == null) {
     initializationFailed = true;
     error("Invalid configuration - No layout for appender: " + name);
   }

   ClientConfiguration clientConfiguration = new ClientConfiguration();
   clientConfiguration = setProxySettingsFromSystemProperties(clientConfiguration);

   clientConfiguration.setMaxErrorRetry(maxRetries);
   clientConfiguration.setRetryPolicy(new RetryPolicy(PredefinedRetryPolicies.DEFAULT_RETRY_CONDITION,
       PredefinedRetryPolicies.DEFAULT_BACKOFF_STRATEGY, maxRetries, true));
   clientConfiguration.setUserAgent(AppenderConstants.USER_AGENT_STRING);

   BlockingQueue<Runnable> taskBuffer = new LinkedBlockingDeque<Runnable>(bufferSize);
   ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(threadCount, threadCount,
       AppenderConstants.DEFAULT_THREAD_KEEP_ALIVE_SEC, TimeUnit.SECONDS, taskBuffer, new BlockFastProducerPolicy());
   threadPoolExecutor.prestartAllCoreThreads();
   kinesisClient = new AmazonKinesisAsyncClient(new CustomCredentialsProviderChain(), clientConfiguration,
       threadPoolExecutor);

   boolean regionProvided = !Validator.isBlank(region);
   if (!regionProvided) {
     region = AppenderConstants.DEFAULT_REGION;
   }
   if (!Validator.isBlank(endpoint)) {
     if (regionProvided) {
LOGGER
    .warn("Received configuration for both region as well as Amazon Kinesis endpoint. ("
	+ endpoint
	+ ") will be used as endpoint instead of default endpoint for region ("
	+ region + ")");
     }
     kinesisClient.setEndpoint(endpoint,
  AppenderConstants.DEFAULT_SERVICE_NAME, region);
   } else {
     kinesisClient.setRegion(Region.getRegion(Regions.fromName(region)));
   }

   DescribeStreamResult describeResult = null;
   try {
     describeResult = kinesisClient.describeStream(streamName);
     String streamStatus = describeResult.getStreamDescription().getStreamStatus();
     if (!StreamStatus.ACTIVE.name().equals(streamStatus) && !StreamStatus.UPDATING.name().equals(streamStatus)) {
       initializationFailed = true;
       error("Stream " + streamName + " is not ready (in active/updating status) for appender: " + name);
     }
   } catch (ResourceNotFoundException rnfe) {
     initializationFailed = true;
     error("Stream " + streamName + " doesn't exist for appender: " + name, rnfe);
   }

   asyncCallHander = new AsyncPutCallStatsReporter(name);
 }
 
开发者ID:awslabs,项目名称:kinesis-log4j-appender,代码行数:72,代码来源:KinesisAppender.java



注:本文中的com.amazonaws.services.kinesis.AmazonKinesisAsyncClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CstNat类代码示例发布时间:2022-05-23
下一篇:
Java DirectoryListingStartAfterNotFoundException类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap