// Path: src/main/java/hr/vsite/hive/dao/HiveDao.java
// public interface HiveDao extends AutoCloseable {
// 
// 	void commit();
// 	
// 	void rollback();
// 	
// 	void archive(int daysBack);
// 	
// 	void persist(Sensor sensor);
// 
// 	void delete(Sensor sensor);
// 
// 	Sensor findSensorById(UUID id);
// 	
// 	Sensor findSensorByDeviceId(String deviceId);
// 	
// 	List<Sensor> listSensors(SensorFilter filter, int count, int offset);
// 
// 	void persist(ValueTick tick);
// 
// 	List<Tick> listTicks(TickFilter filter, int count, int offset);
// 
// 	void persist(CounterTick tick);
// 
// 	List<ValueTick> listTicks(ValueTickFilter filter, int count, int offset);
// 
// 	void persist(ToggleTick tick);
// 
// }


import javax.inject.Inject;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import hr.vsite.hive.dao.HiveDao;
package hr.vsite.hive;




@DisallowConcurrentExecution
public class Garbageman implements Job {

	@Inject
	Garbageman(HiveDao dao) {
		daysBack = HiveConfiguration.get().getInt("hive.garbageman.DaysBack");
		this.dao = dao;
	}

	@Override
	public void execute(JobExecutionContext context) throws JobExecutionException {

		log.info("Garbageman starts, throwing away stuff older than {} days", daysBack);

		long startTime = System.currentTimeMillis();
		
		dao.archive(daysBack);
		
		dao.commit();

		log.info("Garbageman ends in {} seconds", (System.currentTimeMillis() - startTime) / 1000);
		
	}
	
    private static final Logger log = LoggerFactory.getLogger(Garbageman.class);

    private final int daysBack;
// Path: src/main/java/hr/vsite/hive/dao/HiveDao.java
// public interface HiveDao extends AutoCloseable {
// 
// 	void commit();
// 	
// 	void rollback();
// 	
// 	void archive(int daysBack);
// 	
// 	void persist(Sensor sensor);
// 
// 	void delete(Sensor sensor);
// 
// 	Sensor findSensorById(UUID id);
// 	
// 	Sensor findSensorByDeviceId(String deviceId);
// 	
// 	List<Sensor> listSensors(SensorFilter filter, int count, int offset);
// 
// 	void persist(ValueTick tick);
// 
// 	List<Tick> listTicks(TickFilter filter, int count, int offset);
// 
// 	void persist(CounterTick tick);
// 
// 	List<ValueTick> listTicks(ValueTickFilter filter, int count, int offset);
// 
// 	void persist(ToggleTick tick);
// 
// }


// Path: src/main/java/hr/vsite/hive/Garbageman.java
import javax.inject.Inject;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import hr.vsite.hive.dao.HiveDao;

package hr.vsite.hive;




@DisallowConcurrentExecution
public class Garbageman implements Job {

	@Inject
	Garbageman(HiveDao dao) {
		daysBack = HiveConfiguration.get().getInt("hive.garbageman.DaysBack");
		this.dao = dao;
	}

	@Override
	public void execute(JobExecutionContext context) throws JobExecutionException {

		log.info("Garbageman starts, throwing away stuff older than {} days", daysBack);

		long startTime = System.currentTimeMillis();
		
		dao.archive(daysBack);
		
		dao.commit();

		log.info("Garbageman ends in {} seconds", (System.currentTimeMillis() - startTime) / 1000);
		
	}
	
    private static final Logger log = LoggerFactory.getLogger(Garbageman.class);

    private final int daysBack;
    private final HiveDao dao;