<commit_before>package com.xeiam.xdropwizard.manager;

import io.dropwizard.lifecycle.Managed;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.xeiam.xdropwizard.XDropWizardApplicationConfiguration.YankConfiguration;
import com.xeiam.xdropwizard.business.Book;
import com.xeiam.xdropwizard.business.BooksDAO;
import com.xeiam.yank.PropertiesUtils;
import com.xeiam.yank.Yank;

/**
 * <p>
 * This is where Yank is bound to the main DropWizard thread.
 * </p>
 *
 * @author timmolter
 */
public class YankManager implements Managed {

  private final Logger logger = LoggerFactory.getLogger(YankManager.class);

  private final YankConfiguration yankConfiguration;

  /**
   * Constructor
   */
  public YankManager(YankConfiguration yankConfiguration) {

    this.yankConfiguration = yankConfiguration;
  }

  @Override
  public void start() throws Exception {

    logger.info("initializing Yank...");

    // setup connection pool
    if (yankConfiguration.getDbPropsFileName() == null) {
      Yank.setupDataSource(PropertiesUtils.getPropertiesFromClasspath("DB.properties"));
    } else {
      Yank.setupDataSource(PropertiesUtils.getPropertiesFromClasspath(yankConfiguration.getDbPropsFileName()));
    }

    // setup sql statements
    if (yankConfiguration.getSqlPropsFileName() != null) {
      Yank.addSQLStatements(PropertiesUtils.getPropertiesFromClasspath(yankConfiguration.getSqlPropsFileName()));
    }

    logger.info("Yank started successfully.");

    /// The below code is just to create some dummy data in an in-memory DB for use later by the REST API. See YankBookResource.

    // put some data in DB
    BooksDAO.createBooksTable();

    List<Book> books = new ArrayList<Book>();

    Book book = new Book();
    book.setTitle("Cryptonomicon");
    book.setAuthor("<NAME>");<commit_msg>improve reliability of YankManager<commit_after>package com.xeiam.xdropwizard.manager;

import io.dropwizard.lifecycle.Managed;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.xeiam.xdropwizard.XDropWizardApplicationConfiguration.YankConfiguration;
import com.xeiam.xdropwizard.business.Book;
import com.xeiam.xdropwizard.business.BooksDAO;
import com.xeiam.yank.PropertiesUtils;
import com.xeiam.yank.Yank;

/**
 * <p>
 * This is where Yank is bound to the main DropWizard thread.
 * </p>
 *
 * @author timmolter
 */
public class YankManager implements Managed {

  private final Logger logger = LoggerFactory.getLogger(YankManager.class);

  private final YankConfiguration yankConfiguration;

  /**
   * Constructor
   */
  public YankManager(YankConfiguration yankConfiguration) {

    this.yankConfiguration = yankConfiguration;
  }

  @Override
  public void start() throws Exception {

    logger.info("initializing Yank...");

    // setup connection pool
    if (yankConfiguration.getDbPropsFileName() == null || yankConfiguration.getSqlPropsFileName().trim().length() == 0) {
      Yank.setupDataSource(PropertiesUtils.getPropertiesFromClasspath("DB.properties"));
    } else {
      Yank.setupDataSource(PropertiesUtils.getPropertiesFromClasspath(yankConfiguration.getDbPropsFileName()));
    }

    // setup sql statements
    if (yankConfiguration.getSqlPropsFileName() != null && yankConfiguration.getSqlPropsFileName().trim().length() > 0) {
      Yank.addSQLStatements(PropertiesUtils.getPropertiesFromClasspath(yankConfiguration.getSqlPropsFileName()));
    }

    logger.info("Yank started successfully.");

    /// The below code is just to create some dummy data in an in-memory DB for use later by the REST API. See YankBookResource.

    // put some data in DB
    BooksDAO.createBooksTable();

    List<Book> books = new ArrayList<Book>();

    Book book = new Book();
    book.setTitle("Cryptonomicon");
    book.setAuthor("<NAME>");
{'fraction_non_alphanumeric': 0.10654062340316811, 'fraction_numerical': 0.0015329586101175269, 'mean_word_length': 4.377747252747253, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3138089', 'n_tokens_mistral': 1165, 'n_tokens_neox': 1123, 'n_words': 252}