Projects >> jrds >>be50aeb6924c3316a99ea0176b1478814802791f

Chunk
Conflicting content
package jrds.mockobjects;

import java.io.IOException;
<<<<<<< HEAD
import java.lang.reflect.InvocationTargetException;
=======
import java.text.ParseException;
>>>>>>> b5a21499824ccc544c81fd909b6da12c0ec0b014
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
Solution content
package jrds.mockobjects;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
File
Full.java
Developer's decision
Version 1
Kind of conflict
Import
Chunk
Conflicting content
        dsMap.clear();
import org.rrd4j.core.Util;

public class Full {
<<<<<<< HEAD
	static final long SEED = 1909752002L;
	static final Random RANDOM = new Random(SEED);
	static final String FILE = "fullmock";

	static public final long START = Util.getTimestamp(2003, 4, 1);
	static public final long END = Util.getTimestamp(2003, 5, 1);
	static public final int STEP = 300;

	static final int IMG_WIDTH = 500;
	static final int IMG_HEIGHT = 300;
	
	static public ProbeDesc getPd() {
		ProbeDesc pd = new ProbeDesc();
		
		Map dsMap = new HashMap();
		dsMap.put("dsName", "sun");
		dsMap.put("dsType", DsType.GAUGE);
		pd.add(dsMap);
		
		dsMap.clear();
		dsMap.put("dsName", "shade");
		dsMap.put("dsType", DsType.GAUGE);
		pd.add(dsMap);

		pd.setName(FILE);
		pd.setProbeName(FILE);

		return pd;
	}
	
	static public GraphDesc getGd() {
		GraphDesc gd = new GraphDesc();

		gd.add("sun", null, GraphDesc.LINE.toString(), "green", null, null, null, null, null, null, null);
		gd.add("shade", null, GraphDesc.LINE.toString(), "blue", null, null, null, null, null, null, null);
		gd.add("median", "sun,shade,+,2,/", GraphDesc.LINE.toString(), "magenta", null, null, null, null, null, null, null);
		gd.add("diff", "sun,shade,-,ABS,-1,*", GraphDesc.AREA.toString(), "yellow", null, null, null, null, null, null, null);

		gd.setGraphTitle("Temperatures in May 2003");
		gd.setVerticalLabel("temperature");
		return gd;
	}
	
	static public Probe getProbe() throws InvocationTargetException {
		Probe p = new Probe() {

			@Override
			public Map getNewSampleValues() {
				return Collections.emptyMap();
			}

			@Override
			public String getSourceType() {
				return "fullmoke";
			}
		};
		Map empty = Collections.emptyMap();
		p.setMainStore(new jrds.store.RrdDbStoreFactory(), empty);
		p.setPd(getPd());
		return p;

	}
	static public Probe create(TemporaryFolder testFolder, int step) throws InvocationTargetException {
		HostInfo host = new HostInfo("Empty");
		host.setHostDir(testFolder.getRoot());
		
		Probe p = getProbe();
		p.setHost(new HostStarter(host));
		p.setStep(step);
		
		Assert.assertTrue("Fail creating probe", p.checkStore());
		
		return p;
	}

	static public long fill(Probe p) throws IOException {
		long start = System.currentTimeMillis() / 1000;
		long end = start + 3600 * 24 * 30;

		// update database
		GaugeSource sunSource = new GaugeSource(1200, 20);
		GaugeSource shadeSource = new GaugeSource(300, 10);
		long t = start;
		
		//Keep an handle to the object, for faster run
		Object o = p.getMainStore().getStoreObject();

		while (t <= end + 86400L) {
	        JrdsSample sample = p.newSample();
		    sample.setTime(new Date(t * 1000));
			sample.put("sun", sunSource.getValue());
			sample.put("shade", shadeSource.getValue());
			p.getMainStore().commit(sample);
			t += RANDOM.nextDouble() * STEP + 1;
		}
		p.getMainStore().closeStoreObject(o);
		return t;
	}
	
	static public Period getPeriod(Probe p, long endSec) {
=======
    static final long SEED = 1909752002L;
    static final Random RANDOM = new Random(SEED);
    static final String FILE = "fullmock";

    static public final long START = Util.getTimestamp(2003, 4, 1);
    static public final long END = Util.getTimestamp(2003, 5, 1);
    static public final int STEP = 300;

    static final int IMG_WIDTH = 500;
    static final int IMG_HEIGHT = 300;

    static public ProbeDesc getPd() {
        ProbeDesc pd = new ProbeDesc();

        Map dsMap = new HashMap();
        dsMap.put("dsName", "sun");
        dsMap.put("dsType", DsType.GAUGE);
        pd.add(dsMap);

        dsMap.put("dsName", "shade");
        dsMap.put("dsType", DsType.GAUGE);
        pd.add(dsMap);

        pd.setName(FILE);
        pd.setProbeName(FILE);

        return pd;
    }

    static public GraphDesc getGd() {
        GraphDesc gd = new GraphDesc();

        gd.add("sun", null, GraphDesc.LINE.toString(), "green", null, null, null, null, null, null, null);
        gd.add("shade", null, GraphDesc.LINE.toString(), "blue", null, null, null, null, null, null, null);
        gd.add("median", "sun,shade,+,2,/", GraphDesc.LINE.toString(), "magenta", null, null, null, null, null, null, null);
        gd.add("diff", "sun,shade,-,ABS,-1,*", GraphDesc.AREA.toString(), "yellow", null, null, null, null, null, null, null);

        gd.setGraphTitle("Temperatures in May 2003");
        gd.setVerticalLabel("temperature");
        return gd;
    }

    static public Probe getProbe() {
        Probe p = new Probe() {

            @Override
            public Map getNewSampleValues() {
                return Collections.emptyMap();
            }

            @Override
            public String getSourceType() {
                return "fullmoke";
            }
        };
        p.setPd(getPd());
        return p;

    }
    static public Probe create(TemporaryFolder testFolder, int step) {
        HostInfo host = new HostInfo("Empty");
        host.setHostDir(testFolder.getRoot());

        Probe p = getProbe();
        p.setHost(new HostStarter(host));
        p.setStep(step);

        Assert.assertTrue("Fail creating probe", p.checkStore());

        return p;
    }

    static public long fill(Probe p) throws IOException {
        long start = System.currentTimeMillis() / 1000;
        long end = start + 3600 * 24 * 30;

        String rrdPath = p.getRrdName();
        // update database
        GaugeSource sunSource = new GaugeSource(1200, 20);
        GaugeSource shadeSource = new GaugeSource(300, 10);
        long t = start;
        RrdDb rrdDb = new RrdDb(rrdPath);
        Sample sample = rrdDb.createSample();

        while (t <= end + 86400L) {
            sample.setTime(t);
            sample.setValue("sun", sunSource.getValue());
            sample.setValue("shade", shadeSource.getValue());
            sample.update();
            t += RANDOM.nextDouble() * STEP + 1;
        }

        rrdDb.close();

        return t;
    }

    static public Period getPeriod(Probe p, long endSec) {
>>>>>>> b5a21499824ccc544c81fd909b6da12c0ec0b014
        Date end = org.rrd4j.core.Util.getDate(endSec);
        Calendar calBegin = Calendar.getInstance();
        calBegin.setTime(end);
Solution content
import org.rrd4j.core.Util;

public class Full {
	static final long SEED = 1909752002L;
	static final Random RANDOM = new Random(SEED);
	static final String FILE = "fullmock";

	static public final long START = Util.getTimestamp(2003, 4, 1);
	static public final long END = Util.getTimestamp(2003, 5, 1);
	static public final int STEP = 300;

	static final int IMG_WIDTH = 500;
	static final int IMG_HEIGHT = 300;
	
	static public ProbeDesc getPd() {
		ProbeDesc pd = new ProbeDesc();
		
		Map dsMap = new HashMap();
		dsMap.put("dsName", "sun");
		dsMap.put("dsType", DsType.GAUGE);
		pd.add(dsMap);
		
		dsMap.clear();
		dsMap.put("dsName", "shade");
		dsMap.put("dsType", DsType.GAUGE);
		pd.add(dsMap);

		pd.setName(FILE);
		pd.setProbeName(FILE);

		return pd;
	}
	
	static public GraphDesc getGd() {
		GraphDesc gd = new GraphDesc();

		gd.add("sun", null, GraphDesc.LINE.toString(), "green", null, null, null, null, null, null, null);
		gd.add("shade", null, GraphDesc.LINE.toString(), "blue", null, null, null, null, null, null, null);
		gd.add("median", "sun,shade,+,2,/", GraphDesc.LINE.toString(), "magenta", null, null, null, null, null, null, null);
		gd.add("diff", "sun,shade,-,ABS,-1,*", GraphDesc.AREA.toString(), "yellow", null, null, null, null, null, null, null);

		gd.setGraphTitle("Temperatures in May 2003");
		gd.setVerticalLabel("temperature");
		return gd;
	}
	
	static public Probe getProbe() throws InvocationTargetException {
		Probe p = new Probe() {

			@Override
			public Map getNewSampleValues() {
				return Collections.emptyMap();
			}

			@Override
			public String getSourceType() {
				return "fullmoke";
			}
		};
		Map empty = Collections.emptyMap();
		p.setMainStore(new jrds.store.RrdDbStoreFactory(), empty);
		p.setPd(getPd());
		return p;

	}
	static public Probe create(TemporaryFolder testFolder, int step) throws InvocationTargetException {
		HostInfo host = new HostInfo("Empty");
		host.setHostDir(testFolder.getRoot());
		
		Probe p = getProbe();
		p.setHost(new HostStarter(host));
		p.setStep(step);
		
		Assert.assertTrue("Fail creating probe", p.checkStore());
		
		return p;
	}

	static public long fill(Probe p) throws IOException {
		long start = System.currentTimeMillis() / 1000;
		long end = start + 3600 * 24 * 30;

		// update database
		GaugeSource sunSource = new GaugeSource(1200, 20);
		GaugeSource shadeSource = new GaugeSource(300, 10);
		long t = start;
		
		//Keep an handle to the object, for faster run
		Object o = p.getMainStore().getStoreObject();

		while (t <= end + 86400L) {
	        JrdsSample sample = p.newSample();
		    sample.setTime(new Date(t * 1000));
			sample.put("sun", sunSource.getValue());
			sample.put("shade", shadeSource.getValue());
			p.getMainStore().commit(sample);
			t += RANDOM.nextDouble() * STEP + 1;
		}
		p.getMainStore().closeStoreObject(o);
		return t;
	}
	
	static public Period getPeriod(Probe p, long endSec) {
        Date end = org.rrd4j.core.Util.getDate(endSec);
        Calendar calBegin = Calendar.getInstance();
        calBegin.setTime(end);
File
Full.java
Developer's decision
Version 1
Kind of conflict
Attribute
Method declaration
Method invocation
Method signature
Chunk
Conflicting content
        )
public abstract class Probe extends StarterNode implements Comparable>  {

<<<<<<< HEAD
    private class LocalJrdsSample extends HashMap implements JrdsSample {
        Date time;

        /**
         * @return the time
         */
        public LocalJrdsSample() {
            super(Probe.this.pd.getSize());
            time = new Date();
        }

        public Date getTime() {
            return time;
        }

        /**
         * @param time the time to set
         */
        public void setTime(Date time) {
            this.time = time;
        }

        public void put(Map.Entry e) {
            this.put(e.getKey(), e.getValue());
        }

        public Probe getProbe() {
            return Probe.this;
        }
    }
=======
    private static final ArcDef[] DEFAULTARC = {
        new ArcDef(ConsolFun.AVERAGE, 0.5, 1, 12 * 24 * 30 * 3),
        new ArcDef(ConsolFun.AVERAGE, 0.5, 12, 24 * 365), 
        new ArcDef(ConsolFun.AVERAGE, 0.5, 288, 365 * 2)
    };
>>>>>>> b5a21499824ccc544c81fd909b6da12c0ec0b014

    private String name = null;
    private HostInfo monitoredHost;
Solution content
        )
public abstract class Probe extends StarterNode implements Comparable>  {

    private class LocalJrdsSample extends HashMap implements JrdsSample {
        Date time;

        /**
         * @return the time
         */
        public LocalJrdsSample() {
            super(Probe.this.pd.getSize());
            time = new Date();
        }

        public Date getTime() {
            return time;
        }

        /**
         * @param time the time to set
         */
        public void setTime(Date time) {
            this.time = time;
        }

        public void put(Map.Entry e) {
            this.put(e.getKey(), e.getValue());
        }

        public Probe getProbe() {
            return Probe.this;
        }
    }

    private String name = null;
    private HostInfo monitoredHost;
File
Probe.java
Developer's decision
Version 1
Kind of conflict
Array initializer
Attribute
Class declaration