/** * Delete the metrics for a profile. * * @param profileId the profile to delete metrics for. */ private void deleteMetrics(ProfileId profileId) { long endTs = System.currentTimeMillis() / 1000; Map<String, String> tags = new LinkedHashMap<>(); tags.put(Constants.Metrics.Tag.PROFILE_SCOPE, profileId.getScope().name()); tags.put(Constants.Metrics.Tag.PROFILE, profileId.getProfile()); // if the profile is in user scope, we need to add the namespace info to distinguish the profile if (profileId.getScope().equals(EntityScope.USER)) { tags.put(Constants.Metrics.Tag.NAMESPACE, profileId.getNamespace()); } MetricDeleteQuery deleteQuery = new MetricDeleteQuery(0, endTs, Collections.emptySet(), tags, new ArrayList<>(tags.keySet())); metricStore.delete(deleteQuery); } }
throw new ProfileConflictException( String.format("Profile %s in namespace %s is currently enabled. A profile can " + "only be deleted if it is disabled", profileId.getProfile(), profileId.getNamespace()), profileId);
/** * Delete the metrics for a profile. * * @param profileId the profile to delete metrics for. */ private void deleteMetrics(ProfileId profileId) { long endTs = System.currentTimeMillis() / 1000; Map<String, String> tags = new LinkedHashMap<>(); tags.put(Constants.Metrics.Tag.PROFILE_SCOPE, profileId.getScope().name()); tags.put(Constants.Metrics.Tag.PROFILE, profileId.getProfile()); // if the profile is in user scope, we need to add the namespace info to distinguish the profile if (profileId.getScope().equals(EntityScope.USER)) { tags.put(Constants.Metrics.Tag.NAMESPACE, profileId.getNamespace()); } MetricDeleteQuery deleteQuery = new MetricDeleteQuery(0, endTs, Collections.emptySet(), tags, new ArrayList<>(tags.keySet())); metricStore.delete(deleteQuery); } }
throw new ProfileConflictException( String.format("Profile %s in namespace %s is currently enabled. A profile can " + "only be deleted if it is disabled", profileId.getProfile(), profileId.getNamespace()), profileId);
protected Optional<ProfileStatus> getProfileStatus(ProfileId profileId, int expectedCode) throws Exception { HttpResponse response = doGet(String.format("/v3/namespaces/%s/profiles/%s/status", profileId.getNamespace(), profileId.getProfile())); Assert.assertEquals(expectedCode, response.getResponseCode()); if (expectedCode == HttpResponseStatus.OK.code()) { return Optional.of(GSON.fromJson(response.getResponseBodyAsString(), ProfileStatus.class)); } return Optional.empty(); }
protected Optional<Profile> getProfile(ProfileId profileId, int expectedCode) throws Exception { HttpResponse response = doGet(String.format("/v3/namespaces/%s/profiles/%s", profileId.getNamespace(), profileId.getProfile())); Assert.assertEquals(expectedCode, response.getResponseCode()); if (expectedCode == HttpResponseStatus.OK.code()) { return Optional.of(GSON.fromJson(response.getResponseBodyAsString(), Profile.class)); } return Optional.empty(); }
throw new ProfileConflictException(String.format("Profile %s in namespace %s is disabled. It cannot be " + "assigned to any programs or schedules", profileId.getProfile(), profileId.getNamespace()), profileId);
throw new ProfileConflictException(String.format("Profile %s in namespace %s is disabled. It cannot be " + "assigned to any programs or schedules", profileId.getProfile(), profileId.getNamespace()), profileId);
protected void putProfile(ProfileId profileId, Object profile, int expectedCode) throws Exception { HttpResponse response = doPut(String.format("/v3/namespaces/%s/profiles/%s", profileId.getNamespace(), profileId.getProfile()), GSON.toJson(profile)); Assert.assertEquals(expectedCode, response.getResponseCode()); }
protected void enableProfile(ProfileId profileId, int expectedCode) throws Exception { HttpResponse response = doPost(String.format("/v3/namespaces/%s/profiles/%s/enable", profileId.getNamespace(), profileId.getProfile())); Assert.assertEquals(expectedCode, response.getResponseCode()); }
protected void disableProfile(ProfileId profileId, int expectedCode) throws Exception { HttpResponse response = doPost(String.format("/v3/namespaces/%s/profiles/%s/disable", profileId.getNamespace(), profileId.getProfile())); Assert.assertEquals(expectedCode, response.getResponseCode()); }
protected void deleteProfile(ProfileId profileId, int expectedCode) throws Exception { HttpResponse response = doDelete(String.format("/v3/namespaces/%s/profiles/%s", profileId.getNamespace(), profileId.getProfile())); Assert.assertEquals(expectedCode, response.getResponseCode()); }
/** * Deletes the profile from the profile store * * @param profileId the id of the profile to delete * @throws NotFoundException if the profile is not found * @throws ProfileConflictException if the profile is enabled */ public void deleteProfile(ProfileId profileId) throws NotFoundException, ProfileConflictException { MDSKey rowKey = getProfileRowKey(profileId); Profile value = table.get(rowKey, Profile.class); if (value == null) { throw new NotFoundException(profileId); } if (value.getStatus() == ProfileStatus.ENABLED) { throw new ProfileConflictException( String.format("Profile %s in namespace %s is currently enabled. A profile can " + "only be deleted if it is disabled", profileId.getProfile(), profileId.getNamespace()), profileId); } table.delete(getProfileRowKey(profileId)); }
/** * Deletes the profile from the profile store * * @param profileId the id of the profile to delete * @throws NotFoundException if the profile is not found * @throws ProfileConflictException if the profile is enabled */ public void deleteProfile(ProfileId profileId) throws NotFoundException, ProfileConflictException { MDSKey rowKey = getProfileRowKey(profileId); Profile value = table.get(rowKey, Profile.class); if (value == null) { throw new NotFoundException(profileId); } if (value.getStatus() == ProfileStatus.ENABLED) { throw new ProfileConflictException( String.format("Profile %s in namespace %s is currently enabled. A profile can " + "only be deleted if it is disabled", profileId.getProfile(), profileId.getNamespace()), profileId); } table.delete(getProfileRowKey(profileId)); }
throw new ProfileConflictException(String.format("Profile %s in namespace %s is disabled. It cannot be " + "used to start the program %s", profileId.getProfile(), profileId.getNamespace(), programId.toString()), profileId);
throw new ProfileConflictException(String.format("Profile %s in namespace %s is disabled. It cannot be " + "used to start the program %s", profileId.getProfile(), profileId.getNamespace(), programId.toString()), profileId);
throw new ProfileConflictException(String.format("Profile %s in namespace %s is disabled. It cannot " + "be assigned to schedule %s", profileId.getProfile(), profileId.getNamespace(), schedule.getName()), profileId);
throw new ProfileConflictException(String.format("Profile %s in namespace %s is disabled. It cannot " + "be assigned to schedule %s", profileId.getProfile(), profileId.getNamespace(), schedule.getName()), profileId);