/** * Finds matching template for the given {@link HttpTimerData} by tag value. * * @param httpTimerData * Data to find matching template. * @param templates * List of templates to search. * @return Matching template of <code>null</code> if one can not be found. */ private HttpTimerData findTemplateForTagData(HttpTimerData httpTimerData, List<HttpTimerData> templates) { for (HttpTimerData template : templates) { if (Objects.equals(template.getHttpInfo().getInspectItTaggingHeaderValue(), httpTimerData.getHttpInfo().getInspectItTaggingHeaderValue())) { if (HttpTimerData.REQUEST_METHOD_MULTIPLE.equals(template.getHttpInfo().getRequestMethod()) || Objects.equals(template.getHttpInfo().getRequestMethod(), httpTimerData.getHttpInfo().getRequestMethod())) { return template; } } } return null; }
/** * Finds matching template for the given {@link HttpTimerData} by uri. * * @param httpTimerData * Data to find matching template. * @param templates * List of templates to search. * @param checkOnlyUri * If matching should be done only by uri. * @return Matching template of <code>null</code> if one can not be found. */ private HttpTimerData findTemplateForUriData(HttpTimerData httpTimerData, List<HttpTimerData> templates, boolean checkOnlyUri) { for (HttpTimerData template : templates) { if (Objects.equals(template.getHttpInfo().getUri(), httpTimerData.getHttpInfo().getUri())) { if (!checkOnlyUri && HttpTimerData.REQUEST_METHOD_MULTIPLE.equals(template.getHttpInfo().getRequestMethod())) { return template; } else if (Objects.equals(template.getHttpInfo().getRequestMethod(), httpTimerData.getHttpInfo().getRequestMethod())) { return template; } } } return null; }
/** * {@inheritDoc} */ @Override public String[] getStringValues(InvocationSequenceData invocSequence, ICachedDataService cachedDataService) { if (!InvocationSequenceDataHelper.hasHttpTimerData(invocSequence)) { return new String[0]; } HttpTimerData httpData = (HttpTimerData) invocSequence.getTimerData(); return new String[] { httpData.getHttpInfo().getRequestMethod() }; }
String requestMethod = httpInfo.getRequestMethod();
/** * Finds matching template for the given {@link HttpTimerData} based on if regular expression * transformation is active or not. * * @param httpTimerData * Data to find matching template. * @return Matching template of <code>null</code> if one can not be found. */ private HttpTimerData findTemplateForData(HttpTimerData httpTimerData) { if (regExTransformation) { for (RegExAggregatedHttpTimerData regExTemplate : regExTemplates) { if (HttpTimerData.REQUEST_METHOD_MULTIPLE.equals(regExTemplate.getHttpInfo().getRequestMethod()) || Objects.equals(regExTemplate.getHttpInfo().getRequestMethod(), httpTimerData.getHttpInfo().getRequestMethod())) { if (null != findTemplateForUriData(httpTimerData, regExTemplate.getAggregatedDataList(), true)) { return regExTemplate; } } } } else if (plotByTagValue) { return findTemplateForTagData(httpTimerData, templates); } else { return findTemplateForUriData(httpTimerData, templates, false); } return null; }
/** * Returns the series key for the {@link HttpTimerData} object. * * @param httpTimerData * {@link HttpTimerData}. * @return Key used to initialize the series and later on compare which series data should be * added to. */ @Override protected Comparable<?> getSeriesKey(HttpTimerData httpTimerData) { if (regExTransformation && (httpTimerData instanceof RegExAggregatedHttpTimerData)) { return "Transformed URI: " + ((RegExAggregatedHttpTimerData) httpTimerData).getTransformedUri() + " [" + httpTimerData.getHttpInfo().getRequestMethod() + "]"; } else { if (plotByTagValue) { return "Tag: " + httpTimerData.getHttpInfo().getInspectItTaggingHeaderValue() + " [" + httpTimerData.getHttpInfo().getRequestMethod() + "]"; } else { return "URI: " + httpTimerData.getHttpInfo().getUri() + " [" + httpTimerData.getHttpInfo().getRequestMethod() + "]"; } } }
/** * {@inheritDoc} */ @Override public Object getAggregationKey(HttpTimerData httpData) { final int prime = 31; int result = 0; if (uriBased) { result = (prime * result) + ((httpData.getHttpInfo().getUri() == null) ? 0 : httpData.getHttpInfo().getUri().hashCode()); } else { result = (prime * result) + ((httpData.getHttpInfo().getInspectItTaggingHeaderValue() == null) ? 0 : httpData.getHttpInfo().getInspectItTaggingHeaderValue().hashCode()); } if (includeRequestMethod) { result = (prime * result) + ((httpData.getHttpInfo().getRequestMethod() == null) ? 0 : httpData.getHttpInfo().getRequestMethod().hashCode()); } return result; }
/** * {@inheritDoc} */ @Override public void aggregate(IAggregatedData<HttpTimerData> aggregatedObject, HttpTimerData objectToAdd) { if (!uriBased) { if (!objectToAdd.getHttpInfo().hasInspectItTaggingHeader()) { // use case aggregation for elements that do not have any tagged value does not // make sense, thus we ignore these. return; } } aggregatedObject.aggregate(objectToAdd); if (!includeRequestMethod) { // If we have different request methods, we set the request method to "multiple" if (!objectToAdd.getHttpInfo().getRequestMethod().equals(aggregatedObject.getData().getHttpInfo().getRequestMethod()) && !aggregatedObject.getData().getHttpInfo().getRequestMethod().equals(HttpTimerData.REQUEST_METHOD_MULTIPLE)) { aggregatedObject.getData().getHttpInfo().setRequestMethod(HttpTimerData.REQUEST_METHOD_MULTIPLE); } } }
@Override public boolean matches(Object object) { if (!HttpTimerData.class.isInstance(object)) { return false; } HttpTimerData other = (HttpTimerData) object; assertThat(data.getHttpInfo().getUri(), is(equalTo(other.getHttpInfo().getUri()))); assertThat(data.getHttpInfo().getRequestMethod(), is(equalTo(other.getHttpInfo().getRequestMethod()))); assertThat(data.getAttributes(), is(equalTo(other.getAttributes()))); assertThat(data.getHeaders(), is(equalTo(other.getHeaders()))); assertThat(data.getSessionAttributes(), is(equalTo(other.getSessionAttributes()))); assertThat(data.getParameters(), is(equalTo(other.getParameters()))); assertThat(data.isCharting(), is(equalTo(other.isCharting()))); assertThat(data.getHttpResponseStatus(), is(equalTo(other.getHttpResponseStatus()))); return true; } }
/** * {@inheritDoc} */ @Override public int compare(HttpTimerData o1, HttpTimerData o2) { switch (this) { case URI: return ObjectUtils.compare(o1.getHttpInfo().getUri(), o2.getHttpInfo().getUri()); case HTTP_METHOD: return ObjectUtils.compare(o1.getHttpInfo().getRequestMethod(), o2.getHttpInfo().getRequestMethod()); case TAG_VALUE: return ObjectUtils.compare(o1.getHttpInfo().getInspectItTaggingHeaderValue(), o2.getHttpInfo().getInspectItTaggingHeaderValue()); default: return 0; } }
table.addContentRow("Method:", null, new DetailsCellContent[] { new DetailsCellContent(StringUtils.defaultString(httpTimerData.getHttpInfo().getRequestMethod(), NOT_AVAILABLE)) }); table.addContentRow("Server Name:", null, new DetailsCellContent[] { new DetailsCellContent(StringUtils.defaultString(httpTimerData.getHttpInfo().getServerName(), NOT_AVAILABLE)) }); table.addContentRow("Port:", null, new DetailsCellContent[] { new DetailsCellContent(portDescription) });
HttpTimerData template = templates.get(0); if (plotByTagValue) { editorPropertiesData.setViewName("Tag: " + template.getHttpInfo().getInspectItTaggingHeaderValue() + " [" + template.getHttpInfo().getRequestMethod() + "]"); } else { editorPropertiesData.setViewName("URI: " + template.getHttpInfo().getUri() + " [" + template.getHttpInfo().getRequestMethod() + "]"); editorPropertiesData.setViewName("Transformed URI: " + regExTemplate.getTransformedUri() + " [" + regExTemplate.getHttpInfo().getRequestMethod() + "]"); } else { editorPropertiesData.setViewName("Multiple HTTP data");
/** * {@inheritDoc} */ @Override public IAggregatedData<HttpTimerData> getClone(HttpTimerData httpData) { AggregatedHttpTimerData clone = new AggregatedHttpTimerData(); clone.setPlatformIdent(httpData.getPlatformIdent()); clone.setSensorTypeIdent(httpData.getSensorTypeIdent()); clone.setMethodIdent(httpData.getMethodIdent()); clone.setCharting(httpData.isCharting()); if (uriBased) { clone.getHttpInfo().setUri(httpData.getHttpInfo().getUri()); } else { // Aggregation based on Usecase. We reset the URI so that we can easily know // that use case aggregation is used. clone.getHttpInfo().setUri(HttpInfo.UNDEFINED); clone.getHttpInfo().setInspectItTaggingHeaderValue(httpData.getHttpInfo().getInspectItTaggingHeaderValue()); } clone.getHttpInfo().setRequestMethod(httpData.getHttpInfo().getRequestMethod()); return clone; }
return new StyledString(data.getHttpInfo().getInspectItTaggingHeaderValue()); case HTTP_METHOD: return new StyledString(data.getHttpInfo().getRequestMethod()); case INVOCATION_AFFILLIATION: int percentage = (int) (data.getInvocationAffiliationPercentage() * 100);
return new StyledString(data.getHttpInfo().getRequestMethod()); case INVOCATION_AFFILLIATION: int percentage = (int) (data.getInvocationAffiliationPercentage() * 100);