/** * @param garFile GAR file. * @param hasDescr Whether GAR file has descriptor. * @throws IOException If GAR file is not found. * @return Whether GAR file structure is correct. */ private boolean checkStructure(File garFile, boolean hasDescr) throws IOException { ZipFile zip = new ZipFile(garFile); String descr = "META-INF/ignite.xml"; ZipEntry entry = zip.getEntry(descr); if (entry == null && !hasDescr) { if (log().isInfoEnabled()) { log() .info( "Process deployment without descriptor file [path=" + descr + ", file=" + garFile.getAbsolutePath() + ']'); } return true; } else if (entry != null && hasDescr) { InputStream in = null; try { in = new BufferedInputStream(zip.getInputStream(entry)); return true; } finally { U.close(in, log()); } } else return false; }
/** @throws Exception if error occur. */ @SuppressWarnings("unchecked") private void checkGar() throws Exception { initGar = true; String garDir = "modules/extdata/p2p/deploy"; String garFileName = "p2p.gar"; File origGarPath = U.resolveIgnitePath(garDir + '/' + garFileName); File tmpPath = new File(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString()); if (!tmpPath.mkdir()) throw new IOException("Can not create temp directory"); try { File newGarFile = new File(tmpPath, garFileName); U.copy(origGarPath, newGarFile, false); assert newGarFile.exists(); try { garFile = "file:///" + tmpPath.getAbsolutePath(); try { Ignite ignite1 = startGrid(1); Ignite ignite2 = startGrid(2); Integer res = ignite1 .compute() .<UUID, Integer>execute(TASK_NAME, ignite2.cluster().localNode().id()); assert res != null; } finally { stopGrid(1); stopGrid(2); } } finally { if (newGarFile != null && !newGarFile.delete()) error("Can not delete temp gar file"); } } finally { if (!tmpPath.delete()) error("Can not delete temp directory"); } }