@@ -0,0 +1,2963 @@
+//snippet-sourcedescription:%5BCreateCluster.java demonstrates how to create a cluster.%5D%0A//snippet-keyword:%5BSDK for Java v2%5D%0A//snippet-service:%5BAmazon MemoryDB for Redis%5D%0A%0A/*%0A   Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.%0A   SPDX-License-Identifier: Apache-2.0%0A*/%0A%0Apackage com.example.memorydb;%0A%0A//snippet-start:%5BmemoryDB.java2.create_cluster.import%5D%0Aimport software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;%0Aimport software.amazon.awssdk.regions.Region;%0Aimport software.amazon.awssdk.services.memorydb.MemoryDbClient;%0Aimport software.amazon.awssdk.services.memorydb.model.CreateClusterRequest;%0Aimport software.amazon.awssdk.services.memorydb.model.CreateClusterResponse;%0Aimport software.amazon.awssdk.services.memorydb.model.MemoryDbException;%0A//snippet-end:%5BmemoryDB.java2.create_cluster.import%5D%0A%0Apublic class CreateCluster %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A        final String usage = %22%5Cn%22 +%0A            %22Usage:%5Cn%22 +%0A            %22    %3CclusterName%3E %3CnodeType%3E %3CsubnetGroupName%3E %3CaclName%3E %5Cn%5Cn%22 +%0A            %22Where:%5Cn%22 +%0A            %22    clusterName - The name of the cluster. %5Cn%22 +%0A            %22    nodeType - The compute and memory capacity of the nodes in the cluster. %5Cn%22 +%0A            %22    subnetGroupName - The name of the subnet group to be used for the cluster. %5Cn%22 +%0A            %22    aclName - The name of the Access Control List to associate with the cluster. %5Cn%22 ;%0A%0A        if (args.length != 4) %7B%0A            System.out.println(usage);%0A            System.exit(1);%0A        %7D%0A%0A        String clusterName = args%5B0%5D;%0A        String nodeType = args%5B1%5D;%0A        String subnetGroupName = args%5B2%5D;%0A        String aclName = args%5B3%5D;%0A        Region region = Region.US_EAST_1;%0A        MemoryDbClient memoryDbClient = MemoryDbClient.builder()%0A            .region(region)%0A            .credentialsProvider(ProfileCredentialsProvider.create())%0A            .build();%0A%0A        createSingleCluster(memoryDbClient, clusterName, nodeType, subnetGroupName, aclName);%0A    %7D%0A%0A    //snippet-start:%5BmemoryDB.java2.create_cluster.import%5D%0A    public static void createSingleCluster(MemoryDbClient memoryDbClient, String clusterName, String nodeType, String subnetGroupName, String aclName) %7B%0A%0A        try%7B%0A            CreateClusterRequest request = CreateClusterRequest.builder()%0A                .clusterName(clusterName)%0A                .aclName(aclName)%0A                .description(%22Created using the AWS SDK for Java%22)%0A                .numShards(1)%0A                .nodeType(nodeType)%0A                .port(6379)%0A                .subnetGroupName(subnetGroupName)%0A                .build() ;%0A%0A            CreateClusterResponse response = memoryDbClient.createCluster(request);%0A            System.out.println(%22Cluster created. The ARN is %22+response.cluster().arn());%0A%0A        %7D catch (MemoryDbException e) %7B%0A            System.err.println(e.awsErrorDetails().errorMessage());%0A            System.exit(1);%0A        %7D%0A    %7D%0A%7D%0A

Create CreateCluster.java