Creates a replica of the specified cluster with the specified identifier and configuration.
(
&mut self,
cluster_id: ClusterId,
replica_id: ReplicaId,
cluster_name: String,
replica_name: String,
role: ClusterRole,
config: ReplicaConfig,
| 445 | /// Creates a replica of the specified cluster with the specified identifier |
| 446 | /// and configuration. |
| 447 | pub fn create_replica( |
| 448 | &mut self, |
| 449 | cluster_id: ClusterId, |
| 450 | replica_id: ReplicaId, |
| 451 | cluster_name: String, |
| 452 | replica_name: String, |
| 453 | role: ClusterRole, |
| 454 | config: ReplicaConfig, |
| 455 | enable_worker_core_affinity: bool, |
| 456 | enable_storage_introspection_logs: bool, |
| 457 | ) -> Result<(), anyhow::Error> { |
| 458 | let storage_location: ClusterReplicaLocation; |
| 459 | let compute_location: ClusterReplicaLocation; |
| 460 | let metrics_task: Option<AbortOnDropHandle<()>>; |
| 461 | |
| 462 | match config.location { |
| 463 | ReplicaLocation::Unmanaged(UnmanagedReplicaLocation { |
| 464 | storagectl_addrs, |
| 465 | computectl_addrs, |
| 466 | }) => { |
| 467 | compute_location = ClusterReplicaLocation { |
| 468 | ctl_addrs: computectl_addrs, |
| 469 | }; |
| 470 | storage_location = ClusterReplicaLocation { |
| 471 | ctl_addrs: storagectl_addrs, |
| 472 | }; |
| 473 | metrics_task = None; |
| 474 | } |
| 475 | ReplicaLocation::Managed(m) => { |
| 476 | let (service, metrics_task_join_handle) = self.provision_replica( |
| 477 | cluster_id, |
| 478 | replica_id, |
| 479 | cluster_name, |
| 480 | replica_name, |
| 481 | role, |
| 482 | m, |
| 483 | enable_worker_core_affinity, |
| 484 | enable_storage_introspection_logs, |
| 485 | )?; |
| 486 | storage_location = ClusterReplicaLocation { |
| 487 | ctl_addrs: service.addresses("storagectl"), |
| 488 | }; |
| 489 | compute_location = ClusterReplicaLocation { |
| 490 | ctl_addrs: service.addresses("computectl"), |
| 491 | }; |
| 492 | metrics_task = Some(metrics_task_join_handle); |
| 493 | |
| 494 | // Register the replica for HTTP proxying. |
| 495 | let http_addresses = service.addresses("internal-http"); |
| 496 | self.replica_http_locator |
| 497 | .register_replica(cluster_id, replica_id, http_addresses); |
| 498 | } |
| 499 | } |
| 500 | |
| 501 | self.storage |
| 502 | .connect_replica(cluster_id, replica_id, storage_location); |
| 503 | self.compute.add_replica_to_instance( |
| 504 | cluster_id, |
no test coverage detected