-
Notifications
You must be signed in to change notification settings - Fork 21
/
cqmgr.go
614 lines (552 loc) · 19.5 KB
/
cqmgr.go
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
package core
import (
"errors"
"fmt"
"github.com/MG-RAST/AWE/lib/conf"
e "github.com/MG-RAST/AWE/lib/errors"
"github.com/MG-RAST/AWE/lib/logger"
"github.com/MG-RAST/AWE/lib/logger/event"
"github.com/MG-RAST/AWE/lib/user"
"labix.org/v2/mgo/bson"
"os"
"strings"
"time"
)
type CQMgr struct {
clientMap map[string]*Client
workQueue *WQueue
reminder chan bool
coReq chan CoReq //workunit checkout request (WorkController -> qmgr.Handler)
coAck chan CoAck //workunit checkout item including data and err (qmgr.Handler -> WorkController)
feedback chan Notice //workunit execution feedback (WorkController -> qmgr.Handler)
coSem chan int //semaphore for checkout (mutual exclusion between different clients)
}
func NewCQMgr() *CQMgr {
return &CQMgr{
clientMap: map[string]*Client{},
workQueue: NewWQueue(),
reminder: make(chan bool),
coReq: make(chan CoReq),
coAck: make(chan CoAck),
feedback: make(chan Notice),
coSem: make(chan int, 1), //non-blocking buffered channel
}
}
//to-do: consider separate some independent tasks into another goroutine to handle
func (qm *CQMgr) Handle() {
for {
select {
case coReq := <-qm.coReq:
logger.Debug(2, fmt.Sprintf("qmgr: workunit checkout request received, Req=%v\n", coReq))
works, err := qm.popWorks(coReq)
ack := CoAck{workunits: works, err: err}
qm.coAck <- ack
case notice := <-qm.feedback:
logger.Debug(2, fmt.Sprintf("qmgr: workunit feedback received, workid=%s, status=%s, clientid=%s\n", notice.WorkId, notice.Status, notice.ClientId))
if err := qm.handleWorkStatusChange(notice); err != nil {
logger.Error("handleWorkStatusChange(): " + err.Error())
}
case <-qm.reminder:
logger.Debug(3, "time to update workunit queue....\n")
}
}
}
func (qm *CQMgr) Timer() {
for {
time.Sleep(10 * time.Second)
qm.reminder <- true
}
}
// show functions used in debug
func (qm *CQMgr) ShowWorkQueue() {
fmt.Printf("current queuing workunits (%d):\n", qm.workQueue.Len())
for key, _ := range qm.workQueue.workMap {
fmt.Printf("workunit id: %s\n", key)
}
return
}
//---end of mgr methods
//--------client methods-------
func (qm *CQMgr) ClientChecker() {
for {
time.Sleep(30 * time.Second)
for clientid, client := range qm.clientMap {
if client.Tag == true {
client.Tag = false
total_minutes := int(time.Now().Sub(client.RegTime).Minutes())
hours := total_minutes / 60
minutes := total_minutes % 60
client.Serve_time = fmt.Sprintf("%dh%dm", hours, minutes)
if len(client.Current_work) > 0 {
client.Idle_time = 0
} else {
client.Idle_time += 30
}
} else {
//now client must be gone as tag set to false 30 seconds ago and no heartbeat received thereafter
logger.Event(event.CLIENT_UNREGISTER, "clientid="+clientid+";name="+qm.clientMap[clientid].Name)
//requeue unfinished workunits associated with the failed client
qm.ReQueueWorkunitByClient(clientid)
//delete the client from client map
delete(qm.clientMap, clientid)
}
}
}
}
func (qm *CQMgr) ClientHeartBeat(id string, cg *ClientGroup) (hbmsg HBmsg, err error) {
hbmsg = make(map[string]string, 1)
if _, ok := qm.clientMap[id]; ok {
// If the name of the clientgroup (from auth token) does not match the name in the client retrieved, throw an error
if cg != nil && qm.clientMap[id].Group != cg.Name {
return nil, errors.New("Clientgroup name in token does not match that in the client.")
}
qm.clientMap[id].Tag = true
logger.Debug(3, "HeartBeatFrom:"+"clientid="+id+",name="+qm.clientMap[id].Name)
//get suspended workunit that need the client to discard
workids := qm.getWorkByClient(id)
suspended := []string{}
for _, workid := range workids {
if work, ok := qm.workQueue.workMap[workid]; ok {
if work.State == WORK_STAT_SUSPEND {
suspended = append(suspended, workid)
}
}
}
if len(suspended) > 0 {
hbmsg["discard"] = strings.Join(suspended, ",")
}
if qm.clientMap[id].Status == CLIENT_STAT_DELETED {
hbmsg["stop"] = id
}
//hbmsg["discard"] = strings.Join(workids, ",")
return hbmsg, nil
}
return hbmsg, errors.New(e.ClientNotFound)
}
func (qm *CQMgr) RegisterNewClient(files FormFiles, cg *ClientGroup) (client *Client, err error) {
if _, ok := files["profile"]; ok {
client, err = NewProfileClient(files["profile"].Path)
os.Remove(files["profile"].Path)
} else {
client = NewClient()
}
if err != nil {
return nil, err
}
// If clientgroup is nil at this point, create a publicly owned clientgroup, with the provided group name (if one doesn't exist with the same name)
if cg == nil {
// See if clientgroup already exists with this name
// If it does and it does not have "public" execution rights, throw error
// If it doesn't, create one owned by public, and continue with client registration
// Otherwise proceed with client registration.
cg, _ = LoadClientGroupByName(client.Group)
if cg != nil {
rights := cg.Acl.Check("public")
if rights["execute"] == false {
return nil, errors.New("Clientgroup with the group specified by your client exists, but you cannot register with it, without clientgroup token.")
}
} else {
u := &user.User{Uuid: "public"}
cg, err = CreateClientGroup(client.Group, u)
if err != nil {
return nil, err
}
}
}
// If the name of the clientgroup (from auth token) does not match the name in the client profile, throw an error
if cg != nil && client.Group != cg.Name {
return nil, errors.New("Clientgroup name in token does not match that in the client configuration.")
}
qm.clientMap[client.Id] = client
if len(client.Current_work) > 0 { //re-registered client
// move already checked-out workunit from waiting queue (workMap) to checked-out list (coWorkMap)
for workid, _ := range client.Current_work {
if qm.workQueue.Has(workid) {
qm.workQueue.StatusChange(workid, WORK_STAT_CHECKOUT)
}
}
}
return
}
func (qm *CQMgr) GetClient(id string) (client *Client, err error) {
if client, ok := qm.clientMap[id]; ok {
return client, nil
}
return nil, errors.New(e.ClientNotFound)
}
func (qm *CQMgr) GetClientByUser(id string, u *user.User) (client *Client, err error) {
// Get all clientgroups that user owns or that are publicly owned, or all if user is admin
q := bson.M{}
clientgroups := new(ClientGroups)
dbFindClientGroups(q, clientgroups)
filtered_clientgroups := map[string]bool{}
for _, cg := range *clientgroups {
if (u.Uuid != "public" && (cg.Acl.Owner == u.Uuid || u.Admin == true || cg.Acl.Owner == "public")) ||
(u.Uuid == "public" && conf.CLIENT_AUTH_REQ == false && cg.Acl.Owner == "public") {
filtered_clientgroups[cg.Name] = true
}
}
if client, ok := qm.clientMap[id]; ok {
if val, exists := filtered_clientgroups[client.Group]; exists == true && val == true {
return client, nil
}
}
return nil, errors.New(e.ClientNotFound)
}
func (qm *CQMgr) GetAllClients() []*Client {
clients := []*Client{}
for _, client := range qm.clientMap {
clients = append(clients, client)
}
return clients
}
func (qm *CQMgr) GetAllClientsByUser(u *user.User) []*Client {
// Get all clientgroups that user owns or that are publicly owned, or all if user is admin
q := bson.M{}
clientgroups := new(ClientGroups)
dbFindClientGroups(q, clientgroups)
filtered_clientgroups := map[string]bool{}
for _, cg := range *clientgroups {
if (u.Uuid != "public" && (cg.Acl.Owner == u.Uuid || u.Admin == true || cg.Acl.Owner == "public")) ||
(u.Uuid == "public" && conf.CLIENT_AUTH_REQ == false && cg.Acl.Owner == "public") {
filtered_clientgroups[cg.Name] = true
}
}
clients := []*Client{}
for _, client := range qm.clientMap {
if val, exists := filtered_clientgroups[client.Group]; exists == true && val == true {
clients = append(clients, client)
}
}
return clients
}
func (qm *CQMgr) DeleteClient(id string) (err error) {
if client, ok := qm.clientMap[id]; ok {
client.Status = CLIENT_STAT_DELETED
return
}
return errors.New("client not found")
}
func (qm *CQMgr) DeleteClientByUser(id string, u *user.User) (err error) {
// Get all clientgroups that user owns or that are publicly owned, or all if user is admin
q := bson.M{}
clientgroups := new(ClientGroups)
dbFindClientGroups(q, clientgroups)
filtered_clientgroups := map[string]bool{}
for _, cg := range *clientgroups {
if (u.Uuid != "public" && (cg.Acl.Owner == u.Uuid || u.Admin == true || cg.Acl.Owner == "public")) ||
(u.Uuid == "public" && conf.CLIENT_AUTH_REQ == false && cg.Acl.Owner == "public") {
filtered_clientgroups[cg.Name] = true
}
}
if client, ok := qm.clientMap[id]; ok {
if val, exists := filtered_clientgroups[client.Group]; exists == true && val == true {
client.Status = CLIENT_STAT_DELETED
return
}
return errors.New(e.UnAuth)
}
return errors.New("client not found")
}
func (qm *CQMgr) SuspendClient(id string) (err error) {
if client, ok := qm.clientMap[id]; ok {
if client.Status == CLIENT_STAT_ACTIVE_IDLE || client.Status == CLIENT_STAT_ACTIVE_BUSY {
client.Status = CLIENT_STAT_SUSPEND
qm.ReQueueWorkunitByClient(id)
return
}
return errors.New("client is not in active state")
}
return errors.New("client not found")
}
func (qm *CQMgr) SuspendClientByUser(id string, u *user.User) (err error) {
// Get all clientgroups that user owns or that are publicly owned, or all if user is admin
q := bson.M{}
clientgroups := new(ClientGroups)
dbFindClientGroups(q, clientgroups)
filtered_clientgroups := map[string]bool{}
for _, cg := range *clientgroups {
if (u.Uuid != "public" && (cg.Acl.Owner == u.Uuid || u.Admin == true || cg.Acl.Owner == "public")) ||
(u.Uuid == "public" && conf.CLIENT_AUTH_REQ == false && cg.Acl.Owner == "public") {
filtered_clientgroups[cg.Name] = true
}
}
if client, ok := qm.clientMap[id]; ok {
if val, exists := filtered_clientgroups[client.Group]; exists == true && val == true {
if client.Status == CLIENT_STAT_ACTIVE_IDLE || client.Status == CLIENT_STAT_ACTIVE_BUSY {
client.Status = CLIENT_STAT_SUSPEND
qm.ReQueueWorkunitByClient(id)
return
}
return errors.New("client is not in active state")
}
return errors.New(e.UnAuth)
}
return errors.New("client not found")
}
func (qm *CQMgr) ResumeClient(id string) (err error) {
if client, ok := qm.clientMap[id]; ok {
if client.Status == CLIENT_STAT_SUSPEND {
client.Status = CLIENT_STAT_ACTIVE_IDLE
return
}
return errors.New("client is not in suspended state")
}
return errors.New("client not found")
}
func (qm *CQMgr) ResumeClientByUser(id string, u *user.User) (err error) {
// Get all clientgroups that user owns or that are publicly owned, or all if user is admin
q := bson.M{}
clientgroups := new(ClientGroups)
dbFindClientGroups(q, clientgroups)
filtered_clientgroups := map[string]bool{}
for _, cg := range *clientgroups {
if (u.Uuid != "public" && (cg.Acl.Owner == u.Uuid || u.Admin == true || cg.Acl.Owner == "public")) ||
(u.Uuid == "public" && conf.CLIENT_AUTH_REQ == false && cg.Acl.Owner == "public") {
filtered_clientgroups[cg.Name] = true
}
}
if client, ok := qm.clientMap[id]; ok {
if val, exists := filtered_clientgroups[client.Group]; exists == true && val == true {
if client.Status == CLIENT_STAT_SUSPEND {
client.Status = CLIENT_STAT_ACTIVE_IDLE
return
}
return errors.New("client is not in suspended state")
}
return errors.New(e.UnAuth)
}
return errors.New("client not found")
}
func (qm *CQMgr) ResumeSuspendedClients() (count int) {
for _, client := range qm.clientMap {
if client.Status == CLIENT_STAT_SUSPEND {
client.Status = CLIENT_STAT_ACTIVE_IDLE
count += 1
}
}
return count
}
func (qm *CQMgr) ResumeSuspendedClientsByUser(u *user.User) (count int) {
// Get all clientgroups that user owns or that are publicly owned, or all if user is admin
q := bson.M{}
clientgroups := new(ClientGroups)
dbFindClientGroups(q, clientgroups)
filtered_clientgroups := map[string]bool{}
for _, cg := range *clientgroups {
if (u.Uuid != "public" && (cg.Acl.Owner == u.Uuid || u.Admin == true || cg.Acl.Owner == "public")) ||
(u.Uuid == "public" && conf.CLIENT_AUTH_REQ == false && cg.Acl.Owner == "public") {
filtered_clientgroups[cg.Name] = true
}
}
for _, client := range qm.clientMap {
if val, exists := filtered_clientgroups[client.Group]; exists == true && val == true && client.Status == CLIENT_STAT_SUSPEND {
client.Status = CLIENT_STAT_ACTIVE_IDLE
count += 1
}
}
return count
}
func (qm *CQMgr) SuspendAllClients() (count int) {
for _, client := range qm.clientMap {
if client.Status == CLIENT_STAT_ACTIVE_IDLE || client.Status == CLIENT_STAT_ACTIVE_BUSY {
qm.SuspendClient(client.Id)
count += 1
}
}
return count
}
func (qm *CQMgr) SuspendAllClientsByUser(u *user.User) (count int) {
// Get all clientgroups that user owns or that are publicly owned, or all if user is admin
q := bson.M{}
clientgroups := new(ClientGroups)
dbFindClientGroups(q, clientgroups)
filtered_clientgroups := map[string]bool{}
for _, cg := range *clientgroups {
if (u.Uuid != "public" && (cg.Acl.Owner == u.Uuid || u.Admin == true || cg.Acl.Owner == "public")) ||
(u.Uuid == "public" && conf.CLIENT_AUTH_REQ == false && cg.Acl.Owner == "public") {
filtered_clientgroups[cg.Name] = true
}
}
for _, client := range qm.clientMap {
if val, exists := filtered_clientgroups[client.Group]; exists == true && val == true && (client.Status == CLIENT_STAT_ACTIVE_IDLE || client.Status == CLIENT_STAT_ACTIVE_BUSY) {
qm.SuspendClient(client.Id)
count += 1
}
}
return count
}
func (qm *CQMgr) UpdateSubClients(id string, count int) {
if _, ok := qm.clientMap[id]; ok {
qm.clientMap[id].SubClients = count
}
}
func (qm *CQMgr) UpdateSubClientsByUser(id string, count int, u *user.User) {
// Get all clientgroups that user owns or that are publicly owned, or all if user is admin
q := bson.M{}
clientgroups := new(ClientGroups)
dbFindClientGroups(q, clientgroups)
filtered_clientgroups := map[string]bool{}
for _, cg := range *clientgroups {
if (u.Uuid != "public" && (cg.Acl.Owner == u.Uuid || u.Admin == true || cg.Acl.Owner == "public")) ||
(u.Uuid == "public" && conf.CLIENT_AUTH_REQ == false && cg.Acl.Owner == "public") {
filtered_clientgroups[cg.Name] = true
}
}
if client, ok := qm.clientMap[id]; ok {
if val, exists := filtered_clientgroups[client.Group]; exists == true && val == true {
qm.clientMap[id].SubClients = count
}
}
}
//--------end client methods-------
//-------start of workunit methods---
func (qm *CQMgr) CheckoutWorkunits(req_policy string, client_id string, num int) (workunits []*Workunit, err error) {
//precheck if the client is registered
if _, hasClient := qm.clientMap[client_id]; !hasClient {
return nil, errors.New(e.ClientNotFound)
}
if qm.clientMap[client_id].Status == CLIENT_STAT_SUSPEND {
return nil, errors.New(e.ClientSuspended)
}
if qm.clientMap[client_id].Status == CLIENT_STAT_DELETED {
delete(qm.clientMap, client_id)
return nil, errors.New(e.ClientDeleted)
}
//lock semephore, at one time only one client's checkout request can be served
qm.coSem <- 1
req := CoReq{policy: req_policy, fromclient: client_id, count: num}
qm.coReq <- req
ack := <-qm.coAck
if ack.err == nil {
for _, work := range ack.workunits {
qm.clientMap[client_id].Total_checkout += 1
qm.clientMap[client_id].Current_work[work.Id] = true
}
if qm.clientMap[client_id].Status == CLIENT_STAT_ACTIVE_IDLE {
qm.clientMap[client_id].Status = CLIENT_STAT_ACTIVE_BUSY
}
}
//unlock
<-qm.coSem
return ack.workunits, ack.err
}
func (qm *CQMgr) GetWorkById(id string) (workunit *Workunit, err error) {
if workunit, hasid := qm.workQueue.workMap[id]; hasid {
return workunit, nil
}
return nil, errors.New(fmt.Sprintf("no workunit found with id %s", id))
}
func (qm *CQMgr) NotifyWorkStatus(notice Notice) {
qm.feedback <- notice
return
}
func (qm *CQMgr) popWorks(req CoReq) (works []*Workunit, err error) {
filtered := qm.filterWorkByClient(req.fromclient)
logger.Debug(2, fmt.Sprintf("popWorks filtered: %d (0 meansNoEligibleWorkunitFound)", filtered))
if len(filtered) == 0 {
return nil, errors.New(e.NoEligibleWorkunitFound)
}
works, err = qm.workQueue.selectWorkunits(filtered, req.policy, req.count)
if err == nil { //get workunits successfully, put them into coWorkMap
for _, work := range works {
if _, ok := qm.workQueue.workMap[work.Id]; ok {
qm.workQueue.workMap[work.Id].Client = req.fromclient
qm.workQueue.workMap[work.Id].CheckoutTime = time.Now()
}
qm.workQueue.StatusChange(work.Id, WORK_STAT_CHECKOUT)
}
}
return
}
func (qm *CQMgr) filterWorkByClient(clientid string) (ids []string) {
client := qm.clientMap[clientid]
for id, _ := range qm.workQueue.wait {
if _, ok := qm.workQueue.workMap[id]; !ok {
logger.Error(fmt.Sprintf("error: workunit %s is in wait queue but not in workMap", id))
continue
}
work := qm.workQueue.workMap[id]
//skip works that are in the client's skip-list
if contains(client.Skip_work, work.Id) {
logger.Debug(2, fmt.Sprintf("2) contains(client.Skip_work, work.Id) %s", id))
continue
}
//skip works that have dedicate client groups which this client doesn't belong to
if len(work.Info.ClientGroups) > 0 {
eligible_groups := strings.Split(work.Info.ClientGroups, ",")
if !contains(eligible_groups, client.Group) {
logger.Debug(2, fmt.Sprintf("3) !contains(eligible_groups, client.Group) %s", id))
continue
}
}
//append works whos apps are supported by the client
if contains(client.Apps, work.Cmd.Name) || contains(client.Apps, conf.ALL_APP) {
ids = append(ids, id)
} else {
logger.Debug(2, fmt.Sprintf("3) contains(client.Apps, work.Cmd.Name) || contains(client.Apps, conf.ALL_APP) %s", id))
}
}
return ids
}
func (qm *CQMgr) getWorkByClient(clientid string) (ids []string) {
if client, ok := qm.clientMap[clientid]; ok {
for id, _ := range client.Current_work {
ids = append(ids, id)
}
}
return
}
//handle feedback from a client about the execution of a workunit
func (qm *CQMgr) handleWorkStatusChange(notice Notice) (err error) {
//to be implemented for proxy or server
return
}
func (qm *CQMgr) FetchDataToken(workid string, clientid string) (token string, err error) {
//to be implemented for proxy or server
return
}
func (qm *CQMgr) ShowWorkunits(status string) (workunits []*Workunit) {
for _, work := range qm.workQueue.workMap {
if work.State == status || status == "" {
workunits = append(workunits, work)
}
}
return workunits
}
func (qm *CQMgr) ShowWorkunitsByUser(status string, u *user.User) (workunits []*Workunit) {
// Only returns workunits of jobs that the user has read access to or is the owner of. If user is admin, return all.
for _, work := range qm.workQueue.workMap {
if jobid, err := GetJobIdByWorkId(work.Id); err == nil {
if job, err := LoadJob(jobid); err == nil {
rights := job.Acl.Check(u.Uuid)
if job.Acl.Owner == u.Uuid || rights["read"] == true || u.Admin == true {
if work.State == status || status == "" {
workunits = append(workunits, work)
}
}
}
}
}
return workunits
}
func (qm *CQMgr) EnqueueWorkunit(work *Workunit) (err error) {
err = qm.workQueue.Add(work)
return
}
func (qm *CQMgr) ReQueueWorkunitByClient(clientid string) (err error) {
workids := qm.getWorkByClient(clientid)
for _, workid := range workids {
if qm.workQueue.Has(workid) {
jobid, _ := GetJobIdByWorkId(workid)
if job, err := LoadJob(jobid); err == nil {
if contains(JOB_STATS_ACTIVE, job.State) { //only requeue workunits belonging to active jobs (rule out suspended jobs)
qm.workQueue.StatusChange(workid, WORK_STAT_QUEUED)
logger.Event(event.WORK_REQUEUE, "workid="+workid)
}
}
}
}
return
}
//---end of workunit methods