use of com.facebook.buck.slb.ClientSideSlb in project buck by facebook.
the class PublicAnnouncementManager method getAndPostAnnouncements.
public void getAndPostAnnouncements() {
final ListenableFuture<ImmutableList<Announcement>> message = service.submit(() -> {
Optional<ClientSideSlb> slb = logConfig.getFrontendConfig().tryCreatingClientSideSlb(clock, eventBus, new CommandThreadFactory("PublicAnnouncement"));
if (slb.isPresent()) {
try (FrontendService frontendService = new FrontendService(ThriftOverHttpServiceConfig.of(new LoadBalancedService(slb.get(), logConfig.createOkHttpClient(), eventBus)))) {
AnnouncementRequest announcementRequest = new AnnouncementRequest();
announcementRequest.setBuckVersion(getBuckVersion());
announcementRequest.setRepository(repository);
FrontendRequest request = new FrontendRequest();
request.setType(FrontendRequestType.ANNOUNCEMENT);
request.setAnnouncementRequest(announcementRequest);
FrontendResponse response = frontendService.makeRequest(request);
return ImmutableList.copyOf(response.announcementResponse.announcements);
} catch (IOException e) {
throw new HumanReadableException("Failed to perform request", e);
}
} else {
throw new HumanReadableException("Failed to establish connection to server.");
}
});
Futures.addCallback(message, new FutureCallback<ImmutableList<Announcement>>() {
@Override
public void onSuccess(ImmutableList<Announcement> announcements) {
LOG.info("Public announcements fetched successfully.");
if (!announcements.isEmpty()) {
String announcement = HEADER_MSG;
for (Announcement entry : announcements) {
announcement = announcement.concat(String.format(ANNOUNCEMENT_TEMPLATE, entry.getErrorMessage(), entry.getSolutionMessage()));
}
consoleEventBusListener.setPublicAnnouncements(eventBus, Optional.of(announcement));
}
}
@Override
public void onFailure(Throwable t) {
LOG.warn("Failed to get public announcements. Reason: %s", t.getMessage());
}
});
}
use of com.facebook.buck.slb.ClientSideSlb 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();
}
use of com.facebook.buck.slb.ClientSideSlb in project buck by facebook.
the class DistBuildFactory method newFrontendService.
public static FrontendService newFrontendService(CommandRunnerParams params) {
DistBuildConfig config = new DistBuildConfig(params.getBuckConfig());
ClientSideSlb slb = config.getFrontendConfig().createClientSideSlb(params.getClock(), params.getBuckEventBus(), new CommandThreadFactory("StampedeNetworkThreadPool", SLB_THREAD_PRIORITY));
OkHttpClient client = config.createOkHttpClient();
return new FrontendService(ThriftOverHttpServiceConfig.of(new LoadBalancedService(slb, client, params.getBuckEventBus())));
}
Aggregations