1 package info.mikethomas.fahview.v6project.model;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 import info.mikethomas.fahview.v6project.utilities.QueueReader;
25 import java.net.Inet4Address;
26 import java.net.MalformedURLException;
27 import java.net.URL;
28 import java.net.UnknownHostException;
29 import java.util.Date;
30 import java.util.logging.Level;
31 import java.util.logging.Logger;
32
33
34
35
36
37
38
39 public class QueueIndexImpl implements QueueIndex {
40
41 private int stat;
42 private int z004;
43 private Date tdata;
44 private int ustat;
45 private URL url;
46 private int m176;
47 private Core core;
48 private int m184;
49 private int dsiz;
50 private byte[] z192;
51 private WorkUnitImpl wuid;
52 private byte[] z224;
53 private int mid;
54 private Inet4Address svr2;
55 private int port;
56 private String type;
57 private String uname;
58 private int teamn;
59 private long uid;
60 private int bench;
61 private int m476;
62 private int cpu_type;
63 private int os_type;
64 private int cpu_spec;
65 private int os_spec;
66 private Date expire;
67 private byte[] z500;
68 private int cltype;
69 private boolean aiflag;
70 private Date aitime;
71 private long aidata;
72 private Inet4Address csip;
73 private Date dstart;
74 private byte[] z528;
75 private int m532;
76 private byte[] z536;
77 private int cores;
78 private String tag;
79 private byte[] z564;
80 private String passkey;
81 private int flops;
82 private int memory;
83 private int gpu_memory;
84 private byte[] z624;
85 private Date due;
86 private int plimit;
87 private int uploads;
88
89 private int indexNumber, position;
90 private QueueReader reader;
91
92
93
94
95
96
97
98
99 public QueueIndexImpl(int indexNumber, QueueReader reader) throws InstantiationException {
100 this.indexNumber = indexNumber;
101 switch (indexNumber) {
102 case 0:
103 position = QueueImpl.QUEUE_INDEX_0_POS;
104 break;
105 case 1:
106 position = QueueImpl.QUEUE_INDEX_1_POS;
107 break;
108 case 2:
109 position = QueueImpl.QUEUE_INDEX_2_POS;
110 break;
111 case 3:
112 position = QueueImpl.QUEUE_INDEX_3_POS;
113 break;
114 case 4:
115 position = QueueImpl.QUEUE_INDEX_4_POS;
116 break;
117 case 5:
118 position = QueueImpl.QUEUE_INDEX_5_POS;
119 break;
120 case 6:
121 position = QueueImpl.QUEUE_INDEX_6_POS;
122 break;
123 case 7:
124 position = QueueImpl.QUEUE_INDEX_7_POS;
125 break;
126 case 8:
127 position = QueueImpl.QUEUE_INDEX_8_POS;
128 break;
129 case 9:
130 position = QueueImpl.QUEUE_INDEX_9_POS;
131 break;
132 default:
133 throw new InstantiationException("Queue index should be 0-9.");
134 }
135 this.reader = reader;
136 update();
137 }
138
139
140 @Override
141 public int getStat() {
142 return stat;
143 }
144
145
146 @Override
147 public Date getTdata() {
148 return tdata;
149 }
150
151
152 @Override
153 public Inet4Address getSvr1() {
154 throw new UnsupportedOperationException("svr1 replaced by svr2.");
155 }
156
157
158 @Override
159 public int getUstat() {
160 return ustat;
161 }
162
163
164 @Override
165 public URL getUrl() {
166 return url;
167 }
168
169
170 @Override
171 public Core getCore() {
172 return core;
173 }
174
175
176 @Override
177 public int getDsiz() {
178 return dsiz;
179 }
180
181
182 @Override
183 public WorkUnitImpl getWuid() {
184 return wuid;
185 }
186
187
188 @Override
189 public int getMid() {
190 throw new UnsupportedOperationException("Not supported yet.");
191 }
192
193
194 @Override
195 public Inet4Address getSvr2() {
196 return svr2;
197 }
198
199
200 @Override
201 public int getPort() {
202 return port;
203 }
204
205
206 @Override
207 public String getType() {
208 return type;
209 }
210
211
212 @Override
213 public String getUname() {
214 return uname;
215 }
216
217
218 @Override
219 public int getTeamn() {
220 return teamn;
221 }
222
223
224 @Override
225 public long getUid() {
226 throw new UnsupportedOperationException("Not supported yet.");
227 }
228
229
230 @Override
231 public int getBench() {
232 throw new UnsupportedOperationException("Not supported yet.");
233 }
234
235
236 @Override
237 public String getCpuType() {
238 String cpu = null;
239 switch (cpu_type) {
240 case 100000:
241 cpu = "x86";
242 break;
243 case 100085:
244 cpu = "x86";
245 break;
246 case 100086:
247 cpu = "i86";
248 break;
249 case 100087:
250 cpu = "Pentium IV";
251 break;
252 case 100186:
253 cpu = "i186";
254 break;
255 case 100286:
256 cpu = "i286";
257 break;
258 case 100386:
259 cpu = "i386";
260 break;
261 case 100486:
262 cpu = "i486";
263 break;
264 case 100586:
265 cpu = "Pentium";
266 break;
267 case 100587:
268 cpu = "Pentium MMX";
269 break;
270 case 100686:
271 cpu = "Pentium Pro";
272 break;
273 case 100687:
274 cpu = "Pentium II/III";
275 break;
276 case 101000:
277 cpu = "Cyrix x86";
278 break;
279 case 102000:
280 cpu = "AMD x86";
281 break;
282 case 200000:
283 cpu = "PowerPC";
284 break;
285 case 1100000:
286 cpu = "IA64";
287 break;
288 case 1600000:
289 cpu = "AMD64";
290 break;
291 default:
292 cpu = "Unknown";
293 break;
294 }
295 return cpu;
296 }
297
298
299 @Override
300 public String getOsType() {
301 String os = null;
302 switch (os_type) {
303 case 100000:
304 os = "Windows";
305 break;
306 case 100001:
307 os = "Win95";
308 break;
309 case 100002:
310 os = "Win95_OSR2";
311 break;
312 case 100003:
313 os = "Win98";
314 break;
315 case 100004:
316 os = "Win98SE";
317 break;
318 case 100005:
319 os = "WinME";
320 break;
321 case 100006:
322 os = "WinNT";
323 break;
324 case 100007:
325 os = "Win2K";
326 break;
327 case 100008:
328 os = "WinXP";
329 break;
330 case 100009:
331 os = "Win2K3";
332 break;
333 case 200000:
334 os = "MacOS";
335 break;
336 case 300000:
337 os = "OSX";
338 break;
339 case 400000:
340 os = "Linux";
341 break;
342 case 700000:
343 os = "FreeBSD";
344 break;
345 case 800000:
346 os = "OpenBSD";
347 break;
348 case 1800000:
349 os = "Win64";
350 break;
351 case 1900000:
352 os = "OS2";
353 break;
354 default:
355 os = "Unknown";
356 break;
357 }
358 return os;
359 }
360
361
362 @Override
363 public String getCpuSpec() {
364 throw new UnsupportedOperationException("Not supported yet.");
365 }
366
367
368 @Override
369 public String getOsSpec() {
370 throw new UnsupportedOperationException("Not supported yet.");
371 }
372
373
374 @Override
375 public Date getExpire() {
376 throw new UnsupportedOperationException("Not supported yet.");
377 }
378
379
380 @Override
381 public int getCltype() {
382 throw new UnsupportedOperationException("Not supported yet.");
383 }
384
385
386 @Override
387 public boolean getAiflag() {
388 throw new UnsupportedOperationException("Not supported yet.");
389 }
390
391
392 @Override
393 public Date getAitime() {
394 throw new UnsupportedOperationException("Not supported yet.");
395 }
396
397
398 @Override
399 public long getAidata() {
400 throw new UnsupportedOperationException("Not supported yet.");
401 }
402
403
404 @Override
405 public Inet4Address getCsip() {
406 return csip;
407 }
408
409
410 @Override
411 public Date getDstart() {
412 throw new UnsupportedOperationException("Not supported yet.");
413 }
414
415
416 @Override
417 public int getCores() {
418 return cores;
419 }
420
421
422 @Override
423 public String getTag() {
424 return tag;
425 }
426
427
428 @Override
429 public String getPasskey() {
430 return passkey;
431 }
432
433
434 @Override
435 public int getFlops() {
436 throw new UnsupportedOperationException("Not supported yet.");
437 }
438
439
440 @Override
441 public int getMemory() {
442 return memory;
443 }
444
445
446 @Override
447 public int getGpuMemory() {
448 throw new UnsupportedOperationException("Not supported yet.");
449 }
450
451
452 @Override
453 public Date getDue() {
454 throw new UnsupportedOperationException("Not supported yet.");
455 }
456
457
458 @Override
459 public int getPlimit() {
460 throw new UnsupportedOperationException("Not supported yet.");
461 }
462
463
464 @Override
465 public int getUploads() {
466 throw new UnsupportedOperationException("Not supported yet.");
467 }
468
469
470
471
472 protected void setStat() {
473 stat = (int) reader.readLEUInt(STAT_POS + position, STAT_LENGTH);
474 }
475
476
477
478
479 protected void setTdata() {
480 throw new UnsupportedOperationException("Not supported yet.");
481 }
482
483
484
485
486 protected void setUstat() {
487 throw new UnsupportedOperationException("Not supported yet.");
488 }
489
490
491
492
493 protected void setUrl() {
494 try {
495 url = new URL("http://" + reader.readString(URL_POS + position, URL_LENGTH));
496 }
497 catch (MalformedURLException ex) {
498 Logger.getLogger(QueueIndexImpl.class.getName()).log(Level.SEVERE, null, ex);
499 }
500 }
501
502
503
504
505 protected void setCore() {
506 try {
507 core = new Core(indexNumber, reader);
508 }
509 catch (InstantiationException ex) {
510 Logger.getLogger(QueueIndexImpl.class.getName()).log(Level.SEVERE, null, ex);
511 }
512 }
513
514
515
516
517 protected void setDsiz() {
518 dsiz = (int) reader.readLEUInt(DSIZ_POS + position, DSIZ_LENGTH);
519 }
520
521
522
523
524 protected void setWuid() {
525 try {
526 wuid = new WorkUnitImpl(indexNumber, reader);
527 }
528 catch (InstantiationException ex) {
529 Logger.getLogger(QueueIndexImpl.class.getName()).log(Level.SEVERE, null, ex);
530 }
531 }
532
533
534
535
536 protected void setMid() {
537 throw new UnsupportedOperationException("Not supported yet.");
538 }
539
540
541
542
543 protected void setSvr2() {
544 try {
545 svr2 = (Inet4Address) Inet4Address.getByAddress(reader.readIP(SVR2_POS + position));
546 }
547 catch (UnknownHostException ex) {
548 Logger.getLogger(QueueIndexImpl.class.getName()).log(Level.SEVERE, null, ex);
549 }
550 }
551
552
553
554
555 protected void setPort() {
556 port = (int) reader.readLEUInt(PORT_POS + position, PORT_LENGTH);
557 }
558
559
560
561
562 protected void setType() {
563 type = reader.readString(TYPE_POS + position, TYPE_LENGTH);
564 }
565
566
567
568
569 protected void setUname() {
570 uname = reader.readString(UNAME_POS + position, UNAME_LENGTH);
571 }
572
573
574
575
576 protected void setTeamn() {
577 teamn = Integer.valueOf(reader.readString(TEAMN_POS + position, TEAMN_LENGTH));
578 }
579
580
581
582
583 protected void setUID() {
584 throw new UnsupportedOperationException("Not supported yet.");
585 }
586
587
588
589
590 protected void setBench() {
591 throw new UnsupportedOperationException("Not supported yet.");
592 }
593
594
595
596
597 protected void setCpuType() {
598 throw new UnsupportedOperationException("Not supported yet.");
599 }
600
601
602
603
604 protected void setOsType() {
605 throw new UnsupportedOperationException("Not supported yet.");
606 }
607
608
609
610
611 protected void setCpuSpec() {
612 throw new UnsupportedOperationException("Not supported yet.");
613 }
614
615
616
617
618 protected void setOsSpec() {
619 throw new UnsupportedOperationException("Not supported yet.");
620 }
621
622
623
624
625 protected void setExpire() {
626 throw new UnsupportedOperationException("Not supported yet.");
627 }
628
629
630
631
632 protected void setCltype() {
633 throw new UnsupportedOperationException("Not supported yet.");
634 }
635
636
637
638
639 protected void setAiflag() {
640 throw new UnsupportedOperationException("Not supported yet.");
641 }
642
643
644
645
646 protected void setAitime() {
647 throw new UnsupportedOperationException("Not supported yet.");
648 }
649
650
651
652
653 protected void setAidata() {
654 throw new UnsupportedOperationException("Not supported yet.");
655 }
656
657
658
659
660 protected void setCsip() {
661 try {
662 csip = (Inet4Address) Inet4Address.getByAddress(reader.readIP(CSIP_POS + position));
663 }
664 catch (UnknownHostException ex) {
665 Logger.getLogger(QueueIndexImpl.class.getName()).log(Level.SEVERE, null, ex);
666 }
667 }
668
669
670
671
672 protected void setDstart() {
673 throw new UnsupportedOperationException("Not supported yet.");
674 }
675
676
677
678
679 protected void setCores() {
680 cores = (int) reader.readLEUInt(CORES_POS + position, CORES_LENGTH);
681 }
682
683
684
685
686 protected void setTag() {
687 tag = reader.readString(TAG_POS + position, TAG_LENGTH);
688 }
689
690
691
692
693 protected void setPasskey() {
694 passkey = reader.readString(PASSKEY_POS + position, PASSKEY_LENGTH);
695 }
696
697
698
699
700 protected void setFlops() {
701 throw new UnsupportedOperationException("Not supported yet.");
702 }
703
704
705
706
707 protected void setMemory() {
708 memory = (int) reader.readBEUInt(MEMORY_POS + position, MEMORY_LENGTH);
709 }
710
711
712
713
714 protected void setGpuMemory() {
715 throw new UnsupportedOperationException("Not supported yet.");
716 }
717
718
719
720
721 protected void setDue() {
722 throw new UnsupportedOperationException("Not supported yet.");
723 }
724
725
726
727
728 protected void setPlimit() {
729 throw new UnsupportedOperationException("Not supported yet.");
730 }
731
732
733
734
735 protected void setUploads() {
736 throw new UnsupportedOperationException("Not supported yet.");
737 }
738
739
740
741
742
743
744 @Override
745 public String toString() {
746 String result = "";
747 result += "queue.index[" + indexNumber + "].stat\t" + getStat();
748 result += "\nqueue.index[" + indexNumber + "].url\t" + getUrl();
749 result += "\n" + getCore();
750 result += "\nqueue.index[" + indexNumber + "].dsiz\t" + getDsiz();
751 result += "\n" + getWuid();
752 result += "\nqueue.index[" + indexNumber + "].svr2\t" + getSvr2();
753 result += "\nqueue.index[" + indexNumber + "].port\t" + getPort();
754 result += "\nqueue.index[" + indexNumber + "].type\t" + getType();
755 result += "\nqueue.index[" + indexNumber + "].uname\t" + getUname();
756 result += "\nqueue.index[" + indexNumber + "].teamn\t" + getTeamn();
757 result += "\nqueue.index[" + indexNumber + "].csip\t" + getCsip();
758 result += "\nqueue.index[" + indexNumber + "].cores\t" + getCores();
759 result += "\nqueue.index[" + indexNumber + "].tag\t" + getTag();
760 result += "\nqueue.index[" + indexNumber + "].passkey\t" + getPasskey();
761 result += "\nqueue.index[" + indexNumber + "].memory\t" + getMemory();
762 return result;
763 }
764
765
766 @Override
767 public final void update() {
768 setStat();
769 setUrl();
770 setCore();
771 setDsiz();
772 setWuid();
773 setSvr2();
774 setPort();
775 setType();
776 setUname();
777 setTeamn();
778 setCsip();
779 setCores();
780 setTag();
781 setPasskey();
782 setMemory();
783 }
784 }