Skip to content

Commit 796e781

Browse files
committed
add some classReset methods and some construct methods
1 parent 0eb9f97 commit 796e781

File tree

7 files changed

+84
-17
lines changed

7 files changed

+84
-17
lines changed

src/main/java/com/cisco/trex/stateful/AstfGlobalInfoPerTemplate.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ public class AstfGlobalInfoPerTemplate implements AstfGlobalInfoBase {
1717

1818
@Override
1919
public AstfGlobalInfoBase scheduler(SchedulerParam schedulerParam, int value) {
20-
throw new IllegalStateException("unsupported method in this class");
20+
throw new IllegalStateException("unsupported method in AstfGlobalInfoPerTemplate class");
2121
}
2222

2323
@Override
2424
public AstfGlobalInfoBase ipv6(Ipv6Param ipv6Param, int value) {
25-
throw new IllegalStateException("unsupported method in this class");
25+
throw new IllegalStateException("unsupported method in AstfGlobalInfoPerTemplate class");
2626
}
2727

2828
@Override

src/main/java/com/cisco/trex/stateful/AstfIpGenDist.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ public static JsonArray clssToJson() {
132132
return jsonArray;
133133
}
134134

135+
/**
136+
* class reset, clear all cached data
137+
*/
138+
public static void classReset() {
139+
inList.clear();
140+
}
141+
135142
/**
136143
* Inner class
137144
*/

src/main/java/com/cisco/trex/stateful/AstfProfile.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ public class AstfProfile {
2323
private List<AstfTemplate> astfTemplateList;
2424
private List<AstfCapInfo> astfCapInfoList;
2525

26+
/**
27+
* construct
28+
*
29+
* @param defaultIpGen
30+
* @param astfTemplateList
31+
*/
32+
public AstfProfile(AstfIpGen defaultIpGen, List<AstfTemplate> astfTemplateList) {
33+
this(defaultIpGen, null, null, astfTemplateList, null);
34+
}
35+
2636
/**
2737
* construct
2838
*
@@ -90,6 +100,15 @@ public JsonObject toJson() {
90100
return json;
91101
}
92102

103+
/**
104+
* clear all cache data.
105+
*/
106+
public static void clearCache() {
107+
AstfProgram.classReset();
108+
AstfIpGenDist.classReset();
109+
AstfTemplateBase.classReset();
110+
}
111+
93112
/**
94113
* print stats
95114
*/

src/main/java/com/cisco/trex/stateful/AstfProgram.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@
1818
* Emulation L7 program
1919
*
2020
* @<code> ASTFProgram progServer =new ASTFProgram()
21-
* progServer.recv(len(http_req))
21+
* progServer.recv(http_req.length())
2222
* progServer.send(http_response)
2323
* progServer.delay(10)
2424
* progServer.reset()
2525
* </code>
2626
*/
2727
public class AstfProgram {
28-
2928
private static final int MIN_DELAY = 50;
3029
private static final int MAX_DELAY = 700000;
3130
private static final int MAX_KEEPALIVE = 500000;
@@ -363,7 +362,7 @@ public static JsonArray classToJson() {
363362
}
364363

365364
/**
366-
* class reset, clear all cached buffer
365+
* class reset, clear all cached data
367366
*/
368367
public static void classReset() {
369368
bufList = new BufferList();

src/main/java/com/cisco/trex/stateful/AstfTcpClientTemplate.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,39 @@ public class AstfTcpClientTemplate extends AstfClientTemplate {
3333
private AstfGlobalInfoPerTemplate globalInfoPerTemplate;
3434
private int limit;
3535

36+
/**
37+
* construct
38+
*
39+
* @param astfProgram
40+
* @param iPGen
41+
*/
42+
public AstfTcpClientTemplate(AstfProgram astfProgram, AstfIpGen iPGen) {
43+
this(astfProgram, iPGen, 0);
44+
}
45+
46+
/**
47+
* construct
48+
*
49+
* @param astfProgram
50+
* @param iPGen
51+
* @param limit
52+
*/
53+
public AstfTcpClientTemplate(AstfProgram astfProgram, AstfIpGen iPGen, int limit) {
54+
this(astfProgram, iPGen, 80, limit);
55+
}
56+
57+
/**
58+
* construct
59+
*
60+
* @param astfProgram
61+
* @param iPGen
62+
* @param port
63+
* @param limit
64+
*/
65+
public AstfTcpClientTemplate(AstfProgram astfProgram, AstfIpGen iPGen, int port, int limit) {
66+
this(astfProgram, iPGen, null, port, 1, null, limit);
67+
}
68+
3669
/**
3770
* construct
3871
*

src/main/java/com/cisco/trex/stateful/AstfTcpServerTemplate.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ public class AstfTcpServerTemplate extends AstfTemplateBase {
99
private AstfGlobalInfoPerTemplate globalInfo;
1010
private AstfAssociation assoc;
1111

12+
/**
13+
* construct
14+
*
15+
* @param astfProgram
16+
*/
17+
public AstfTcpServerTemplate(AstfProgram astfProgram) {
18+
this(astfProgram, null, null);
19+
}
20+
1221
/**
1322
* construct
1423
*

src/main/java/com/cisco/trex/stateful/AstfTemplateBase.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,14 @@ public static int getTotalSendBytes(int index) {
4545
* @param astfProgram
4646
* @return program index in the program List
4747
*/
48-
public int addProgram(AstfProgram astfProgram) {
48+
public static int addProgram(AstfProgram astfProgram) {
4949
if (programHash.containsKey(astfProgram)) {
5050
return programHash.get(astfProgram);
5151
}
5252
programList.add(astfProgram);
53-
programIndex = programList.size() - 1;
54-
programHash.put(astfProgram, programIndex);
55-
return programIndex;
56-
}
57-
58-
/**
59-
* clear all cached program
60-
*/
61-
public void clearCache() {
62-
programList.clear();
63-
programHash.clear();
53+
int index = programList.size() - 1;
54+
programHash.put(astfProgram, index);
55+
return index;
6456
}
6557

6658
/**
@@ -90,6 +82,14 @@ public JsonObject toJson() {
9082
return fields;
9183
}
9284

85+
/**
86+
* clear all cached data
87+
*/
88+
public static void classReset() {
89+
programList.clear();
90+
programHash.clear();
91+
}
92+
9393
/**
9494
* including all cached astf template json string
9595
*

0 commit comments

Comments
 (0)