Container for the parameters to the CreateStream operation.

This operation adds a new Amazon Kinesis stream to your AWS account. A stream captures and transports data records that are continuously emitted from different data sources or producers . Scale-out within an Amazon Kinesis stream is explicitly supported by means of shards, which are uniquely identified groups of data records in an Amazon Kinesis stream.

You specify and control the number of shards that a stream is composed of. Each shard can support up to 5 read transactions per second up to a maximum total of 2 MB of data read per second. Each shard can support up to 1000 write transactions per second up to a maximum total of 1 MB data written per second. You can add shards to a stream if the amount of data input increases and you can remove shards if the amount of data input decreases.

The stream name identifies the stream. The name is scoped to the AWS account used by the application. It is also scoped by region. That is, two streams in two different accounts can have the same name, and two streams in the same account, but in two different regions, can have the same name.

CreateStream is an asynchronous operation. Upon receiving a CreateStream request, Amazon Kinesis immediately returns and sets the stream status to CREATING. After the stream is created, Amazon Kinesis sets the stream status to ACTIVE. You should perform read and write operations only on an ACTIVE stream.

You receive a LimitExceededException when making a CreateStream request if you try to do one of the following:

  • Have more than five streams in the CREATING state at any point in time.
  • Create more shards than are authorized for your account.

Note: The default limit for an AWS account is two shards per stream. If you need to create a stream with more than two shards, contact AWS Support to increase the limit on your account.

You can use the DescribeStream operation to check the stream status, which is returned in StreamStatus .

CreateStream has a limit of 5 transactions per second per account.

Inheritance: AmazonKinesisRequest
        /// <summary>
        /// This method verifies your credentials, creates a Kinesis stream, waits for the stream
        /// to become active, then puts 10 records in it, and (optionally) deletes the stream.
        /// </summary>
        public static void Main(string[] args)
        {
            const string myStreamName = "myTestStream";
            const int myStreamSize = 1;

            try
            {
                var createStreamRequest = new CreateStreamRequest();
                createStreamRequest.StreamName = myStreamName;
                createStreamRequest.ShardCount = myStreamSize;
                var createStreamReq = createStreamRequest;
                kinesisClient.CreateStream(createStreamReq);
                Console.Error.WriteLine("Created Stream : " + myStreamName);
            }
            catch (ResourceInUseException)
            {
                Console.Error.WriteLine("Producer is quitting without creating stream " + myStreamName +
                    " to put records into as a stream of the same name already exists.");
                Environment.Exit(1);
            }

            WaitForStreamToBecomeAvailable(myStreamName);

            Console.Error.WriteLine("Putting records in stream : " + myStreamName);
            // Write 10 UTF-8 encoded records to the stream.
            for (int j = 0; j < 10; ++j)
            {
                PutRecordRequest requestRecord = new PutRecordRequest();
                requestRecord.StreamName = myStreamName;
                requestRecord.Data = new MemoryStream(Encoding.UTF8.GetBytes("testData-" + j));
                requestRecord.PartitionKey = "partitionKey-" + j;
                PutRecordResult putResult = kinesisClient.PutRecord(requestRecord);
                Console.Error.WriteLine(
                    String.Format("Successfully putrecord {0}:\n\t partition key = {1,15}, shard ID = {2}",
                        j, requestRecord.PartitionKey, putResult.ShardId));
            }

            // Uncomment the following if you wish to delete the stream here.
            //Console.Error.WriteLine("Deleting stream : " + myStreamName);
            //DeleteStreamRequest deleteStreamReq = new DeleteStreamRequest();
            //deleteStreamReq.StreamName = myStreamName;
            //try
            //{
            //    kinesisClient.DeleteStream(deleteStreamReq);
            //    Console.Error.WriteLine("Stream is now being deleted : " + myStreamName);
            //}
            //catch (ResourceNotFoundException ex)
            //
            //    Console.Error.WriteLine("Stream could not be found; " + ex);
            //}
            //catch (AmazonClientException ex)
            //{
            //    Console.Error.WriteLine("Error deleting stream; " + ex);
            //}
        }
Example #2
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.Kinesis.Model.CreateStreamRequest();

            if (cmdletContext.ShardCount != null)
            {
                request.ShardCount = cmdletContext.ShardCount.Value;
            }

            // populate StreamModeDetails
            var requestStreamModeDetailsIsNull = true;

            request.StreamModeDetails = new Amazon.Kinesis.Model.StreamModeDetails();
            Amazon.Kinesis.StreamMode requestStreamModeDetails_streamModeDetails_StreamMode = null;
            if (cmdletContext.StreamModeDetails_StreamMode != null)
            {
                requestStreamModeDetails_streamModeDetails_StreamMode = cmdletContext.StreamModeDetails_StreamMode;
            }
            if (requestStreamModeDetails_streamModeDetails_StreamMode != null)
            {
                request.StreamModeDetails.StreamMode = requestStreamModeDetails_streamModeDetails_StreamMode;
                requestStreamModeDetailsIsNull       = false;
            }
            // determine if request.StreamModeDetails should be set to null
            if (requestStreamModeDetailsIsNull)
            {
                request.StreamModeDetails = null;
            }
            if (cmdletContext.StreamName != null)
            {
                request.StreamName = cmdletContext.StreamName;
            }

            CmdletOutput output;

            // issue call
            var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint);

            try
            {
                var    response       = CallAWSServiceOperation(client, request);
                object pipelineOutput = null;
                pipelineOutput = cmdletContext.Select(response, this);
                output         = new CmdletOutput
                {
                    PipelineOutput  = pipelineOutput,
                    ServiceResponse = response
                };
            }
            catch (Exception e)
            {
                output = new CmdletOutput {
                    ErrorResponse = e
                };
            }

            return(output);
        }
Example #3
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.Kinesis.Model.CreateStreamRequest();

            if (cmdletContext.ShardCount != null)
            {
                request.ShardCount = cmdletContext.ShardCount.Value;
            }
            if (cmdletContext.StreamName != null)
            {
                request.StreamName = cmdletContext.StreamName;
            }

            CmdletOutput output;

            // issue call
            var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint);

            try
            {
                var    response       = CallAWSServiceOperation(client, request);
                object pipelineOutput = null;
                pipelineOutput = cmdletContext.Select(response, this);
                output         = new CmdletOutput
                {
                    PipelineOutput  = pipelineOutput,
                    ServiceResponse = response
                };
            }
            catch (Exception e)
            {
                output = new CmdletOutput {
                    ErrorResponse = e
                };
            }

            return(output);
        }
        /// <summary>
        /// <para>This operation adds a new Amazon Kinesis stream to your AWS account. A stream captures and transports data records that are
        /// continuously emitted from different data sources or <i>producers</i> .
        /// Scale-out within an Amazon Kinesis stream is explicitly supported by means of shards, which are uniquely identified groups of
        /// data records in an Amazon Kinesis stream.</para> <para>You specify and control the number of shards that a stream is composed of. Each shard
        /// can support up to 5 read transactions per second up to a maximum total of 2 MB of data read per second. Each shard can support up to 1000
        /// write transactions per second up to a maximum total of 1 MB data written per second. You can add shards to a stream if the amount of data
        /// input increases and you can remove shards if the amount of data input decreases.</para> <para>The stream name identifies the stream. The
        /// name is scoped to the AWS account used by the application. It is also scoped by region. That is, two streams in two different accounts can
        /// have the same name, and two streams in the same account, but in two different regions, can have the same name. </para> <para>
        /// <c>CreateStream</c> is an asynchronous operation. Upon receiving a <c>CreateStream</c> request, Amazon Kinesis immediately returns and sets
        /// the stream status to CREATING. After the stream is created, Amazon Kinesis sets the stream status to ACTIVE. You should perform read and
        /// write operations only on an ACTIVE stream. </para> <para>You receive a <c>LimitExceededException</c> when making a <c>CreateStream</c>
        /// request if you try to do one of the following:</para>
        /// <ul>
        /// <li>Have more than five streams in the CREATING state at any point in time.</li>
        /// <li>Create more shards than are authorized for your account.</li>
        /// 
        /// </ul>
        /// <para> <b>Note:</b> The default limit for an AWS account is two shards per stream. If you need to create a stream with more than two
        /// shards, contact AWS Support to increase the limit on your account.</para> <para>You can use the <c>DescribeStream</c> operation to check the
        /// stream status, which is returned in <c>StreamStatus</c> .</para> <para> <c>CreateStream</c> has a limit of 5 transactions per second per
        /// account.</para>
        /// </summary>
        /// 
        /// <param name="createStreamRequest">Container for the necessary parameters to execute the CreateStream service method on
        /// AmazonKinesis.</param>
        /// 
        /// <exception cref="T:Amazon.Kinesis.Model.LimitExceededException" />
        /// <exception cref="T:Amazon.Kinesis.Model.ResourceInUseException" />
        /// <exception cref="T:Amazon.Kinesis.Model.InvalidArgumentException" />
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
		public Task<CreateStreamResponse> CreateStreamAsync(CreateStreamRequest createStreamRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new CreateStreamRequestMarshaller();
            var unmarshaller = CreateStreamResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, CreateStreamRequest, CreateStreamResponse>(createStreamRequest, marshaller, unmarshaller, signer, cancellationToken);
        }
		internal CreateStreamResponse CreateStream(CreateStreamRequest request)
        {
            var task = CreateStreamAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                throw e.InnerException;
            }
        }
        /// <summary>
        /// Initiates the asynchronous execution of the CreateStream operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the CreateStream operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task<CreateStreamResponse> CreateStreamAsync(CreateStreamRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new CreateStreamRequestMarshaller();
            var unmarshaller = CreateStreamResponseUnmarshaller.Instance;

            return InvokeAsync<CreateStreamRequest,CreateStreamResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
        internal CreateStreamResponse CreateStream(CreateStreamRequest request)
        {
            var marshaller = new CreateStreamRequestMarshaller();
            var unmarshaller = CreateStreamResponseUnmarshaller.Instance;

            return Invoke<CreateStreamRequest,CreateStreamResponse>(request, marshaller, unmarshaller);
        }
        /// <summary>
        /// Initiates the asynchronous execution of the CreateStream operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the CreateStream operation on AmazonKinesisClient.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        /// 
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndCreateStream
        ///         operation.</returns>
        public IAsyncResult BeginCreateStream(CreateStreamRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new CreateStreamRequestMarshaller();
            var unmarshaller = CreateStreamResponseUnmarshaller.Instance;

            return BeginInvoke<CreateStreamRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
Example #9
0
 private Amazon.Kinesis.Model.CreateStreamResponse CallAWSServiceOperation(IAmazonKinesis client, Amazon.Kinesis.Model.CreateStreamRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Kinesis", "CreateStream");
     try
     {
         #if DESKTOP
         return(client.CreateStream(request));
         #elif CORECLR
         return(client.CreateStreamAsync(request).GetAwaiter().GetResult());
         #else
                 #error "Unknown build edition"
         #endif
     }
     catch (AmazonServiceException exc)
     {
         var webException = exc.InnerException as System.Net.WebException;
         if (webException != null)
         {
             throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException);
         }
         throw;
     }
 }
        /// <summary>
        /// <para>This operation adds a new Amazon Kinesis stream to your AWS account. A stream captures and transports data records that are
        /// continuously emitted from different data sources or <i>producers</i> .
        /// Scale-out within an Amazon Kinesis stream is explicitly supported by means of shards, which are uniquely identified groups of
        /// data records in an Amazon Kinesis stream.</para> <para>You specify and control the number of shards that a stream is composed of. Each open
        /// shard can support up to 5 read transactions per second, up to a maximum total of 2 MB of data read per second. Each shard can support up to
        /// 1000 write transactions per second, up to a maximum total of 1 MB data written per second. You can add shards to a stream if the amount of
        /// data input increases and you can remove shards if the amount of data input decreases.</para> <para>The stream name identifies the stream.
        /// The name is scoped to the AWS account used by the application. It is also scoped by region. That is, two streams in two different accounts
        /// can have the same name, and two streams in the same account, but in two different regions, can have the same name. </para> <para>
        /// <c>CreateStream</c> is an asynchronous operation. Upon receiving a <c>CreateStream</c> request, Amazon Kinesis immediately returns and sets
        /// the stream status to CREATING. After the stream is created, Amazon Kinesis sets the stream status to ACTIVE. You should perform read and
        /// write operations only on an ACTIVE stream. </para> <para>You receive a <c>LimitExceededException</c> when making a <c>CreateStream</c>
        /// request if you try to do one of the following:</para>
        /// <ul>
        /// <li>Have more than five streams in the CREATING state at any point in time.</li>
        /// <li>Create more shards than are authorized for your account.</li>
        /// 
        /// </ul>
        /// <para> <b>Note:</b> The default limit for an AWS account is 10 shards per stream. If you need to create a stream with more than 10 shards,
        /// <a href="http://docs.aws.amazon.com/general/latest/gr/aws_service_limits.html">contact AWS Support</a> to increase the limit on your
        /// account.</para> <para>You can use the <c>DescribeStream</c> operation to check the stream status, which is returned in <c>StreamStatus</c>
        /// .</para> <para> <c>CreateStream</c> has a limit of 5 transactions per second per account.</para>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the CreateStream service method on
        /// AmazonKinesis.</param>
        /// 
        /// <exception cref="T:Amazon.Kinesis.Model.LimitExceededException" />
        /// <exception cref="T:Amazon.Kinesis.Model.ResourceInUseException" />
        /// <exception cref="T:Amazon.Kinesis.Model.InvalidArgumentException" />
		public CreateStreamResponse CreateStream(CreateStreamRequest request)
        {
            var task = CreateStreamAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return null;
            }
        }
Example #11
0
 /// <summary>
 /// Initiates the asynchronous execution of the CreateStream operation.
 /// </summary>
 /// 
 /// <param name="request">Container for the necessary parameters to execute the CreateStream operation on AmazonKinesisClient.</param>
 /// <param name="callback">An Action delegate that is invoked when the operation completes.</param>
 /// <param name="options">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 public void CreateStreamAsync(CreateStreamRequest request, AmazonServiceCallback<CreateStreamRequest, CreateStreamResponse> callback, AsyncOptions options = null)
 {
     options = options == null?new AsyncOptions():options;
     var marshaller = new CreateStreamRequestMarshaller();
     var unmarshaller = CreateStreamResponseUnmarshaller.Instance;
     Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null;
     if(callback !=null )
         callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { 
             AmazonServiceResult<CreateStreamRequest,CreateStreamResponse> responseObject 
                     = new AmazonServiceResult<CreateStreamRequest,CreateStreamResponse>((CreateStreamRequest)req, (CreateStreamResponse)res, ex , ao.State);    
                 callback(responseObject); 
         };
     BeginInvoke<CreateStreamRequest>(request, marshaller, unmarshaller, options, callbackHelper);
 }
 IAsyncResult invokeCreateStream(CreateStreamRequest createStreamRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new CreateStreamRequestMarshaller().Marshall(createStreamRequest);
     var unmarshaller = CreateStreamResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
 /// <summary>
 /// Initiates the asynchronous execution of the CreateStream operation.
 /// <seealso cref="Amazon.Kinesis.IAmazonKinesis.CreateStream"/>
 /// </summary>
 /// 
 /// <param name="createStreamRequest">Container for the necessary parameters to execute the CreateStream operation on AmazonKinesis.</param>
 /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 public IAsyncResult BeginCreateStream(CreateStreamRequest createStreamRequest, AsyncCallback callback, object state)
 {
     return invokeCreateStream(createStreamRequest, callback, state, false);
 }
 /// <summary>
 /// <para>This operation adds a new Amazon Kinesis stream to your AWS account. A stream captures and transports data records that are
 /// continuously emitted from different data sources or <i>producers</i> .
 /// Scale-out within an Amazon Kinesis stream is explicitly supported by means of shards, which are uniquely identified groups of
 /// data records in an Amazon Kinesis stream.</para> <para>You specify and control the number of shards that a stream is composed of. Each open
 /// shard can support up to 5 read transactions per second, up to a maximum total of 2 MB of data read per second. Each shard can support up to
 /// 1000 write transactions per second, up to a maximum total of 1 MB data written per second. You can add shards to a stream if the amount of
 /// data input increases and you can remove shards if the amount of data input decreases.</para> <para>The stream name identifies the stream.
 /// The name is scoped to the AWS account used by the application. It is also scoped by region. That is, two streams in two different accounts
 /// can have the same name, and two streams in the same account, but in two different regions, can have the same name. </para> <para>
 /// <c>CreateStream</c> is an asynchronous operation. Upon receiving a <c>CreateStream</c> request, Amazon Kinesis immediately returns and sets
 /// the stream status to CREATING. After the stream is created, Amazon Kinesis sets the stream status to ACTIVE. You should perform read and
 /// write operations only on an ACTIVE stream. </para> <para>You receive a <c>LimitExceededException</c> when making a <c>CreateStream</c>
 /// request if you try to do one of the following:</para>
 /// <ul>
 /// <li>Have more than five streams in the CREATING state at any point in time.</li>
 /// <li>Create more shards than are authorized for your account.</li>
 /// 
 /// </ul>
 /// <para> <b>Note:</b> The default limit for an AWS account is 10 shards per stream. If you need to create a stream with more than 10 shards,
 /// <a href="http://docs.aws.amazon.com/general/latest/gr/aws_service_limits.html" >contact AWS Support</a> to increase the limit on your
 /// account.</para> <para>You can use the <c>DescribeStream</c> operation to check the stream status, which is returned in <c>StreamStatus</c>
 /// .</para> <para> <c>CreateStream</c> has a limit of 5 transactions per second per account.</para>
 /// </summary>
 /// 
 /// <param name="createStreamRequest">Container for the necessary parameters to execute the CreateStream service method on
 ///          AmazonKinesis.</param>
 /// 
 /// <exception cref="LimitExceededException"/>
 /// <exception cref="ResourceInUseException"/>
 /// <exception cref="InvalidArgumentException"/>
 public CreateStreamResponse CreateStream(CreateStreamRequest createStreamRequest)
 {
     IAsyncResult asyncResult = invokeCreateStream(createStreamRequest, null, null, true);
     return EndCreateStream(asyncResult);
 }
        static CreateStreamResponse CreateStream(IAmazonKinesis kinesisClient, string streamName, int shardCount)
        {
            var request = new CreateStreamRequest { StreamName = streamName, ShardCount = shardCount };
            try
            {
                CreateStreamResponse response = kinesisClient.CreateStream(request);
                return response;
            }
            catch (AmazonServiceException e)
            {
                var error = string.Format("Failed to create stream '{0}'. Reason: {1}", streamName, e.Message);
                SelfLog.WriteLine(error);

                return null;
            }
        }