-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCfgDump.java
More file actions
105 lines (84 loc) · 3.63 KB
/
CfgDump.java
File metadata and controls
105 lines (84 loc) · 3.63 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
/* CfgDump.java - performance measurement tool.
* See https://github.com/UltraMessaging/cfg_dump */
/*
Copyright (c) 2022-2023 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 CfgDump implements LBMReceiverCallback {
public static void main(String[] args) throws Exception {
// The body of the program is in the "run" method.
CfgDump application = new CfgDump();
application.run(args);
} // main
private void printContext(LBMContext ctx, String header)
{
LBMConfigOption[] opts = ctx.dumpAttributeList();
System.out.println(header);
for(int i=0; i<opts.length; i++) {
System.out.println(" " + opts[i].getType() + " " + opts[i].getOptionName() + " " + opts[i].getValue());
}
} // printContext
private void printRcv(LBMReceiver rcv, String header)
{
LBMConfigOption[] opts = rcv.dumpAttributeList();
System.out.println(header);
for(int i=0; i<opts.length; i++) {
System.out.println(" " + opts[i].getType() + " " + opts[i].getOptionName() + " " + opts[i].getValue());
}
} // printRcv
private void printSrc(LBMSource src, String header)
{
LBMConfigOption[] opts = src.dumpAttributeList();
System.out.println(header);
for(int i=0; i<opts.length; i++) {
System.out.println(" " + opts[i].getType() + " " + opts[i].getOptionName() + " " + opts[i].getValue());
}
} // printSrc
private void printSSrc(LBMSSource ssrc, String header)
{
LBMConfigOption[] opts = ssrc.dumpAttributeList();
System.out.println(header);
for(int i=0; i<opts.length; i++) {
System.out.println(" " + opts[i].getType() + " " + opts[i].getOptionName() + " " + opts[i].getValue());
}
} // printSSrc
private void run(String[] args) throws Exception {
LBM lbm = new LBM();
LBM.setConfiguration("cfg_dump.cfg");
LBMContext myCtx = new LBMContext();
printContext(myCtx, "Context");
LBMTopic topicObj = myCtx.lookupTopic("MyTopic");
LBMReceiver myRcv = myCtx.createReceiver(topicObj, this, null);
printRcv(myRcv, "Receiver MyTopic");
topicObj = myCtx.allocTopic("MyTopic");;
LBMSource mySrc = myCtx.createSource(topicObj);
printSrc(mySrc, "Source MyTopic");
topicObj = myCtx.allocTopic("MySmartTopic");;
LBMSSource mySSrc = new LBMSSource(myCtx, topicObj);
printSSrc(mySSrc, "SmartSource MySmartTopic");
} // run
public int onReceive(Object cbArg, LBMMessage msg) {
msg.dispose();
return 0;
} // onReceive
} // class CfgDump