Forces a failover for a DB cluster.
A failover for a DB cluster promotes one of the Read Replicas (read-only instances) in the DB cluster to be the primary instance (the cluster writer).
Amazon Neptune will automatically fail over to a Read Replica, if one exists, when the primary instance fails. You can force a failover when you want to simulate a failure of a primary instance for testing. Because each instance in a DB cluster has its own endpoint address, you will need to clean up and re-establish any existing connections that use those endpoint addresses when the failover is complete.
Parameters:
-
db_cluster_identifier
(Optional[String], default:
None
)
–
A DB cluster identifier to force a failover for. This parameter is not case-sensitive.
Constraints:
-
target_db_instance_identifier
(Optional[String], default:
None
)
–
The name of the instance to promote to the primary instance.
You must specify the instance identifier for an Read Replica in the DB cluster. For example, mydbcluster-replica1.
Raises:
Source code in docs_src/capo_neptune/_services/async_neptune.py
| async def failover_db_cluster(
self,
*,
config_overrides: Optional[AsyncNeptuneClientConfig] = None,
db_cluster_identifier: Optional["capo_neptune.types.string.String"] = None,
target_db_instance_identifier: Optional[
"capo_neptune.types.string.String"
] = None,
) -> "capo_neptune.types.failover_db_cluster_result.FailoverDBClusterResult":
"""<p>Forces a failover for a DB cluster.</p> <p>A failover for a DB cluster promotes one of the Read Replicas (read-only instances) in the DB cluster to be the primary instance (the cluster writer).</p> <p>Amazon Neptune will automatically fail over to a Read Replica, if one exists, when the primary instance fails. You can force a failover when you want to simulate a failure of a primary instance for testing. Because each instance in a DB cluster has its own endpoint address, you will need to clean up and re-establish any existing connections that use those endpoint addresses when the failover is complete.</p>
Args:
db_cluster_identifier: <p>A DB cluster identifier to force a failover for. This parameter is not case-sensitive.</p> <p>Constraints:</p> <ul> <li> <p>Must match the identifier of an existing DBCluster.</p> </li> </ul>
target_db_instance_identifier: <p>The name of the instance to promote to the primary instance.</p> <p>You must specify the instance identifier for an Read Replica in the DB cluster. For example, <code>mydbcluster-replica1</code>.</p>
Raises:
capo_neptune.errors.db_cluster_not_found_fault.DBClusterNotFoundFault: <p> <i>DBClusterIdentifier</i> does not refer to an existing DB cluster.</p>
capo_neptune.errors.invalid_db_cluster_state_fault.InvalidDBClusterStateFault: <p>The DB cluster is not in a valid state.</p>
capo_neptune.errors.invalid_db_instance_state_fault.InvalidDBInstanceStateFault: <p>The specified DB instance is not in the <i>available</i> state.</p>
capo_neptune.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
async def _handler(
req: "AsyncOperationRequest[capo_neptune.types.failover_db_cluster_message.FailoverDBClusterMessage]",
) -> AsyncOperationResponse[
"capo_neptune.types.failover_db_cluster_result.FailoverDBClusterResult"
]:
import capo_neptune._operations.amazon_rd_sv19.failover_db_cluster
(
output,
http_response,
) = await capo_neptune._operations.amazon_rd_sv19.failover_db_cluster.async_failover_db_cluster(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("FailoverDBCluster")
)
input_: capo_neptune.types.failover_db_cluster_message.FailoverDBClusterMessage = {}
if db_cluster_identifier is not None:
input_["db_cluster_identifier"] = db_cluster_identifier
if target_db_instance_identifier is not None:
input_["target_db_instance_identifier"] = target_db_instance_identifier
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|