List of usage examples for org.apache.commons.configuration BaseConfiguration getStringArray
public String[] getStringArray(String key)
From source file:uk.ac.sanger.cgp.wwdocker.daemon.PrimaryDaemon.java
private void hostSet(BaseConfiguration config, Map<String, String> hosts) { // first remove the killed off hosts List toRemove = new ArrayList(); for (Map.Entry<String, String> e : hosts.entrySet()) { if (e.getValue().equals("DELETE")) { toRemove.add(e.getKey());/* w w w .j a v a2 s . c o m*/ } } hosts.keySet().removeAll(toRemove); // add the new hosts BaseConfiguration workerConf = Config.loadWorkers(config.getString("workerCfg")); String[] rawHosts = workerConf.getStringArray("hosts"); if (rawHosts.length == 1 && rawHosts[0].equals(new String())) { rawHosts = new String[0]; } Set<String> tmp = new LinkedHashSet<>(); for (String h : rawHosts) { if (!hosts.containsKey(h)) { hosts.put(h, "TO_PROVISION"); } tmp.add(h); } // identify which hosts need to be killed for (Map.Entry<String, String> e : hosts.entrySet()) { if (!tmp.contains(e.getKey())) { hosts.replace(e.getKey(), "KILL"); } } }
From source file:uk.ac.sanger.cgp.wwdocker.interfaces.Workflow.java
default String seqwareWhiteStarImage(BaseConfiguration config) { String[] pullImages = config.getStringArray("pullDockerImages"); String whitestar = null;//from w w w . j a va 2 s .c o m for (String i : pullImages) { if (i.contains("seqware_whitestar_pancancer")) { whitestar = i; break; } } return whitestar; }
From source file:uk.ac.sanger.cgp.wwdocker.workflow.DEWorkflow.java
@Override public boolean provisionHost(String host, BaseConfiguration config, File thisJar, File tmpConf, String mode, Map<String, String> envs) throws InterruptedException { boolean provisioned = false; String remoteWorkflowDir = config.getString("workflowDir"); String localSeqwareJar = config.getString("seqware"); String localWorkflowZip = config.getString("workflow"); File jreDist = Utils.expandUserFile(config, "jreDist", true); File remoteSeqwareJar = new File( remoteWorkflowDir.concat("/").concat(localSeqwareJar.replaceAll(".*/", ""))); File remoteWorkflowZip = new File( remoteWorkflowDir.concat("/").concat(localWorkflowZip.replaceAll(".*/", ""))); String[] pullDockerImages = config.getStringArray("pullDockerImages"); String[] curlDockerImages = config.getStringArray("curlDockerImages"); String[] pushDockerImages = config.getStringArray("pushDockerImages"); String optDir = "/opt/wwdocker"; String workerLog = config.getString("log4-worker"); File localTmp = Utils.expandUserDirPath(config, "primaryLargeTmp", true); List<String> createPaths = new ArrayList(); createPaths.add("/opt/wwdocker"); createPaths.add("/opt/wwdocker/jre"); createPaths.add(remoteWorkflowDir);//from ww w.ja v a 2s.co m createPaths.add(config.getString("datastoreDir")); Session ssh = Remote.getSession(config, host); Remote.createPaths(ssh, createPaths); Remote.chmodPaths(ssh, "a+wrx", createPaths, true); Remote.cleanFiles(ssh, new String[] { config.getString("log4-delete") }); Remote.cleanupOldImages(ssh); // incase lots of stale ones are already present if (Local.pushFileSetToHost(pushDockerImages, host, "/opt/wwdocker", envs, ssh, null) != 0) { return provisioned; } String[] pushedDockerImages = new String[pushDockerImages.length]; for (int i = 0; i < pushDockerImages.length; i++) { pushedDockerImages[i] = Paths.get("/opt/wwdocker", new File(pushDockerImages[i]).getName()).toFile() .getPath(); } if (Remote.dockerPull(ssh, pullDockerImages) != 0 || Remote.dockerLoad(ssh, curlDockerImages, remoteWorkflowDir) != 0 || Remote.dockerLoad(ssh, pushedDockerImages, remoteWorkflowDir) != 0) { return provisioned; } Remote.cleanupOldImages(ssh); // incase lots of stale ones are already present if (Remote.curl(ssh, localSeqwareJar, remoteWorkflowDir) == null) { return provisioned; } Local.pushToHost(jreDist.getAbsolutePath(), host, optDir, envs, ssh, localTmp); if (Remote.expandJre(ssh, jreDist) != 0) { return provisioned; } Remote.curl(ssh, localWorkflowZip, remoteWorkflowDir); if (Remote.expandWorkflow(ssh, remoteWorkflowZip, remoteSeqwareJar, remoteWorkflowDir) != 0) { return provisioned; } //String workflowBase = remoteWorkflowZip.getName().replaceAll("\\.zip$", ""); //Path gnosDest = Paths.get(remoteWorkflowDir, workflowBase); if (Local.pushToHost(thisJar.getAbsolutePath(), host, optDir, envs, ssh, localTmp) != 0 // this jar file || Local.pushToHost(workerLog, host, optDir, envs, ssh, localTmp) != 0 // worker log config || Local.pushToHost(tmpConf.getAbsolutePath(), host, optDir, envs, ssh, localTmp) != 0 // config file || Remote.chmodPath(ssh, "go-wrx", optDir.concat("/*"), true) != 0 // file will have passwords || Local.pushFileSetToHost(Utils.getGnosKeys(config), host, config.getString("datastoreDir"), envs, ssh, localTmp) != 0 // GNOS keys, note DATASTORE || Remote.chmodPath(ssh, "a+r", config.getString("datastoreDir").concat("/*.pem"), false) != 0 // need to ensure these are readable within the image || Remote.startWorkerDaemon(ssh, thisJar.getName(), tmpConf.getName(), mode) != 0) { return provisioned; } provisioned = true; return provisioned; }
From source file:uk.ac.sanger.cgp.wwdocker.workflow.SangerWorkflow.java
@Override public boolean provisionHost(String host, BaseConfiguration config, File thisJar, File tmpConf, String mode, Map<String, String> envs) throws InterruptedException { boolean provisioned = false; String remoteWorkflowDir = config.getString("workflowDir"); String localSeqwareJar = config.getString("seqware"); String localWorkflowZip = config.getString("workflow"); File jreDist = Utils.expandUserFile(config, "jreDist", true); File remoteSeqwareJar = new File( remoteWorkflowDir.concat("/").concat(localSeqwareJar.replaceAll(".*/", ""))); File remoteWorkflowZip = new File( remoteWorkflowDir.concat("/").concat(localWorkflowZip.replaceAll(".*/", ""))); String[] pullDockerImages = config.getStringArray("pullDockerImages"); String optDir = "/opt/wwdocker"; String workerLog = config.getString("log4-worker"); File localTmp = Utils.expandUserDirPath(config, "primaryLargeTmp", true); List<String> createPaths = new ArrayList(); createPaths.add("/opt/wwdocker"); createPaths.add("/opt/wwdocker/jre"); createPaths.add(remoteWorkflowDir);/*from w w w .j ava 2 s.c o m*/ createPaths.add(config.getString("datastoreDir")); Session ssh = Remote.getSession(config, host); Remote.createPaths(ssh, createPaths); Remote.chmodPaths(ssh, "a+wrx", createPaths, true); Remote.cleanFiles(ssh, new String[] { config.getString("log4-delete") }); if (Remote.dockerPull(ssh, pullDockerImages) != 0) { return provisioned; } if (Remote.curl(ssh, localSeqwareJar, remoteWorkflowDir) == null) { return provisioned; } Local.pushToHost(jreDist.getAbsolutePath(), host, optDir, envs, ssh, localTmp); if (Remote.expandJre(ssh, jreDist) != 0) { return provisioned; } if (Remote.curl(ssh, localWorkflowZip, remoteWorkflowDir) == null || Remote.expandWorkflow(ssh, remoteWorkflowZip, remoteSeqwareJar, remoteWorkflowDir) != 0) { return provisioned; } String workflowBase = remoteWorkflowZip.getName().replaceAll("\\.zip$", ""); Path gnosDest = Paths.get(remoteWorkflowDir, workflowBase); if (Local.pushToHost(thisJar.getAbsolutePath(), host, optDir, envs, ssh, localTmp) != 0 // this jar file || Local.pushToHost(workerLog, host, optDir, envs, ssh, localTmp) != 0 // worker log config || Local.pushToHost(tmpConf.getAbsolutePath(), host, optDir, envs, ssh, localTmp) != 0 // config file || Remote.chmodPath(ssh, "go-wrx", optDir.concat("/*"), true) != 0 // file will have passwords || Local.pushFileSetToHost(Utils.getGnosKeys(config), host, gnosDest.toString(), envs, ssh, localTmp) != 0 // GNOS keys || Remote.startWorkerDaemon(ssh, thisJar.getName(), tmpConf.getName(), mode) != 0) { return provisioned; } provisioned = true; return provisioned; }
From source file:uk.ac.sanger.cgp.wwdocker.workflow.TestWorkflow.java
@Override public boolean provisionHost(String host, BaseConfiguration config, File thisJar, File tmpConf, String mode, Map<String, String> envs) throws InterruptedException { boolean provisioned = false; String remoteWorkflowDir = config.getString("workflowDir"); String localSeqwareJar = config.getString("seqware"); File jreDist = Utils.expandUserFile(config, "jreDist", true); String[] pullDockerImages = config.getStringArray("pullDockerImages"); String optDir = "/opt/wwdocker"; String workerLog = config.getString("log4-worker"); File localTmp = Utils.expandUserDirPath(config, "primaryLargeTmp", true); List<String> createPaths = new ArrayList(); createPaths.add("/opt/wwdocker"); createPaths.add("/opt/wwdocker/jre"); createPaths.add(remoteWorkflowDir);/* w ww . j a v a 2 s .c om*/ createPaths.add(config.getString("datastoreDir")); Session ssh = Remote.getSession(config, host); Remote.createPaths(ssh, createPaths); Remote.chmodPaths(ssh, "a+wrx", createPaths, true); Remote.cleanFiles(ssh, new String[] { config.getString("log4-delete") }); if (Remote.dockerPull(ssh, pullDockerImages) != 0) { return provisioned; } if (Remote.curl(ssh, localSeqwareJar, remoteWorkflowDir) == null) { return provisioned; } Local.pushToHost(jreDist.getAbsolutePath(), host, optDir, envs, ssh, localTmp); if (Remote.expandJre(ssh, jreDist) != 0) { return provisioned; } Local.pushToHost("testData/run.pl", host, config.getString("datastoreDir"), envs, ssh, localTmp); if (Local.pushToHost(thisJar.getAbsolutePath(), host, optDir, envs, ssh, localTmp) != 0 // this jar file || Local.pushToHost(workerLog, host, optDir, envs, ssh, localTmp) != 0 // worker log config || Local.pushToHost(tmpConf.getAbsolutePath(), host, optDir, envs, ssh, localTmp) != 0 // config file || Remote.chmodPath(ssh, "go-wrx", optDir.concat("/*"), true) != 0 // file will have passwords || Remote.startWorkerDaemon(ssh, thisJar.getName(), tmpConf.getName(), mode) != 0) { return provisioned; } provisioned = true; return provisioned; }