/** * Disable the profile. After the profile is disabled, any program/schedule cannot be associated with this profile. * * @param profileId the id of the profile to disable * @throws NotFoundException if the profile is not found * @throws ProfileConflictException if the profile is already disabled * @throws MethodNotAllowedException if trying to disable the native profile */ public void disableProfile(ProfileId profileId) throws NotFoundException, ProfileConflictException, MethodNotAllowedException { if (profileId.equals(ProfileId.NATIVE)) { throw new MethodNotAllowedException(String.format("Cannot change status for Profile Native %s, " + "it should always be ENABLED", profileId.getScopedName())); } Transactionals.execute(transactional, context -> { getProfileDataset(context).disableProfile(profileId); }, NotFoundException.class, ProfileConflictException.class); }
/** * Disable the profile. After the profile is disabled, any program/schedule cannot be associated with this profile. * * @param profileId the id of the profile to disable * @throws NotFoundException if the profile is not found * @throws ProfileConflictException if the profile is already disabled * @throws MethodNotAllowedException if trying to disable the native profile */ public void disableProfile(ProfileId profileId) throws NotFoundException, ProfileConflictException, MethodNotAllowedException { if (profileId.equals(ProfileId.NATIVE)) { throw new MethodNotAllowedException(String.format("Cannot change status for Profile Native %s, " + "it should always be ENABLED", profileId.getScopedName())); } Transactionals.execute(transactional, context -> { getProfileDataset(context).disableProfile(profileId); }, NotFoundException.class, ProfileConflictException.class); }
/** * Save the profile to the profile store. By default the profile status will be enabled. * * @param profileId the id of the profile to save * @param profile the information of the profile * @throws MethodNotAllowedException if trying to update the Native profile */ public void saveProfile(ProfileId profileId, Profile profile) throws MethodNotAllowedException { Transactionals.execute(transactional, context -> { ProfileDataset dataset = getProfileDataset(context); if (profileId.equals(ProfileId.NATIVE)) { try { dataset.getProfile(profileId); throw new MethodNotAllowedException(String.format("Profile Native %s already exists. It cannot be updated", profileId.getScopedName())); } catch (NotFoundException e) { // if native profile is not found, we can add it to the dataset } } dataset.saveProfile(profileId, profile); }, MethodNotAllowedException.class); }
/** * Save the profile to the profile store. By default the profile status will be enabled. * * @param profileId the id of the profile to save * @param profile the information of the profile * @throws MethodNotAllowedException if trying to update the Native profile */ public void saveProfile(ProfileId profileId, Profile profile) throws MethodNotAllowedException { Transactionals.execute(transactional, context -> { ProfileDataset dataset = getProfileDataset(context); if (profileId.equals(ProfileId.NATIVE)) { try { dataset.getProfile(profileId); throw new MethodNotAllowedException(String.format("Profile Native %s already exists. It cannot be updated", profileId.getScopedName())); } catch (NotFoundException e) { // if native profile is not found, we can add it to the dataset } } dataset.saveProfile(profileId, profile); }, MethodNotAllowedException.class); }
/** * Deletes the profile from the profile store. Native profile cannot be deleted. * Other profile deletion must satisfy the following: * 1. Profile must exist and must be DISABLED * 2. Profile must not be assigned to any entities. Profiles can be assigned to an entity by setting a preference * or a schedule property. * 3. There must be no active program runs using this profile * * @param profileId the id of the profile to delete * @throws NotFoundException if the profile is not found * @throws ProfileConflictException if the profile is enabled * @throws MethodNotAllowedException if trying to delete the Native profile */ public void deleteProfile(ProfileId profileId) throws MethodNotAllowedException, NotFoundException, ProfileConflictException { if (profileId.equals(ProfileId.NATIVE)) { throw new MethodNotAllowedException(String.format("Profile Native %s cannot be deleted.", profileId.getScopedName())); } Transactionals.execute(transactional, context -> { ProfileDataset profileDataset = getProfileDataset(context); Profile profile = profileDataset.getProfile(profileId); AppMetadataStore appMetadataStore = AppMetadataStore.create(cConf, context, datasetFramework); deleteProfile(profileDataset, appMetadataStore, profileId, profile); }, NotFoundException.class, ProfileConflictException.class); deleteMetrics(profileId); }
/** * Deletes the profile from the profile store. Native profile cannot be deleted. * Other profile deletion must satisfy the following: * 1. Profile must exist and must be DISABLED * 2. Profile must not be assigned to any entities. Profiles can be assigned to an entity by setting a preference * or a schedule property. * 3. There must be no active program runs using this profile * * @param profileId the id of the profile to delete * @throws NotFoundException if the profile is not found * @throws ProfileConflictException if the profile is enabled * @throws MethodNotAllowedException if trying to delete the Native profile */ public void deleteProfile(ProfileId profileId) throws MethodNotAllowedException, NotFoundException, ProfileConflictException { if (profileId.equals(ProfileId.NATIVE)) { throw new MethodNotAllowedException(String.format("Profile Native %s cannot be deleted.", profileId.getScopedName())); } Transactionals.execute(transactional, context -> { ProfileDataset profileDataset = getProfileDataset(context); Profile profile = profileDataset.getProfile(profileId); AppMetadataStore appMetadataStore = AppMetadataStore.create(cConf, context, datasetFramework); deleteProfile(profileDataset, appMetadataStore, profileId, profile); }, NotFoundException.class, ProfileConflictException.class); deleteMetrics(profileId); }
(ProfileId.NATIVE.equals(profileId) ? ClusterMode.ON_PREMISE : ClusterMode.ISOLATED).name()); ProgramSpecification programSpecification = getProgramSpecificationWithoutAuthz(programId); if (programSpecification == null) {
(ProfileId.NATIVE.equals(profileId) ? ClusterMode.ON_PREMISE : ClusterMode.ISOLATED).name()); ProgramSpecification programSpecification = getProgramSpecificationWithoutAuthz(programId); if (programSpecification == null) {