Search in sources :

Example 6 with CollectedUpdateMetrics

use of org.wikidata.query.rdf.tool.rdf.CollectedUpdateMetrics in project wikidata-query-rdf by wikimedia.

the class UpdateMetricsResponseHandler method extractMetrics.

private CollectedUpdateMetrics extractMetrics(String[] lines) throws IOException {
    CollectedUpdateMetrics collectedUpdateMetrics = new CollectedUpdateMetrics();
    Iterator<String> lineIterator = getPerQueryResponses(lines);
    for (MultiSyncStep step : requiredSteps) {
        if (lineIterator.hasNext()) {
            collectedUpdateMetrics.merge(step, getUpdateMetrics(lineIterator.next()));
        } else {
            throw new IOException("Response didn't match the query!");
        }
    }
    Map<String, String> summaryMetrics = extractSummaryMetrics(lines);
    Integer commitTotalElapsed = asInt(summaryMetrics.get(COMMIT_TOTAL_ELAPSED));
    if (commitTotalElapsed != null)
        collectedUpdateMetrics.setCommitTotalElapsed(commitTotalElapsed);
    Integer mutationCount = asInt(summaryMetrics.get(MUTATION_COUNT));
    if (mutationCount == null)
        throw new IOException("Couldn't find the mutation count!");
    collectedUpdateMetrics.setMutationCount(mutationCount);
    return collectedUpdateMetrics;
}
Also used : MultiSyncStep(org.wikidata.query.rdf.tool.rdf.MultiSyncStep) CollectedUpdateMetrics(org.wikidata.query.rdf.tool.rdf.CollectedUpdateMetrics) IOException(java.io.IOException)

Example 7 with CollectedUpdateMetrics

use of org.wikidata.query.rdf.tool.rdf.CollectedUpdateMetrics in project wikidata-query-rdf by wikimedia.

the class UpdateMetricsResponseHandler method parse.

@Override
public CollectedUpdateMetrics parse(ContentResponse entity) throws IOException {
    String content = entity.getContentAsString();
    String[] lines = content.split("\\r?\\n");
    CollectedUpdateMetrics collectedUpdateMetrics = extractMetrics(lines);
    log.debug("Received metrics from update: {}", collectedUpdateMetrics);
    return collectedUpdateMetrics;
}
Also used : CollectedUpdateMetrics(org.wikidata.query.rdf.tool.rdf.CollectedUpdateMetrics)

Aggregations

CollectedUpdateMetrics (org.wikidata.query.rdf.tool.rdf.CollectedUpdateMetrics)7 Test (org.junit.Test)4 MultiSyncStep (org.wikidata.query.rdf.tool.rdf.MultiSyncStep)3 Counter (com.codahale.metrics.Counter)1 MetricRegistry (com.codahale.metrics.MetricRegistry)1 IOException (java.io.IOException)1 Instant (java.time.Instant)1 Arrays.asList (java.util.Arrays.asList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 ExecutorService (java.util.concurrent.ExecutorService)1 Change (org.wikidata.query.rdf.tool.change.Change)1 Munger (org.wikidata.query.rdf.tool.rdf.Munger)1 RdfRepository (org.wikidata.query.rdf.tool.rdf.RdfRepository)1 WikibaseRepository (org.wikidata.query.rdf.tool.wikibase.WikibaseRepository)1