/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ @startuml ' Note: in TEOZ mode som skinparams don't work ' and currently notes on messages can't be customized - ' but this mode creates more compact layout, enable if needed '!pragma teoz true skinparam noteFontSize 10 skinparam ParticipantPadding 5 skinparam SequenceGroupBorderThickness 1 skinparam SequenceGroupBorderColor #blue skinparam SequenceDividerBorderThickness 1 skinparam SequenceDividerFontStyle plain skinparam sequence { MessageAlign center } title Split shard into N parts with RF replicas actor User control Overseer entity ShardLeader collections OtherNodes User -> Overseer : SPLITSHARD activate Overseer == Prepare == Overseer -> Overseer : checkLeaderDiskSpace Overseer -> Overseer : fillRanges(N) loop 1..N Overseer -> Overseer : deleteOldSubShard rnote right: left-overs from a\nprevious failed split end == Sub shards construction == loop 1..N Overseer -> Overseer : createSubShard rnote right : subShard state\nCONSTRUCTION Overseer -> Overseer : waitForSubShard Overseer --> Overseer : addSubLeader rnote right : placeholder, no core,\nsame node as parent end Overseer -> Overseer : waitForSubLeadersVisible loop 1..N Overseer -> Overseer : waitForCoreNodeVisible Overseer --> Overseer : setSubLeaderActive end Overseer -> Overseer : waitForSubLeadersActive == Split parent shard leader == Overseer --> ShardLeader : splitParentCore activate ShardLeader ShardLeader --> Overseer : splitComplete deactivate ShardLeader loop 1..N Overseer --> ShardLeader : applyBufferedUpdates activate ShardLeader end ShardLeader --> Overseer : updatesComplete deactivate ShardLeader == Create sub replicas == loop N * (RF-1) Overseer --> Overseer : addSubReplica rnote right : placeholder, no core,\nstate DOWN, other node end alt Overseer -> Overseer : checkParentStillLeader else Overseer -> User : changed / error end Overseer -> Overseer : updateSubShardStates rnote right : subShards in RECOVERY or\nACTIVE if RF=1 loop N * (RF-1) Overseer --> OtherNodes : createSubReplicaCore activate OtherNodes end OtherNodes --> Overseer : createComplete Overseer -> User : success deactivate Overseer ... OtherNodes ---> Overseer : replicasRecovering ... alt OtherNodes --> Overseer : allReplicasActive activate Overseer Overseer -> Overseer : switchShards rnote right : parent shard INACTIVE\nsub shards ACTIVE else alt OtherNodes --> Overseer : someReplicasFailed else Overseer --> Overseer : parentShardLeaderChanged end deactivate OtherNodes Overseer -> Overseer : shardRecoveryFailed rnote right : parent shard ACTIVE\nsub shards RECOVERY_FAILED end deactivate Overseer @enduml