diff --git a/modules/dcache/src/main/java/org/dcache/pool/migration/Task.java b/modules/dcache/src/main/java/org/dcache/pool/migration/Task.java index 1ee2cedaaec..605eb4d533d 100644 --- a/modules/dcache/src/main/java/org/dcache/pool/migration/Task.java +++ b/modules/dcache/src/main/java/org/dcache/pool/migration/Task.java @@ -241,6 +241,10 @@ synchronized boolean needsMoreReplicas() { return _replicas.size() < _parameters.replicas; } + synchronized boolean moreReplicasPossible() { + return _parameters.waitForTargets || (_replicas.size() < _parameters.poolList.getPools().size()); + } + /** * FSM Action */ @@ -347,6 +351,16 @@ void notifyCompleted() { new FireAndForgetTask(() -> _callbackHandler.taskCompleted(Task.this))); } + /** + * FSM Action + */ + void notifyCompletedWithInsufficientReplicas() { + _parameters.executor.execute( + new FireAndForgetTask(() -> _callbackHandler.taskCompletedWithNote(Task.this, + String.format("File replicas truncated at %s due to pool availability (%s requested)", + _replicas.size(), _parameters.replicas)))); + } + /** * FSM Action */ diff --git a/modules/dcache/src/main/smc/org/dcache/pool/migration/Task.sm b/modules/dcache/src/main/smc/org/dcache/pool/migration/Task.sm index f1031bd485e..c977c389e54 100644 --- a/modules/dcache/src/main/smc/org/dcache/pool/migration/Task.sm +++ b/modules/dcache/src/main/smc/org/dcache/pool/migration/Task.sm @@ -181,6 +181,7 @@ Entry messageArrived(message: PoolMigrationCopyFinishedMessage) Done { + notifyCompleted(); } } @@ -266,6 +267,7 @@ Entry messageArrived(message: PoolMigrationCopyFinishedMessage) Done { + notifyCompleted(); } } @@ -359,6 +361,12 @@ Exit UpdatingExistingFile { } + messageArrived(message: PoolMigrationCopyFinishedMessage) + [ ctxt.needsMoreReplicas() && ! (ctxt.moreReplicasPossible() || ctxt.isMetaOnly()) ] + Done + { + notifyCompletedWithInsufficientReplicas(); + } messageArrived(message: PoolMigrationCopyFinishedMessage) [ ctxt.needsMoreReplicas() && !ctxt.isMetaOnly() ] InitiatingCopy @@ -378,6 +386,7 @@ Exit messageArrived(message: PoolMigrationCopyFinishedMessage) Done { + notifyCompleted(); } cancel Cancelling @@ -435,6 +444,12 @@ Entry UpdatingExistingFile { } + messageArrived(message: PoolMigrationCopyFinishedMessage) + [ ctxt.needsMoreReplicas() && ! (ctxt.moreReplicasPossible() || ctxt.isMetaOnly()) ] + Done + { + notifyCompletedWithInsufficientReplicas(); + } messageArrived(message: PoolMigrationCopyFinishedMessage) [ ctxt.needsMoreReplicas() && !ctxt.isMetaOnly() ] InitiatingCopy @@ -454,6 +469,7 @@ Entry messageArrived(message: PoolMigrationCopyFinishedMessage) Done { + notifyCompleted(); } cancel Cancelling @@ -527,6 +543,12 @@ Exit UpdatingExistingFile { } + messageArrived(message: PoolMigrationCopyFinishedMessage) + [ ctxt.needsMoreReplicas() && ! (ctxt.moreReplicasPossible() || ctxt.isMetaOnly()) ] + Done + { + notifyCompletedWithInsufficientReplicas(); + } messageArrived(message: PoolMigrationCopyFinishedMessage) [ ctxt.needsMoreReplicas() && !ctxt.isMetaOnly() ] InitiatingCopy @@ -546,6 +568,7 @@ Exit messageArrived(message: PoolMigrationCopyFinishedMessage) Done { + notifyCompleted(); } cancel Cancelling @@ -595,6 +618,12 @@ Exit UpdatingExistingFile { } + messageArrived(message: PoolMigrationCopyFinishedMessage) + [ ctxt.needsMoreReplicas() && ! (ctxt.moreReplicasPossible() || ctxt.isMetaOnly()) ] + Done + { + notifyCompletedWithInsufficientReplicas(); + } messageArrived(message: PoolMigrationCopyFinishedMessage) [ ctxt.needsMoreReplicas() && !ctxt.isMetaOnly() ] InitiatingCopy @@ -614,6 +643,7 @@ Exit messageArrived(message: PoolMigrationCopyFinishedMessage) Done { + notifyCompleted(); } } @@ -626,6 +656,7 @@ Entry move_success Done { + notifyCompleted(); } move_failure(rc: Integer, cause: Object) Failed @@ -689,6 +720,7 @@ Exit [ message.getReturnCode() == 0 ] Done { + notifyCompleted(); } cancel_success nil @@ -731,7 +763,6 @@ Failed Done Entry { - notifyCompleted(); } { } diff --git a/modules/dcache/src/main/smc/org/dcache/pool/migration/Task_sm.dot b/modules/dcache/src/main/smc/org/dcache/pool/migration/Task_sm.dot index 5c17948423f..43d4128e399 100644 --- a/modules/dcache/src/main/smc/org/dcache/pool/migration/Task_sm.dot +++ b/modules/dcache/src/main/smc/org/dcache/pool/migration/Task_sm.dot @@ -51,7 +51,7 @@ digraph Task { [label="{Failed|Default()/\l}"]; "TASK::Done" - [label="{Done|Entry/\l   notifyCompleted();\l|Default()/\l}"]; + [label="{Done|Entry/\l|Default()/\l}"]; "%start" [label="" shape=circle style=filled fillcolor=black width=0.25]; @@ -143,7 +143,7 @@ digraph Task { [label="messageArrived(message: PoolMigrationCopyFinishedMessage)\l\[ ctxt.getMustMovePins() \]/\l"]; "TASK::UpdatingExistingFile" -> "TASK::Done" - [label="messageArrived(message: PoolMigrationCopyFinishedMessage)/\l"]; + [label="messageArrived(message: PoolMigrationCopyFinishedMessage)/\lnotifyCompleted();\l"]; "TASK::InitiatingCopy" -> "TASK::Copying" [label="copy_success()/\l"]; @@ -187,7 +187,7 @@ digraph Task { [label="messageArrived(message: PoolMigrationCopyFinishedMessage)\l\[ ctxt.getMustMovePins() \]/\l"]; "TASK::InitiatingCopy" -> "TASK::Done" - [label="messageArrived(message: PoolMigrationCopyFinishedMessage)/\l"]; + [label="messageArrived(message: PoolMigrationCopyFinishedMessage)/\lnotifyCompleted();\l"]; "TASK::WaitingForCopyReplicaReply" -> "TASK::UpdatingExistingFile" [label="copy_success()\l\[ ctxt.hasMoreLocations() \]/\l"]; @@ -232,6 +232,9 @@ digraph Task { "TASK::Copying" -> "TASK::UpdatingExistingFile" [label="messageArrived(message: PoolMigrationCopyFinishedMessage)\l\[ ctxt.needsMoreReplicas() && ctxt.hasMoreLocations() \]/\l"]; + "TASK::Copying" -> "TASK::Done" + [label="messageArrived(message: PoolMigrationCopyFinishedMessage)\l\[ ctxt.needsMoreReplicas() && ! (ctxt.moreReplicasPossible() || ctxt.isMetaOnly()) \]/\lnotifyCompletedWithInsufficientReplicas();\l"]; + "TASK::Copying" -> "TASK::InitiatingCopy" [label="messageArrived(message: PoolMigrationCopyFinishedMessage)\l\[ ctxt.needsMoreReplicas() && !ctxt.isMetaOnly() \]/\l"]; @@ -242,7 +245,7 @@ digraph Task { [label="messageArrived(message: PoolMigrationCopyFinishedMessage)\l\[ ctxt.getMustMovePins() \]/\l"]; "TASK::Copying" -> "TASK::Done" - [label="messageArrived(message: PoolMigrationCopyFinishedMessage)/\l"]; + [label="messageArrived(message: PoolMigrationCopyFinishedMessage)/\lnotifyCompleted();\l"]; "TASK::Copying" -> "TASK::Cancelling" [label="cancel()/\l"]; @@ -272,6 +275,9 @@ digraph Task { "TASK::Pinging" -> "TASK::UpdatingExistingFile" [label="messageArrived(message: PoolMigrationCopyFinishedMessage)\l\[ ctxt.needsMoreReplicas() && ctxt.hasMoreLocations() \]/\l"]; + "TASK::Pinging" -> "TASK::Done" + [label="messageArrived(message: PoolMigrationCopyFinishedMessage)\l\[ ctxt.needsMoreReplicas() && ! (ctxt.moreReplicasPossible() || ctxt.isMetaOnly()) \]/\lnotifyCompletedWithInsufficientReplicas();\l"]; + "TASK::Pinging" -> "TASK::InitiatingCopy" [label="messageArrived(message: PoolMigrationCopyFinishedMessage)\l\[ ctxt.needsMoreReplicas() && !ctxt.isMetaOnly() \]/\l"]; @@ -282,7 +288,7 @@ digraph Task { [label="messageArrived(message: PoolMigrationCopyFinishedMessage)\l\[ ctxt.getMustMovePins() \]/\l"]; "TASK::Pinging" -> "TASK::Done" - [label="messageArrived(message: PoolMigrationCopyFinishedMessage)/\l"]; + [label="messageArrived(message: PoolMigrationCopyFinishedMessage)/\lnotifyCompleted();\l"]; "TASK::Pinging" -> "TASK::Cancelling" [label="cancel()/\l"]; @@ -314,6 +320,9 @@ digraph Task { "TASK::NoResponse" -> "TASK::UpdatingExistingFile" [label="messageArrived(message: PoolMigrationCopyFinishedMessage)\l\[ ctxt.needsMoreReplicas() && ctxt.hasMoreLocations() \]/\l"]; + "TASK::NoResponse" -> "TASK::Done" + [label="messageArrived(message: PoolMigrationCopyFinishedMessage)\l\[ ctxt.needsMoreReplicas() && ! (ctxt.moreReplicasPossible() || ctxt.isMetaOnly()) \]/\lnotifyCompletedWithInsufficientReplicas();\l"]; + "TASK::NoResponse" -> "TASK::InitiatingCopy" [label="messageArrived(message: PoolMigrationCopyFinishedMessage)\l\[ ctxt.needsMoreReplicas() && !ctxt.isMetaOnly() \]/\l"]; @@ -324,7 +333,7 @@ digraph Task { [label="messageArrived(message: PoolMigrationCopyFinishedMessage)\l\[ ctxt.getMustMovePins() \]/\l"]; "TASK::NoResponse" -> "TASK::Done" - [label="messageArrived(message: PoolMigrationCopyFinishedMessage)/\l"]; + [label="messageArrived(message: PoolMigrationCopyFinishedMessage)/\lnotifyCompleted();\l"]; "TASK::NoResponse" -> "TASK::Cancelling" [label="cancel()/\l"]; @@ -346,6 +355,9 @@ digraph Task { "TASK::WaitingForCopyFinishedMessage" -> "TASK::UpdatingExistingFile" [label="messageArrived(message: PoolMigrationCopyFinishedMessage)\l\[ ctxt.needsMoreReplicas() && ctxt.hasMoreLocations() \]/\l"]; + "TASK::WaitingForCopyFinishedMessage" -> "TASK::Done" + [label="messageArrived(message: PoolMigrationCopyFinishedMessage)\l\[ ctxt.needsMoreReplicas() && ! (ctxt.moreReplicasPossible() || ctxt.isMetaOnly()) \]/\lnotifyCompletedWithInsufficientReplicas();\l"]; + "TASK::WaitingForCopyFinishedMessage" -> "TASK::InitiatingCopy" [label="messageArrived(message: PoolMigrationCopyFinishedMessage)\l\[ ctxt.needsMoreReplicas() && !ctxt.isMetaOnly() \]/\l"]; @@ -356,10 +368,10 @@ digraph Task { [label="messageArrived(message: PoolMigrationCopyFinishedMessage)\l\[ ctxt.getMustMovePins() \]/\l"]; "TASK::WaitingForCopyFinishedMessage" -> "TASK::Done" - [label="messageArrived(message: PoolMigrationCopyFinishedMessage)/\l"]; + [label="messageArrived(message: PoolMigrationCopyFinishedMessage)/\lnotifyCompleted();\l"]; "TASK::MovingPin" -> "TASK::Done" - [label="move_success()/\l"]; + [label="move_success()/\lnotifyCompleted();\l"]; "TASK::MovingPin" -> "TASK::Failed" [label="move_failure(rc: Integer, cause: Object)/\lfail(rc, \"Pin manager failed (\" + cause + \")\");\l"]; @@ -386,7 +398,7 @@ digraph Task { ctxt.getCancelReason()));\l"]; "TASK::Cancelling" -> "TASK::Done" - [label="messageArrived(message: PoolMigrationCopyFinishedMessage)\l\[ message.getReturnCode() == 0 \]/\l"]; + [label="messageArrived(message: PoolMigrationCopyFinishedMessage)\l\[ message.getReturnCode() == 0 \]/\lnotifyCompleted();\l"]; "TASK::Cancelling" -> "TASK::Failed" [label="cancel_noroute()/\lfail(SERVICE_UNAVAILABLE, String.format(\"Cancelling task (%s) failed (no route)\", diff --git a/modules/dcache/src/main/smc/org/dcache/pool/migration/Task_sm.dot.png b/modules/dcache/src/main/smc/org/dcache/pool/migration/Task_sm.dot.png index 520ca4a7a8d..f3f88e645a2 100644 Binary files a/modules/dcache/src/main/smc/org/dcache/pool/migration/Task_sm.dot.png and b/modules/dcache/src/main/smc/org/dcache/pool/migration/Task_sm.dot.png differ