protected void setUp() { super.setUp(); testUtil = new TestUtil(); fileUtil = new TestFileUtil(); utils = new Utils(fileUtil, new Shell.Factory(), new Streams(), new Threads(), new Str()); baseDir = new File(fileUtil.testDir(), "MRTest"); dataDir = new File(baseDir, "data"); fileUtil.deleteTree(baseDir); if (baseDir.exists()) { warn("residual files"); } mysqldResource = new MysqldResource(baseDir, dataDir, null, System.out, System.err, utils); mysqldResource.setKillDelay(testUtil.testKillDelay()); }
/** called from option parser as well */ synchronized Shell exec(String threadName, Map mysqldArgs, PrintStream outStream, PrintStream errStream, boolean withListeners) { mysqldArgs.put(MysqldResourceI.BASEDIR, baseDir.getPath()); mysqldArgs.put(MysqldResourceI.PID_FILE, pidFile().getPath()); socket(mysqldArgs); File dataDir = dataDir(mysqldArgs); makeMysqld(); ensureEssentialFilesExist(dataDir); String[] args = constructArgs(mysqldArgs); outStream.println(str.toString(args)); Shell launch = shellFactory.newShell(args, threadName, outStream, errStream); if (withListeners) { for (int i = 0; i < completionListensers.size(); i++) { Runnable listener = (Runnable) completionListensers.get(i); launch.addCompletionListener(listener); } } launch.setDaemon(true); printMessage("launching mysqld (" + threadName + ")"); launch.start(); return launch; }
private Shell exec(String threadName, Map mysqldArgs, PrintStream outStream, PrintStream errStream, boolean withListeners) { makeMysqld(); ensureEssentialFilesExist(); adjustParameterMap(mysqldArgs); String[] args = constructArgs(mysqldArgs); outStream.println(new ListToString().toString(args)); log.info("starting mysqld: " + new ListToString().toString(args)); Shell launch = utils.shellFactory().newShell(args, threadName, outStream, errStream); if (withListeners) { for (int i = 0; i < completionListensers.size(); i++) { Runnable listener = (Runnable) completionListensers.get(i); launch.addCompletionListener(listener); } } launch.setDaemon(true); printMessage("launching mysqld (" + threadName + ")"); launch.start(); return launch; }
protected void setUp() { super.setUp(); testUtil = new TestUtil(); threads = new Threads(); fileUtil = new TestFileUtil(); shellFactory = new Shell.Factory(); streams = new Streams(); str = new Str(); classUtil = new ClassUtil(); mysqldResource = new MysqldResource(fileUtil.nullFile(), System.out, System.err, fileUtil, shellFactory, streams, threads, str, classUtil); mysqldResource.setKillDelay(10000); File baseDir = mysqldResource.getBaseDir(); fileUtil.deleteTree(baseDir); if (baseDir.exists()) { warn("residual files"); } }
private Shell launchShell(String threadName, String[] args, int seconds) { Shell shell = shellFactory.newShell(args, threadName, out, err); shell.start(); int fraction = 20; int loops = (fraction * seconds); do { threads.pause((1000/fraction)); } while(!shell.hasReturned() && loops-- > 0); if (!shell.hasReturned()) { err.println("Thread \"" +threadName + "\" may be hung"); err.println("(did not return after " + seconds + " seconds)"); err.println("command line used: "); err.println(str.toString(Arrays.asList(args), "", " ", "")); } return shell; }
private Shell exec(String threadName, Map mysqldArgs, PrintStream outStream, PrintStream errStream, boolean withListeners) { deployFiles(); adjustParameterMap(mysqldArgs); String[] args = constructArgs(mysqldArgs); outStream.println(new ListToString().toString(args)); Shell launch = utils.shellFactory().newShell(args, threadName, outStream, errStream); if (withListeners) { for (int i = 0; i < completionListensers.size(); i++) { Runnable listener = (Runnable) completionListensers.get(i); launch.addCompletionListener(listener); } } launch.setDaemon(true); printMessage("launching mysqld (" + threadName + ")"); launch.start(); return launch; }
private Shell launchShell(String threadName, String[] args, int seconds) { Shell shell = utils.shellFactory().newShell(args, threadName, out, err); shell.start(); int fraction = 20; int loops = (fraction * seconds); do { utils.threads().pause((1000 / fraction)); } while (!shell.hasReturned() && loops-- > 0); if (!shell.hasReturned()) { err.println("Thread \"" + threadName + "\" may be hung"); err.println("(did not return after " + seconds + " seconds)"); err.println("command line used: "); err.println(new ListToString("", " ", "").toString(args)); } return shell; }
public Files() { this(new Shell.Factory(), File.separatorChar, new Streams()); }
private Shell launchShell(String threadName, String[] args, int seconds) { Shell shell = utils.shellFactory().newShell(args, threadName, out, err); shell.start(); int fraction = 20; int loops = (fraction * seconds); do { utils.threads().pause((1000 / fraction)); } while (!shell.hasReturned() && loops-- > 0); if (!shell.hasReturned()) { err.println("Thread \"" + threadName + "\" may be hung"); err.println("(did not return after " + seconds + " seconds)"); err.println("command line used: "); err.println(new ListToString("", " ", "").toString(args)); } return shell; }
/** * On UNIX systems, in order for a file to be executable, it needs to have * the execute bit set. This method executes a "chmod +x filename" */ public void addExecutableRights(File executable, PrintStream out, PrintStream err) { if (isWindows()) { return; } String[] args = { "/bin/chmod", "+x", executable.getPath() }; String tName = "make " + executable + " runable"; shellFactory.newShell(args, tName, out, err).run(); }
public FileUtil() { this(new Shell.Factory(), File.separatorChar, new Streams()); }
public Files() { this(new Shell.Factory(), File.separatorChar, new Streams()); }
/** * On UNIX systems, in order for a file to be executable, it needs to have * the execute bit set. This method executes a "chmod +x filename" */ public void addExecutableRights(File executable, PrintStream out, PrintStream err) { if (isWindows()) { return; } String[] args = { "chmod", "+x", executable.getPath() }; String tName = "make " + executable + " runable"; shellFactory.newShell(args, tName, out, err).run(); }
public MysqldResource(File baseDir, PrintStream out, PrintStream err) { this(baseDir, out, err, new FileUtil(), new Shell.Factory(), new Streams(), new Threads(), new Str(), new ClassUtil()); }
public ProcessUtil(String pid, PrintStream out, PrintStream err) { this(new FileUtil(), pid, out, err, new Str(), new Shell.Factory(), new Streams(), new Threads()); }
public Utils() { this.shellFactory = new Shell.Factory(); this.str = new Str(); this.streams = new Streams(); this.threads = new Threads(); this.files = new Files(shellFactory, File.separatorChar, streams); }
/** * On UNIX systems, in order for a file to be executable, it needs to have * the execute bit set. This method executes a "chmod +x filename" */ public void addExecutableRights(File executable, PrintStream out, PrintStream err) { if (isWindows()) { return; } String[] args = { "chmod", "+x", executable.getPath() }; String tName = "make " + executable + " runable"; shellFactory.newShell(args, tName, out, err).run(); }
protected void setUp() { super.setUp(); fileUtil = new FileUtil(); shellFactory = new Shell.Factory(); }
public Utils() { this.shellFactory = new Shell.Factory(); this.str = new Str(); this.streams = new Streams(); this.threads = new Threads(); this.files = new Files(shellFactory, File.separatorChar, streams); }