/** * Construct a synchronous implementation of AmazonKinesisFirehose using the current builder configuration. * * @param params * Current builder configuration represented as a parameter object. * @return Fully configured implementation of AmazonKinesisFirehose. */ @Override protected AmazonKinesisFirehose build(AwsSyncClientParams params) { return new AmazonKinesisFirehoseClient(params); }
@SdkInternalApi final ListDeliveryStreamsResult executeListDeliveryStreams(ListDeliveryStreamsRequest listDeliveryStreamsRequest) { ExecutionContext executionContext = createExecutionContext(listDeliveryStreamsRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request<ListDeliveryStreamsRequest> request = null; Response<ListDeliveryStreamsResult> response = null; try { awsRequestMetrics.startEvent(Field.RequestMarshallTime); try { request = new ListDeliveryStreamsRequestProtocolMarshaller(protocolFactory).marshall(super.beforeMarshalling(listDeliveryStreamsRequest)); // Binds the request metrics to the current request. request.setAWSRequestMetrics(awsRequestMetrics); request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion()); request.addHandlerContext(HandlerContextKey.SERVICE_ID, "Firehose"); request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "ListDeliveryStreams"); request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig); } finally { awsRequestMetrics.endEvent(Field.RequestMarshallTime); } HttpResponseHandler<AmazonWebServiceResponse<ListDeliveryStreamsResult>> responseHandler = protocolFactory.createResponseHandler( new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new ListDeliveryStreamsResultJsonUnmarshaller()); response = invoke(request, responseHandler, executionContext); return response.getAwsResponse(); } finally { endClientExecution(awsRequestMetrics, request, response); } }
/** * Constructs a new client to invoke service methods on Firehose using the specified parameters. * * <p> * All service calls made using this new client object are blocking, and will not return until the service call * completes. * * @param clientParams * Object providing client parameters. */ AmazonKinesisFirehoseClient(AwsSyncClientParams clientParams, boolean endpointDiscoveryEnabled) { super(clientParams); this.awsCredentialsProvider = clientParams.getCredentialsProvider(); this.advancedConfig = clientParams.getAdvancedConfig(); init(); }
private void init() { setServiceNameIntern(DEFAULT_SIGNING_NAME); setEndpointPrefix(ENDPOINT_PREFIX); // calling this.setEndPoint(...) will also modify the signer accordingly setEndpoint("https://firehose.us-east-1.amazonaws.com"); HandlerChainFactory chainFactory = new HandlerChainFactory(); requestHandler2s.addAll(chainFactory.newRequestHandlerChain("/com/amazonaws/services/kinesisfirehose/request.handlers")); requestHandler2s.addAll(chainFactory.newRequestHandler2Chain("/com/amazonaws/services/kinesisfirehose/request.handler2s")); requestHandler2s.addAll(chainFactory.getGlobalHandlers()); }
@Override public void setConf(AbstractConfig config) { this.config = (FirehoseTransportConfig) config; this.serializer = new FirehoseTransportSerializer(this.config.getAppendNewline()); this.client = new AmazonKinesisFirehoseClient(new ClientConfiguration().withGzip(true)); if (this.config.getRegion() != null) { this.client.withRegion(this.config.getRegion()); } } }
putRecordBatchRequest.setDeliveryStreamName(streamName); putRecordBatchRequest.setRecords(records); PutRecordBatchResult results = client.putRecordBatch(putRecordBatchRequest);
@Override public void start(Map<String, String> props) { batch = Boolean.parseBoolean(props.get(FirehoseSinkConnector.BATCH)); batchSize = Integer.parseInt(props.get(FirehoseSinkConnector.BATCH_SIZE)); batchSizeInBytes = Integer.parseInt(props.get(FirehoseSinkConnector.BATCH_SIZE_IN_BYTES)); deliveryStreamName = props.get(FirehoseSinkConnector.DELIVERY_STREAM); firehoseClient = new AmazonKinesisFirehoseClient(new DefaultAWSCredentialsProviderChain()); firehoseClient.setRegion(RegionUtils.getRegion(props.get(FirehoseSinkConnector.REGION))); // Validate delivery stream validateDeliveryStream(); }
ExecutionContext executionContext = createExecutionContext(putRecordBatchRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); unmarshaller); response = invoke(request, responseHandler, executionContext); endClientExecution(awsRequestMetrics, request, response, LOGGING_AWS_REQUEST_METRIC);
/** * Constructs a new client to invoke service methods on * AmazonKinesisFirehose using the specified AWS account credentials * provider, client configuration options and request metric collector. * <p> * All service calls made using this new client object are blocking, and * will not return until the service call completes. * * @param awsCredentialsProvider The AWS credentials provider which will * provide credentials to authenticate requests with AWS * services. * @param clientConfiguration The client configuration options controlling * how this client connects to AmazonKinesisFirehose (ex: proxy * settings, retry counts, etc.). * @param httpClient A http client */ public AmazonKinesisFirehoseClient(AWSCredentialsProvider awsCredentialsProvider, ClientConfiguration clientConfiguration, HttpClient httpClient) { super(adjustClientConfiguration(clientConfiguration), httpClient); this.awsCredentialsProvider = awsCredentialsProvider; init(); }
/** * Normal invoke with authentication. Credentials are required and may be overriden at the request level. **/ private <X, Y extends AmazonWebServiceRequest> Response<X> invoke(Request<Y> request, HttpResponseHandler<AmazonWebServiceResponse<X>> responseHandler, ExecutionContext executionContext) { return invoke(request, responseHandler, executionContext, null, null); }
private void init() { jsonErrorUnmarshallers = new ArrayList<JsonErrorUnmarshaller>(); jsonErrorUnmarshallers.add(new InvalidArgumentExceptionUnmarshaller()); jsonErrorUnmarshallers.add(new ResourceNotFoundExceptionUnmarshaller()); jsonErrorUnmarshallers.add(new ServiceUnavailableExceptionUnmarshaller()); jsonErrorUnmarshallers.add(new JsonErrorUnmarshaller()); // calling this.setEndPoint(...) will also modify the signer accordingly this.setEndpoint("firehose.us-east-1.amazonaws.com"); this.endpointPrefix = "firehose"; HandlerChainFactory chainFactory = new HandlerChainFactory(); requestHandler2s.addAll(chainFactory.newRequestHandlerChain( "/com/amazonaws/services/kinesisfirehose/request.handlers")); requestHandler2s.addAll(chainFactory.newRequestHandler2Chain( "/com/amazonaws/services/kinesisfirehose/request.handler2s")); }
@Override public void setConf(AbstractConfig config) { this.config = (FirehoseTransportConfig) config; this.serializer = new FirehoseTransportSerializer(this.config.getAppendNewline()); this.client = new AmazonKinesisFirehoseClient(new ClientConfiguration().withGzip(true)); if (this.config.getRegion() != null) { this.client.withRegion(this.config.getRegion()); } } }
/** * Method to perform PutRecordBatch operation with the given record list. * * @param recordList * the collection of records * @return the output of PutRecordBatch */ private PutRecordBatchResult putRecordBatch(List<Record> recordList) { PutRecordBatchRequest putRecordBatchRequest = new PutRecordBatchRequest(); putRecordBatchRequest.setDeliveryStreamName(deliveryStreamName); putRecordBatchRequest.setRecords(recordList); // Put Record Batch records. Max No.Of Records we can put in a // single put record batch request is 500 and total size < 4MB PutRecordBatchResult putRecordBatchResult = null; try { putRecordBatchResult = firehoseClient.putRecordBatch(putRecordBatchRequest); }catch(AmazonKinesisFirehoseException akfe){ System.out.println("Amazon Kinesis Firehose Exception:" + akfe.getLocalizedMessage()); }catch(Exception e){ System.out.println("Connector Exception" + e.getLocalizedMessage()); } return putRecordBatchResult; }
private void init() { setServiceNameIntern(DEFAULT_SIGNING_NAME); setEndpointPrefix(ENDPOINT_PREFIX); // calling this.setEndPoint(...) will also modify the signer accordingly setEndpoint("https://firehose.us-east-1.amazonaws.com"); HandlerChainFactory chainFactory = new HandlerChainFactory(); requestHandler2s.addAll(chainFactory.newRequestHandlerChain("/com/amazonaws/services/kinesisfirehose/request.handlers")); requestHandler2s.addAll(chainFactory.newRequestHandler2Chain("/com/amazonaws/services/kinesisfirehose/request.handler2s")); requestHandler2s.addAll(chainFactory.getGlobalHandlers()); }
/** * Constructs a new client to invoke service methods on * AmazonKinesisFirehose using the specified AWS account credentials * provider, client configuration options and request metric collector. * <p> * All service calls made using this new client object are blocking, and * will not return until the service call completes. * * @param awsCredentialsProvider The AWS credentials provider which will * provide credentials to authenticate requests with AWS * services. * @param clientConfiguration The client configuration options controlling * how this client connects to AmazonKinesisFirehose (ex: proxy * settings, retry counts, etc.). * @param requestMetricCollector optional request metric collector */ @Deprecated public AmazonKinesisFirehoseClient(AWSCredentialsProvider awsCredentialsProvider, ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector) { super(adjustClientConfiguration(clientConfiguration), requestMetricCollector); this.awsCredentialsProvider = awsCredentialsProvider; init(); }
/** * Normal invoke with authentication. Credentials are required and may be overriden at the request level. **/ private <X, Y extends AmazonWebServiceRequest> Response<X> invoke(Request<Y> request, HttpResponseHandler<AmazonWebServiceResponse<X>> responseHandler, ExecutionContext executionContext) { return invoke(request, responseHandler, executionContext, null, null); }
@SdkInternalApi final StopDeliveryStreamEncryptionResult executeStopDeliveryStreamEncryption(StopDeliveryStreamEncryptionRequest stopDeliveryStreamEncryptionRequest) { ExecutionContext executionContext = createExecutionContext(stopDeliveryStreamEncryptionRequest); AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics(); awsRequestMetrics.startEvent(Field.ClientExecuteTime); Request<StopDeliveryStreamEncryptionRequest> request = null; Response<StopDeliveryStreamEncryptionResult> response = null; try { awsRequestMetrics.startEvent(Field.RequestMarshallTime); try { request = new StopDeliveryStreamEncryptionRequestProtocolMarshaller(protocolFactory).marshall(super .beforeMarshalling(stopDeliveryStreamEncryptionRequest)); // Binds the request metrics to the current request. request.setAWSRequestMetrics(awsRequestMetrics); request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion()); request.addHandlerContext(HandlerContextKey.SERVICE_ID, "Firehose"); request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "StopDeliveryStreamEncryption"); request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig); } finally { awsRequestMetrics.endEvent(Field.RequestMarshallTime); } HttpResponseHandler<AmazonWebServiceResponse<StopDeliveryStreamEncryptionResult>> responseHandler = protocolFactory.createResponseHandler( new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false), new StopDeliveryStreamEncryptionResultJsonUnmarshaller()); response = invoke(request, responseHandler, executionContext); return response.getAwsResponse(); } finally { endClientExecution(awsRequestMetrics, request, response); } }
/** * Create client using AWSCredentails * * @deprecated use {@link #createClient(ProcessContext, AWSCredentialsProvider, ClientConfiguration)} instead */ @Deprecated @Override protected AmazonKinesisFirehoseClient createClient(final ProcessContext context, final AWSCredentials credentials, final ClientConfiguration config) { getLogger().info("Creating client using aws credentials"); return new AmazonKinesisFirehoseClient(credentials, config); } }
public void sendBatch(TransportBuffer buffer) { FirehoseTransportBuffer tb = (FirehoseTransportBuffer) buffer; /* * Create batch put request with given records */ PutRecordBatchRequest batch = new PutRecordBatchRequest() .withDeliveryStreamName(this.deliveryStreamName).withRecords(tb.getInternalBuffer()); /* * Put recored */ client.putRecordBatch(batch); } }
/** * Constructs a new client to invoke service methods on Firehose using the specified AWS account credentials * provider, client configuration options, and request metric collector. * * <p> * All service calls made using this new client object are blocking, and will not return until the service call * completes. * * @param awsCredentialsProvider * The AWS credentials provider which will provide credentials to authenticate requests with AWS services. * @param clientConfiguration * The client configuration options controlling how this client connects to Firehose (ex: proxy settings, * retry counts, etc.). * @param requestMetricCollector * optional request metric collector * @deprecated use {@link AmazonKinesisFirehoseClientBuilder#withCredentials(AWSCredentialsProvider)} and * {@link AmazonKinesisFirehoseClientBuilder#withClientConfiguration(ClientConfiguration)} and * {@link AmazonKinesisFirehoseClientBuilder#withMetricsCollector(RequestMetricCollector)} */ @Deprecated public AmazonKinesisFirehoseClient(AWSCredentialsProvider awsCredentialsProvider, ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector) { super(clientConfiguration, requestMetricCollector); this.awsCredentialsProvider = awsCredentialsProvider; this.advancedConfig = AdvancedConfig.EMPTY; init(); }