@@ -67,17 +67,18 @@ public Arguments getDefaultParameters() {
67
67
@ Override
68
68
public void setupTest (BackendListenerContext context ) throws Exception {
69
69
try {
70
- String host = context .getParameter (ES_HOST );
71
- this .filters = new LinkedList <String >();
72
- int port = Integer .parseInt (context .getParameter (ES_PORT ));
73
- this .index = context .getParameter (ES_INDEX ).toLowerCase ();
74
- this .bulkSize = Integer .parseInt (context .getParameter (ES_BULK_SIZE ));
75
- this .timeoutMs = JMeterUtils .getPropDefault (ES_TIMEOUT_MS , DEFAULT_TIMEOUT_MS );
76
- this .buildNumber = (JMeterUtils .getProperty (ElasticsearchBackend .BUILD_NUMBER ) != null && JMeterUtils .getProperty (ElasticsearchBackend .BUILD_NUMBER ).trim () != "" )
77
- ? Integer .parseInt (JMeterUtils .getProperty (ElasticsearchBackend .BUILD_NUMBER )) : 0 ;
70
+ String host = context .getParameter (ES_HOST );
71
+ int port = Integer .parseInt (context .getParameter (ES_PORT ));
72
+
73
+ this .filters = new LinkedList <String >();
74
+ this .bulkRequestList = new LinkedList <String >();
75
+ this .index = context .getParameter (ES_INDEX ).toLowerCase ();
76
+ this .bulkSize = Integer .parseInt (context .getParameter (ES_BULK_SIZE ));
77
+ this .timeoutMs = JMeterUtils .getPropDefault (ES_TIMEOUT_MS , DEFAULT_TIMEOUT_MS );
78
+ this .buildNumber = (JMeterUtils .getProperty (ElasticsearchBackend .BUILD_NUMBER ) != null && JMeterUtils .getProperty (ElasticsearchBackend .BUILD_NUMBER ).trim () != "" ) ? Integer .parseInt (JMeterUtils .getProperty (ElasticsearchBackend .BUILD_NUMBER )) : 0 ;
78
79
this .client = RestClient .builder (new HttpHost (context .getParameter (ES_HOST ), port , context .getParameter (ES_SCHEME )))
79
80
.setRequestConfigCallback (requestConfigBuilder -> requestConfigBuilder .setConnectTimeout (5000 )
80
- .setSocketTimeout ((int ) timeoutMs ))
81
+ .setSocketTimeout ((int ) timeoutMs ))
81
82
.setFailureListener (new RestClient .FailureListener () {
82
83
@ Override
83
84
public void onFailure (HttpHost host ) {
@@ -86,7 +87,7 @@ public void onFailure(HttpHost host) {
86
87
})
87
88
.setMaxRetryTimeoutMillis (60000 )
88
89
.build ();
89
- this . bulkRequestList = new LinkedList < String >();
90
+
90
91
String [] filterArray = (context .getParameter (ES_SAMPLE_FILTER ).contains (";" )) ? context .getParameter (ES_SAMPLE_FILTER ).split (";" ) : new String [] {context .getParameter (ES_SAMPLE_FILTER )};
91
92
if (filterArray .length >= 1 && filterArray [0 ].trim () != "" ) {
92
93
for (String filter : filterArray ) {
@@ -125,11 +126,8 @@ public void handleSampleResults(List<SampleResult> results, BackendListenerConte
125
126
126
127
validSample = (context .getParameter (ES_TEST_MODE ).trim ().equals ("error" ) && sr .isSuccessful ()) ? false : true ;
127
128
128
- if (validSample ) {
129
- Gson gson = new Gson ();
130
- String json = gson .toJson (this .getElasticData (sr , context ));
131
- this .bulkRequestList .add (json );
132
- }
129
+ if (validSample )
130
+ this .bulkRequestList .add (new Gson ().toJson (this .getElasticData (sr , context )));
133
131
}
134
132
135
133
if (this .bulkRequestList .size () >= this .bulkSize ) {
0 commit comments