<commit_before>package com.netflix.kayenta.atlas.backends;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.netflix.kayenta.atlas.model.Backend;
import com.netflix.kayenta.atlas.service.BackendsRemoteService;
import com.netflix.kayenta.retrofit.config.RemoteService;
import com.netflix.kayenta.retrofit.config.RetrofitClientFactory;
import com.squareup.okhttp.OkHttpClient;
import lombok.Builder;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import retrofit.RetrofitError;
import retrofit.converter.JacksonConverter;

import javax.validation.constraints.NotNull;
import java.util.List;

@Slf4j
@Builder
public class BackendUpdater {
  @Getter
  private final BackendDatabase backendDatabase = new BackendDatabase();

  @NotNull
  private String uri;

  // If we have retrieved backends.json at least once, we will keep using it forever
  // even if we fail later.  It doesn't really change much over time, so this
  // is likely safe enough.
  private boolean succeededAtLeastOnce = false;

  boolean run(RetrofitClientFactory retrofitClientFactory, ObjectMapper objectMapper, OkHttpClient okHttpClient) {
    RemoteService remoteService = new RemoteService();
    remoteService.setBaseUrl(uri);
    BackendsRemoteService backendsRemoteService = retrofitClientFactory.createClient(BackendsRemoteService.class,
                                                                                     new JacksonConverter(objectMapper),
                                                                                     remoteService,
                                                                                     okHttpClient);
    try {
      List<Backend> backends = backendsRemoteService.fetch();
      backendDatabase.update(backends);
    } catch (RetrofitError e) {<commit_msg>add @Builder.Default to silence a warning<commit_after>package com.netflix.kayenta.atlas.backends;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.netflix.kayenta.atlas.model.Backend;
import com.netflix.kayenta.atlas.service.BackendsRemoteService;
import com.netflix.kayenta.retrofit.config.RemoteService;
import com.netflix.kayenta.retrofit.config.RetrofitClientFactory;
import com.squareup.okhttp.OkHttpClient;
import lombok.Builder;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import retrofit.RetrofitError;
import retrofit.converter.JacksonConverter;

import javax.validation.constraints.NotNull;
import java.util.List;

@Slf4j
@Builder
public class BackendUpdater {
  @Getter
  private final BackendDatabase backendDatabase = new BackendDatabase();

  @NotNull
  private String uri;

  // If we have retrieved backends.json at least once, we will keep using it forever
  // even if we fail later.  It doesn't really change much over time, so this
  // is likely safe enough.
  @Builder.Default
  private boolean succeededAtLeastOnce = false;

  boolean run(RetrofitClientFactory retrofitClientFactory, ObjectMapper objectMapper, OkHttpClient okHttpClient) {
    RemoteService remoteService = new RemoteService();
    remoteService.setBaseUrl(uri);
    BackendsRemoteService backendsRemoteService = retrofitClientFactory.createClient(BackendsRemoteService.class,
                                                                                     new JacksonConverter(objectMapper),
                                                                                     remoteService,
                                                                                     okHttpClient);
    try {
      List<Backend> backends = backendsRemoteService.fetch();
      backendDatabase.update(backends);
    } catch (RetrofitError e) {
{'fraction_non_alphanumeric': 0.0691909561427404, 'fraction_numerical': 0.0016344320348678834, 'mean_word_length': 2.7128412537917086, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2374275', 'n_tokens_mistral': 945, 'n_tokens_neox': 920, 'n_words': 220}