Repository navigation
Expand file tree
/
Copy pathTMLProfile.java
More file actions
1016 lines (951 loc) · 34.3 KB
/
Copy pathTMLProfile.java
File metadata and controls
1016 lines (951 loc) · 34.3 KB
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
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* libTML: A BEEP based Messaging Suite
* Copyright (C) 2015 wobe-systems GmbH
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* You may find a copy of the license under this software is released
* at COPYING file. This is LGPL software: you are welcome to develop
* proprietary applications using this library without any royalty or
* fee but returning back any change, improvement or addition in the
* form of source code, project image, documentation patches, etc.
*
* Homepage:
* http://www.libtml.org
*
* For professional support contact us:
*
* wobe-systems GmbH
*/
package com.tmlsidex.tml;
import com.tmlsidex.jni.Tml;
import com.tmlsidex.jni.TmlJniCmdDispatchIF;
import com.tmlsidex.jni.TmlJniCustomDispatchIF;
import com.tmlsidex.jni.TmlJniCmdDeleteIF;
import com.tmlsidex.jni.TmlJniBalBusyStatusRequestHandlerIF;
import com.tmlsidex.jni.TmlJniBalCalculationHandlerIF;
import com.tmlsidex.jni.TmlJniBalPopulateHandlerIF;
import com.tmlsidex.jni.TmlJniBalPeerRegisterHandlerIF;
import com.tmlsidex.jni.TmlJniEvtPopulateHandlerIF;
import com.tmlsidex.jni.TmlJniEvtPeerRegisterHandlerIF;
import com.tmlsidex.jni.TmlJniEvtErrorHandlerIF;
import com.tmlsidex.jni.TmlJniEvtQueueOverflowHandlerIF;
import com.tmlsidex.jni.TmlErr;
import com.tmlsidex.jni.TmlSidexException;
/**
* @ingroup tmlClasses
* @brief TML Profile
*
* Profiles represent different TML interfaces.
*/
public class TMLProfile extends Object implements TmlJniCmdDispatchIF,
TmlJniCustomDispatchIF,
TmlJniCmdDeleteIF,
TmlJniBalBusyStatusRequestHandlerIF,
TmlJniBalCalculationHandlerIF,
TmlJniBalPopulateHandlerIF,
TmlJniBalPeerRegisterHandlerIF,
TmlJniEvtPopulateHandlerIF,
TmlJniEvtPeerRegisterHandlerIF,
TmlJniEvtErrorHandlerIF,
TmlJniEvtQueueOverflowHandlerIF{
// Member
Tml m_tml = null;
TMLCore m_core = null;
long m_coreHandle = 0;
String m_sProfile = null;
Object[] m_CmdReadyObjArr = null;
Object[] m_CmdProgressObjArr = null;
Object[] m_CmdStatusObjArr = null;
/**
* @brief command dispatch handler implementation
*
* The handler implements the low level interface and calls the
* the high level handler method.
*
* @see com.tmlsidex.tml.TMLCmdDispatchIF
*/
@Override
public void jniCmdDispatchCB(long cmdHandle, Object cbData) {
Object[] objArr = (Object[]) cbData;
if (null != objArr[0]){
try {
TMLCmd cmd = new TMLCmd(cmdHandle, false);
((TMLCmdDispatchIF) objArr[0]).cmdDispatchCB(cmd, objArr[1]);
} catch (TmlSidexException e) {
// Suppress exceptions:
e.printStackTrace();
}
}
}
/**
* @brief custom dispatch handler implementation
*
* The handler implements the low level interface and calls the
* the high level handler method.
*
* @see com.tmlsidex.tml.TMLCustomDispatchIF
*/
@Override
public void jniCustomDispatchCB(int iCmdID, long cmdHandle, Object cbData) {
Object[] objArr = (Object[]) cbData;
if (null != objArr[0]){
try {
TMLCmd cmd = new TMLCmd(cmdHandle, false);
((TMLCustomDispatchIF) objArr[0]).customDispatchCB(iCmdID, cmd, objArr[1]);
} catch (TmlSidexException e) {
// Suppress exceptions:
e.printStackTrace();
}
}
}
/**
* @brief command delete handler implementation
*
* The handler implements the low level interface and calls the
* the high level handler method.
*
* @see com.tmlsidex.tml.TMLCmdDeleteIF
*/
@Override
public void jniCmdDeleteHandlerCB(int iCmdID, Object cbCmdData, Object cbData) {
Object[] objArr = (Object[]) cbData;
if (null != objArr[0]){
((TMLCmdDeleteIF) objArr[0]).cmdDeleteHandlerCB(iCmdID, cbCmdData, objArr[1]);
}
}
/**
* @brief balancing busy status request handler implementation
*
* The handler implements the low level interface and calls the
* the high level handler method.
*
* @see com.tmlsidex.tml.TMLBalBusyStatusRequestHandlerIF
*/
@Override
public int jniBalBusyStatusRequestCB(long cmdHandle, Object cbData) {
int iRet = TmlErr.TML_ERR_INFORMATION_UNDEFINED;
Object[] objArr = (Object[]) cbData;
if (null != objArr[0]){
try {
TMLCmd cmd = new TMLCmd(cmdHandle, false);
iRet = ((TMLBalBusyStatusRequestHandlerIF) objArr[0]).balBusyStatusRequestCB(cmd, objArr[1]);
} catch (TmlSidexException e) {
// Suppress exceptions:
e.printStackTrace();
}
}
return iRet;
}
/**
* @brief calculate next load balancing peer handler implementation
*
* The handler implements the low level interface and calls the
* the high level handler method.
*
* @see com.tmlsidex.tml.TMLBalCalculationHandlerIF
*/
@Override
public int jniBalCalculateNextReceiverCB(int iCountOfDestinations, long[] listenerBusyStateArray, Object cbData, int[] iNextIndex) {
int iRet = TmlErr.TML_ERR_INFORMATION_UNDEFINED;
Object[] objArr = (Object[]) cbData;
if (null != objArr[0]){
try {
TMLCmd[] cmdArray = new TMLCmd[iCountOfDestinations];
for (int i = 0; i < iCountOfDestinations; ++i){
TMLCmd cmd = new TMLCmd(listenerBusyStateArray[i], false);
cmdArray[i] = cmd;
}
int iNextIdx = ((TMLBalCalculationHandlerIF) objArr[0]).balCalculateNextReceiverCB(iCountOfDestinations, cmdArray, objArr[1]);
if (-1 < iNextIdx){
iRet = TmlErr.TML_SUCCESS;
iNextIndex[0] = iNextIdx;
}
} catch (TmlSidexException e) {
// Suppress exceptions:
e.printStackTrace();
}
}
return iRet;
}
/**
* @brief populate balancer peers handler implementation
*
* The handler implements the low level interface and calls the
* the high level handler method.
*
* @see com.tmlsidex.tml.TMLBalPopulateHandlerIF
*/
@Override
public int jniBalPopulateCB(String profile, Object cbData) {
int iRet = TmlErr.TML_SUCCESS;
Object[] objArr = (Object[]) cbData;
if (null != objArr[0]){
iRet = ((TMLBalPopulateHandlerIF) objArr[0]).balPopulateCB(profile, objArr[1]);
}
return iRet;
}
/**
* @brief populate event receiver list handler implementation
*
* The handler implements the low level interface and calls the
* the high level handler method.
*
* @see com.tmlsidex.tml.TMLEvtPopulateHandlerIF
*/
@Override
public int jniEvtPopulateCB(String profile, Object cbData) {
int iRet = TmlErr.TML_SUCCESS;
Object[] objArr = (Object[]) cbData;
if (null != objArr[0]){
iRet = ((TMLEvtPopulateHandlerIF) objArr[0]).evtPopulateCB(profile, objArr[1]);
}
return iRet;
}
/**
* @brief register balancing peer handler implementation
*
* The handler implements the low level interface and calls the
* the high level handler method.
*
* @see com.tmlsidex.tml.TMLBalPeerRegisterHandlerIF
*/
@Override
public boolean jniBalPeerRegistrationCB(boolean bSubscribe, String sIP, String sPort, Object cbData) {
boolean bRet = true;
Object[] objArr = (Object[]) cbData;
if (null != objArr[0]){
bRet = ((TMLBalPeerRegisterHandlerIF) objArr[0]).balPeerRegistrationCB(bSubscribe, sIP, sPort, objArr[1]);
}
return bRet;
}
/**
* @brief register event consumer handler implementation
*
* The handler implements the low level interface and calls the
* the high level handler method.
*
* @see com.tmlsidex.tml.TMLEvtPeerRegisterHandlerIF
*/
@Override
public boolean jniEvtPeerRegistrationCB(boolean bSubscribe, String sIP, String sPort, Object cbData) {
boolean bRet = true;
Object[] objArr = (Object[]) cbData;
if (null != objArr[0]){
bRet = ((TMLEvtPeerRegisterHandlerIF) objArr[0]).evtPeerRegistrationCB(bSubscribe, sIP, sPort, objArr[1]);
}
return bRet;
}
/**
* @brief register event error handler implementation
*
* The handler implements the low level interface and calls the
* the high level handler method.
*
* @see com.tmlsidex.tml.TMLEvtErrorHandlerIF
*/
@Override
public void jniEvtErrorCB(String profile, String sIP, String sPort, int iCmdID, int iError, Object cbData) {
Object[] objArr = (Object[]) cbData;
if (null != objArr[0]){
((TMLEvtErrorHandlerIF) objArr[0]).evtErrorCB(profile, sIP, sPort, iCmdID, iError, objArr[1]);
}
}
/**
* @brief register event overflow handler implementation
*
* The handler implements the low level interface and calls the
* the high level handler method.
*
* @see com.tmlsidex.tml.TMLEvtErrorHandlerIF
*/
@Override
public void jniEvtQueueOverflowCB(String sProfile, int iCmdID, Object cbData) {
Object[] objArr = (Object[]) cbData;
if (null != objArr[0]){
((TMLEvtQueueOverflowHandlerIF) objArr[0]).evtQueueOverflowCB(sProfile, iCmdID, objArr[1]);
}
}
/**
* @brief constructs a TMLProfile
*
* @param profile profile name (ID)
*
* @param core TML core instance
*
* @throws TmlSidexException
*
*/
public TMLProfile(String profile, TMLCore core) throws TmlSidexException{
m_tml = new Tml();
m_sProfile = profile;
m_core = core;
m_coreHandle = m_core.getCHandle();
m_tml.tml_Profile_Register (m_coreHandle, m_sProfile);
}
/**
* @brief destructor
*/
protected void finalize() throws Throwable {
m_CmdReadyObjArr = null;
m_CmdProgressObjArr = null;
m_CmdStatusObjArr = null;
// Internal destructrion:
if (m_tml.tml_Profile_Get_RegisterState (m_coreHandle, m_sProfile)){
m_tml.tml_Profile_Unregister (m_coreHandle, m_sProfile);
}
m_tml = null;
// Super destructrion
super.finalize();
}
/**
* @brief get low lwvwl TML core Handle
*
* @return TML command variant
*/
public long getCHandle(){
return m_coreHandle;
}
/**
* @brief get profile id
*
* @return Profile string identifier.
*/
public String getProfileUrl(){
return m_sProfile;
}
/**
* @brief register command handler
*
* The command handler is a called if the listerner
* receives a message with the iCmdID. If no command handler is registered for this id
* either an error is returned to the caller or the general command handler
* is called.
*
* @param iCmdID command id
* @param cbInstance instance of an implementation of the callback method interface / set null for deregistration
* @param pCBData custom data or null
*
* @throws TmlSidexException
* @see TMLProfile#registerCustomDispatch(TMLCustomDispatchIF, Object)
*/
public void registerCmd(int iCmdID, TMLCmdDispatchIF cbInstance, Object pCBData) throws TmlSidexException {
if (null != cbInstance){
Object[] objArr = new Object[2];
objArr[0] = cbInstance;
objArr[1] = pCBData;
m_tml.tml_Profile_Register_Cmd(m_coreHandle, m_sProfile, iCmdID, this, objArr);
}
else{
m_tml.tml_Profile_Register_Cmd(m_coreHandle, m_sProfile, iCmdID, null, null);
}
}
/**
* @brief register a general command handler
*
* If no command handler was registered for a command id,
* the profile calls the general command handler if registered.
* This can be used to implement an own dispatching mechanism
* to handle incoming commands and events.
*
* @param cbInstance instance of an implementation of the callback method interface / set null for deregistration
* @param pCBData custom data or null
*
* @throws TmlSidexException
*/
public void registerCustomDispatch(TMLCustomDispatchIF cbInstance, Object pCBData) throws TmlSidexException {
if (null != cbInstance){
Object[] objArr = new Object[2];
objArr[0] = cbInstance;
objArr[1] = pCBData;
m_tml.tml_Profile_Set_OnCustomDispatch(m_coreHandle, m_sProfile, this, objArr);
}
else{
m_tml.tml_Profile_Set_OnCustomDispatch(m_coreHandle, m_sProfile, null, null);
}
}
/**
* @brief register delete command handler
*
* The delete command handler is used to release custon data.
*
* @param cbInstance instance of an implementation of the callback method interface / set null for deregistration
* @param pCBData custom data or null
*
* @throws TmlSidexException
*/
public void registerCmdDeleteHandler(TMLCmdDeleteIF cbInstance, Object pCBData) throws TmlSidexException{
if (null != cbInstance){
Object[] objArr = new Object[2];
objArr[0] = cbInstance;
objArr[1] = pCBData;
m_tml.tml_Profile_Set_OnDeleteCmd(m_coreHandle, m_sProfile, this, objArr);
}
else{
m_tml.tml_Profile_Set_OnDeleteCmd(m_coreHandle, m_sProfile, null, null);
}
}
/**
* @brief register cmd callback handler
*
* @param cmd TMLCmd object
*
* @throws TmlSidexException
*/
private void registerCmdCallbackHandler(TMLCmd cmd) throws TmlSidexException{
if (null != m_CmdReadyObjArr){
TMLCmdReadyIF[] cbInstanceCmdReady = new TMLCmdReadyIF[1];
Object[] pCBData = new Object[1];
cmd.registeredCmdReady(cbInstanceCmdReady, pCBData);
if (null == cbInstanceCmdReady[0]){
cmd.registerCmdReady((TMLCmdReadyIF)m_CmdReadyObjArr[0], m_CmdReadyObjArr[1]);
}
cbInstanceCmdReady = null;
pCBData = null;
}
if (null != m_CmdProgressObjArr){
TMLCmdProgressReplyIF[] cbInstanceCmdProgress = new TMLCmdProgressReplyIF[1];
Object[] pCBData = new Object[1];
cmd.registeredCmdProgressReply(cbInstanceCmdProgress, pCBData);
if (null == cbInstanceCmdProgress[0]){
cmd.registerCmdProgressReply((TMLCmdProgressReplyIF)m_CmdProgressObjArr[0], m_CmdProgressObjArr[1]);
}
cbInstanceCmdProgress = null;
pCBData = null;
}
if (null != m_CmdStatusObjArr){
TMLCmdStatusReplyIF[] cbInstanceCmdStatus = new TMLCmdStatusReplyIF[1];
Object[] pCBData = new Object[1];
cmd.registeredCmdStatusReply(cbInstanceCmdStatus, pCBData);
if (null == cbInstanceCmdStatus[0]){
cmd.registerCmdStatusReply((TMLCmdStatusReplyIF)m_CmdStatusObjArr[0], m_CmdStatusObjArr[1]);
}
cbInstanceCmdStatus = null;
pCBData = null;
}
}
/**
* @brief send an asynchronous message
*
* The call returns after sending the message without waiting for a reply.
* To process a reply the command ready event is called.
*
* @param sIP hostname or IP address
* @param sPort port number
* @param cmd TMLCmd object
* @param timeout timeout in milliseconds
*
* @throws TmlSidexException
* @see TMLCmd#registerCmdReady(TMLCmdReadyIF, Object)
*/
public void sendAsyncMessage(String sIP, String sPort, TMLCmd cmd, long timeout) throws TmlSidexException{
registerCmdCallbackHandler(cmd);
long cmdHandle = cmd.getVHandle();
m_tml.tml_Send_AsyncMessage(m_coreHandle, cmdHandle, m_sProfile, sIP, sPort, timeout);
}
/**
* @brief send a synchronous message
*
* Sending a message synchronously means that the call waits for a reply
* and returns the result of the message or an error.
*
* @param sIP hostname or IP address
* @param sPort port number
* @param cmd TMLCmd object
* @param timeout timeout in milliseconds
*
* @throws TmlSidexException
*/
public void sendSyncMessage(String sIP, String sPort, TMLCmd cmd, long timeout) throws TmlSidexException{
registerCmdCallbackHandler(cmd);
long cmdHandle = cmd.getVHandle();
m_tml.tml_Send_SyncMessage(m_coreHandle, cmdHandle, m_sProfile, sIP, sPort, timeout);
}
/**
* @brief send an event to all registered event consumers
*
* @param cmd TMLCmd object
*
* @throws TmlSidexException
*/
public void sendEventMessage(TMLCmd cmd) throws TmlSidexException{
long cmdHandle = cmd.getVHandle();
m_tml.tml_Evt_Send_Message(m_coreHandle, cmdHandle, m_sProfile);
}
/**
* @brief send an event subscription request
*
* @param sSourceHost host name / IP addresse of the subscriber
* @param sSourcePort port number of the subscriber
* @param sDestHost host name / IP addresse of the event producer
* @param sDestPort port number of the event producer
* @param timeout timeout in milliseconds
*
* @throws TmlSidexException
*/
public void sendEventConsumerSubscription(String sSourceHost, String sSourcePort, String sDestHost, String sDestPort, long timeout) throws TmlSidexException{
m_tml.tml_Evt_Send_SubscriptionRequest(m_coreHandle, m_sProfile, sSourceHost, sSourcePort, sDestHost, sDestPort, timeout);
}
/**
* @brief unregister an event message receiver
*
* @param sSourceHost host name / IP addresse of the subscriber
* @param sSourcePort port number of the subscriber
* @param sDestHost host name / IP addresse of the event producer
* @param sDestPort port number of the event producer
* @param timeout timeout in milliseconds
*
* @throws TmlSidexException
*/
public void sendEventConsumerUnsubscription(String sSourceHost, String sSourcePort, String sDestHost, String sDestPort, long timeout) throws TmlSidexException{
m_tml.tml_Evt_Send_UnsubscriptionRequest(m_coreHandle, m_sProfile, sSourceHost, sSourcePort, sDestHost, sDestPort, timeout);
}
/**
* @brief send a load balanced asynchronous message
*
* This call works like TMLProfile#sendAsyncMessage but sends the command to a peer
* picked from a group of registered command receivers utilizing the TML load balancing.
*
* @param cmd TMLCmd object
* @param iTimeout timeout in milliseconds
*
* @throws TmlSidexException
*/
public void sendBalancedAsyncMessage(TMLCmd cmd, long iTimeout) throws TmlSidexException{
registerCmdCallbackHandler(cmd);
long cmdHandle = cmd.getVHandle();
m_tml.tml_Bal_Send_AsyncMessage(m_coreHandle, cmdHandle, m_sProfile, iTimeout);
}
/**
* @brief send a load balancing subscription request
*
* A subscription as a load balancing peer informs a sender about a new resource to
* process commands.
*
* @param sSourceHost host name / IP addresse of the subscriber
* @param sSourcePort port number of the subscriber
* @param sDestHost host name / IP addresse of the destination
* @param sDestPort port number of the destination
* @param timeout timeout in milliseconds
*
* @throws TmlSidexException
*/
public void sendBalancedReceiverSubscription(String sSourceHost, String sSourcePort, String sDestHost, String sDestPort, long timeout) throws TmlSidexException{
m_tml.tml_Bal_Send_SubscriptionRequest(m_coreHandle, m_sProfile, sSourceHost, sSourcePort, sDestHost, sDestPort, timeout);
}
/**
* @brief send a load balanced synchronous message
*
* This call works like TMLProfile#sendSyncMessage but sends the command to a peer
* picked from a group of registered command receivers utilizing the TML load balancing.
*
* @param cmd TMLCmd object
* @param iTimeout timeout in milliseconds
*
* @throws TmlSidexException
*/
public void sendBalancedSyncMessage(TMLCmd cmd, long iTimeout) throws TmlSidexException{
registerCmdCallbackHandler(cmd);
long cmdHandle = cmd.getVHandle();
m_tml.tml_Bal_Send_SyncMessage(m_coreHandle, cmdHandle, m_sProfile, iTimeout);
}
/**
* @brief unregister a load balancing command receiver
*
* @param sSourceHost host name / IP addresse of the subscriber
* @param sSourcePort port number of the subscriber
* @param sDestHost host name / IP addresse of the destination
* @param sDestPort port number of the destination
* @param timeout timeout in milliseconds
*
* @throws TmlSidexException
*/
public void sendBalancedReceiverUnsubscription(String sSourceHost, String sSourcePort, String sDestHost, String sDestPort, long timeout) throws TmlSidexException{
m_tml.tml_Bal_Send_UnsubscriptionRequest(m_coreHandle, m_sProfile, sSourceHost, sSourcePort, sDestHost, sDestPort, timeout);
}
/**
* @brief add event consumer
*
* @param sIP hostname or IP address
* @param sPort port number
*
* @throws TmlSidexException
*/
public void addEventConsumer(String sIP, String sPort) throws TmlSidexException{
m_tml.tml_Evt_Subscribe_MessageDestination(m_coreHandle, m_sProfile, sIP, sPort);
}
/**
* @brief clear event consumer list
*
* @throws TmlSidexException
*/
public void clearEventConsumer() throws TmlSidexException{
m_tml.tml_Evt_Unsubscribe_All_MessageDestinations(m_coreHandle, m_sProfile);
}
/**
* @brief remove event consumer
*
* @param sIP hostname or IP address
* @param sPort port number
*
* @throws TmlSidexException
*/
public void removeEventConsumer(String sIP, String sPort) throws TmlSidexException{
m_tml.tml_Evt_Unsubscribe_MessageDestination(m_coreHandle, m_sProfile, sIP, sPort);
}
/**
* @brief add command receiver for load balancing
*
* @param sIP hostname or IP address
* @param sPort port number
*
* @throws TmlSidexException
*/
public void addBalanceReceiver(String sIP, String sPort) throws TmlSidexException{
m_tml.tml_Bal_Subscribe_MessageDestination(m_coreHandle, m_sProfile, sIP, sPort);
}
/**
* @brief clear load balanced command receiver list
*
* @throws TmlSidexException
*/
public void clearBalanceReceiver() throws TmlSidexException{
m_tml.tml_Bal_Unsubscribe_All_MessageDestinations(m_coreHandle, m_sProfile);
}
/**
* @brief remove load balancing command receiver
*
* @param sIP hostname or IP address
* @param sPort port number
*
* @throws TmlSidexException
*/
public void removeBalanceReceiver(String sIP, String sPort) throws TmlSidexException{
m_tml.tml_Bal_Unsubscribe_MessageDestination(m_coreHandle, m_sProfile, sIP, sPort);
}
/**
* @brief register event error handler
*
* @param cbInstance instance of an implementation of the callback method interface / set null for deregistration
* @param pCBData custom data or null
*
* @throws TmlSidexException
*/
public void registerEvtErrorHandler(TMLEvtErrorHandlerIF cbInstance, Object pCBData) throws TmlSidexException{
if (null != cbInstance){
Object[] objArr = new Object[2];
objArr[0] = cbInstance;
objArr[1] = pCBData;
m_tml.tml_Evt_Set_OnError(m_coreHandle, m_sProfile, this, objArr);
}
else{
m_tml.tml_Evt_Set_OnError(m_coreHandle, m_sProfile, null, null);
}
}
/**
* @brief register an event subscription request handler
*
* @param cbInstance instance of an implementation of the callback method interface / set null for deregistration
* @param pCBData custom data or null
*
* @throws TmlSidexException
*/
public void registerEvtPeerHandler(TMLEvtPeerRegisterHandlerIF cbInstance, Object pCBData) throws TmlSidexException{
if (null != cbInstance){
Object[] objArr = new Object[2];
objArr[0] = cbInstance;
objArr[1] = pCBData;
m_tml.tml_Evt_Set_OnPeerRegister(m_coreHandle, m_sProfile, this, objArr);
}
else{
m_tml.tml_Evt_Set_OnPeerRegister(m_coreHandle, m_sProfile, null, null);
}
}
/**
* @brief register on populate handler (events)
*
* @param cbInstance instance of an implementation of the callback method interface / set null for deregistration
* @param pCBData custom data or null
*
* @throws TmlSidexException
*/
public void registerEvtPopulateHandler(TMLEvtPopulateHandlerIF cbInstance, Object pCBData) throws TmlSidexException{
if (null != cbInstance){
Object[] objArr = new Object[2];
objArr[0] = cbInstance;
objArr[1] = pCBData;
m_tml.tml_Evt_Set_OnPopulate(m_coreHandle, m_sProfile, this, objArr);
}
else{
m_tml.tml_Evt_Set_OnPopulate(m_coreHandle, m_sProfile, null, null);
}
}
/**
* @brief register event queue overflow handler
*
* Events are internally queued before they are sent. If the number
* of queue entries reaches it's maximum the overflow handler is called.
*
* @param cbInstance instance of an implementation of the callback method interface / set null for deregistration
* @param pCBData custom data or null
*
* @throws TmlSidexException
*/
public void registerEvtQueueOverflowHandler(TMLEvtQueueOverflowHandlerIF cbInstance, Object pCBData) throws TmlSidexException{
if (null != cbInstance){
Object[] objArr = new Object[2];
objArr[0] = cbInstance;
objArr[1] = pCBData;
m_tml.tml_Evt_Set_OnQueueOverflow(m_coreHandle, m_sProfile, this, objArr);
}
else{
m_tml.tml_Evt_Set_OnQueueOverflow(m_coreHandle, m_sProfile, null, null);
}
}
/**
* @brief register balancer busy status request handler
*
* To implement a custom load balancing instead of a round robin
* the status request handler can collect and return host specifc data.
* The data is added to the TML command passed to the handler function.
* On sender side the data is collected and passed to a load balance
* calculation handler that will
* return the index of the next registered peer to call. If either the busy
* status request handler or the load balancing calculation handler is not
* implemented round robin will be used.
*
* @param cbInstance instance of an implementation of the callback method interface / set null for deregistration
* @param pCBData custom data or null
*
* @throws TmlSidexException
* @see TMLProfile#registerBalCalculationHandler(TMLBalCalculationHandlerIF, Object)
* @see TMLBalCalculationHandlerIF
*/
public void registerBalBusyStatusRequestHandler(TMLBalBusyStatusRequestHandlerIF cbInstance, Object pCBData) throws TmlSidexException{
if (null != cbInstance){
Object[] objArr = new Object[2];
objArr[0] = cbInstance;
objArr[1] = pCBData;
m_tml.tml_Bal_Set_OnBusyStatusRequest(m_coreHandle, m_sProfile, this, objArr);
}
else{
m_tml.tml_Bal_Set_OnBusyStatusRequest(m_coreHandle, m_sProfile, null, null);
}
}
/**
* @brief register load balancing calculation handler
*
* Evaluate load information returned by the status request handlers of
* registered command receivers to calculate the index of the next peer
* to receive a load balanced command.
*
* @param cbInstance instance of an implementation of the callback method interface / set null for deregistration
* @param pCBData custom data or null
*
* @throws TmlSidexException
* @see TMLProfile#registerBalBusyStatusRequestHandler(TMLBalBusyStatusRequestHandlerIF, Object)
*/
public void registerBalCalculationHandler(TMLBalCalculationHandlerIF cbInstance, Object pCBData) throws TmlSidexException{
if (null != cbInstance){
Object[] objArr = new Object[2];
objArr[0] = cbInstance;
objArr[1] = pCBData;
m_tml.tml_Bal_Set_OnCalculation(m_coreHandle, m_sProfile, this, objArr);
}
else{
m_tml.tml_Bal_Set_OnCalculation(m_coreHandle, m_sProfile, null, null);
}
}
/**
* @brief register load balancing subscription request handler
*
* The handler is called if a load balancing subscription or unsubscription request is received.
*
* @param cbInstance instance of an implementation of the callback method interface / set null for deregistration
* @param pCBData custom data or null
*
* @throws TmlSidexException
*/
public void registerBalPeerHandler(TMLBalPeerRegisterHandlerIF cbInstance, Object pCBData) throws TmlSidexException{
if (null != cbInstance){
Object[] objArr = new Object[2];
objArr[0] = cbInstance;
objArr[1] = pCBData;
m_tml.tml_Bal_Set_OnPeerRegister(m_coreHandle, m_sProfile, this,objArr);
}
else{
m_tml.tml_Bal_Set_OnPeerRegister(m_coreHandle, m_sProfile, null, null);
}
}
/**
* @brief register on populate handler (balancer)
*
* If no load balanced command receiver is registered and a load
* balanced command is requested by TMLProfile#sendSyncMessage() or
* TMLProfile#sendAsyncMessage(), the OnPopulate handler can register
* or reregister load balanced command receivers.
*
* @param cbInstance instance of an implementation of the callback method interface / set null for deregistration
* @param pCBData custom data or null
*
* @throws TmlSidexException
*/
public void registerBalPopulateHandler(TMLBalPopulateHandlerIF cbInstance, Object pCBData) throws TmlSidexException{
if (null != cbInstance){
Object[] objArr = new Object[2];
objArr[0] = cbInstance;
objArr[1] = pCBData;
m_tml.tml_Bal_Set_OnPopulate(m_coreHandle, m_sProfile, this, objArr);
}
else{
m_tml.tml_Bal_Set_OnPopulate(m_coreHandle, m_sProfile, null, null);
}
}
/**
* @brief register command ready handler
*
* The result of a command is passed to a command ready handler. In case of asynchronous commands
* this is the only way to process the reply.
*
* @param cbInstance instance of an implementation of the callback method interface / set null for deregistration
* @param pCBData custom data or null
*
* @throws TmlSidexException
* @see TMLCmdReadyIF
* @see TMLCmd#registerCmdReady(TMLCmdReadyIF, Object)
*/
public void registerCmdReady(TMLCmdReadyIF cbInstance, Object pCBData) throws TmlSidexException {
if (null == m_CmdReadyObjArr){
m_CmdReadyObjArr = new Object[2];
}
m_CmdReadyObjArr[0] = cbInstance;
m_CmdReadyObjArr[1] = pCBData;
}
/**
* @brief register progress reply handler
*
* The progress reply handler is called if a progress reply was received.
*
* @param cbInstance instance of an implementation of the callback method interface / set null for deregistration
* @param pCBData custom data or null
*
* @throws TmlSidexException
* @see TMLCmdProgressReplyIF
* @see TMLCmd#registerCmdProgressReply(TMLCmdProgressReplyIF, Object)
*/
public void registerCmdProgressReply(TMLCmdProgressReplyIF cbInstance, Object pCBData) throws TmlSidexException {
if (null == m_CmdProgressObjArr){
m_CmdProgressObjArr = new Object[2];
}
m_CmdProgressObjArr[0] = cbInstance;
m_CmdProgressObjArr[1] = pCBData;
}
/**
* @brief register status reply handler
*
* The status reply handler is called if a status reply was received.
*
* @param cbInstance instance of an implementation of the callback method interface / set null for deregistration
* @param pCBData custom data or null
*
* @throws TmlSidexException
* @see TMLCmdStatusReplyIF
* @see TMLCmd#registerCmdStatusReply(TMLCmdStatusReplyIF, Object)
*/
public void registerCmdStatusReply(TMLCmdStatusReplyIF cbInstance, Object pCBData) throws TmlSidexException {
if (null == m_CmdStatusObjArr){
m_CmdStatusObjArr = new Object[2];
}
m_CmdStatusObjArr[0] = cbInstance;
m_CmdStatusObjArr[1] = pCBData;
}
/**
* @brief get registered command ready handler and custom data
*
* @param cbInstance array of size 1 containing command ready handler
* @param pCBData array of size 1 - returns custom data
*
* @throws TmlSidexException
* @see TMLCmdReadyIF
*/
public void registeredCmdReady(TMLCmdReadyIF[] cbInstance, Object[] pCBData) throws TmlSidexException {
if (null == m_CmdReadyObjArr){
cbInstance[0] = null;
pCBData[0] = null;
}
else{
if (null == m_CmdReadyObjArr[0]){
cbInstance[0] = null;
pCBData[0] = null;
}
else{
cbInstance[0] = (TMLCmdReadyIF) m_CmdReadyObjArr[0];
pCBData[0] = m_CmdReadyObjArr[1];
}
}
}
/**
* @brief get registered progress reply handler and custom data
*
* @param cbInstance array of size 1 containing progress reply handler
* @param pCBData array of size 1 - returns custom data
*
* @throws TmlSidexException
* @see TMLCmdProgressReplyIF
*/
public void registeredCmdProgressReply(TMLCmdProgressReplyIF[] cbInstance, Object[] pCBData) throws TmlSidexException{
if (null == m_CmdProgressObjArr){
cbInstance[0] = null;
pCBData[0] = null;
}
else{
if (null == m_CmdProgressObjArr[0]){
cbInstance[0] = null;
pCBData[0] = null;
}
else{
cbInstance[0] = (TMLCmdProgressReplyIF) m_CmdProgressObjArr[0];
pCBData[0] = m_CmdProgressObjArr[1];
}
}
}
/**
* @brief get registered status reply handler and custom data
*
* @param cbInstance array of size 1 containing status reply handler
* @param pCBData array of size 1 - returns custom data
*
* @throws TmlSidexException
* @see TMLCmdStatusReplyIF
*/
public void registeredCmdStatusReply(TMLCmdStatusReplyIF[] cbInstance, Object[] pCBData) throws TmlSidexException{