@Override public Location call() throws Exception { Location baseLocation = StreamUtils.createGenerationLocation(config.getLocation(), generation); Locations.mkdirsIfNotExists(baseLocation); return baseLocation; } });
Locations.mkdirsIfNotExists(jarDir);
Locations.mkdirsIfNotExists(jarDir);
private Location copyFile(Id.Artifact artifactId, File artifactContent) throws IOException { Location fileDirectory = namespacePathLocator.get(artifactId.getNamespace().toEntityId()) .append(ARTIFACTS_PATH).append(artifactId.getName()); Location destination = fileDirectory.append(artifactId.getVersion().getVersion()).getTempFile(".jar"); Locations.mkdirsIfNotExists(fileDirectory); // write the file contents try (OutputStream destinationStream = destination.getOutputStream()) { Files.copy(artifactContent.toPath(), destinationStream); } return destination; }
Locations.mkdirsIfNotExists(archiveDir);
Locations.mkdirsIfNotExists(archiveDir);
private Location copyFile(Id.Artifact artifactId, InputSupplier<? extends InputStream> artifactContentSupplier) throws IOException { Location fileDirectory = namespacedLocationFactory.get(artifactId.getNamespace().toEntityId()) .append(ARTIFACTS_PATH).append(artifactId.getName()); Location destination = fileDirectory.append(artifactId.getVersion().getVersion()).getTempFile(".jar"); Locations.mkdirsIfNotExists(fileDirectory); // write the file contents try (InputStream artifactContents = artifactContentSupplier.getInput(); OutputStream destinationStream = destination.getOutputStream()) { ByteStreams.copy(artifactContents, destinationStream); } return destination; }
@BeforeClass public static void setup() throws Exception { NamespacePathLocator namespacePathLocator = AppFabricTestHelper.getInjector().getInstance(NamespacePathLocator.class); namespaceHomeLocation = namespacePathLocator.get(DefaultId.NAMESPACE); NamespaceAdmin namespaceAdmin = AppFabricTestHelper.getInjector().getInstance(NamespaceAdmin.class); namespaceAdmin.create(new NamespaceMeta.Builder().setName(DefaultId.NAMESPACE).build()); Locations.mkdirsIfNotExists(namespaceHomeLocation); }
waitForService(Constants.Service.DATASET_MANAGER); Locations.mkdirsIfNotExists(namespacePathLocator.get(NamespaceId.DEFAULT));
@Test public void testProgramGeneration() throws Exception { cConf.set(Constants.AppFabric.OUTPUT_DIR, "programs"); LocationFactory lf = new LocalLocationFactory(TEMP_FOLDER.newFolder()); // have to do this since we are not going through the route of create namespace -> deploy application // in real scenarios, the namespace directory would already be created Location namespaceLocation = lf.create(DefaultId.APPLICATION.getNamespace()); Locations.mkdirsIfNotExists(namespaceLocation); LocationFactory jarLf = new LocalLocationFactory(TEMP_FOLDER.newFolder()); Location appArchive = AppJarHelper.createDeploymentJar(jarLf, AllProgramsApp.class); ApplicationSpecification appSpec = Specifications.from(new AllProgramsApp()); ApplicationSpecificationAdapter adapter = ApplicationSpecificationAdapter.create(); ApplicationSpecification newSpec = adapter.fromJson(adapter.toJson(appSpec)); ProgramGenerationStage pgmStage = new ProgramGenerationStage(); pgmStage.process(new StageContext(Object.class)); // Can do better here - fixed right now to run the test. pgmStage.process(new ApplicationDeployable(NamespaceId.DEFAULT.artifact("AllProgramApp", "1.0"), appArchive, DefaultId.APPLICATION, newSpec, null, ApplicationDeployScope.USER)); Assert.assertTrue(true); }