@Override public void run(DatasetContext context) throws Exception { String desc = Optional.fromNullable(description).orNull(); getMetadataStore(context).write(getKey(streamId), createStreamSpec(streamId, desc)); } }, Exception.class);
/** * Mark the CDAP instance as bootstrapped. */ public void bootstrapped() { Transactionals.execute(transactional, dsContext -> { MetadataStoreDataset ds = get(dsContext, datasetFramework); ds.write(KEY, Boolean.TRUE); }); }
/** * Mark the CDAP instance as bootstrapped. */ public void bootstrapped() { Transactionals.execute(transactional, dsContext -> { MetadataStoreDataset ds = get(dsContext, datasetFramework); ds.write(KEY, Boolean.TRUE); }); }
public void putTaskInfo(ProvisioningTaskInfo taskInfo) { ProvisioningTaskKey key = new ProvisioningTaskKey(taskInfo.getProgramRunId(), taskInfo.getProvisioningOp().getType()); table.write(getRowKey(key), taskInfo); }
public void putTaskInfo(ProvisioningTaskInfo taskInfo) { ProvisioningTaskKey key = new ProvisioningTaskKey(taskInfo.getProgramRunId(), taskInfo.getProvisioningOp().getType()); table.write(getRowKey(key), taskInfo); }
/** * Add an assignment to the profile. Assignment can only be added if the profile is ENABLED * * @param profileId the profile id * @param entityId the entity to add to the assgiment */ public void addProfileAssignment(ProfileId profileId, EntityId entityId) throws ProfileConflictException, NotFoundException { Profile profile = table.get(getProfileRowKey(profileId), Profile.class); if (profile == null) { throw new NotFoundException(profileId); } if (profile.getStatus() == ProfileStatus.DISABLED) { throw new ProfileConflictException( String.format("Profile %s is DISABLED. No entity can be assigned to it.", profileId.getProfile()), profileId); } table.write(getEntityIndexRowKey(profileId, entityId), entityId); }
/** * Add an assignment to the profile. Assignment can only be added if the profile is ENABLED * * @param profileId the profile id * @param entityId the entity to add to the assgiment */ public void addProfileAssignment(ProfileId profileId, EntityId entityId) throws ProfileConflictException, NotFoundException { Profile profile = table.get(getProfileRowKey(profileId), Profile.class); if (profile == null) { throw new NotFoundException(profileId); } if (profile.getStatus() == ProfileStatus.DISABLED) { throw new ProfileConflictException( String.format("Profile %s is DISABLED. No entity can be assigned to it.", profileId.getProfile()), profileId); } table.write(getEntityIndexRowKey(profileId, entityId), entityId); }
/** * Add a profile if it does not exist in the store * * @param profileId the id of the profile to add * @param profile the information of the profile */ public void createIfNotExists(ProfileId profileId, Profile profile) { MDSKey rowKey = getProfileRowKey(profileId); Profile oldProfile = table.get(rowKey, Profile.class); if (oldProfile != null) { return; } table.write(rowKey, new Profile(profile.getName(), profile.getLabel(), profile.getDescription(), profile.getScope(), ProfileStatus.ENABLED, profile.getProvisioner())); }
/** * Add a profile if it does not exist in the store * * @param profileId the id of the profile to add * @param profile the information of the profile */ public void createIfNotExists(ProfileId profileId, Profile profile) { MDSKey rowKey = getProfileRowKey(profileId); Profile oldProfile = table.get(rowKey, Profile.class); if (oldProfile != null) { return; } table.write(rowKey, new Profile(profile.getName(), profile.getLabel(), profile.getDescription(), profile.getScope(), ProfileStatus.ENABLED, profile.getProvisioner())); }
private void changeProfileStatus(ProfileId profileId, ProfileStatus expectedStatus) throws NotFoundException, ProfileConflictException { MDSKey rowKey = getProfileRowKey(profileId); Profile oldProfile = table.get(rowKey, Profile.class); if (oldProfile == null) { throw new NotFoundException(profileId); } if (oldProfile.getStatus() == expectedStatus) { throw new ProfileConflictException( String.format("Profile %s already %s", profileId.getProfile(), expectedStatus.toString()), profileId); } table.write(rowKey, new Profile(oldProfile.getName(), oldProfile.getLabel(), oldProfile.getDescription(), oldProfile.getScope(), expectedStatus, oldProfile.getProvisioner(), oldProfile.getCreatedTsSeconds())); }
private void changeProfileStatus(ProfileId profileId, ProfileStatus expectedStatus) throws NotFoundException, ProfileConflictException { MDSKey rowKey = getProfileRowKey(profileId); Profile oldProfile = table.get(rowKey, Profile.class); if (oldProfile == null) { throw new NotFoundException(profileId); } if (oldProfile.getStatus() == expectedStatus) { throw new ProfileConflictException( String.format("Profile %s already %s", profileId.getProfile(), expectedStatus.toString()), profileId); } table.write(rowKey, new Profile(oldProfile.getName(), oldProfile.getLabel(), oldProfile.getDescription(), oldProfile.getScope(), expectedStatus, oldProfile.getProvisioner(), oldProfile.getCreatedTsSeconds())); }
/** * 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 */ public void saveProfile(ProfileId profileId, Profile profile) { MDSKey rowKey = getProfileRowKey(profileId); Profile oldProfile = table.get(rowKey, Profile.class); table.write( rowKey, new Profile(profile.getName(), profile.getLabel(), profile.getDescription(), profile.getScope(), oldProfile == null ? ProfileStatus.ENABLED : oldProfile.getStatus(), profile.getProvisioner(), oldProfile == null ? profile.getCreatedTsSeconds() : oldProfile.getCreatedTsSeconds())); }
/** * 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 */ public void saveProfile(ProfileId profileId, Profile profile) { MDSKey rowKey = getProfileRowKey(profileId); Profile oldProfile = table.get(rowKey, Profile.class); table.write( rowKey, new Profile(profile.getName(), profile.getLabel(), profile.getDescription(), profile.getScope(), oldProfile == null ? ProfileStatus.ENABLED : oldProfile.getStatus(), profile.getProvisioner(), oldProfile == null ? profile.getCreatedTsSeconds() : oldProfile.getCreatedTsSeconds())); }
for (int i = 0; i < 5; ++i) { MDSKey mdsKey = new MDSKey.Builder().add(i).build(); metadataStoreDataset.write(mdsKey, i); expectedMap.put(mdsKey, i); if ((i % 2) == 0) {
for (int i = 0; i < 25; ++i) { MDSKey mdsKey = new MDSKey.Builder().add(i).build(); metadataStoreDataset.write(mdsKey, i); expected.add(i);