/* Copyright 2016--2018 The Tor Project
 * See LICENSE for licensing information */

package org.torproject.metrics.collector.cron;

import org.torproject.metrics.collector.conf.Configuration;

import java.util.concurrent.atomic.AtomicInteger;

public class Broken extends CollecTorMain {

  static AtomicInteger count = new AtomicInteger(0);

  public Broken(Configuration conf) {
    super(conf);
  }

  @Override
  public void startProcessing() {
    count.getAndIncrement();
    try {
      Thread.sleep(10);
    } catch (Exception e) { /* ignored */ }
    if (count.get() % 2 == 0) {
      throw new Error("Throwing an Error.");
    } else {
      throw new RuntimeException("Throwing an Exception.");
    }
  }

  @Override
  public String module() {
    return "broken";
  }

  @Override
  protected String syncMarker() {
    return "Broken";
  }

}

