private ApplicationSpecification getAppSpecOrFail(AppMetadataStore mds, ApplicationId id) { ApplicationSpecification appSpec = getApplicationSpec(mds, id); if (appSpec == null) { throw new NoSuchElementException("no such application @ namespace id: " + id.getNamespaceId() + ", app id: " + id.getApplication()); } return appSpec; }
private ApplicationSpecification getAppSpecOrFail(AppMetadataStore mds, ApplicationId id) { ApplicationSpecification appSpec = getApplicationSpec(mds, id); if (appSpec == null) { throw new NoSuchElementException("no such application @ namespace id: " + id.getNamespaceId() + ", app id: " + id.getApplication()); } return appSpec; }
@Override public EntityId apply(DatasetDetail input) { return appId.getNamespaceId().dataset(input.getName()); } }, null);
@Override public EntityId apply(DatasetDetail input) { return appId.getNamespaceId().dataset(input.getName()); } }, null);
@Override public EntityId apply(StreamDetail input) { return appId.getNamespaceId().stream(input.getName()); } }, null);
@Override public DatasetId apply(DatasetDetail input) { return appId.getNamespaceId().dataset(input.getName()); }}))); Assert.assertEquals(
/** * Helper function to get the authorizing user for app deployment, the authorzing user will be the app owner if it * is present. If not, it will be the namespace owner. If that is also not present, it will be the user who is making * the request */ public static String getAppAuthorizingUser(OwnerAdmin ownerAdmin, AuthenticationContext authenticationContext, ApplicationId applicationId, @Nullable KerberosPrincipalId appOwner) throws IOException { KerberosPrincipalId effectiveOwner = SecurityUtil.getEffectiveOwner(ownerAdmin, applicationId.getNamespaceId(), appOwner == null ? null : appOwner.getPrincipal()); // CDAP-13154 If impersonation is configured for either the application or namespace the effective owner will be // a kerberos principal which can have different form // (refer: https://docs.oracle.com/cd/E21455_01/common/tutorials/kerberos_principal.html). For example it can be // a complete principal name (alice/somehost.net@someREALM). For authorization we need the enforcement to happen // on the username and not the complete principal. The user name is the shortname of the principal so return the // shortname as authorizing user. String appAuthorizingUser = effectiveOwner != null ? new KerberosName(effectiveOwner.getPrincipal()).getShortName() : authenticationContext.getPrincipal().getName(); LOG.trace("Returning {} as authorizing app user for {}", appAuthorizingUser, applicationId); return appAuthorizingUser; }
if (store.getStream(appId.getNamespaceId(), spec.getName()) != null) { verifyOwner(appId.getParent().stream(spec.getName()), ownerPrincipal);
ArtifactId artifactId = appId.getNamespaceId().artifact("testArtifact", "1.0").toApiArtifactId();
for (int i = 0; i < 99; ++i) { ApplicationId application = NamespaceId.DEFAULT.app("app" + i); ArtifactId artifactId = application.getNamespaceId().artifact("testArtifact", "1.0").toApiArtifactId(); ProgramId program = application.program(ProgramType.values()[i % ProgramType.values().length], "program" + i);
@Test public void testRunsLimit() { ApplicationSpecification spec = Specifications.from(new AllProgramsApp()); ApplicationId appId = new ApplicationId("testRunsLimit", spec.getName()); store.addApplication(appId, spec); ProgramId mapreduceProgramId = new ApplicationId("testRunsLimit", spec.getName()) .mr(AllProgramsApp.NoOpMR.class.getSimpleName()); ArtifactId artifactId = appId.getNamespaceId().artifact("testArtifact", "1.0").toApiArtifactId(); Assert.assertNotNull(store.getApplication(appId)); long now = System.currentTimeMillis(); ProgramRunId programRunId = mapreduceProgramId.run(RunIds.generate(now - 3000)); setStartAndRunning(programRunId, artifactId); store.setStop(programRunId, now - 100, ProgramController.State.COMPLETED.getRunStatus(), AppFabricTestHelper.createSourceId(++sourceId)); setStartAndRunning(mapreduceProgramId.run(RunIds.generate(now - 2000)), artifactId); // even though there's two separate run records (one that's complete and one that's active), only one should be // returned by the query, because the limit parameter of 1 is being passed in. Map<ProgramRunId, RunRecordMeta> historymap = store.getRuns(mapreduceProgramId, ProgramRunStatus.ALL, 0, Long.MAX_VALUE, 1); Assert.assertEquals(1, historymap.size()); }
getDatasetMeta(applicationId.getNamespaceId().dataset(AllProgramsApp.DATASET_NAME)) .getOwnerPrincipal()); getDatasetMeta(applicationId.getNamespaceId().dataset(AllProgramsApp.DATASET_NAME)) .getOwnerPrincipal());
ArtifactId artifactId = appId1.getNamespaceId().artifact("testArtifact", "1.0").toApiArtifactId();