use of io.cdap.cdap.internal.app.store.profile.ProfileStore in project cdap by caskdata.
the class PreferencesService method setConfig.
/**
* Validate the profile status is enabled and set the preferences in same transaction
*/
private void setConfig(EntityId entityId, Map<String, String> propertyMap) throws NotFoundException, ProfileConflictException, BadRequestException {
TransactionRunners.run(transactionRunner, context -> {
ProfileStore profileStore = ProfileStore.get(context);
PreferencesTable preferencesTable = new PreferencesTable(context);
setConfig(profileStore, preferencesTable, entityId, propertyMap);
}, NotFoundException.class, ProfileConflictException.class, BadRequestException.class);
}
use of io.cdap.cdap.internal.app.store.profile.ProfileStore in project cdap by caskdata.
the class ProfileService method deleteAllProfiles.
/**
* Delete all profiles in a given namespace. Deleting all profiles in SYSTEM namespace is not allowed.
*
* @param namespaceId the id of the namespace
*/
public void deleteAllProfiles(NamespaceId namespaceId) throws MethodNotAllowedException, NotFoundException, ProfileConflictException {
if (namespaceId.equals(NamespaceId.SYSTEM)) {
throw new MethodNotAllowedException("Deleting all system profiles is not allowed.");
}
List<ProfileId> deleted = new ArrayList<>();
TransactionRunners.run(transactionRunner, context -> {
ProfileStore profileStore = ProfileStore.get(context);
AppMetadataStore appMetadataStore = AppMetadataStore.create(context);
List<Profile> profiles = profileStore.getProfiles(namespaceId, false);
for (Profile profile : profiles) {
ProfileId profileId = namespaceId.profile(profile.getName());
deleteProfile(profileStore, appMetadataStore, profileId, profile);
deleted.add(profileId);
}
}, ProfileConflictException.class, NotFoundException.class);
// delete the metrics
for (ProfileId profileId : deleted) {
deleteMetrics(profileId);
}
}
use of io.cdap.cdap.internal.app.store.profile.ProfileStore in project cdap by caskdata.
the class CoreSchedulerService method execute.
@SuppressWarnings("UnusedReturnValue")
private <V, T extends Exception> V execute(StoreQueueAndProfileTxRunnable<V, ? extends Exception> runnable, Class<? extends T> tClass) throws T {
return TransactionRunners.run(transactionRunner, context -> {
ProgramScheduleStoreDataset store = Schedulers.getScheduleStore(context);
ProfileStore profileStore = ProfileStore.get(context);
JobQueueTable queue = JobQueueTable.getJobQueue(context, cConf);
return runnable.run(store, queue, profileStore);
}, tClass);
}
use of io.cdap.cdap.internal.app.store.profile.ProfileStore in project cdap by caskdata.
the class PreferencesService method addProperties.
/**
* Set instance level preferences if they are not already set. Only adds the properties that don't already exist.
*
* @param properties the preferences to add
* @return the preference keys that were added
*/
public Set<String> addProperties(Map<String, String> properties) throws NotFoundException, ProfileConflictException, BadRequestException {
InstanceId instanceId = new InstanceId("");
Set<String> added = new HashSet<>();
TransactionRunners.run(transactionRunner, context -> {
ProfileStore profileStore = ProfileStore.get(context);
PreferencesTable preferencesTable = new PreferencesTable(context);
Map<String, String> oldProperties = preferencesTable.getPreferences(instanceId).getProperties();
Map<String, String> newProperties = new HashMap<>(properties);
added.addAll(Sets.difference(newProperties.keySet(), oldProperties.keySet()));
newProperties.putAll(oldProperties);
setConfig(profileStore, preferencesTable, instanceId, newProperties);
}, NotFoundException.class, ProfileConflictException.class, BadRequestException.class);
return added;
}
use of io.cdap.cdap.internal.app.store.profile.ProfileStore in project cdap by caskdata.
the class CoreSchedulerService method execute.
@SuppressWarnings({ "UnusedReturnValue", "SameParameterValue" })
private <V, T extends Exception> V execute(StoreAndProfileTxRunnable<V, ? extends Exception> runnable, Class<? extends T> tClass) throws T {
return TransactionRunners.run(transactionRunner, context -> {
ProgramScheduleStoreDataset store = Schedulers.getScheduleStore(context);
ProfileStore profileStore = ProfileStore.get(context);
return runnable.run(store, profileStore);
}, tClass);
}
Aggregations