public ArtifactId artifact(String artifact, String version) { return new ArtifactId(namespace, artifact, version); }
public ArtifactId artifact(String artifact, String version) { return new ArtifactId(namespace, artifact, version); }
private ArtifactId deserializeArtifactId(JsonObject id) { NamespaceId namespace = deserializeNamespace(id); String artifactName = id.get("artifact").getAsString(); return new ArtifactId(namespace.getNamespace(), artifactName, id.get("version").getAsString()); }
private ArtifactId deserializeArtifactId(JsonObject id) { NamespaceId namespace = deserializeNamespace(id); String artifactName = id.get("artifact").getAsString(); return new ArtifactId(namespace.getNamespace(), artifactName, id.get("version").getAsString()); }
private ArtifactId deserializeArtifactId(JsonObject id) { NamespaceId namespace = deserializeNamespace(id); String artifactName = id.get("name").getAsString(); ArtifactVersion artifactVersion = new ArtifactVersion(id.get("version").getAsJsonObject() .get("version").getAsString()); return new ArtifactId(namespace.getNamespace(), artifactName, artifactVersion.getVersion()); }
@Override public ArtifactId toEntityId() { return new ArtifactId(namespace.getId(), name, version.getVersion()); } }
@Override public ArtifactId toEntityId() { return new ArtifactId(namespace.getId(), name, version.getVersion()); } }
@SuppressWarnings("unused") public static ArtifactId fromIdParts(Iterable<String> idString) { Iterator<String> iterator = idString.iterator(); return new ArtifactId( next(iterator, "namespace"), next(iterator, "artifact"), remaining(iterator, "version")); }
protected static void setupStreamingArtifacts(ArtifactId artifactId, Class<?> appClass) throws Exception { // add the app artifact addAppArtifact(artifactId, appClass, StreamingSource.class.getPackage().getName(), Transform.class.getPackage().getName(), SparkCompute.class.getPackage().getName(), PipelineConfigurable.class.getPackage().getName()); // add plugins artifact addPluginArtifact(new ArtifactId(artifactId.getNamespace(), artifactId.getArtifact() + "-mocks", "1.0.0"), artifactId, STREAMING_MOCK_PLUGINS, co.cask.cdap.etl.mock.spark.streaming.MockSource.class, co.cask.cdap.etl.mock.batch.MockSink.class, co.cask.cdap.etl.mock.spark.streaming.MockSink.class, DoubleTransform.class, AllErrorTransform.class, IdentityTransform.class, IntValueFilterTransform.class, StringValueFilterTransform.class, StringValueFilterCompute.class, Window.class, NullFieldSplitterTransform.class, NullAlertTransform.class); }
@SuppressWarnings("unused") public static ArtifactId fromIdParts(Iterable<String> idString) { Iterator<String> iterator = idString.iterator(); return new ArtifactId( next(iterator, "namespace"), next(iterator, "artifact"), remaining(iterator, "version")); }
protected static void setupBatchArtifacts(ArtifactId artifactId, Class<?> appClass) throws Exception { // add the app artifact addAppArtifact(artifactId, appClass, BatchSource.class.getPackage().getName(), Action.class.getPackage().getName(), Condition.class.getPackage().getName(), PipelineConfigurable.class.getPackage().getName(), "org.apache.avro.mapred", "org.apache.avro", "org.apache.avro.generic", "org.apache.avro.io"); // add plugins artifact addPluginArtifact(new ArtifactId(artifactId.getNamespace(), artifactId.getArtifact() + "-mocks", "1.0.0"), artifactId, BATCH_MOCK_PLUGINS, co.cask.cdap.etl.mock.batch.MockSource.class, co.cask.cdap.etl.mock.batch.MockSink.class, MockExternalSource.class, MockExternalSink.class, DoubleTransform.class, AllErrorTransform.class, IdentityTransform.class, IntValueFilterTransform.class, StringValueFilterTransform.class, FieldCountAggregator.class, IdentityAggregator.class, FieldsPrefixTransform.class, StringValueFilterCompute.class, NodeStatesAction.class, LookupTransform.class, NullFieldSplitterTransform.class, NullAlertTransform.class, IncapableSource.class, IncapableSink.class); }
@Override public ApplicationManager deployApplication(NamespaceId namespace, Class<? extends Application> applicationClz, @Nullable Config configObject, File... bundleEmbeddedJars) { Preconditions.checkNotNull(applicationClz, "Application class cannot be null."); Type configType = Artifacts.getConfigType(applicationClz); try { ArtifactId artifactId = new ArtifactId(namespace.getNamespace(), applicationClz.getSimpleName(), "1.0-SNAPSHOT"); addAppArtifact(artifactId, applicationClz, new Manifest(), bundleEmbeddedJars); if (configObject == null) { configObject = (Config) TypeToken.of(configType).getRawType().newInstance(); } Application app = applicationClz.newInstance(); MockAppConfigurer configurer = new MockAppConfigurer(app); app.configure(configurer, new DefaultApplicationContext<>(configObject)); ApplicationId applicationId = new ApplicationId(namespace.getNamespace(), configurer.getName()); ArtifactSummary artifactSummary = new ArtifactSummary(artifactId.getArtifact(), artifactId.getVersion()); appFabricClient.deployApplication(Id.Application.fromEntityId(applicationId), new AppRequest(artifactSummary, configObject)); return appManagerFactory.create(applicationId); } catch (Exception e) { throw Throwables.propagate(e); } }
@Override public ApplicationManager deployApplication(NamespaceId namespace, Class<? extends Application> applicationClz, @Nullable Config configObject, File... bundleEmbeddedJars) { Preconditions.checkNotNull(applicationClz, "Application class cannot be null."); Type configType = Artifacts.getConfigType(applicationClz); try { ArtifactId artifactId = new ArtifactId(namespace.getNamespace(), applicationClz.getSimpleName(), "1.0-SNAPSHOT"); addAppArtifact(artifactId, applicationClz, new Manifest(), bundleEmbeddedJars); if (configObject == null) { configObject = (Config) TypeToken.of(configType).getRawType().newInstance(); } Application app = applicationClz.newInstance(); MockAppConfigurer configurer = new MockAppConfigurer(app); app.configure(configurer, new DefaultApplicationContext<>(configObject)); ApplicationId applicationId = new ApplicationId(namespace.getNamespace(), configurer.getName()); ArtifactSummary artifactSummary = new ArtifactSummary(artifactId.getArtifact(), artifactId.getVersion()); appFabricClient.deployApplication(Id.Application.fromEntityId(applicationId), new AppRequest(artifactSummary, configObject)); return appManagerFactory.create(applicationId); } catch (Exception e) { throw Throwables.propagate(e); } }
String name = keySplitter.getString(); String version = keySplitter.getString(); return new ArtifactId(namespaceId, name, version); } else if (type.equals(TYPE_MAP.get(DatasetId.class)) || type.equals("datasetinstance")) { String namespaceId = keySplitter.getString();
/** * Deploys an {@link Application} using the given artifact jar with an optional config object. */ protected static <T> ApplicationManager deployWithArtifact(NamespaceId namespaceId, Class<? extends Application> appClass, File artifactJar, @Nullable T config) throws Exception { ArtifactId artifactId = new ArtifactId(namespaceId.getNamespace(), appClass.getSimpleName(), "1.0-SNAPSHOT"); addArtifact(artifactId, artifactJar); AppRequest<T> appRequest = new AppRequest<>(new ArtifactSummary(artifactId.getArtifact(), artifactId.getVersion()), config); return deployApplication(namespaceId.app(appClass.getSimpleName()), appRequest); }
private ApplicationManager deploy(NamespaceId namespaceId, Class<? extends Application> appClass) throws Exception { ArtifactId artifactId = new ArtifactId(namespaceId.getNamespace(), appClass.getSimpleName(), "1.0-SNAPSHOT"); addArtifact(artifactId, ARTIFACTS.get(appClass)); AppRequest<?> appRequest = new AppRequest<>(new ArtifactSummary(artifactId.getArtifact(), artifactId.getVersion()), null); return deployApplication(namespaceId.app(appClass.getSimpleName()), appRequest); }
throw new IllegalArgumentException("If a name is specified, a version must also be specified."); } else if (name == null) { artifactId = new ArtifactId(cliConfig.getCurrentNamespace().getNamespace(), artifactFile.getName()); } else { artifactId = cliConfig.getCurrentNamespace().artifact(name, version);
throw new IllegalArgumentException("If a name is specified, a version must also be specified."); } else if (name == null) { artifactId = new ArtifactId(cliConfig.getCurrentNamespace().getNamespace(), artifactFile.getName()); } else { artifactId = cliConfig.getCurrentNamespace().artifact(name, version);
@Test public void testSearchDifferentEntityScope() throws InterruptedException, TransactionFailureException { MetadataEntity sysArtifact = NamespaceId.SYSTEM.artifact("artifact", "1.0").toMetadataEntity(); MetadataEntity nsArtifact = new ArtifactId("ns1", "artifact", "1.0").toMetadataEntity(); String multiWordKey = "multiword"; String multiWordValue = "aV1 av2 , - , av3 - av4_av5 av6";
@Test public void testAppVersionsCreation() throws Exception { ArtifactId artifactId = new ArtifactId(NamespaceId.DEFAULT.getNamespace(), "cfg-app", "1.0.0-SNAPSHOT"); addAppArtifact(artifactId, ConfigTestApp.class); ApplicationId appId = new ApplicationId(NamespaceId.DEFAULT.getNamespace(), "AppV1", "version1"); AppRequest<ConfigTestApp.ConfigClass> createRequest = new AppRequest<>( new ArtifactSummary(artifactId.getArtifact(), artifactId.getVersion()), new ConfigTestApp.ConfigClass("tD1", "tV1")); ApplicationManager appManager = deployApplication(appId, createRequest); ServiceManager serviceManager = appManager.getServiceManager(ConfigTestApp.SERVICE_NAME); serviceManager.start(); serviceManager.waitForRun(ProgramRunStatus.RUNNING, 10, TimeUnit.SECONDS); URL serviceURL = serviceManager.getServiceURL(); Gson gson = new Gson(); Assert.assertEquals("tV1", gson.fromJson(callServiceGet(serviceURL, "ping"), String.class)); serviceManager.stop(); serviceManager.waitForStopped(10, TimeUnit.SECONDS); appId = new ApplicationId(NamespaceId.DEFAULT.getNamespace(), "AppV1", "version2"); createRequest = new AppRequest<>( new ArtifactSummary(artifactId.getArtifact(), artifactId.getVersion()), new ConfigTestApp.ConfigClass("tD2", "tV2")); appManager = deployApplication(appId, createRequest); serviceManager = appManager.getServiceManager(ConfigTestApp.SERVICE_NAME); serviceManager.start(); serviceManager.waitForRun(ProgramRunStatus.RUNNING, 10, TimeUnit.SECONDS); serviceURL = serviceManager.getServiceURL(); Assert.assertEquals("tV2", gson.fromJson(callServiceGet(serviceURL, "ping"), String.class)); serviceManager.stop(); }