Example usage for com.amazonaws.services.kinesisfirehose.model DescribeDeliveryStreamResult getDeliveryStreamDescription

List of usage examples for com.amazonaws.services.kinesisfirehose.model DescribeDeliveryStreamResult getDeliveryStreamDescription

Introduction

In this page you can find the example usage for com.amazonaws.services.kinesisfirehose.model DescribeDeliveryStreamResult getDeliveryStreamDescription.

Prototype


public DeliveryStreamDescription getDeliveryStreamDescription() 

Source Link

Document

Information about the delivery stream.

Usage

From source file:AbstractAmazonKinesisFirehoseDelivery.java

License:Open Source License

/**
 * Method to describe the delivery stream.
 *
 * @param deliveryStreamName the delivery stream
 * @return the delivery description// www . j  a  va  2s. c o m
 */
protected static DeliveryStreamDescription describeDeliveryStream(String deliveryStreamName) {
    DescribeDeliveryStreamRequest describeDeliveryStreamRequest = new DescribeDeliveryStreamRequest();
    describeDeliveryStreamRequest.withDeliveryStreamName(deliveryStreamName);
    DescribeDeliveryStreamResult describeDeliveryStreamResponse = firehoseClient
            .describeDeliveryStream(describeDeliveryStreamRequest);
    return describeDeliveryStreamResponse.getDeliveryStreamDescription();
}

From source file:ch.bbv.application.lambda.KinesisToFirehose.java

private void checkHoseStatus() {
    DescribeDeliveryStreamRequest describeHoseRequest = new DescribeDeliveryStreamRequest()
            .withDeliveryStreamName(deliveryStreamName);
    DescribeDeliveryStreamResult describeHoseResult = null;
    String status = "UNDEFINED";
    try {//from   ww w  .  j  ava 2 s  . c  om
        describeHoseResult = firehoseClient.describeDeliveryStream(describeHoseRequest);
        status = describeHoseResult.getDeliveryStreamDescription().getDeliveryStreamStatus();
    } catch (Exception e) {
        System.out.println(e.getLocalizedMessage());
        logIt("Firehose Not Existent...will create");
        createFirehose();
        checkHoseStatus();
    }
    if (status.equalsIgnoreCase("ACTIVE")) {
        logIt("Firehose ACTIVE");
        //return;
    } else if (status.equalsIgnoreCase("CREATING")) {
        logIt("Firehose CREATING");
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        checkHoseStatus();
    } else {
        logIt("Status = " + status);
    }
}

From source file:com.gu.logback.appender.kinesis.FirehoseAppender.java

License:Open Source License

@Override
protected void validateStreamName(AmazonKinesisFirehoseAsyncClient client, String streamName) {
    DescribeDeliveryStreamResult describeResult = null;
    try {/* w w w .j a  va2 s  .com*/
        describeResult = getClient()
                .describeDeliveryStream(new DescribeDeliveryStreamRequest().withDeliveryStreamName(streamName));
        String streamStatus = describeResult.getDeliveryStreamDescription().getDeliveryStreamStatus();
        if (!DeliveryStreamStatus.ACTIVE.name().equals(streamStatus)) {
            setInitializationFailed(true);
            addError("Stream " + streamName + " is not ready (in active status) for appender: " + name);
        }
    } catch (ResourceNotFoundException rnfe) {
        setInitializationFailed(true);
        addError("Stream " + streamName + " doesn't exist for appender: " + name, rnfe);
    }
}

From source file:com.tcl.gateway.firehose.log4j.FirehoseAppender.java

License:Open Source License

/**
 * 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.
 * // ww  w  .j ava2 s  .co m
 * 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 (deliveryStreamName == 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);

    final 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();
    firehoseClient = new AmazonKinesisFirehoseAsyncClient(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
                    + ")");
        }
        firehoseClient.setEndpoint(endpoint);
    } else {
        firehoseClient.setRegion(Region.getRegion(Regions.fromName(region)));
    }

    DescribeDeliveryStreamResult describeResult = null;
    try {
        describeResult = firehoseClient.describeDeliveryStream(
                new DescribeDeliveryStreamRequest().withDeliveryStreamName(deliveryStreamName));
        String streamStatus = describeResult.getDeliveryStreamDescription().getDeliveryStreamStatus();
        if (!StreamStatus.ACTIVE.name().equals(streamStatus)
                && !StreamStatus.UPDATING.name().equals(streamStatus)) {
            initializationFailed = true;
            error("Delivery Stream " + deliveryStreamName
                    + " is not ready (in active/updating status) for appender: " + name);
        }
    } catch (ResourceNotFoundException rnfe) {
        initializationFailed = true;
        error("Delivery  Stream " + deliveryStreamName + " doesn't exist for appender: " + name, rnfe);
    }

    asyncCallHander = new AsyncPutCallStatsReporter(name);

    if (metric) {
        MetricRegistry registry = new MetricRegistry();
        registry.register("Gauge", new Gauge<Integer>() {

            @Override
            public Integer getValue() {
                return taskBuffer.size();
            }

        });

        ConsoleReporter.forRegistry(registry).build().start(3, TimeUnit.SECONDS);
    }
}