Search in sources :

Example 16 with LocalLocationFactory

use of org.apache.twill.filesystem.LocalLocationFactory in project cdap by caskdata.

the class CLIMainTest method createAppJarFile.

private static File createAppJarFile(Class<?> cls) throws IOException {
    File tmpFolder = TMP_FOLDER.newFolder();
    LocationFactory locationFactory = new LocalLocationFactory(tmpFolder);
    Location deploymentJar = AppJarHelper.createDeploymentJar(locationFactory, cls);
    File appJarFile = new File(tmpFolder, String.format("%s-1.0.%d.jar", cls.getSimpleName(), System.currentTimeMillis()));
    Files.copy(Locations.newInputSupplier(deploymentJar), appJarFile);
    return appJarFile;
}
Also used : File(java.io.File) LocalLocationFactory(org.apache.twill.filesystem.LocalLocationFactory) LocalLocationFactory(org.apache.twill.filesystem.LocalLocationFactory) LocationFactory(org.apache.twill.filesystem.LocationFactory) Location(org.apache.twill.filesystem.Location)

Example 17 with LocalLocationFactory

use of org.apache.twill.filesystem.LocalLocationFactory in project cdap by caskdata.

the class ServiceClientTestRun method addArtifact.

/**
   * Add AppReturnsArgs artifact
   */
private void addArtifact() throws Exception {
    LocalLocationFactory locationFactory = new LocalLocationFactory(TMP_FOLDER.newFolder());
    Manifest manifest = new Manifest();
    manifest.getMainAttributes().put(ManifestFields.BUNDLE_VERSION, "1.0.0");
    final Location appJarLoc = AppJarHelper.createDeploymentJar(locationFactory, AppReturnsArgs.class, manifest);
    InputSupplier<InputStream> inputSupplier = new InputSupplier<InputStream>() {

        @Override
        public InputStream getInput() throws IOException {
            return appJarLoc.getInputStream();
        }
    };
    artifactClient.add(NamespaceId.DEFAULT, artifactId.getArtifact(), inputSupplier, artifactId.getVersion());
    appJarLoc.delete();
}
Also used : InputStream(java.io.InputStream) Manifest(java.util.jar.Manifest) LocalLocationFactory(org.apache.twill.filesystem.LocalLocationFactory) Location(org.apache.twill.filesystem.Location) InputSupplier(com.google.common.io.InputSupplier)

Example 18 with LocalLocationFactory

use of org.apache.twill.filesystem.LocalLocationFactory in project cdap by caskdata.

the class DatasetServiceAuthorizationTest method setup.

@BeforeClass
public static void setup() throws Exception {
    locationFactory = new LocalLocationFactory(TMP_FOLDER.newFolder());
    initializeAndStartService(createCConf());
    authorizer = injector.getInstance(AuthorizerInstantiator.class).get();
}
Also used : LocalLocationFactory(org.apache.twill.filesystem.LocalLocationFactory) BeforeClass(org.junit.BeforeClass)

Example 19 with LocalLocationFactory

use of org.apache.twill.filesystem.LocalLocationFactory in project cdap by caskdata.

the class EntityExistenceTest method setup.

@BeforeClass
public static void setup() throws Exception {
    CConfiguration cConf = CConfiguration.create();
    cConf.set(Constants.INSTANCE_NAME, EXISTS);
    Injector injector = AppFabricTestHelper.getInjector(cConf);
    NamespaceStore nsStore = injector.getInstance(NamespaceStore.class);
    ArtifactRepository artifactRepository = injector.getInstance(ArtifactRepository.class);
    cConf = injector.getInstance(CConfiguration.class);
    nsStore.create(new NamespaceMeta.Builder().setName(EXISTS).build());
    existenceVerifier = injector.getInstance(EntityExistenceVerifier.class);
    LocalLocationFactory lf = new LocalLocationFactory(TEMPORARY_FOLDER.newFolder());
    File artifactFile = new File(AppJarHelper.createDeploymentJar(lf, AllProgramsApp.class).toURI());
    artifactRepository.addArtifact(ARTIFACT.toId(), artifactFile);
    AppFabricTestHelper.deployApplication(NAMESPACE.toId(), AllProgramsApp.class, null, cConf);
    StreamAdmin streamAdmin = injector.getInstance(StreamAdmin.class);
    streamAdmin.createOrUpdateView(VIEW, new ViewSpecification(new FormatSpecification("csv", null)));
}
Also used : StreamAdmin(co.cask.cdap.data2.transaction.stream.StreamAdmin) EntityExistenceVerifier(co.cask.cdap.common.entity.EntityExistenceVerifier) Injector(com.google.inject.Injector) NamespaceMeta(co.cask.cdap.proto.NamespaceMeta) NamespaceStore(co.cask.cdap.store.NamespaceStore) FormatSpecification(co.cask.cdap.api.data.format.FormatSpecification) ViewSpecification(co.cask.cdap.proto.ViewSpecification) ArtifactRepository(co.cask.cdap.internal.app.runtime.artifact.ArtifactRepository) CConfiguration(co.cask.cdap.common.conf.CConfiguration) LocalLocationFactory(org.apache.twill.filesystem.LocalLocationFactory) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 20 with LocalLocationFactory

use of org.apache.twill.filesystem.LocalLocationFactory in project cdap by caskdata.

the class SystemArtifactsAuthorizationTest method createAppJar.

private static File createAppJar(Class<?> cls, File destFile, Manifest manifest) throws IOException {
    Location deploymentJar = AppJarHelper.createDeploymentJar(new LocalLocationFactory(TMP_FOLDER.newFolder()), cls, manifest);
    DirUtils.mkdirs(destFile.getParentFile());
    Files.copy(Locations.newInputSupplier(deploymentJar), destFile);
    return destFile;
}
Also used : LocalLocationFactory(org.apache.twill.filesystem.LocalLocationFactory) Location(org.apache.twill.filesystem.Location)

Aggregations

LocalLocationFactory (org.apache.twill.filesystem.LocalLocationFactory)41 Location (org.apache.twill.filesystem.Location)29 LocationFactory (org.apache.twill.filesystem.LocationFactory)21 File (java.io.File)15 CConfiguration (co.cask.cdap.common.conf.CConfiguration)11 BeforeClass (org.junit.BeforeClass)11 Test (org.junit.Test)11 NamespacedLocationFactory (co.cask.cdap.common.namespace.NamespacedLocationFactory)5 ApplicationSpecification (co.cask.cdap.api.app.ApplicationSpecification)4 NamespaceAdmin (co.cask.cdap.common.namespace.NamespaceAdmin)4 ArtifactRepository (co.cask.cdap.internal.app.runtime.artifact.ArtifactRepository)4 ReflectionSchemaGenerator (co.cask.cdap.internal.io.ReflectionSchemaGenerator)4 Injector (com.google.inject.Injector)4 ApplicationSpecificationAdapter (co.cask.cdap.internal.app.ApplicationSpecificationAdapter)3 URL (java.net.URL)3 CloseableClassLoader (co.cask.cdap.api.artifact.CloseableClassLoader)2 ConfigResponse (co.cask.cdap.app.deploy.ConfigResponse)2 Configurator (co.cask.cdap.app.deploy.Configurator)2 DummyProgramRunnerFactory (co.cask.cdap.app.runtime.DummyProgramRunnerFactory)2 StreamAdmin (co.cask.cdap.data2.transaction.stream.StreamAdmin)2