55
66import org .slf4j .Logger ;
77import org .slf4j .LoggerFactory ;
8+
89import java .util .Scanner ;
910
1011// snippet-start:[neptune.java2.scenario.main]
@@ -15,42 +16,52 @@ public class NeptuneScenario {
1516 static NeptuneActions neptuneActions = new NeptuneActions ();
1617
1718 public static void main (String [] args ) {
18- String subnetGroupName = "neptuneSubnetGroup56" ;
19- String vpcId = "vpc-e97a4393" ;
20- String clusterName = "neptuneCluster56" ;
21- String dbInstanceId = "neptuneDB56" ;
19+ final String usage =
20+ """
21+ Usage:
22+ <subnetGroupName> <clusterName> <dbInstanceId>
23+
24+ Where:
25+ subnetGroupName - The name of an existing Neptune DB subnet group that includes subnets in at least two Availability Zones.
26+ vpcId - The ID of the Amazon Virtual Private Cloud (VPC) where the Neptune cluster and resources will be created.
27+ clusterName - The unique identifier for the Neptune DB cluster.
28+ dbInstanceId - The identifier for a specific Neptune DB instance within the cluster.
29+ """ ;
30+ String subnetGroupName = "neptuneSubnetGroup56" ;
31+ String clusterName = "neptuneCluster56" ;
32+ String dbInstanceId = "neptuneDB56" ;
2233
2334 logger .info ("""
24- Amazon Neptune is a fully managed graph
25- database service by AWS, designed specifically
26- for handling complex relationships and connected
27- datasets at scale. It supports two popular graph models:
28- property graphs (via openCypher and Gremlin) and RDF
29- graphs (via SPARQL). This makes Neptune ideal for
30- use cases such as knowledge graphs, fraud detection,
31- social networking, recommendation engines, and
32- network management, where relationships between
33- entities are central to the data.
34-
35- Being fully managed, Neptune handles database
36- provisioning, patching, backups, and replication,
37- while also offering high availability and durability
38- within AWS's infrastructure.
39-
40- For developers, programming with Neptune allows
41- for building intelligent, relationship-aware
42- applications that go beyond traditional tabular
43- databases. Developers can use the AWS SDK for Java
44- V2 to automate infrastructure operations
45- (via NeptuneClient).
46-
47- Let's get started...
48- """ );
35+ Amazon Neptune is a fully managed graph
36+ database service by AWS, designed specifically
37+ for handling complex relationships and connected
38+ datasets at scale. It supports two popular graph models:
39+ property graphs (via openCypher and Gremlin) and RDF
40+ graphs (via SPARQL). This makes Neptune ideal for
41+ use cases such as knowledge graphs, fraud detection,
42+ social networking, recommendation engines, and
43+ network management, where relationships between
44+ entities are central to the data.
45+
46+ Being fully managed, Neptune handles database
47+ provisioning, patching, backups, and replication,
48+ while also offering high availability and durability
49+ within AWS's infrastructure.
50+
51+ For developers, programming with Neptune allows
52+ for building intelligent, relationship-aware
53+ applications that go beyond traditional tabular
54+ databases. Developers can use the AWS SDK for Java
55+ V2 to automate infrastructure operations
56+ (via NeptuneClient).
57+
58+ Let's get started...
59+ """ );
4960 waitForInputToContinue (scanner );
50- runScenario (subnetGroupName , vpcId , dbInstanceId , clusterName );
61+ runScenario (subnetGroupName , vpcId , dbInstanceId , clusterName );
5162 }
5263
53- public static void runScenario (String subnetGroupName , String vpcId , String dbInstanceId , String clusterName ) {
64+ public static void runScenario (String subnetGroupName , String vpcId , String dbInstanceId , String clusterName ) {
5465 logger .info (DASHES );
5566 logger .info ("1. Create a Neptune DB Subnet Group" );
5667 logger .info ("The Neptune DB subnet group is used when launching a Neptune cluster" );
@@ -78,9 +89,9 @@ public static void runScenario(String subnetGroupName, String vpcId, String dbI
7889 logger .info (DASHES );
7990 logger .info ("4. Check the status of the Neptune DB Instance" );
8091 logger .info ("""
81- In this step, we will wait until the DB instance
82- becomes available. This may take around 10 minutes.
83- """ );
92+ In this step, we will wait until the DB instance
93+ becomes available. This may take around 10 minutes.
94+ """ );
8495 waitForInputToContinue (scanner );
8596 neptuneActions .checkInstanceStatus (dbInstanceId , "available" ).join ();
8697 waitForInputToContinue (scanner );
@@ -96,25 +107,25 @@ public static void runScenario(String subnetGroupName, String vpcId, String dbI
96107 logger .info (DASHES );
97108 logger .info ("6. Stop the Amazon Neptune cluster" );
98109 logger .info ("""
99- Once stopped, this step polls the status
100- until the cluster is in a stopped state.
101- """ );
110+ Once stopped, this step polls the status
111+ until the cluster is in a stopped state.
112+ """ );
102113 waitForInputToContinue (scanner );
103114 neptuneActions .stopDBCluster (dbClusterId );
104- neptuneActions .waitForClusterStatus (dbClusterId ,"stopped" );
115+ neptuneActions .waitForClusterStatus (dbClusterId , "stopped" );
105116 waitForInputToContinue (scanner );
106117 logger .info (DASHES );
107118
108119 logger .info (DASHES );
109120 logger .info ("7. Start the Amazon Neptune cluster" );
110121 logger .info ("""
111- Once started, this step polls the clusters
112- status until it's in an available state.
113- We will also poll the instance status.
114- """ );
122+ Once started, this step polls the clusters
123+ status until it's in an available state.
124+ We will also poll the instance status.
125+ """ );
115126 waitForInputToContinue (scanner );
116127 neptuneActions .startDBCluster (dbClusterId );
117- neptuneActions .waitForClusterStatus (dbClusterId ,"available" );
128+ neptuneActions .waitForClusterStatus (dbClusterId , "available" );
118129 neptuneActions .checkInstanceStatus (dbInstanceId , "available" ).join ();
119130 logger .info (DASHES );
120131 logger .info (DASHES );
@@ -133,12 +144,12 @@ public static void runScenario(String subnetGroupName, String vpcId, String dbI
133144
134145 logger .info (DASHES );
135146 logger .info (
136- """
137- Thank you for checking out the Amazon Neptune Service Use demo. We hope you
138- learned something new, or got some inspiration for your own apps today.
139- For more AWS code examples, have a look at:
140- https://docs.aws.amazon.com/code-library/latest/ug/what-is-code-library.html
141- """ );
147+ """
148+ Thank you for checking out the Amazon Neptune Service Use demo. We hope you
149+ learned something new, or got some inspiration for your own apps today.
150+ For more AWS code examples, have a look at:
151+ https://docs.aws.amazon.com/code-library/latest/ug/what-is-code-library.html
152+ """ );
142153 logger .info (DASHES );
143154 }
144155
0 commit comments