package org.bench4q.monitor.file.Linux;

import java.io.FileNotFoundException;
import java.io.PrintWriter;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;

import org.bench4q.monitor.model.PhysicalDiskModel;
import org.bench4q.monitor.performance.linux.PhysicalDiskMonitor;
import org.bench4q.monitor.files.Write;

public class WritePhysicalDiskLinux extends Write {

	private PhysicalDiskMonitor physicalDiskMonitor;

	public WritePhysicalDiskLinux(PrintWriter out, int idleTime)
			throws FileNotFoundException {
		this.out = out;
		this.physicalDiskMonitor = new PhysicalDiskMonitor();
		this.idleTime = idleTime;
	}

	public void run() {
		try {
			JAXBContext context = JAXBContext
					.newInstance(PhysicalDiskModel.class);
			Marshaller marshaller = context.createMarshaller();
			PhysicalDiskModel physicalDiskModel = physicalDiskMonitor
					.getPhysicalDiskInfo(idleTime);
			marshaller.marshal(physicalDiskModel, out);
		} catch (Exception e) {
			System.out.println(e);
		}

	}

}
