Search in sources :

Example 6 with Subscribe

use of com.google.common.eventbus.Subscribe in project buck by facebook.

the class JavaUtilsLoggingBuildListener method ruleSuspended.

@Subscribe
public void ruleSuspended(BuildRuleEvent.Suspended suspended) {
    LogRecord record = new LogRecord(LEVEL, suspended.toString());
    record.setMillis(suspended.getTimestamp());
    LOG.log(record);
}
Also used : LogRecord(java.util.logging.LogRecord) Subscribe(com.google.common.eventbus.Subscribe)

Example 7 with Subscribe

use of com.google.common.eventbus.Subscribe in project buck by facebook.

the class RuleKeyLoggerListener method onArtifactCacheEvent.

@Subscribe
public void onArtifactCacheEvent(HttpArtifactCacheEvent.Finished event) {
    if (event.getOperation() != ArtifactCacheEvent.Operation.FETCH || !event.getCacheResult().isPresent()) {
        return;
    }
    CacheResultType cacheResultType = event.getCacheResult().get().getType();
    if (cacheResultType != CacheResultType.MISS && cacheResultType != CacheResultType.ERROR) {
        return;
    }
    List<String> newLogLines = Lists.newArrayList();
    for (RuleKey key : event.getRuleKeys()) {
        newLogLines.add(toTsv(key, cacheResultType));
    }
    synchronized (lock) {
        logLines.addAll(newLogLines);
    }
    flushLogLinesIfNeeded();
}
Also used : RuleKey(com.facebook.buck.rules.RuleKey) CacheResultType(com.facebook.buck.artifact_cache.CacheResultType) Subscribe(com.google.common.eventbus.Subscribe)

Example 8 with Subscribe

use of com.google.common.eventbus.Subscribe in project buck by facebook.

the class SuperConsoleEventBusListener method testSummaryFinished.

@Subscribe
public void testSummaryFinished(TestSummaryEvent.Finished finished) {
    threadsToRunningTestSummaryEvent.put(finished.getThreadId(), Optional.empty());
    TestResultSummary testResult = finished.getTestResultSummary();
    ResultType resultType = testResult.getType();
    switch(resultType) {
        case SUCCESS:
            numPassingTests.incrementAndGet();
            break;
        case FAILURE:
            numFailingTests.incrementAndGet();
            // We don't use TestResultFormatter.reportResultSummary() here since that also
            // includes the stack trace and stdout/stderr.
            logEvents.add(ConsoleEvent.severe(String.format(locale, "%s %s %s: %s", testResult.getType().toString(), testResult.getTestCaseName(), testResult.getTestName(), testResult.getMessage())));
            break;
        case ASSUMPTION_VIOLATION:
            numAssumptionViolationTests.incrementAndGet();
            break;
        case DISABLED:
            numDisabledTests.incrementAndGet();
            break;
        case DRY_RUN:
            numDryRunTests.incrementAndGet();
            break;
        case EXCLUDED:
            numExcludedTests.incrementAndGet();
            break;
    }
}
Also used : ResultType(com.facebook.buck.test.result.type.ResultType) TestResultSummary(com.facebook.buck.test.TestResultSummary) Subscribe(com.google.common.eventbus.Subscribe)

Example 9 with Subscribe

use of com.google.common.eventbus.Subscribe in project buck by facebook.

the class AbstractConsoleEventBusListener method parseStarted.

@Subscribe
public void parseStarted(ParseEvent.Started started) {
    parseStarted.add(started);
    EventKey eventKey = started.getEventKey();
    if (!buckFilesProcessing.containsKey(eventKey)) {
        buckFilesProcessing.put(eventKey, EventPair.builder().setStart(started).build());
    } else {
        EventPair pair = buckFilesProcessing.get(eventKey);
        buckFilesProcessing.put(eventKey, pair.withStart(started));
    }
}
Also used : EventKey(com.facebook.buck.event.EventKey) Subscribe(com.google.common.eventbus.Subscribe)

Example 10 with Subscribe

use of com.google.common.eventbus.Subscribe in project buck by facebook.

the class AbstractConsoleEventBusListener method parseFinished.

@Subscribe
public void parseFinished(ParseEvent.Finished finished) {
    parseFinished.add(finished);
    if (progressEstimator.isPresent()) {
        progressEstimator.get().didFinishParsing();
    }
    EventKey eventKey = finished.getEventKey();
    if (!buckFilesProcessing.containsKey(eventKey)) {
        buckFilesProcessing.put(eventKey, EventPair.builder().setFinish(finished).build());
    } else {
        EventPair pair = buckFilesProcessing.get(eventKey);
        buckFilesProcessing.put(eventKey, pair.withFinish(finished));
    }
}
Also used : EventKey(com.facebook.buck.event.EventKey) Subscribe(com.google.common.eventbus.Subscribe)

Aggregations

Subscribe (com.google.common.eventbus.Subscribe)115 AllowConcurrentEvents (com.google.common.eventbus.AllowConcurrentEvents)13 EventBus (com.google.common.eventbus.EventBus)11 BuckEventBus (com.facebook.buck.event.BuckEventBus)10 Test (org.junit.Test)10 UPID (com.groupon.mesos.util.UPID)8 Scheduler (org.apache.mesos.Scheduler)8 SchedulerDriver (org.apache.mesos.SchedulerDriver)8 IOException (java.io.IOException)7 InternalCallContext (org.killbill.billing.callcontext.InternalCallContext)7 FakeClock (com.facebook.buck.timing.FakeClock)6 ArrayList (java.util.ArrayList)6 LogRecord (java.util.logging.LogRecord)6 Description (org.junit.runner.Description)6 WatchEvent (java.nio.file.WatchEvent)5 EasyMock.anyObject (org.easymock.EasyMock.anyObject)5 EventKey (com.facebook.buck.event.EventKey)4 Action (com.google.devtools.build.lib.actions.Action)4 File (java.io.File)4 UUID (java.util.UUID)4