-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMonSelf.java
More file actions
92 lines (73 loc) · 3.21 KB
/
MonSelf.java
File metadata and controls
92 lines (73 loc) · 3.21 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
/* MonSelf.java - Example demonstration of "StatsThread" class.
* See https://github.com/UltraMessaging/cfg_dump */
/*
(c) Copyright 2023-2024 Informatica Corporation
Permission is granted to licensees to use or alter this software for any
purpose, including commercial applications, according to the terms laid
out in the Software License Agreement.
This source code example is provided by Informatica for educational
and evaluation purposes only.
THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES
EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF
NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE
UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES,
BE LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR
INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE
TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF
THE LIKELIHOOD OF SUCH DAMAGES.
*/
import java.util.*;
import java.nio.*;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.atomic.AtomicInteger;
import com.latencybusters.lbm.*;
// The application class supplies the onReceive, onSourceEvent,
// onTransportMapping, and LBMLog callbacks directly.
class MonSelf implements LBMReceiverCallback {
public static void main(String[] args) throws Exception {
// The body of the program is in the "run" method.
MonSelf application = new MonSelf();
application.run(args);
} // main
private void run(String[] args) throws Exception {
int i;
LBM lbm = new LBM();
LBM.setConfiguration("tst.cfg");
LBMContext myCtx1 = new LBMContext();
LBMContext myCtx2 = new LBMContext();
StatsThread myStatsThread1 = new StatsThread(myCtx1, "ctx1", 2);
myStatsThread1.start();
try { Thread.sleep(1000); } catch (Exception e) {}
StatsThread myStatsThread2 = new StatsThread(myCtx2, "ctx2", 2);
myStatsThread2.start();
LBMTopic topicObj = myCtx1.lookupTopic("MyTopic");
LBMReceiver myRcv = myCtx1.createReceiver(topicObj, this, null);
topicObj = myCtx1.allocTopic("MyTopic");
LBMSource mySrc1 = myCtx1.createSource(topicObj);
topicObj = myCtx2.allocTopic("MyTopic");
LBMSource mySrc2 = myCtx2.createSource(topicObj);
try { Thread.sleep(500); } catch (Exception e) {}
ByteBuffer mySrcBuffer = ByteBuffer.allocateDirect(128);
mySrcBuffer.position(0); mySrcBuffer.put("123456789".getBytes());
for (i = 0; i < 5; i++) {
mySrc1.send(mySrcBuffer, 0, 9, LBM.MSG_FLUSH, null);
mySrc2.send(mySrcBuffer, 0, 9, LBM.MSG_FLUSH, null);
try { Thread.sleep(1000); } catch (Exception e) {}
}
try { Thread.sleep(1000); } catch (Exception e) {}
myRcv.close();
mySrc1.close();
mySrc2.close();
System.out.println("terminate stats thread1");
myStatsThread1.terminate();
System.out.println("terminate stats thread2");
myStatsThread2.terminate();
myCtx1.close();
myCtx2.close();
} // run
public int onReceive(Object cbArg, LBMMessage msg) {
msg.dispose();
return 0;
} // onReceive
} // class MonSelf