Search in sources :

Example 1 with SlbBuckConfig

use of com.facebook.buck.slb.SlbBuckConfig in project buck by facebook.

the class DefaultDefectReporter method submitReport.

@Override
public DefectSubmitResult submitReport(DefectReport defectReport) throws IOException {
    DefectSubmitResult.Builder defectSubmitResult = DefectSubmitResult.builder();
    defectSubmitResult.setRequestProtocol(rageConfig.getProtocolVersion());
    Optional<SlbBuckConfig> frontendConfig = rageConfig.getFrontendConfig();
    if (frontendConfig.isPresent()) {
        Optional<ClientSideSlb> slb = frontendConfig.get().tryCreatingClientSideSlb(clock, buckEventBus, new CommandThreadFactory("RemoteLog.HttpLoadBalancer"));
        if (slb.isPresent()) {
            try {
                return uploadReport(defectReport, defectSubmitResult, slb.get());
            } catch (IOException e) {
                LOG.debug(e, "Failed uploading report to server.");
                defectSubmitResult.setIsRequestSuccessful(false);
                defectSubmitResult.setReportSubmitErrorMessage(e.getMessage());
            }
        }
    }
    filesystem.mkdirs(filesystem.getBuckPaths().getBuckOut());
    Path defectReportPath = filesystem.createTempFile(filesystem.getBuckPaths().getBuckOut(), "defect_report", ".zip");
    try (OutputStream outputStream = filesystem.newFileOutputStream(defectReportPath)) {
        writeReport(defectReport, outputStream);
    }
    return defectSubmitResult.setIsRequestSuccessful(Optional.empty()).setReportSubmitLocation(defectReportPath.toString()).build();
}
Also used : Path(java.nio.file.Path) ClientSideSlb(com.facebook.buck.slb.ClientSideSlb) SlbBuckConfig(com.facebook.buck.slb.SlbBuckConfig) BufferedOutputStream(java.io.BufferedOutputStream) OutputStream(java.io.OutputStream) CustomZipOutputStream(com.facebook.buck.zip.CustomZipOutputStream) CommandThreadFactory(com.facebook.buck.log.CommandThreadFactory) IOException(java.io.IOException)

Aggregations

CommandThreadFactory (com.facebook.buck.log.CommandThreadFactory)1 ClientSideSlb (com.facebook.buck.slb.ClientSideSlb)1 SlbBuckConfig (com.facebook.buck.slb.SlbBuckConfig)1 CustomZipOutputStream (com.facebook.buck.zip.CustomZipOutputStream)1 BufferedOutputStream (java.io.BufferedOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 Path (java.nio.file.Path)1