Projects >> jrds >>9b9d2e3ab00ed6dc82814fa2c76022ea987463e2

Chunk
Conflicting content
        HostStarter host = new HostStarter(new HostInfo("DummyHost"));
        host.setParent(Tools.getDefaultTimer());
<<<<<<< HEAD
        MokeProbe p = new MokeProbe(pd) {
            @Override
            public boolean isCollectRunning() {
                return true;
            }			
            @Override
            public void modifySample(Sample oneSample, Map values) {
                oneSample.setTime(getLastUpdate().getTime() + 1000);
                super.modifySample(oneSample, values);
            }			
        };
        host.getHost().setHostDir(testFolder.newFolder("testHighLow"));
        p.setHost(host);
=======
        host.getHost().setHostDir(testFolder.newFolder("testDefault"));
        p.setHost(host);

>>>>>>> 115986652ff4650747e059d9132fb2bd2e7cd025
        p.configure();
        Assert.assertTrue("Failed to create storage", p.checkStore());
        Map val = new HashMap();
Solution content
        HostStarter host = new HostStarter(new HostInfo("DummyHost"));
        host.setParent(Tools.getDefaultTimer());
        host.getHost().setHostDir(testFolder.newFolder("testDefault"));
        p.setHost(host);

        p.configure();
        Assert.assertTrue("Failed to create storage", p.checkStore());
        Map val = new HashMap();
File
TestProbe.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
        HostStarter host = new HostStarter(new HostInfo("DummyHost"));
        host.setParent(Tools.getDefaultTimer());
<<<<<<< HEAD
        MokeProbe p = new MokeProbe(pd) {
            @Override
            public boolean isCollectRunning() {
                return true;
            }
            @Override
            public void modifySample(Sample oneSample, Map values) {
                oneSample.setTime(getLastUpdate().getTime() + 1000);
                super.modifySample(oneSample, values);
            }			
        };
        host.getHost().setHostDir(testFolder.newFolder("testDefault"));
        p.setHost(host);
        p.configure();
        System.out.println();
        Map val = new HashMap();
=======
        host.getHost().setHostDir(testFolder.newFolder("testDefault"));
        p.setHost(host);

        Assert.assertTrue("Failed to create storage", p.checkStore());
        Map val = new HashMap();
>>>>>>> 115986652ff4650747e059d9132fb2bd2e7cd025
        val.put("ds1", 2L);

        p.checkStore();
Solution content
        HostStarter host = new HostStarter(new HostInfo("DummyHost"));
        host.setParent(Tools.getDefaultTimer());
        host.getHost().setHostDir(testFolder.newFolder("testDefault"));
        p.setHost(host);

        Assert.assertTrue("Failed to create storage", p.checkStore());
        Map val = new HashMap();
        val.put("ds1", 2L);

        p.checkStore();
File
TestProbe.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
        timerMap.put(t.getName(), t);
        return timerMap;
    }
<<<<<<< HEAD
    
=======

>>>>>>> 115986652ff4650747e059d9132fb2bd2e7cd025
    static public final Timer getDefaultTimer() {
        TimerInfo ti = new PropertiesManager.TimerInfo();
        ti.numCollectors = 1;
Solution content
        timerMap.put(t.getName(), t);
        return timerMap;
    }

    static public final Timer getDefaultTimer() {
        TimerInfo ti = new PropertiesManager.TimerInfo();
        ti.numCollectors = 1;
File
Tools.java
Developer's decision
Version 1
Kind of conflict
Blank
Chunk
Conflicting content
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.security.Principal;
<<<<<<< HEAD
=======
import java.util.Collections;
>>>>>>> 115986652ff4650747e059d9132fb2bd2e7cd025
import java.util.Collection;
import java.util.Enumeration;
import java.util.Locale;
Solution content
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.security.Principal;
import java.util.Collections;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Locale;
File
GetMoke.java
Developer's decision
Version 2
Kind of conflict
Import
Chunk
Conflicting content
import jrds.starter.SocketFactory;
import jrds.starter.Starter;
import jrds.starter.Timer;
<<<<<<< HEAD
=======
import jrds.store.RrdDbStoreFactory;
>>>>>>> 115986652ff4650747e059d9132fb2bd2e7cd025

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
Solution content
import jrds.starter.SocketFactory;
import jrds.starter.Starter;
import jrds.starter.Timer;
import jrds.store.RrdDbStoreFactory;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
File
ApacheHttpClientTest.java
Developer's decision
Version 2
Kind of conflict
Import
Chunk
Conflicting content
        localhost.find(Resolver.class).doStart();
        cnx.doStart();
        TestHttpProbe p = new TestHttpProbe();
<<<<<<< HEAD
=======
        p.setMainStore(new RrdDbStoreFactory(), empty);
>>>>>>> 115986652ff4650747e059d9132fb2bd2e7cd025
        p.setHost(localhost);
        p.setPort(server.getURI().toURL().getPort());
        p.configure();
Solution content
        localhost.find(Resolver.class).doStart();
        cnx.doStart();
        TestHttpProbe p = new TestHttpProbe();
        p.setMainStore(new RrdDbStoreFactory(), empty);
        p.setHost(localhost);
        p.setPort(server.getURI().toURL().getPort());
        p.configure();
File
ApacheHttpClientTest.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Chunk
Conflicting content
        localhost.find(Resolver.class).doStart();
        cnx.doStart();
        TestHttpProbe p = new TestHttpProbe();
<<<<<<< HEAD
=======
        p.setMainStore(new RrdDbStoreFactory(), empty);
>>>>>>> 115986652ff4650747e059d9132fb2bd2e7cd025
        p.setHost(localhost);
        p.setPort(server.getURI().toURL().getPort());
        p.setScheme("https");
Solution content
        localhost.find(Resolver.class).doStart();
        cnx.doStart();
        TestHttpProbe p = new TestHttpProbe();
        p.setMainStore(new RrdDbStoreFactory(), empty);
        p.setHost(localhost);
        p.setPort(server.getURI().toURL().getPort());
        p.setScheme("https");
File
ApacheHttpClientTest.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Chunk
Conflicting content
    /**
        }
    }

<<<<<<< HEAD
     * return the RrdGraphDef for this graph, used the indicated probe
     *
     * @param probe Probe
     * @return RrdGraphDef
     * @throws IOException
     */
    public RrdGraphDef getGraphDef(Probe probe) throws IOException {
        return getGraphDef(probe, null);
    }

=======
>>>>>>> 115986652ff4650747e059d9132fb2bd2e7cd025
    public RrdGraphDef getEmptyGraphDef() {
        RrdGraphDef retValue = new RrdGraphDef();
        if( ! Double.isNaN(lowerLimit))
Solution content
        }
    }

    public RrdGraphDef getEmptyGraphDef() {
        RrdGraphDef retValue = new RrdGraphDef();
        if( ! Double.isNaN(lowerLimit))
File
GraphDesc.java
Developer's decision
Version 2
Kind of conflict
Comment
Method declaration
Chunk
Conflicting content
package jrds;

<<<<<<< HEAD
=======
import java.beans.PropertyDescriptor;
import java.io.IOException;
import java.lang.reflect.Constructor;
>>>>>>> 115986652ff4650747e059d9132fb2bd2e7cd025
import java.util.Collections;
import java.util.LinkedList;
import java.util.Map;
Solution content
package jrds;

import java.beans.PropertyDescriptor;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.util.Collections;
import java.util.LinkedList;
import java.util.Map;
File
GraphNode.java
Developer's decision
Version 2
Kind of conflict
Import
Chunk
Conflicting content
>>>>>>> 115986652ff4650747e059d9132fb2bd2e7cd025
import java.util.Date;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
<<<<<<< HEAD
import java.util.Comparator;
=======
import java.util.HashMap;
import java.util.HashSet;
Solution content
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
File
Probe.java
Developer's decision
Version 2
Kind of conflict
Import
Chunk
Conflicting content
import jrds.probe.UrlProbe;
import jrds.starter.HostStarter;
import jrds.starter.StarterNode;
<<<<<<< HEAD
=======
import jrds.store.ExtractInfo;
import jrds.store.Extractor;
import jrds.store.Store;
import jrds.store.StoreFactory;
>>>>>>> 115986652ff4650747e059d9132fb2bd2e7cd025
import jrds.starter.Timer;

import org.apache.log4j.Level;
Solution content
import jrds.probe.UrlProbe;
import jrds.starter.HostStarter;
import jrds.starter.StarterNode;
import jrds.store.ExtractInfo;
import jrds.store.Extractor;
import jrds.store.Store;
import jrds.store.StoreFactory;
import jrds.starter.Timer;

import org.apache.log4j.Level;
File
Probe.java
Developer's decision
Version 2
Kind of conflict
Import
Chunk
Conflicting content
            log(Level.DEBUG, "updating %s to %s",source, dest);

            Set badDs = new HashSet();
        this.name = name;
    }

<<<<<<< HEAD
    public String getRrdName() {
        String rrdName = getName().replaceAll("/","_");
        return monitoredHost.getHostDir() +
                Util.getFileSeparator() + rrdName + ".rrd";
    }

    private String parseTemplate(String template) {
        Object[] arguments = {
                "${host}",
                "${index}",
                "${url}",
                "${port}",
                "${index.signature}",
                "${url.signature}"
        };
        return jrds.Util.parseOldTemplate(template, arguments, this);
    }

    protected DsDef[] getDsDefs() {
        return getPd().getDsDefs();
    }

    public RrdDef getRrdDef() {
        RrdDef def = new RrdDef(getRrdName());
        def.setVersion(2);
        def.addArchive(archives.getArchives());
        def.addDatasource(getDsDefs());
        def.setStep(getStep());
        return def;
    }

    /**
     * Create the probe file
     * @throws IOException
     */
    protected void create() throws IOException {
        log(Level.INFO, "Need to create rrd");
        RrdDef def = getRrdDef();
        RrdDb rrdDb = new RrdDb(def);
        rrdDb.close();
    }

    private void upgrade() {
        RrdDb rrdSource = null;
        try {
            log(Level.WARN,"Definition is changed, the store needs to be upgraded");
            File source = new File(getRrdName());
            rrdSource = new RrdDb(source.getCanonicalPath());

            RrdDef rrdDef = getRrdDef();
            File dest = File.createTempFile("JRDS_", ".tmp", source.getParentFile());
            rrdDef.setPath(dest.getCanonicalPath());
            RrdDb rrdDest = new RrdDb(rrdDef);
            Header header = rrdSource.getHeader();
            int dsCount = header.getDsCount();
            header.copyStateTo(rrdDest.getHeader());
            for (int i = 0; i < dsCount; i++) {
                Datasource srcDs = rrdSource.getDatasource(i);
                String dsName = srcDs.getName();
                Datasource dstDS = rrdDest.getDatasource(dsName);
                if (dstDS != null ) {
                    try {
                        srcDs.copyStateTo(dstDS);
                        log(Level.TRACE, "Update %s", dsName);
                    } catch (RuntimeException e) {
                        badDs.add(dsName);
                        log(Level.ERROR, e, "Datasource %s can't be upgraded: %s", dsName,  e.getMessage());
                    }
                }
            }
            int robinMigrated = 0;
            for (int i = 0; i < rrdSource.getArcCount(); i++) {
                Archive srcArchive = rrdSource.getArchive(i);
                ConsolFun consolFun = srcArchive.getConsolFun();
                int steps = srcArchive.getSteps();
                Archive dstArchive = rrdDest.getArchive(consolFun, steps);
                if (dstArchive != null) {
                    if ( dstArchive.getConsolFun().equals(srcArchive.getConsolFun())  &&
                            dstArchive.getSteps() == srcArchive.getSteps() ) {
                        for (int k = 0; k < dsCount; k++) {
                            Datasource srcDs = rrdSource.getDatasource(k);
                            String dsName = srcDs.getName();
                            try {
                                int j = rrdDest.getDsIndex(dsName);
                                if (j >= 0 && ! badDs.contains(dsName)) {
                                    log(Level.TRACE, "Upgrade of %s from %s", dsName, srcArchive);
                                    srcArchive.getArcState(k).copyStateTo(dstArchive.getArcState(j));
                                    srcArchive.getRobin(k).copyStateTo(dstArchive.getRobin(j));
                                    robinMigrated++;
                                }
                            }
                            catch (IllegalArgumentException e) {
                                log(Level.TRACE, "Datastore %s removed", dsName);
                            }

                        }
                        log(Level.TRACE, "Update %s", srcArchive);
                    }
                }
            }
            log(Level.DEBUG, "Robin migrated: %s", robinMigrated);

            rrdDest.close();
            rrdSource.close();
            log(Level.DEBUG, "Size difference : %d", (dest.length() - source.length()));
            copyFile(dest.getCanonicalPath(), source.getCanonicalPath());
        } catch (IOException e) {
            log(Level.ERROR, e, "Upgrade failed: %s", e);
        }
        finally {
            if(rrdSource != null)
                try {
                    rrdSource.close();
                } catch (IOException e) {
                }
        }
    }

    private static void copyFile(String sourcePath, String destPath)
            throws IOException {
        File source = new File(sourcePath);
        File dest = new File(destPath);
        File destOld = new File(destPath + ".old");
        if (!dest.renameTo(destOld)) {
            throw new IOException("Could not rename file " + destPath + " from " + destOld);
        }
        if (!source.renameTo(dest)) {
            throw new IOException("Could not rename file " + destPath + " from " + sourcePath);
        }
        deleteFile(destOld);
    }

    private static void deleteFile(File file) throws IOException {
        if (file.exists() && !file.delete()) {
            throw new IOException("Could not delete file: " + file.getCanonicalPath());
        }
    }

    /**
     * Check the final status of the probe. It must be called once before an probe can be used
     * 
     * Open the rrd backend of the probe.
     * it's created if it's needed
     */
    public boolean checkStore()  {
        if(pd == null) {
            log(Level.ERROR, "Missing Probe description");
            return false;
        }
        if(monitoredHost == null) {
            log(Level.ERROR, "Missing host");
            return false;
        }

        //Name can be set by other means
        if(name == null)
            name = parseTemplate(getPd().getProbeName());

        finished = checkStoreFile();
        return finished;
    }

    protected boolean checkStoreFile() {
        File rrdFile = new File(getRrdName());

        File rrdDir = monitoredHost.getHostDir();
        if (!rrdDir.isDirectory()) {
            if( ! rrdDir.mkdir()) {
                try {
                    log(Level.ERROR, "probe dir %s creation failed ", rrdDir.getCanonicalPath());
                } catch (IOException e) {
                }
                return false;
            }
        }

        boolean retValue = false;
        RrdDb rrdDb = null;
        try {
            if ( rrdFile.isFile() ) {
                rrdDb = new RrdDb(getRrdName());
                //old definition
                RrdDef tmpdef = rrdDb.getRrdDef();
                Date startTime = new Date();
                tmpdef.setStartTime(startTime);
                String oldDef = tmpdef.dump();
                long oldstep = tmpdef.getStep();
                log(Level.TRACE, "Definition found: %s\n", oldDef);

                //new definition
                tmpdef = getRrdDef();
                tmpdef.setStartTime(startTime);
                String newDef = tmpdef.dump();
                long newstep = tmpdef.getStep();

                if(newstep != oldstep ) {
                    log(Level.ERROR, "step changed, you're in trouble" );
                    return false;
                }
                else if(! newDef.equals(oldDef)) {

                    rrdDb.close();
                    rrdDb = null;
                    upgrade();
                    rrdDb = new RrdDb(getRrdName());
                }
                log(Level.TRACE, "******");
            } else
                create();
            retValue = true;
        } catch (Exception e) {
            log(Level.ERROR, e, "Store %s unusable: %s", getRrdName(), e);
        }
        finally {
            if(rrdDb != null)
                try {
                    rrdDb.close();
                } catch (IOException e) {
                }

        }
        return retValue;
    }

=======
>>>>>>> 115986652ff4650747e059d9132fb2bd2e7cd025
    /**
     * The method that return a map of data collected.
* It should return return as raw as possible, they can even be opaque data tied to the probe.
Solution content
        this.name = name;
    }

    /**
     * The method that return a map of data collected.
* It should return return as raw as possible, they can even be opaque data tied to the probe.
File
Probe.java
Developer's decision
Version 2
Kind of conflict
Comment
Method declaration
Chunk
Conflicting content
=======
     * 
     * @param collect
     * @return
<<<<<<< HEAD
     */
    public boolean isOptional(KeyType collect ) {
        return getPd().isOptional(getCollectMapping().get(collect));
    }

    /**
     * Store the values on the rrd backend.
     * @param oneSample
>>>>>>> 115986652ff4650747e059d9132fb2bd2e7cd025
     */
    public boolean isOptional(KeyType collect ) {
        return getPd().isOptional(getCollectMapping().get(collect));
Solution content
     * 
     * @param collect
     * @return
     */
    public boolean isOptional(KeyType collect ) {
        return getPd().isOptional(getCollectMapping().get(collect));
File
Probe.java
Developer's decision
Version 2
Kind of conflict
Comment
Method declaration
Chunk
Conflicting content
        ti.slowCollectTime = slowcollecttime;
        timers.put(Timer.DEFAULTNAME, ti);

<<<<<<< HEAD

        dbPoolSize = parseInteger(getProperty("dbPoolSize", "10")) + numCollectors;

=======
>>>>>>> 115986652ff4650747e059d9132fb2bd2e7cd025
        strictparsing = parseBoolean(getProperty("strictparsing", "false"));
        try {
            Enumeration descurl = getClass().getClassLoader().getResources("desc");
Solution content
        ti.slowCollectTime = slowcollecttime;
        timers.put(Timer.DEFAULTNAME, ti);

        strictparsing = parseBoolean(getProperty("strictparsing", "false"));
        try {
            Enumeration descurl = getClass().getClassLoader().getResources("desc");
File
PropertiesManager.java
Developer's decision
Version 2
Kind of conflict
Attribute
Method invocation
Chunk
Conflicting content
    static final Map cmdClasses = new HashMap();
    static {
        cmdClasses.put("jetty", "jrds.standalone.Jetty");
<<<<<<< HEAD
=======
        cmdClasses.put("jmxserver", "jrds.standalone.JMX");
>>>>>>> 115986652ff4650747e059d9132fb2bd2e7cd025
        cmdClasses.put("wikidoc", "jrds.standalone.EnumerateWikiProbes");
        cmdClasses.put("checkjar", "jrds.standalone.CheckJar");
        cmdClasses.put("collect", "jrds.standalone.Collector");
Solution content
    static final Map cmdClasses = new HashMap();
    static {
        cmdClasses.put("jetty", "jrds.standalone.Jetty");
        cmdClasses.put("jmxserver", "jrds.standalone.JMX");
        cmdClasses.put("wikidoc", "jrds.standalone.EnumerateWikiProbes");
        cmdClasses.put("checkjar", "jrds.standalone.CheckJar");
        cmdClasses.put("collect", "jrds.standalone.Collector");
File
BootStrap.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Chunk
Conflicting content
                        //First pass, no data to use
                        if(allvalues == null) {
<<<<<<< HEAD
                            allvalues = fd.getValues().clone();
=======
                            allvalues = dp.getValues().clone();
>>>>>>> 115986652ff4650747e059d9132fb2bd2e7cd025
                        }
                        //Next step, sum previous values
                        else {
Solution content
                        //First pass, no data to use
                        if(allvalues == null) {
                            allvalues = dp.getValues().clone();
                        }
                        //Next step, sum previous values
                        else {
File
Sum.java
Developer's decision
Version 2
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
import java.util.Map;

<<<<<<< HEAD
import org.rrd4j.core.Sample;
=======
import jrds.JrdsSample;

>>>>>>> 115986652ff4650747e059d9132fb2bd2e7cd025
import org.snmp4j.smi.OID;

/**
Solution content
import java.util.Map;

import jrds.JrdsSample;

import org.snmp4j.smi.OID;

/**
File
ProcessStatusHostResources.java
Developer's decision
Version 2
Kind of conflict
Import
Chunk
Conflicting content
                }
            };
        }
<<<<<<< HEAD
            };
=======
    };
>>>>>>> 115986652ff4650747e059d9132fb2bd2e7cd025

    public void doGet(HttpServletRequest req, HttpServletResponse res) {
Solution content
                }
            };
        }
    };

    public void doGet(HttpServletRequest req, HttpServletResponse res) {
File
Download.java
Developer's decision
Version 1
Kind of conflict
Other
Chunk
Conflicting content
        DataProcessor sourceDp;
        String fileName;
<<<<<<< HEAD
        jrds.Graph graph;
=======
>>>>>>> 115986652ff4650747e059d9132fb2bd2e7cd025
        if("graph".equals(cmd)) {
            jrds.Graph graph = params.getGraph(this);
            if(graph == null) {
Solution content
        DataProcessor sourceDp;
        String fileName;
        if("graph".equals(cmd)) {
            jrds.Graph graph = params.getGraph(this);
            if(graph == null) {
File
Download.java
Developer's decision
Version 2
Kind of conflict
Variable