All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jlot.stats.client.StatsDumper Maven / Gradle / Ivy

package org.jlot.stats.client;

import java.util.Map;

import org.jlot.client.remote.StatsPushRestCommand;
import org.jlot.core.form.StatsForm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class StatsDumper implements Runnable
{
	private StatsHarvester			statsHarvester;
	private StatsPushRestCommand	statsPushRestCommand;
	private String					projectName;
	private static final Logger		logger	= LoggerFactory.getLogger(StatsDumper.class);

	public StatsDumper ( String projectName, StatsHarvester statsHarvester, StatsPushRestCommand statsPushRestCommand )
	{
		this.projectName = projectName;
		this.statsHarvester = statsHarvester;
		this.statsPushRestCommand = statsPushRestCommand;
	}

	public void dumpStats ( )
	{
		try
		{
			if (statsPushRestCommand != null)
			{
				Map map = statsHarvester.getMap();
				StatsForm statsForm = new StatsForm();
				statsForm.setProjectName(projectName);
				statsForm.setTokenStats(map);
				statsPushRestCommand.execute(statsForm);
			}
			statsHarvester.reset();
		}
		catch (Throwable e)
		{
			logger.error(e.getMessage(), e);
		}
	}

	@Override
	public void run ( )
	{
		dumpStats();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy