@@ -207,7 +207,7 @@ suspend fun deleteDBSubnetGroup(neptuneClient: NeptuneClient, subnetGroupName: S
207207 *
208208 * @param clusterId the identifier of the cluster to delete
209209 */
210- suspend fun deleteDBCluster (neptuneClient : NeptuneClient , clusterId : String ) {
210+ suspend fun deleteDBCluster (neptuneClient : NeptuneClient , clusterId : String ) {
211211 val request = DeleteDbClusterRequest {
212212 dbClusterIdentifier = clusterId
213213 skipFinalSnapshot = true
@@ -216,22 +216,21 @@ suspend fun deleteDBCluster(neptuneClient:NeptuneClient, clusterId: String) {
216216 try {
217217 neptuneClient.deleteDbCluster(request)
218218 println (" ️ Deleting DB Cluster: $clusterId " )
219-
220219 } catch (e: DbClusterNotFoundFault ) {
221220 println (" \n Resource not found: ${e.message} " )
222221 throw e
223222 } catch (e: NeptuneException ) {
224223 println (" Neptune exception occurred : ${e.message} " )
225224 throw e
226225 }
227- }
226+ }
228227// snippet-end:[neptune.kotlin.delete.cluster.main]
229228
230229suspend fun waitUntilInstanceDeleted (
231230 neptuneClient : NeptuneClient ,
232231 instanceId : String ,
233232 timeout : Duration = Duration .ofMinutes(20),
234- pollInterval : Duration = Duration .ofSeconds(10)
233+ pollInterval : Duration = Duration .ofSeconds(10),
235234): Boolean {
236235 println (" Waiting for instance '$instanceId ' to be deleted..." )
237236
@@ -248,7 +247,6 @@ suspend fun waitUntilInstanceDeleted(
248247 val elapsed = (System .currentTimeMillis() - startTime) / 1000
249248 print (" \r Waiting: Instance $instanceId status: ${status.padEnd(10 )} (${elapsed} s elapsed)" )
250249 System .out .flush()
251-
252250 } catch (e: NeptuneException ) {
253251 val errorCode = e.sdkErrorMetadata.errorCode
254252 return if (errorCode == " DBInstanceNotFound" ) {
@@ -293,7 +291,6 @@ suspend fun deleteDbInstance(neptuneClient: NeptuneClient, instanceId: String) {
293291 try {
294292 neptuneClient.deleteDbInstance(request)
295293 println (" Deleting DB Instance: $instanceId " )
296-
297294 } catch (e: DbInstanceNotFoundFault ) {
298295 println (" \n The DB instance was not found: ${e.message} " )
299296 throw e
@@ -320,9 +317,8 @@ suspend fun waitForClusterStatus(
320317 timeout : Duration = Duration .ofMinutes(20),
321318 pollInterval : Duration = Duration .ofSeconds(10)
322319) {
323- println (" Waiting for cluster ' $clusterId ' to reach status '$desiredStatus '..." )
320+ println (" Waiting for cluster $clusterId to reach status '$desiredStatus '..." )
324321 val startTime = System .currentTimeMillis()
325-
326322 while (true ) {
327323 val request = DescribeDbClustersRequest {
328324 dbClusterIdentifier = clusterId
@@ -337,18 +333,14 @@ suspend fun waitForClusterStatus(
337333 " Cluster status: ${currentStatus.padEnd(20 )} "
338334 )
339335 System .out .flush()
340- if (desiredStatus.equals(currentStatus, ignoreCase = true )) {
341- println (
342- " \n Neptune cluster reached desired status '$desiredStatus ' after " +
343- " ${formatElapsedTime(elapsedSeconds.toInt())} ."
344- )
336+ if (currentStatus.equals(desiredStatus, ignoreCase = true )) {
337+ println (" Neptune cluster reached desired status $desiredStatus after ${formatElapsedTime(elapsedSeconds.toInt())} " )
345338 return
346339 }
347340
348- if (( System .currentTimeMillis() - startTime) > timeout.toMillis()) {
349- throw RuntimeException (" Timeout waiting for Neptune cluster to reach status: $desiredStatus " )
341+ if (System .currentTimeMillis() - startTime > timeout.toMillis()) {
342+ throw RuntimeException (" Timed out waiting for Neptune cluster to reach status: $desiredStatus " )
350343 }
351-
352344 delay(pollInterval.toMillis())
353345 }
354346}
@@ -400,7 +392,6 @@ suspend fun stopDBCluster(neptuneClient: NeptuneClient, clusterIdentifier: Strin
400392 try {
401393 neptuneClient.stopDbCluster(request)
402394 println (" DB Cluster stopped: $clusterIdentifier " )
403-
404395 } catch (e: DbClusterNotFoundFault ) {
405396 println (" \n The Neptune DB cluster was not found: ${e.message} " )
406397 throw e
0 commit comments