5
5
6
6
import org .slf4j .Logger ;
7
7
import org .slf4j .LoggerFactory ;
8
+
8
9
import java .util .Scanner ;
9
10
10
11
// snippet-start:[neptune.java2.scenario.main]
@@ -15,42 +16,52 @@ public class NeptuneScenario {
15
16
static NeptuneActions neptuneActions = new NeptuneActions ();
16
17
17
18
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" ;
22
33
23
34
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
+ """ );
49
60
waitForInputToContinue (scanner );
50
- runScenario (subnetGroupName , vpcId , dbInstanceId , clusterName );
61
+ runScenario (subnetGroupName , vpcId , dbInstanceId , clusterName );
51
62
}
52
63
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 ) {
54
65
logger .info (DASHES );
55
66
logger .info ("1. Create a Neptune DB Subnet Group" );
56
67
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
78
89
logger .info (DASHES );
79
90
logger .info ("4. Check the status of the Neptune DB Instance" );
80
91
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
+ """ );
84
95
waitForInputToContinue (scanner );
85
96
neptuneActions .checkInstanceStatus (dbInstanceId , "available" ).join ();
86
97
waitForInputToContinue (scanner );
@@ -96,25 +107,25 @@ public static void runScenario(String subnetGroupName, String vpcId, String dbI
96
107
logger .info (DASHES );
97
108
logger .info ("6. Stop the Amazon Neptune cluster" );
98
109
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
+ """ );
102
113
waitForInputToContinue (scanner );
103
114
neptuneActions .stopDBCluster (dbClusterId );
104
- neptuneActions .waitForClusterStatus (dbClusterId ,"stopped" );
115
+ neptuneActions .waitForClusterStatus (dbClusterId , "stopped" );
105
116
waitForInputToContinue (scanner );
106
117
logger .info (DASHES );
107
118
108
119
logger .info (DASHES );
109
120
logger .info ("7. Start the Amazon Neptune cluster" );
110
121
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
+ """ );
115
126
waitForInputToContinue (scanner );
116
127
neptuneActions .startDBCluster (dbClusterId );
117
- neptuneActions .waitForClusterStatus (dbClusterId ,"available" );
128
+ neptuneActions .waitForClusterStatus (dbClusterId , "available" );
118
129
neptuneActions .checkInstanceStatus (dbInstanceId , "available" ).join ();
119
130
logger .info (DASHES );
120
131
logger .info (DASHES );
@@ -133,12 +144,12 @@ public static void runScenario(String subnetGroupName, String vpcId, String dbI
133
144
134
145
logger .info (DASHES );
135
146
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
+ """ );
142
153
logger .info (DASHES );
143
154
}
144
155
0 commit comments