Search in sources :

Example 6 with TraceContext

use of com.google.cloud.trace.core.TraceContext in project activityinfo by bedatadriven.

the class GetSitesHandler method executeBatch.

private void executeBatch() {
    TraceContext batchExecutionTrace = Trace.startSpan("ai/cmd/GetSites/executeBatch");
    try {
        queryExecTime.start();
        TraceContext fetchTrace = Trace.startSpan("ai/cmd/GetSites/executeBatch/fetchColumns");
        queryFetchTime.start();
        builder.execute(batch);
        linkedBuilder.execute(linkedBatch);
        queryFetchTime.stop();
        Trace.endSpan(fetchTrace);
    } catch (Exception excp) {
        throw new RuntimeException("Failed to execute query batch", excp);
    }
    TraceContext dataExtractionTrace = Trace.startSpan("ai/cmd/GetSites/executeBatch/extractColumnData");
    queryExtractTime.start();
    for (Runnable handler : queryResultHandlers) {
        handler.run();
    }
    queryExtractTime.stop();
    Trace.endSpan(dataExtractionTrace);
    queryExecTime.stop();
    Trace.endSpan(batchExecutionTrace);
}
Also used : TraceContext(com.google.cloud.trace.core.TraceContext) SQLException(java.sql.SQLException) CommandException(org.activityinfo.legacy.shared.exception.CommandException)

Example 7 with TraceContext

use of com.google.cloud.trace.core.TraceContext in project activityinfo by bedatadriven.

the class GetSitesHandler method sort.

private void sort() {
    if (sortInfo != null && !siteList.isEmpty()) {
        TraceContext sortTrace = Trace.startSpan("ai/cmd/GetSites/executeBatch/sortSites");
        SiteComparator comparator = new SiteComparator(sortInfo);
        Collections.sort(siteList, comparator);
        Trace.endSpan(sortTrace);
    }
}
Also used : TraceContext(com.google.cloud.trace.core.TraceContext)

Example 8 with TraceContext

use of com.google.cloud.trace.core.TraceContext in project activityinfo by bedatadriven.

the class GetSyncRegionUpdatesHandler method execute.

@Override
public CommandResult execute(GetSyncRegionUpdates cmd, User user) throws CommandException {
    Log.info("Fetching updates for " + cmd.getRegionPath() + ", localVersion = " + cmd.getLocalVersion());
    UpdateBuilder builder;
    if (cmd.getRegionType().equals(DbUpdateBuilder.REGION_TYPE)) {
        builder = injector.getInstance(DbUpdateBuilder.class);
    } else if (cmd.getRegionType().equals(AdminUpdateBuilder.REGION_TYPE)) {
        builder = injector.getInstance(AdminUpdateBuilder.class);
    } else if (cmd.getRegionType().equals(LocationUpdateBuilder.REGION_TYPE)) {
        builder = injector.getInstance(LocationUpdateBuilder.class);
    } else if (cmd.getRegionType().equals(SiteUpdateBuilder.REGION_TYPE)) {
        builder = injector.getInstance(SiteUpdateBuilder.class);
    } else if (cmd.getRegionType().equals(TableDefinitionUpdateBuilder.REGION_TYPE)) {
        builder = injector.getInstance(TableDefinitionUpdateBuilder.class);
    } else if (cmd.getRegionType().equals(CountryUpdateBuilder.REGION_TYPE)) {
        builder = injector.getInstance(CountryUpdateBuilder.class);
    } else {
        throw new CommandException("Unknown sync region: " + cmd.getRegionPath());
    }
    TraceContext traceContext = Trace.startSpan("/ai/cmd/sync/" + prefix(cmd.getRegionPath()));
    try {
        return builder.build(user, cmd);
    } catch (Exception e) {
        LOGGER.log(Level.SEVERE, e.getMessage(), e);
        throw new RuntimeException(e);
    } finally {
        Trace.endSpan(traceContext);
    }
}
Also used : TraceContext(com.google.cloud.trace.core.TraceContext) CommandException(org.activityinfo.legacy.shared.exception.CommandException) CommandException(org.activityinfo.legacy.shared.exception.CommandException)

Aggregations

TraceContext (com.google.cloud.trace.core.TraceContext)8 CommandException (org.activityinfo.legacy.shared.exception.CommandException)4 SQLException (java.sql.SQLException)3 ResourceId (org.activityinfo.model.resource.ResourceId)2 Filter (org.activityinfo.legacy.shared.command.Filter)1 FormTree (org.activityinfo.model.formTree.FormTree)1 QueryFilter (org.activityinfo.server.command.QueryFilter)1 Activity (org.activityinfo.store.mysql.metadata.Activity)1 LinkedActivity (org.activityinfo.store.mysql.metadata.LinkedActivity)1