/
GridJobExecuteRequest.java
919 lines (702 loc) · 23.9 KB
/
GridJobExecuteRequest.java
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
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
/*
* 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.
*/
package org.apache.ignite.internal;
import org.apache.ignite.compute.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.internal.util.direct.*;
import org.apache.ignite.internal.util.tostring.*;
import org.apache.ignite.internal.util.typedef.internal.*;
import org.jetbrains.annotations.*;
import java.io.*;
import java.nio.*;
import java.util.*;
/**
* Job execution request.
*/
public class GridJobExecuteRequest extends GridTcpCommunicationMessageAdapter implements GridTaskMessage {
/** */
private static final long serialVersionUID = 0L;
/** Subject ID. */
private UUID subjId;
/** */
private IgniteUuid sesId;
/** */
private IgniteUuid jobId;
/** */
@GridToStringExclude
private byte[] jobBytes;
/** */
@GridToStringExclude
@GridDirectTransient
private ComputeJob job;
/** */
private long startTaskTime;
/** */
private long timeout;
/** */
private String taskName;
/** */
private String userVer;
/** */
private String taskClsName;
/** Node class loader participants. */
@GridToStringInclude
@GridDirectMap(keyType = UUID.class, valueType = IgniteUuid.class)
private Map<UUID, IgniteUuid> ldrParticipants;
/** */
@GridToStringExclude
private byte[] sesAttrsBytes;
/** */
@GridToStringExclude
@GridDirectTransient
private Map<Object, Object> sesAttrs;
/** */
@GridToStringExclude
private byte[] jobAttrsBytes;
/** */
@GridToStringExclude
@GridDirectTransient
private Map<? extends Serializable, ? extends Serializable> jobAttrs;
/** Checkpoint SPI name. */
private String cpSpi;
/** */
@GridDirectTransient
private Collection<ComputeJobSibling> siblings;
/** */
private byte[] siblingsBytes;
/** Transient since needs to hold local creation time. */
@GridDirectTransient
private long createTime0 = U.currentTimeMillis();
/** @deprecated need to remove and use only {@link #createTime0}. */
@Deprecated
private long createTime = createTime0;
/** */
private IgniteUuid clsLdrId;
/** */
private IgniteDeploymentMode depMode;
/** */
private boolean dynamicSiblings;
/** */
private boolean forceLocDep;
/** */
private boolean sesFullSup;
/** */
private boolean internal;
/** */
@GridDirectCollection(UUID.class)
private Collection<UUID> top;
/**
* No-op constructor to support {@link Externalizable} interface.
*/
public GridJobExecuteRequest() {
// No-op.
}
/**
* @param sesId Task session ID.
* @param jobId Job ID.
* @param taskName Task name.
* @param userVer Code version.
* @param taskClsName Fully qualified task name.
* @param jobBytes Job serialized body.
* @param job Job.
* @param startTaskTime Task execution start time.
* @param timeout Task execution timeout.
* @param top Topology.
* @param siblingsBytes Serialized collection of split siblings.
* @param siblings Collection of split siblings.
* @param sesAttrsBytes Map of session attributes.
* @param sesAttrs Session attributes.
* @param jobAttrsBytes Job context attributes.
* @param jobAttrs Job attributes.
* @param cpSpi Collision SPI.
* @param clsLdrId Task local class loader id.
* @param depMode Task deployment mode.
* @param dynamicSiblings {@code True} if siblings are dynamic.
* @param ldrParticipants Other node class loader IDs that can also load classes.
* @param forceLocDep {@code True} If remote node should ignore deployment settings.
* @param sesFullSup {@code True} if session attributes are disabled.
* @param internal {@code True} if internal job.
* @param subjId Subject ID.
*/
public GridJobExecuteRequest(
IgniteUuid sesId,
IgniteUuid jobId,
String taskName,
String userVer,
String taskClsName,
byte[] jobBytes,
ComputeJob job,
long startTaskTime,
long timeout,
@Nullable Collection<UUID> top,
byte[] siblingsBytes,
Collection<ComputeJobSibling> siblings,
byte[] sesAttrsBytes,
Map<Object, Object> sesAttrs,
byte[] jobAttrsBytes,
Map<? extends Serializable, ? extends Serializable> jobAttrs,
String cpSpi,
IgniteUuid clsLdrId,
IgniteDeploymentMode depMode,
boolean dynamicSiblings,
Map<UUID, IgniteUuid> ldrParticipants,
boolean forceLocDep,
boolean sesFullSup,
boolean internal,
UUID subjId) {
this.top = top;
assert sesId != null;
assert jobId != null;
assert taskName != null;
assert taskClsName != null;
assert job != null || jobBytes != null;
assert sesAttrs != null || sesAttrsBytes != null || !sesFullSup;
assert jobAttrs != null || jobAttrsBytes != null;
assert clsLdrId != null;
assert userVer != null;
assert depMode != null;
this.sesId = sesId;
this.jobId = jobId;
this.taskName = taskName;
this.userVer = userVer;
this.taskClsName = taskClsName;
this.jobBytes = jobBytes;
this.job = job;
this.startTaskTime = startTaskTime;
this.timeout = timeout;
this.top = top;
this.siblingsBytes = siblingsBytes;
this.siblings = siblings;
this.sesAttrsBytes = sesAttrsBytes;
this.sesAttrs = sesAttrs;
this.jobAttrsBytes = jobAttrsBytes;
this.jobAttrs = jobAttrs;
this.clsLdrId = clsLdrId;
this.depMode = depMode;
this.dynamicSiblings = dynamicSiblings;
this.ldrParticipants = ldrParticipants;
this.forceLocDep = forceLocDep;
this.sesFullSup = sesFullSup;
this.internal = internal;
this.subjId = subjId;
this.cpSpi = cpSpi == null || cpSpi.isEmpty() ? null : cpSpi;
}
/** {@inheritDoc} */
@Override public IgniteUuid getSessionId() {
return sesId;
}
/**
* @return Job session ID.
*/
public IgniteUuid getJobId() {
return jobId;
}
/**
* @return Task version.
*/
public String getTaskClassName() {
return taskClsName;
}
/**
* @return Task name.
*/
public String getTaskName() {
return taskName;
}
/**
* @return Task version.
*/
public String getUserVersion() {
return userVer;
}
/**
* @return Serialized job bytes.
*/
public byte[] getJobBytes() {
return jobBytes;
}
/**
* @return Grid job.
*/
public ComputeJob getJob() {
return job;
}
/**
* @return Task start time.
*/
public long getStartTaskTime() {
return startTaskTime;
}
/**
* @return Timeout.
*/
public long getTimeout() {
return timeout;
}
/**
* Gets this instance creation time.
*
* @return This instance creation time.
*/
public long getCreateTime() {
return createTime0;
}
/**
* @return Serialized collection of split siblings.
*/
public byte[] getSiblingsBytes() {
return siblingsBytes;
}
/**
* @return Job siblings.
*/
public Collection<ComputeJobSibling> getSiblings() {
return siblings;
}
/**
* @return Session attributes.
*/
public byte[] getSessionAttributesBytes() {
return sesAttrsBytes;
}
/**
* @return Session attributes.
*/
public Map<Object, Object> getSessionAttributes() {
return sesAttrs;
}
/**
* @return Job attributes.
*/
public byte[] getJobAttributesBytes() {
return jobAttrsBytes;
}
/**
* @return Job attributes.
*/
public Map<? extends Serializable, ? extends Serializable> getJobAttributes() {
return jobAttrs;
}
/**
* @return Checkpoint SPI name.
*/
public String getCheckpointSpi() {
return cpSpi;
}
/**
* @return Task local class loader id.
*/
public IgniteUuid getClassLoaderId() {
return clsLdrId;
}
/**
* @return Deployment mode.
*/
public IgniteDeploymentMode getDeploymentMode() {
return depMode;
}
/**
* Returns true if siblings list is dynamic, i.e. task is continuous.
*
* @return True if siblings list is dynamic.
*/
public boolean isDynamicSiblings() {
return dynamicSiblings;
}
/**
* @return Node class loader participant map.
*/
public Map<UUID, IgniteUuid> getLoaderParticipants() {
return ldrParticipants;
}
/**
* @return Returns {@code true} if deployment should always be used.
*/
public boolean isForceLocalDeployment() {
return forceLocDep;
}
/**
* @return Topology.
*/
@Nullable public Collection<UUID> topology() {
return top;
}
/**
* @return {@code True} if session attributes are enabled.
*/
public boolean isSessionFullSupport() {
return sesFullSup;
}
/**
* @return {@code True} if internal job.
*/
public boolean isInternal() {
return internal;
}
/**
* @return Subject ID.
*/
public UUID getSubjectId() {
return subjId;
}
/** {@inheritDoc} */
@SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"})
@Override public GridTcpCommunicationMessageAdapter clone() {
GridJobExecuteRequest _clone = new GridJobExecuteRequest();
clone0(_clone);
return _clone;
}
/** {@inheritDoc} */
@Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) {
GridJobExecuteRequest _clone = (GridJobExecuteRequest)_msg;
_clone.subjId = subjId;
_clone.sesId = sesId;
_clone.jobId = jobId;
_clone.jobBytes = jobBytes;
_clone.job = job;
_clone.startTaskTime = startTaskTime;
_clone.timeout = timeout;
_clone.taskName = taskName;
_clone.userVer = userVer;
_clone.taskClsName = taskClsName;
_clone.ldrParticipants = ldrParticipants;
_clone.sesAttrsBytes = sesAttrsBytes;
_clone.sesAttrs = sesAttrs;
_clone.jobAttrsBytes = jobAttrsBytes;
_clone.jobAttrs = jobAttrs;
_clone.cpSpi = cpSpi;
_clone.siblings = siblings;
_clone.siblingsBytes = siblingsBytes;
_clone.createTime0 = createTime0;
_clone.createTime = createTime;
_clone.clsLdrId = clsLdrId;
_clone.depMode = depMode;
_clone.dynamicSiblings = dynamicSiblings;
_clone.forceLocDep = forceLocDep;
_clone.sesFullSup = sesFullSup;
_clone.internal = internal;
_clone.top = top;
}
/** {@inheritDoc} */
@SuppressWarnings("all")
@Override public boolean writeTo(ByteBuffer buf) {
commState.setBuffer(buf);
if (!commState.typeWritten) {
if (!commState.putByte(null, directType()))
return false;
commState.typeWritten = true;
}
switch (commState.idx) {
case 0:
if (!commState.putGridUuid("clsLdrId", clsLdrId))
return false;
commState.idx++;
case 1:
if (!commState.putString("cpSpi", cpSpi))
return false;
commState.idx++;
case 2:
if (!commState.putLong("createTime", createTime))
return false;
commState.idx++;
case 3:
if (!commState.putEnum("depMode", depMode))
return false;
commState.idx++;
case 4:
if (!commState.putBoolean("dynamicSiblings", dynamicSiblings))
return false;
commState.idx++;
case 5:
if (!commState.putBoolean("forceLocDep", forceLocDep))
return false;
commState.idx++;
case 6:
if (!commState.putBoolean("internal", internal))
return false;
commState.idx++;
case 7:
if (!commState.putByteArray("jobAttrsBytes", jobAttrsBytes))
return false;
commState.idx++;
case 8:
if (!commState.putByteArray("jobBytes", jobBytes))
return false;
commState.idx++;
case 9:
if (!commState.putGridUuid("jobId", jobId))
return false;
commState.idx++;
case 10:
if (ldrParticipants != null) {
if (commState.it == null) {
if (!commState.putInt(null, ldrParticipants.size()))
return false;
commState.it = ldrParticipants.entrySet().iterator();
}
while (commState.it.hasNext() || commState.cur != NULL) {
if (commState.cur == NULL)
commState.cur = commState.it.next();
Map.Entry<UUID, IgniteUuid> e = (Map.Entry<UUID, IgniteUuid>)commState.cur;
if (!commState.keyDone) {
if (!commState.putUuid(null, e.getKey()))
return false;
commState.keyDone = true;
}
if (!commState.putGridUuid(null, e.getValue()))
return false;
commState.keyDone = false;
commState.cur = NULL;
}
commState.it = null;
} else {
if (!commState.putInt(null, -1))
return false;
}
commState.idx++;
case 11:
if (!commState.putByteArray("sesAttrsBytes", sesAttrsBytes))
return false;
commState.idx++;
case 12:
if (!commState.putBoolean("sesFullSup", sesFullSup))
return false;
commState.idx++;
case 13:
if (!commState.putGridUuid("sesId", sesId))
return false;
commState.idx++;
case 14:
if (!commState.putByteArray("siblingsBytes", siblingsBytes))
return false;
commState.idx++;
case 15:
if (!commState.putLong("startTaskTime", startTaskTime))
return false;
commState.idx++;
case 16:
if (!commState.putUuid("subjId", subjId))
return false;
commState.idx++;
case 17:
if (!commState.putString("taskClsName", taskClsName))
return false;
commState.idx++;
case 18:
if (!commState.putString("taskName", taskName))
return false;
commState.idx++;
case 19:
if (!commState.putLong("timeout", timeout))
return false;
commState.idx++;
case 20:
if (top != null) {
if (commState.it == null) {
if (!commState.putInt(null, top.size()))
return false;
commState.it = top.iterator();
}
while (commState.it.hasNext() || commState.cur != NULL) {
if (commState.cur == NULL)
commState.cur = commState.it.next();
if (!commState.putUuid(null, (UUID)commState.cur))
return false;
commState.cur = NULL;
}
commState.it = null;
} else {
if (!commState.putInt(null, -1))
return false;
}
commState.idx++;
case 21:
if (!commState.putString("userVer", userVer))
return false;
commState.idx++;
}
return true;
}
/** {@inheritDoc} */
@SuppressWarnings("all")
@Override public boolean readFrom(ByteBuffer buf) {
commState.setBuffer(buf);
switch (commState.idx) {
case 0:
clsLdrId = commState.getGridUuid("clsLdrId");
if (!commState.lastRead())
return false;
commState.idx++;
case 1:
cpSpi = commState.getString("cpSpi");
if (!commState.lastRead())
return false;
commState.idx++;
case 2:
createTime = commState.getLong("createTime");
if (!commState.lastRead())
return false;
commState.idx++;
case 3:
byte depMode0 = commState.getByte("depMode");
if (!commState.lastRead())
return false;
depMode = IgniteDeploymentMode.fromOrdinal(depMode0);
commState.idx++;
case 4:
dynamicSiblings = commState.getBoolean("dynamicSiblings");
if (!commState.lastRead())
return false;
commState.idx++;
case 5:
forceLocDep = commState.getBoolean("forceLocDep");
if (!commState.lastRead())
return false;
commState.idx++;
case 6:
internal = commState.getBoolean("internal");
if (!commState.lastRead())
return false;
commState.idx++;
case 7:
jobAttrsBytes = commState.getByteArray("jobAttrsBytes");
if (!commState.lastRead())
return false;
commState.idx++;
case 8:
jobBytes = commState.getByteArray("jobBytes");
if (!commState.lastRead())
return false;
commState.idx++;
case 9:
jobId = commState.getGridUuid("jobId");
if (!commState.lastRead())
return false;
commState.idx++;
case 10:
if (commState.readSize == -1) {
commState.readSize = commState.getInt(null);
if (!commState.lastRead())
return false;
}
if (commState.readSize >= 0) {
if (ldrParticipants == null)
ldrParticipants = new HashMap<>(commState.readSize, 1.0f);
for (int i = commState.readItems; i < commState.readSize; i++) {
if (!commState.keyDone) {
UUID _val = commState.getUuid(null);
if (!commState.lastRead())
return false;
commState.cur = _val;
commState.keyDone = true;
}
IgniteUuid _val = commState.getGridUuid(null);
if (!commState.lastRead())
return false;
ldrParticipants.put((UUID)commState.cur, _val);
commState.keyDone = false;
commState.readItems++;
}
}
commState.readSize = -1;
commState.readItems = 0;
commState.cur = null;
commState.idx++;
case 11:
sesAttrsBytes = commState.getByteArray("sesAttrsBytes");
if (!commState.lastRead())
return false;
commState.idx++;
case 12:
sesFullSup = commState.getBoolean("sesFullSup");
if (!commState.lastRead())
return false;
commState.idx++;
case 13:
sesId = commState.getGridUuid("sesId");
if (!commState.lastRead())
return false;
commState.idx++;
case 14:
siblingsBytes = commState.getByteArray("siblingsBytes");
if (!commState.lastRead())
return false;
commState.idx++;
case 15:
startTaskTime = commState.getLong("startTaskTime");
if (!commState.lastRead())
return false;
commState.idx++;
case 16:
UUID subjId0 = commState.getUuid(null);
if (subjId0 == UUID_NOT_READ)
return false;
subjId = subjId0;
commState.idx++;
case 17:
String taskClsName0 = commState.getString("taskClsName");
if (!commState.lastRead())
return false;
commState.idx++;
case 18:
String taskName0 = commState.getString("taskName");
if (!commState.lastRead())
return false;
commState.idx++;
case 19:
timeout = commState.getLong("timeout");
if (!commState.lastRead())
return false;
commState.idx++;
case 20:
if (commState.readSize == -1) {
commState.readSize = commState.getInt(null);
if (!commState.lastRead())
return false;
}
if (commState.readSize >= 0) {
if (top == null)
top = new ArrayList<>(commState.readSize);
for (int i = commState.readItems; i < commState.readSize; i++) {
UUID _val = commState.getUuid(null);
if (!commState.lastRead())
return false;
top.add((UUID)_val);
commState.readItems++;
}
}
commState.readSize = -1;
commState.readItems = 0;
commState.idx++;
case 21:
String userVer0 = commState.getString("userVer");
if (!commState.lastRead())
return false;
commState.idx++;
}
return true;
}
/** {@inheritDoc} */
@Override public byte directType() {
return 81;
}
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(GridJobExecuteRequest.class, this);
}
}