Java Code Examples for org.apache.jmeter.visualizers.backend.BackendListenerContext#getParameter()
The following examples show how to use
org.apache.jmeter.visualizers.backend.BackendListenerContext#getParameter() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoadosophiaClient.java From jmeter-bzm-plugins with Apache License 2.0 | 5 votes |
private void init(BackendListenerContext context) { token = context.getParameter(LoadosophiaUploader.UPLOAD_TOKEN); project = context.getParameter(LoadosophiaUploader.PROJECT); color = context.getParameter(LoadosophiaUploader.COLOR); title = context.getParameter(LoadosophiaUploader.TITLE); fileName = context.getParameter(LoadosophiaUploader.FILE_NAME); isOnlineInitiated = Boolean.parseBoolean(context.getParameter(LoadosophiaUploader.USE_ONLINE)); }
Example 2
Source File: ElasticsearchBackendClient.java From jmeter-elasticsearch-backend-listener with MIT License | 5 votes |
/** * Method that converts a semicolon separated list contained in a parameter into a string set * @param context * @param parameter * @param set */ private void convertParameterToSet(BackendListenerContext context, String parameter, Set<String> set) { String[] array = (context.getParameter(parameter).contains(";")) ? context.getParameter(parameter).split(";") : new String[] { context.getParameter(parameter) }; if (array.length > 0 && !array[0].trim().equals("")) { for (String entry : array) { set.add(entry.toLowerCase().trim()); if(logger.isDebugEnabled()) logger.debug("Parsed from " + parameter + ": " + entry.toLowerCase().trim()); } } }
Example 3
Source File: ElasticsearchBackendClient.java From jmeter-elasticsearch-backend-listener with MIT License | 5 votes |
/** * Method that sets the SSL configuration to be able to send requests to a secured endpoint * @param context */ private void setSSLConfiguration(BackendListenerContext context) { String keyStorePath = context.getParameter(ES_SSL_KEYSTORE_PATH); if (!keyStorePath.equalsIgnoreCase("")) { logger.warn("KeyStore system properties overwritten by ES SSL configuration."); System.setProperty("javax.net.ssl.keyStore", keyStorePath); System.setProperty("javax.net.ssl.keyStorePassword", context.getParameter(ES_SSL_KEYSTORE_PW)); switch (FilenameUtils.getExtension(keyStorePath)) { case "jks": System.setProperty("javax.net.ssl.keyStoreType", "jks"); break; case "p12": System.setProperty("javax.net.ssl.keyStoreType", "pkcs12"); break; default: System.setProperty("javax.net.ssl.keyStoreType", ""); break; } } String trustStorePath = context.getParameter(ES_SSL_TRUSTSTORE_PATH); if (!trustStorePath.equalsIgnoreCase("")) { logger.warn("TrustStore system properties overwritten by ES SSL configuration."); System.setProperty("javax.net.ssl.trustStore", trustStorePath); System.setProperty("javax.net.ssl.trustStorePassword", context.getParameter(ES_SSL_TRUSTSTORE_PW)); switch (FilenameUtils.getExtension(trustStorePath)) { case "jks": System.setProperty("javax.net.ssl.trustStoreType", "jks"); break; case "p12": System.setProperty("javax.net.ssl.trustStoreType", "pkcs12"); break; default: System.setProperty("javax.net.ssl.trustStoreType", ""); break; } } }
Example 4
Source File: JMeterInfluxDBBackendListenerClient.java From JMeter-InfluxDB-Writer with Apache License 2.0 | 5 votes |
@Override public void setupTest(BackendListenerContext context) throws Exception { testName = context.getParameter(KEY_TEST_NAME, "Test"); runId = context.getParameter(KEY_RUN_ID,"R001"); //Will be used to compare performance of R001, R002, etc of 'Test' randomNumberGenerator = new Random(); nodeName = context.getParameter(KEY_NODE_NAME, "Test-Node"); setupInfluxClient(context); influxDB.write( influxDBConfig.getInfluxDatabase(), influxDBConfig.getInfluxRetentionPolicy(), Point.measurement(TestStartEndMeasurement.MEASUREMENT_NAME).time(System.currentTimeMillis(), TimeUnit.MILLISECONDS) .tag(TestStartEndMeasurement.Tags.TYPE, TestStartEndMeasurement.Values.STARTED) .tag(TestStartEndMeasurement.Tags.NODE_NAME, nodeName) .tag(TestStartEndMeasurement.Tags.TEST_NAME, testName) .addField(TestStartEndMeasurement.Fields.PLACEHOLDER, "1") .build()); parseSamplers(context); scheduler = Executors.newScheduledThreadPool(1); scheduler.scheduleAtFixedRate(this, 1, 1, TimeUnit.SECONDS); // Indicates whether to write sub sample records to the database recordSubSamples = Boolean.parseBoolean(context.getParameter(KEY_RECORD_SUB_SAMPLES, "false")); }
Example 5
Source File: JMeterInfluxDBBackendListenerClient.java From JMeter-InfluxDB-Writer with Apache License 2.0 | 5 votes |
/** * Parses list of samplers. * * @param context * {@link BackendListenerContext}. */ private void parseSamplers(BackendListenerContext context) { samplersList = context.getParameter(KEY_SAMPLERS_LIST, ""); samplersToFilter = new HashSet<String>(); if (context.getBooleanParameter(KEY_USE_REGEX_FOR_SAMPLER_LIST, false)) { regexForSamplerList = samplersList; } else { regexForSamplerList = null; String[] samplers = samplersList.split(SEPARATOR); samplersToFilter = new HashSet<String>(); for (String samplerName : samplers) { samplersToFilter.add(samplerName); } } }
Example 6
Source File: InfluxDBConfig.java From JMeter-InfluxDB-Writer with Apache License 2.0 | 5 votes |
public InfluxDBConfig(BackendListenerContext context) { String influxDBHost = context.getParameter(KEY_INFLUX_DB_HOST); if (StringUtils.isEmpty(influxDBHost)) { throw new IllegalArgumentException(KEY_INFLUX_DB_HOST + "must not be empty!"); } setInfluxDBHost(influxDBHost); int influxDBPort = context.getIntParameter(KEY_INFLUX_DB_PORT, InfluxDBConfig.DEFAULT_PORT); setInfluxDBPort(influxDBPort); String influxUser = context.getParameter(KEY_INFLUX_DB_USER); setInfluxUser(influxUser); String influxPassword = context.getParameter(KEY_INFLUX_DB_PASSWORD); setInfluxPassword(influxPassword); String influxDatabase = context.getParameter(KEY_INFLUX_DB_DATABASE); if (StringUtils.isEmpty(influxDatabase)) { throw new IllegalArgumentException(KEY_INFLUX_DB_DATABASE + "must not be empty!"); } setInfluxDatabase(influxDatabase); String influxRetentionPolicy = context.getParameter(KEY_RETENTION_POLICY, DEFAULT_RETENTION_POLICY); if (StringUtils.isEmpty(influxRetentionPolicy)) { influxRetentionPolicy = DEFAULT_RETENTION_POLICY; } setInfluxRetentionPolicy(influxRetentionPolicy); String influxHTTPScheme = context.getParameter(KEY_HTTP_SCHEME, DEFAULT_HTTP_SCHEME); if (StringUtils.isEmpty(influxHTTPScheme)) { influxHTTPScheme = DEFAULT_HTTP_SCHEME; } // TODO: no checks but should be only "http" and "https" setInfluxHTTPScheme(influxHTTPScheme); }
Example 7
Source File: JMeterInfluxDBImportFileClient.java From JMeter-InfluxDB-Writer with Apache License 2.0 | 5 votes |
@Override public void setupTest(BackendListenerContext context) throws Exception { testName = context.getParameter(KEY_TEST_NAME, "Test"); File exportFile = new File(context.getParameter(KEY_FILE_PATH, "influxDBExport.txt")); if (exportFile.getParentFile() != null && !exportFile.getParentFile().exists()) { exportFile.getParentFile().mkdirs(); } if (exportFile.exists()) { exportFile.delete(); boolean created = exportFile.createNewFile(); if (!created) { throw new RuntimeException("Export file could not be created!"); } } exportFileWriter = new BufferedWriter(new FileWriter(exportFile)); Point startPoint = Point.measurement(TestStartEndMeasurement.MEASUREMENT_NAME).time(System.currentTimeMillis(), TimeUnit.MILLISECONDS) .tag(TestStartEndMeasurement.Tags.TYPE, TestStartEndMeasurement.Values.STARTED).tag(TestStartEndMeasurement.Tags.TEST_NAME, testName).build(); exportFileWriter.append(startPoint.lineProtocol()); exportFileWriter.newLine(); parseSamplers(context); scheduler = Executors.newScheduledThreadPool(1); scheduler.scheduleAtFixedRate(this, 1, 1, TimeUnit.SECONDS); }
Example 8
Source File: JMeterInfluxDBImportFileClient.java From JMeter-InfluxDB-Writer with Apache License 2.0 | 5 votes |
/** * Parses list of samplers. * * @param context * {@link BackendListenerContext}. */ private void parseSamplers(BackendListenerContext context) { samplersList = context.getParameter(KEY_SAMPLERS_LIST, ""); samplersToFilter = new HashSet<String>(); if (context.getBooleanParameter(KEY_USE_REGEX_FOR_SAMPLER_LIST, false)) { regexForSamplerList = samplersList; } else { regexForSamplerList = null; String[] samplers = samplersList.split(SEPARATOR); samplersToFilter = new HashSet<String>(); for (String samplerName : samplers) { samplersToFilter.add(samplerName); } } }
Example 9
Source File: ElasticsearchBackendClient.java From jmeter-elasticsearch-backend-listener with MIT License | 4 votes |
@Override public void setupTest(BackendListenerContext context) throws Exception { try { this.filters = new HashSet<>(); this.fields = new HashSet<>(); this.modes = new HashSet<>(Arrays.asList("info", "debug", "error", "quiet")); this.bulkSize = Integer.parseInt(context.getParameter(ES_BULK_SIZE)); this.timeoutMs = Integer.parseInt((context.getParameter(ES_TIMEOUT_MS))); this.buildNumber = (JMeterUtils.getProperty(ElasticsearchBackendClient.BUILD_NUMBER) != null && !JMeterUtils.getProperty(ElasticsearchBackendClient.BUILD_NUMBER).trim().equals("")) ? Integer.parseInt(JMeterUtils.getProperty(ElasticsearchBackendClient.BUILD_NUMBER)) : 0; setSSLConfiguration(context); if (context.getParameter(ES_AWS_ENDPOINT).equalsIgnoreCase("")) { client = RestClient .builder(new HttpHost(context.getParameter(ES_HOST), Integer.parseInt(context.getParameter(ES_PORT)), context.getParameter(ES_SCHEME))) .setRequestConfigCallback(requestConfigBuilder -> requestConfigBuilder.setConnectTimeout(5000) .setSocketTimeout((int) timeoutMs)) .setFailureListener(new RestClient.FailureListener() { @Override public void onFailure(Node node) { logger.error("Error with node: " + node.toString()); } }).build(); } else { AWS4Signer signer = new AWS4Signer(); signer.setServiceName(SERVICE_NAME); signer.setRegionName(context.getParameter(ES_AWS_REGION)); HttpRequestInterceptor interceptor = new AWSRequestSigningApacheInterceptor(SERVICE_NAME, signer, credentialsProvider); client = RestClient.builder(HttpHost.create(context.getParameter(ES_AWS_ENDPOINT))) .setHttpClientConfigCallback(hacb -> hacb.addInterceptorLast(interceptor)).build(); } convertParameterToSet(context, ES_SAMPLE_FILTER, this.filters); convertParameterToSet(context, ES_FIELDS, this.fields); this.sender = new ElasticSearchMetricSender(client, context.getParameter(ES_INDEX).toLowerCase(), context.getParameter(ES_AUTH_USER), context.getParameter(ES_AUTH_PWD), context.getParameter(ES_AWS_ENDPOINT)); this.sender.createIndex(); this.esVersion = sender.getElasticSearchVersion(); checkTestMode(context.getParameter(ES_TEST_MODE)); super.setupTest(context); } catch (Exception e) { throw new IllegalStateException("Unable to connect to the ElasticSearch engine", e); } }