-
Notifications
You must be signed in to change notification settings - Fork 131
/
Task.sm
740 lines (722 loc) · 23.3 KB
/
Task.sm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
%{
//
%}
%class Task
%package org.dcache.pool.migration
%access package
%import static diskCacheV111.util.CacheException.*
%start TASK::Queued
%map TASK
%%
Queued
{
startWithoutLocations
GettingLocations
{
}
startWithLocations
[ ctxt.hasMoreLocations() ]
UpdatingExistingFile
{
}
startWithLocations
[ !ctxt.isMetaOnly() ]
InitiatingCopy
{
}
startWithLocations
Failed
{
failPermanently(FILE_NOT_IN_REPOSITORY, "File skipped because it has no existing replicas");
}
}
GettingLocations
Entry
{
queryLocations();
}
{
query_timeout
Failed
{
fail(TIMEOUT, "PnfsManager failed (no response)");
}
query_noroute
Failed
{
fail(SERVICE_UNAVAILABLE, "PnfsManager failed (no route to cell)");
}
query_failure(rc: Integer, cause: Object)
[ rc == FILE_NOT_FOUND ]
Failed
{
failPermanently(FILE_NOT_FOUND, "File does not exist, skipped");
}
query_failure(rc: Integer, cause: Object)
Failed
{
fail(rc, "PnfsManager failed (" + cause + ")");
}
cancel
Cancelled
{
}
query_success
[ ctxt.hasMoreLocations() ]
UpdatingExistingFile
{
}
query_success
[ !ctxt.isMetaOnly() ]
InitiatingCopy
{
}
query_success
Failed
{
failPermanently(FILE_NOT_IN_REPOSITORY, "File skipped because it has no existing replicas");
}
}
// We got existing copies. Try to update one of them. Keep
// trying until we succeed or we tried them all.
UpdatingExistingFile
Entry
{
updateExistingReplica();
}
{
copy_timeout
[ ctxt.hasMoreLocations() ]
UpdatingExistingFile
{
}
copy_timeout
[ ctxt.isEager() && !ctxt.isMetaOnly() ]
InitiatingCopy
{
}
copy_timeout
Failed
{
fail(TIMEOUT, "Remote pool failed (no response)");
}
copy_noroute
[ ctxt.hasMoreLocations() ]
nil
{
updateExistingReplica();
}
copy_noroute
[ ctxt.isEager() && !ctxt.isMetaOnly() ]
InitiatingCopy
{
}
copy_noroute
Failed
{
fail(SERVICE_UNAVAILABLE, "Remote pool failed (no route to cell)");
}
copy_failure(rc: Integer, cause: Object)
[ rc == LOCKED ]
Failed
{
fail(rc, "Replica is locked on target pool");
}
copy_failure(rc: Integer, cause: Object)
[ ctxt.hasMoreLocations() ]
nil
{
updateExistingReplica();
}
copy_failure(rc: Integer, cause: Object)
[ !ctxt.isMetaOnly() ]
InitiatingCopy
{
}
copy_failure(rc: Integer, cause: Object)
Failed
{
fail(rc, String.format("Transfer to %s failed (%s)", ctxt.getTarget(), cause));
}
copy_success
Copying
{
}
cancel
Cancelling
{
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ message.getReturnCode() == FILE_NOT_FOUND ]
Failed
{
failPermanently(message.getReturnCode(),
String.format("Transfer to %s failed (%s); will not be retried",
ctxt.getTarget(),
message.getErrorObject()));
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ message.getReturnCode() != 0 ]
Failed
{
fail(message.getReturnCode(),
String.format("Transfer to %s failed (%s)",
ctxt.getTarget(),
message.getErrorObject()));
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ ctxt.needsMoreReplicas() ]
WaitingForCopyReplicaReply
{
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ ctxt.getMustMovePins() ]
MovingPin
{
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
Done
{
}
}
// Ask pool to copy the file.
InitiatingCopy
Entry
{
initiateCopy();
}
{
copy_success
Copying
{
}
copy_nopools
Failed
{
fail(NO_POOL_ONLINE, "No targets");
}
copy_noroute
Failed
{
fail(SERVICE_UNAVAILABLE,
String.format("Pool %s failed (no route to cell)",
ctxt.getTarget()));
}
copy_failure(rc: Integer, cause: Object)
Failed
{
fail(rc,
String.format("Pool %s failed (%s)",
ctxt.getTarget(), cause));
}
copy_timeout
WaitingForCopyFinishedMessage
{
// No reply, but message could have been
// received anyway, so try to cancel it.
cancelCopy("Timeout waiting for target pool "
+ ctxt.getTarget());
}
cancel
Cancelling
{
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ message.getReturnCode() == FILE_NOT_FOUND ]
Failed
{
failPermanently(message.getReturnCode(),
String.format("Transfer to %s failed (%s); will not be retried",
ctxt.getTarget(),
message.getErrorObject()));
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ message.getReturnCode() != 0 ]
Failed
{
fail(message.getReturnCode(),
String.format("Transfer to %s failed (%s)",
ctxt.getTarget(),
message.getErrorObject()));
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ ctxt.needsMoreReplicas() ]
WaitingForCopyReplicaReply
{
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ ctxt.getMustMovePins() ]
MovingPin
{
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
Done
{
}
}
// Need to create more copies and received PoolMigrationCopyFinishedMessage ahead of
// PoolMigrationCopyReplicaMessage reply. Wait for reply before proceeding.
WaitingForCopyReplicaReply
{
copy_success
[ ctxt.hasMoreLocations() ]
UpdatingExistingFile
{
}
copy_success
[ !ctxt.isMetaOnly() ]
InitiatingCopy
{
}
copy_success
Failed
{
failPermanently(FILE_NOT_IN_REPOSITORY, "File skipped because it does not have enough existing replicas");
}
copy_nopools
Failed
{
fail(NO_POOL_ONLINE, "No targets");
}
copy_noroute
Failed
{
fail(SERVICE_UNAVAILABLE,
String.format("Pool %s failed (no route to cell)",
ctxt.getTarget()));
}
copy_failure(rc: Integer, cause: Object)
Failed
{
fail(rc,
String.format("Pool %s failed (%s)",
ctxt.getTarget(), cause));
}
copy_timeout
Failed
{
fail(TIMEOUT,
String.format("Pool %s failed (no response)",
ctxt.getTarget()));
}
cancel
Cancelled
{
}
}
// Pool accepted the task. Wait for it to finish and
// periodically send a ping to verify it is alive.
Copying
Entry
{
startTimer(ctxt.getPingPeriod());
}
Exit
{
stopTimer();
}
{
timer
Pinging
{
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ message.getReturnCode() == FILE_NOT_FOUND ]
Failed
{
failPermanently(message.getReturnCode(),
String.format("Transfer to %s failed (%s); will not be retried",
ctxt.getTarget(),
message.getErrorObject()));
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ message.getReturnCode() != 0 ]
Failed
{
fail(message.getReturnCode(),
String.format("Transfer to %s failed (%s)",
ctxt.getTarget(),
message.getErrorObject()));
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ ctxt.needsMoreReplicas() && ctxt.hasMoreLocations() ]
UpdatingExistingFile
{
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ ctxt.needsMoreReplicas() && !ctxt.isMetaOnly() ]
InitiatingCopy
{
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ ctxt.needsMoreReplicas() ]
Failed
{
failPermanently(FILE_NOT_IN_REPOSITORY, "File skipped because it does not have enough existing replicas");
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ ctxt.getMustMovePins() ]
MovingPin
{
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
Done
{
}
cancel
Cancelling
{
}
}
// Send a ping.
Pinging
Entry
{
ping();
}
{
ping_success
Copying
{
// Task is alive
}
ping_failure(rc: Integer, cause: Object)
WaitingForCopyFinishedMessage
{
// Task is gone
}
ping_noroute
NoResponse
{
// We cannot talk to the pool
}
ping_timeout
NoResponse
{
// Pool does not respond.
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ message.getReturnCode() == FILE_NOT_FOUND ]
Failed
{
failPermanently(message.getReturnCode(),
String.format("Transfer to %s failed (%s); will not be retried",
ctxt.getTarget(),
message.getErrorObject()));
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ message.getReturnCode() != 0 ]
Failed
{
fail(message.getReturnCode(),
String.format("Transfer to %s failed (%s)",
ctxt.getTarget(),
message.getErrorObject()));
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ ctxt.needsMoreReplicas() && ctxt.hasMoreLocations() ]
UpdatingExistingFile
{
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ ctxt.needsMoreReplicas() && !ctxt.isMetaOnly() ]
InitiatingCopy
{
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ ctxt.needsMoreReplicas() ]
Failed
{
failPermanently(FILE_NOT_IN_REPOSITORY, "File skipped because it does not have enough existing replicas");
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ ctxt.getMustMovePins() ]
MovingPin
{
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
Done
{
}
cancel
Cancelling
{
}
}
// Pool did not reply to ping. Let's give it some time
// and ping it again.
NoResponse
Entry
{
startTimer(ctxt.getNoResponseTimeout());
}
Exit
{
stopTimer();
}
{
timer
nil
{
ping();
}
ping_success
Copying
{
// Task is alive
}
ping_failure(rc: Integer, cause: Object)
WaitingForCopyFinishedMessage
{
// Task is gone
}
ping_noroute
Failed
{
// We still cannot talk to the pool
fail(SERVICE_UNAVAILABLE,
String.format("Pool %s failed (no route to cell)",
ctxt.getTarget()));
}
ping_timeout
Failed
{
// Message timed out again
fail(TIMEOUT,
String.format("Pool %s failed (no response)",
ctxt.getTarget()));
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ message.getReturnCode() == FILE_NOT_FOUND ]
Failed
{
failPermanently(message.getReturnCode(),
String.format("Transfer to %s failed (%s); will not be retried",
ctxt.getTarget(),
message.getErrorObject()));
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ message.getReturnCode() != 0 ]
Failed
{
fail(message.getReturnCode(),
String.format("Transfer to %s failed (%s)",
ctxt.getTarget(),
message.getErrorObject()));
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ ctxt.needsMoreReplicas() && ctxt.hasMoreLocations() ]
UpdatingExistingFile
{
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ ctxt.needsMoreReplicas() && !ctxt.isMetaOnly() ]
InitiatingCopy
{
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ ctxt.needsMoreReplicas() ]
Failed
{
failPermanently(FILE_NOT_IN_REPOSITORY, "File skipped because it does not have enough existing replicas");
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ ctxt.getMustMovePins() ]
MovingPin
{
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
Done
{
}
cancel
Cancelling
{
}
}
// Target pool no longer has the task. Let's wait for
// the CopyFinished message.
WaitingForCopyFinishedMessage
Entry
{
startTimer(ctxt.getTaskDeadTimeout());
}
Exit
{
stopTimer();
}
{
timer
Failed
{
fail(TIMEOUT,
String.format("Pool %s failed (no response)",
ctxt.getTarget()));
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ message.getReturnCode() == FILE_NOT_FOUND ]
Failed
{
failPermanently(message.getReturnCode(),
String.format("Transfer to %s failed (%s); will not be retried",
ctxt.getTarget(),
message.getErrorObject()));
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ message.getReturnCode() != 0 ]
Failed
{
fail(message.getReturnCode(),
String.format("Transfer to %s failed (%s)",
ctxt.getTarget(),
message.getErrorObject()));
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ ctxt.needsMoreReplicas() && ctxt.hasMoreLocations() ]
UpdatingExistingFile
{
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ ctxt.needsMoreReplicas() && !ctxt.isMetaOnly() ]
InitiatingCopy
{
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ ctxt.needsMoreReplicas() ]
Failed
{
failPermanently(FILE_NOT_IN_REPOSITORY, "File skipped because it does not have enough existing replicas");
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ ctxt.getMustMovePins() ]
MovingPin
{
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
Done
{
}
}
MovingPin
Entry
{
movePin();
}
{
move_success
Done
{
}
move_failure(rc: Integer, cause: Object)
Failed
{
fail(rc, "Pin manager failed (" + cause + ")");
}
move_noroute
Failed
{
fail(SERVICE_UNAVAILABLE, "Pin manager failed (no route to cell)");
}
move_timeout
Failed
{
fail(TIMEOUT, "Pin manager failed (timeout)");
}
cancel
Failed
{
fail(DEFAULT_ERROR_CODE,
String.format("Cancelling task (%s) failed (data migrated but pin movement still underway)",
ctxt.getCancelReason()));
}
}
// User requested to abort the task, but we already asked
// a pool to copy the file. Let's try to cancel the copy
// and wait for CopyFinished.
Cancelling
Entry
{
startTimer(ctxt.getTaskDeadTimeout());
cancelCopy();
}
Exit
{
stopTimer();
}
{
timer
Failed
{
fail(TIMEOUT,
String.format("Cancelling task (%s) failed (no response from %s)",
ctxt.getCancelReason(), ctxt.getTarget()));
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ message.getReturnCode() != 0 ]
Cancelled
{
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ message.getReturnCode() == 0 && ctxt.getMustMovePins() ]
Failed
{
fail(DEFAULT_ERROR_CODE,
String.format("Cancelling task (%s) failed (data migrated but still pins to move)",
ctxt.getCancelReason()));
}
messageArrived(message: PoolMigrationCopyFinishedMessage)
[ message.getReturnCode() == 0 ]
Done
{
}
cancel_success
nil
{
}
cancel_failure(rc: Integer, cause: Object)
nil
{
}
cancel_noroute
Failed
{
fail(SERVICE_UNAVAILABLE,
String.format("Cancelling task (%s) failed (no route)",
ctxt.getCancelReason()));
}
cancel_timeout
nil
{
}
}
// Successfully cancelled task. We got confirmation that the
// transfer did not go through
Cancelled
Entry
{
notifyCancelled();
}
{
}
// Something went wrong. In some cases the transfer could have
// succeeded, but we don't know.
Failed
{
}
// Transfer completed.
Done
Entry
{
notifyCompleted();
}
{
}
// This will cause the state machine to always be input enabled
Default
{
Default
nil
{
}
}
%%