use of datawave.microservice.querymetric.BaseQueryMetric.PageMetric in project datawave by NationalSecurityAgency.
the class HudBean method getRunningQueries.
/**
* Return true if there is at least one log in the last 60 minutes.
*
* @return
* @throws org.apache.accumulo.core.client.TableNotFoundException
*/
@Path("/runningqueries/{userid}")
@GET
public String getRunningQueries(@PathParam("userid") String userId) throws Exception {
DatawavePrincipal principal = getPrincipal();
boolean isAnAdmin = isAnAdmin(principal);
QueryImplListResponse runningQueries = null;
if (isAnAdmin) {
runningQueries = queryExecutor.listQueriesForUser(userId);
} else {
runningQueries = queryExecutor.listUserQueries();
}
List<Query> queryList = runningQueries.getQuery();
List<HudQuerySummary> querySummaryList = new ArrayList<>();
for (Query query : queryList) {
HudQuerySummary summary = summaryBuilder.build(query);
String queryId = query.getId().toString();
List<? extends BaseQueryMetric> queryMetricsList;
queryMetricsList = queryMetrics.query(queryId).getResult();
if (queryMetricsList != null && !queryMetricsList.isEmpty()) {
BaseQueryMetric qm = queryMetricsList.get(0);
List<PageMetric> pageMetrics = qm.getPageTimes();
summary.setPageMetrics(pageMetrics);
summary.setCreateDate(qm.getCreateDate().getTime());
summary.setNumPages(qm.getNumPages());
summary.setNumResults(qm.getNumResults());
summary.setLastUpdated(qm.getLastUpdated().getTime());
summary.setLifeCycle(qm.getLifecycle().toString());
}
querySummaryList.add(summary);
}
return gson.toJson(querySummaryList);
}
use of datawave.microservice.querymetric.BaseQueryMetric.PageMetric in project datawave by NationalSecurityAgency.
the class QueryMetricsBean method updateMetric.
/*
* @PermitAll is necessary because this method is called indirectly from the @PreDestroy method of the QueryExpirationBean and the QueryExpirationBean's
*
* @RunAs annotation is not being honored in the @PreDestroy hook
*/
@PermitAll
public void updateMetric(BaseQueryMetric metric) throws Exception {
DatawavePrincipal dp = getPrincipal();
if (metric.getLastWrittenHash() != metric.hashCode()) {
metric.setLastWrittenHash(metric.hashCode());
try {
metric.setLastUpdated(new Date());
sendQueryMetric(dp, metric);
// PageMetrics now know their own page numbers
// this should keep large queries from blowing up the queue
// Leave the last page on the list so that interceptors can update it.
Iterator<PageMetric> itr = metric.getPageTimes().iterator();
while (metric.getPageTimes().size() > 1) {
itr.next();
itr.remove();
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}
use of datawave.microservice.querymetric.BaseQueryMetric.PageMetric in project datawave-query-metric-service by NationalSecurityAgency.
the class QueryMetricTest method testPageMetricParsingLegacy1.
@Test
public void testPageMetricParsingLegacy1() {
PageMetric pmRef1 = new PageMetric(null, null, 2500, 2000, 3500, 3600, -1, 2200, 3000, 10000);
// pageSize/returnTime/callTime/serializationTime/bytesWritten/pageRequested/pageReturned
String pmText1 = "2500/2000/2200/3000/10000/3500/3600";
PageMetric pm1 = PageMetric.parse(pmText1);
assertEquals("page metrics not equal", pmRef1, pm1);
}
use of datawave.microservice.querymetric.BaseQueryMetric.PageMetric in project datawave-query-metric-service by NationalSecurityAgency.
the class QueryMetricTest method testPageMetricParsingLegacy3.
@Test
public void testPageMetricParsingLegacy3() {
PageMetric pmRef1 = new PageMetric(null, null, 2500, 2000, 0, 0, -1, 0, 0, -1);
// pageSize/returnTime
String pmText1 = "2500/2000";
PageMetric pm1 = PageMetric.parse(pmText1);
assertEquals("page metrics not equal", pmRef1, pm1);
}
use of datawave.microservice.querymetric.BaseQueryMetric.PageMetric in project datawave-query-metric-service by NationalSecurityAgency.
the class QueryMetricTest method testPageMetricParsingLegacy2.
@Test
public void testPageMetricParsingLegacy2() {
PageMetric pmRef1 = new PageMetric(null, null, 2500, 2000, 0, 0, -1, 2200, 3000, 10000);
// pageSize/returnTime/callTime/serializationTime/bytesWritten
String pmText1 = "2500/2000/2200/3000/10000";
PageMetric pm1 = PageMetric.parse(pmText1);
assertEquals("page metrics not equal", pmRef1, pm1);
}
Aggregations