Search in sources :

Example 1 with CacheResultType

use of com.facebook.buck.artifact_cache.CacheResultType 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 2 with CacheResultType

use of com.facebook.buck.artifact_cache.CacheResultType in project buck by facebook.

the class CacheCommand method cacheResultToString.

private String cacheResultToString(CacheResult cacheResult) {
    CacheResultType type = cacheResult.getType();
    String typeString = type.toString();
    switch(type) {
        case ERROR:
            return String.format("%s %s", typeString, cacheResult.getCacheError());
        case HIT:
            return String.format("%s %s", typeString, cacheResult.getCacheSource());
        case MISS:
        case IGNORED:
        case LOCAL_KEY_UNCHANGED_HIT:
        default:
            return typeString;
    }
}
Also used : CacheResultType(com.facebook.buck.artifact_cache.CacheResultType)

Aggregations

CacheResultType (com.facebook.buck.artifact_cache.CacheResultType)2 RuleKey (com.facebook.buck.rules.RuleKey)1 Subscribe (com.google.common.eventbus.Subscribe)1