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()));
}
}
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());
}
Aggregations