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

io.hyperfoil.tools.qdup.config.ScriptRepo Maven / Gradle / Ivy

Go to download

Coordinate multiple terminal shell connections for queuing performance tests and collecting output files

There is a newer version: 0.8.3
Show newest version
package io.hyperfoil.tools.qdup.config;

import io.hyperfoil.tools.qdup.cmd.Script;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Created by wreicher
 * A Map of scripts by name that will return a new, empty Script if the name was not already used
 */
public class ScriptRepo {

    private Map scripts;

    public ScriptRepo(){
        scripts = new ConcurrentHashMap<>();
    }

    protected void addScript(Script script){
        scripts.put(script.getName(),script);
    }

    public Script getScript(String name){
        if(!hasScript(name)){
            Script previous = scripts.put(name,new Script(name));
            if(previous!=null){
                //TODO this is bad, means multiple threads clashed for the same getScript name
            }
        }
        return scripts.get(name);
    }
    public boolean hasScript(String name){
        return scripts.containsKey(name);
    }
    public List getNames(){
        return Arrays.asList(scripts.keySet().toArray(new String[0]));
    }
    public int size(){return scripts.size();}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy