Search in sources :

Example 1 with ScribeData

use of com.facebook.buck.distributed.thrift.ScribeData in project buck by facebook.

the class ThriftScribeLogger method sendViaThrift.

private void sendViaThrift(String category, Iterable<String> lines) throws IOException {
    //Prepare log request.
    ScribeData scribeData = new ScribeData();
    scribeData.setCategory(category);
    copyLinesWithoutNulls(lines, scribeData);
    LogRequest logRequest = new LogRequest();
    logRequest.setType(LogRequestType.SCRIBE_DATA);
    logRequest.setScribeData(scribeData);
    // Wrap in high-level request & response.
    FrontendRequest request = new FrontendRequest();
    request.setType(FrontendRequestType.LOG);
    request.setLogRequest(logRequest);
    FrontendResponse response = new FrontendResponse();
    thriftService.makeRequest(request, response);
    if (!response.isWasSuccessful()) {
        throw new IOException(String.format("Log request failed. Error from response: %s", response.getErrorMessage()));
    }
}
Also used : ScribeData(com.facebook.buck.distributed.thrift.ScribeData) LogRequest(com.facebook.buck.distributed.thrift.LogRequest) FrontendResponse(com.facebook.buck.distributed.thrift.FrontendResponse) FrontendRequest(com.facebook.buck.distributed.thrift.FrontendRequest) IOException(java.io.IOException)

Example 2 with ScribeData

use of com.facebook.buck.distributed.thrift.ScribeData in project buck by facebook.

the class ThriftScribeLoggerTest method testAllNullLinesAreRemoved.

@Test
public void testAllNullLinesAreRemoved() {
    ScribeData data = new ScribeData().setCategory("slicespin");
    assertEquals(0, data.getLinesSize());
    List<String> lines = Lists.newArrayList("topspin", null, "down", "the", "lines");
    ThriftScribeLogger.copyLinesWithoutNulls(lines, data);
    assertEquals(lines.size() - 1, data.getLinesSize());
}
Also used : ScribeData(com.facebook.buck.distributed.thrift.ScribeData) Test(org.junit.Test)

Aggregations

ScribeData (com.facebook.buck.distributed.thrift.ScribeData)2 FrontendRequest (com.facebook.buck.distributed.thrift.FrontendRequest)1 FrontendResponse (com.facebook.buck.distributed.thrift.FrontendResponse)1 LogRequest (com.facebook.buck.distributed.thrift.LogRequest)1 IOException (java.io.IOException)1 Test (org.junit.Test)1