Rollouts can be deleted (#436)
* Management UI Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com> * Repository Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com> * Optimisations and scheduler deleting enabled Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
committed by
Kai Zimmermann
parent
804522f966
commit
5628d625e8
@@ -15,7 +15,6 @@ import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.artifact.repository.model.DbArtifact;
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||
import org.eclipse.hawkbit.repository.exception.ArtifactBinaryNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.exception.ArtifactDeleteFailedException;
|
||||
import org.eclipse.hawkbit.repository.exception.ArtifactUploadFailedException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
@@ -58,7 +57,10 @@ public interface ArtifactManagement {
|
||||
*
|
||||
* @return uploaded {@link Artifact}
|
||||
*
|
||||
* @throw ArtifactUploadFailedException if upload fails
|
||||
* @throws ArtifactUploadFailedException
|
||||
* if upload fails
|
||||
* @throws EntityNotFoundException
|
||||
* if given software module does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
Artifact createArtifact(@NotNull InputStream inputStream, @NotNull Long moduleId, final String filename,
|
||||
@@ -101,16 +103,20 @@ public interface ArtifactManagement {
|
||||
String providedMd5Sum, String providedSha1Sum, boolean overrideExisting, String contentType);
|
||||
|
||||
/**
|
||||
* Garbage collects local artifact binary file if only referenced by given
|
||||
* {@link Artifact} metadata object.
|
||||
* Garbage collects artifact binaries if only referenced by given
|
||||
* {@link SoftwareModule#getId()} or {@link SoftwareModules} that are marged
|
||||
* as deleted.
|
||||
*
|
||||
*
|
||||
* @param artifactId
|
||||
* the related local artifact
|
||||
* @param artifactSha1Hash
|
||||
* no longer needed
|
||||
* @param moduleId
|
||||
* the garbage colelction call is made for
|
||||
*
|
||||
* @return <code>true</code> if an binary was actually garbage collected
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||
boolean clearArtifactBinary(@NotNull Long artifactId);
|
||||
boolean clearArtifactBinary(@NotEmpty String artifactSha1Hash, @NotNull Long moduleId);
|
||||
|
||||
/**
|
||||
* Deletes {@link Artifact} based on given id.
|
||||
@@ -144,6 +150,9 @@ public interface ArtifactManagement {
|
||||
* @param softwareModuleId
|
||||
* software module id.
|
||||
* @return found {@link Artifact}
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if software module with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_CONTROLLER)
|
||||
@@ -179,6 +188,9 @@ public interface ArtifactManagement {
|
||||
* @param swId
|
||||
* software module id
|
||||
* @return Page<Artifact>
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if software module with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<Artifact> findArtifactBySoftwareModule(@NotNull Pageable pageReq, @NotNull Long swId);
|
||||
@@ -190,11 +202,9 @@ public interface ArtifactManagement {
|
||||
* to search for
|
||||
* @return loaded {@link DbArtifact}
|
||||
*
|
||||
* @throws ArtifactBinaryNotFoundException
|
||||
* if file could not be found in store
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DOWNLOAD_ARTIFACT + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.HAS_CONTROLLER_DOWNLOAD)
|
||||
DbArtifact loadArtifactBinary(@NotEmpty String sha1Hash);
|
||||
Optional<DbArtifact> loadArtifactBinary(@NotEmpty String sha1Hash);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Rollout Management properties.
|
||||
*
|
||||
*/
|
||||
@ConfigurationProperties("hawkbit.autoassign")
|
||||
public class AutoAssignProperties {
|
||||
/**
|
||||
* Autoassign scheduler configuration.
|
||||
*/
|
||||
public static class Scheduler {
|
||||
// used by @Scheduled annotation which needs constant
|
||||
public static final String PROP_SCHEDULER_DELAY_PLACEHOLDER = "${hawkbit.autoassign.scheduler.fixedDelay:60000}";
|
||||
|
||||
/**
|
||||
* Schedule where the autoassign scheduler looks necessary state changes
|
||||
* in milliseconds.
|
||||
*/
|
||||
private long fixedDelay = 60000L;
|
||||
|
||||
/**
|
||||
* Set to true to run the autoassign scheduler.
|
||||
*/
|
||||
private boolean enabled = true;
|
||||
|
||||
public long getFixedDelay() {
|
||||
return fixedDelay;
|
||||
}
|
||||
|
||||
public void setFixedDelay(final long fixedDelay) {
|
||||
this.fixedDelay = fixedDelay;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(final boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private final Scheduler scheduler = new Scheduler();
|
||||
|
||||
public Scheduler getScheduler() {
|
||||
return scheduler;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -120,6 +120,9 @@ public interface ControllerManagement {
|
||||
* @param controllerId
|
||||
* identifies the target to retrieve the actions from
|
||||
* @return a list of actions assigned to given target which are active
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if target with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||
Optional<Action> findOldestActiveActionByTarget(@NotNull String controllerId);
|
||||
@@ -157,6 +160,9 @@ public interface ControllerManagement {
|
||||
* of the the {@link SoftwareModule} that should be assigned to
|
||||
* the target
|
||||
* @return last {@link Action} for given combination
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if target with given ID does not exist
|
||||
*
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||
@@ -184,6 +190,9 @@ public interface ControllerManagement {
|
||||
* @return {@code true} if the given target has currently or had ever a
|
||||
* relation to the given artifact through the action history,
|
||||
* otherwise {@code false}
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if target with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||
boolean hasTargetArtifactAssigned(@NotEmpty String controllerId, @NotEmpty String sha1Hash);
|
||||
@@ -203,6 +212,9 @@ public interface ControllerManagement {
|
||||
* @return {@code true} if the given target has currently or had ever a
|
||||
* relation to the given artifact through the action history,
|
||||
* otherwise {@code false}
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if target with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||
boolean hasTargetArtifactAssigned(@NotNull Long targetId, @NotEmpty String sha1Hash);
|
||||
|
||||
@@ -149,6 +149,8 @@ public interface DeploymentManagement {
|
||||
* given {@code fieldNameProvider}
|
||||
* @throws RSQLParameterSyntaxException
|
||||
* if the RSQL syntax is wrong
|
||||
* @throws EntityNotFoundException
|
||||
* if target with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Long countActionsByTarget(@NotNull String rsqlParam, @NotEmpty String controllerId);
|
||||
@@ -171,6 +173,9 @@ public interface DeploymentManagement {
|
||||
* @param controllerId
|
||||
* the target associated to the actions to count
|
||||
* @return the count value of found actions associated to the target
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if target with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Long countActionsByTarget(@NotEmpty String controllerId);
|
||||
@@ -309,6 +314,9 @@ public interface DeploymentManagement {
|
||||
* @param controllerId
|
||||
* the target associated with the actions
|
||||
* @return a list of actions associated with the given target
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if target with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
List<Action> findActiveActionsByTarget(@NotEmpty String controllerId);
|
||||
@@ -320,6 +328,9 @@ public interface DeploymentManagement {
|
||||
* @param controllerId
|
||||
* the target associated with the actions
|
||||
* @return a list of actions associated with the given target
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if target with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
List<Action> findInActiveActionsByTarget(@NotEmpty String controllerId);
|
||||
|
||||
@@ -21,7 +21,6 @@ import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetWithActionStatus;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
@@ -40,6 +39,9 @@ public interface RolloutGroupManagement {
|
||||
* @param pageable
|
||||
* the page request to sort and limit the result
|
||||
* @return a page of found {@link RolloutGroup}s
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* of rollout with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Page<RolloutGroup> findAllRolloutGroupsWithDetailedStatus(@NotNull Long rolloutId, @NotNull Pageable pageable);
|
||||
@@ -52,14 +54,16 @@ public interface RolloutGroupManagement {
|
||||
* distribution set we do not create an action for it but the target is in
|
||||
* the result list of the rollout-group.
|
||||
*
|
||||
* @param pageRequest
|
||||
* @param pageable
|
||||
* the page request to sort and limit the result
|
||||
* @param rolloutGroupId
|
||||
* rollout group
|
||||
* @return {@link TargetWithActionStatus} target with action status
|
||||
* @throws EntityNotFoundException
|
||||
* if rollout group with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
|
||||
Page<TargetWithActionStatus> findAllTargetsWithActionStatus(@NotNull PageRequest pageRequest,
|
||||
Page<TargetWithActionStatus> findAllTargetsWithActionStatus(@NotNull Pageable pageable,
|
||||
@NotNull Long rolloutGroupId);
|
||||
|
||||
/**
|
||||
@@ -165,6 +169,9 @@ public interface RolloutGroupManagement {
|
||||
* @param rolloutGroupId
|
||||
* the rollout group id for the count
|
||||
* @return the target rollout group count
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if rollout group with given ID does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Long countTargetsOfRolloutsGroup(@NotNull Long rolloutGroupId);
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupStatus;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroupConditions;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroupsValidation;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -44,72 +45,37 @@ import org.springframework.util.concurrent.ListenableFuture;
|
||||
public interface RolloutManagement {
|
||||
|
||||
/**
|
||||
* Checking running rollouts. Rollouts which are checked updating the
|
||||
* lastCheck to indicate that the current instance is handling the specific
|
||||
* rollout. This code should run as system-code.
|
||||
*
|
||||
* <pre>
|
||||
* {@code
|
||||
* SystemSecurityContext.runAsSystem(new Callable<Void>() {
|
||||
* public Void call() throws Exception {
|
||||
* //run system-code
|
||||
* }
|
||||
* });
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* This method is intended to be called by a scheduler. And must be running
|
||||
* in an transaction so it's splitted from the scheduler.
|
||||
*
|
||||
* Rollouts which are currently running are investigated, by means the
|
||||
* error- and finish condition of running groups in this rollout are
|
||||
* evaluated.
|
||||
*
|
||||
* @param delayBetweenChecks
|
||||
* the time in milliseconds of the delay between the further and
|
||||
* this check. This check is only applied if the last check is
|
||||
* less than (lastcheck-delay).
|
||||
* Process rollout based on its current {@link Rollout#getStatus()}.
|
||||
*
|
||||
* For {@link RolloutStatus#CREATING} that means creating the
|
||||
* {@link RolloutGroup}s with {@link Target}s and when finished switch to
|
||||
* {@link RolloutStatus#READY}.
|
||||
*
|
||||
* For {@link RolloutStatus#READY} that means switching to
|
||||
* {@link RolloutStatus#STARTING} if the {@link Rollout#getStartAt()} is set
|
||||
* and time of calling this method is beyond this point in time. This auto
|
||||
* start mechanism is optional. Call {@link #startRollout(Long)} otherwise.
|
||||
*
|
||||
* For {@link RolloutStatus#STARTING} that means starting the first
|
||||
* {@link RolloutGroup}s in line and when finished switch to
|
||||
* {@link RolloutStatus#RUNNING}.
|
||||
*
|
||||
* For {@link RolloutStatus#RUNNING} that means checking to activate further
|
||||
* groups based on the defined thresholds. Switched to
|
||||
* {@link RolloutStatus#FINISHED} is all groups are finished.
|
||||
*
|
||||
* For {@link RolloutStatus#DELETING} that means either soft delete in case
|
||||
* rollout was already {@link RolloutStatus#RUNNING} which results in status
|
||||
* change {@link RolloutStatus#DELETED} or hard delete from the persistence
|
||||
* otherwise.
|
||||
*
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
||||
void checkRunningRollouts(long delayBetweenChecks);
|
||||
void handleRollouts();
|
||||
|
||||
/**
|
||||
* Checking Rollouts that are currently being created with asynchronous
|
||||
* assignment of targets to the Rollout Groups.
|
||||
*
|
||||
* @param delayBetweenChecks
|
||||
* the time in milliseconds of the delay between the further and
|
||||
* this check. This check is only applied if the last check is
|
||||
* less than (lastcheck-delay).
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
||||
void checkCreatingRollouts(long delayBetweenChecks);
|
||||
|
||||
/**
|
||||
* Checking Rollouts that are currently being started with asynchronous
|
||||
* creation of actions to the targets of a group.
|
||||
*
|
||||
* @param delayBetweenChecks
|
||||
* the time in milliseconds of the delay between the further and
|
||||
* this check. This check is only applied if the last check is
|
||||
* less than (lastcheck-delay).
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
||||
void checkStartingRollouts(long delayBetweenChecks);
|
||||
|
||||
/**
|
||||
* Checking Rollouts that are currently ready for an auto start.
|
||||
*
|
||||
* @param delayBetweenChecks
|
||||
* the time in milliseconds of the delay between the further and
|
||||
* this check. This check is only applied if the last check is
|
||||
* less than (lastcheck-delay).
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
||||
void checkReadyRollouts(long delayBetweenChecks);
|
||||
|
||||
/**
|
||||
* Counts all {@link Rollout}s in the repository.
|
||||
* Counts all {@link Rollout}s in the repository that are not marked as
|
||||
* deleted.
|
||||
*
|
||||
* @return number of roll outs
|
||||
*/
|
||||
@@ -212,44 +178,30 @@ public interface RolloutManagement {
|
||||
ListenableFuture<RolloutGroupsValidation> validateTargetsInGroups(List<RolloutGroupCreate> groups,
|
||||
String targetFilter, Long createdAt);
|
||||
|
||||
/**
|
||||
* Can be called on a Rollout in {@link RolloutStatus#CREATING} to
|
||||
* automatically fill it with targets.
|
||||
*
|
||||
* Works through all Rollout groups in {@link RolloutGroupStatus#CREATING}
|
||||
* and fills them with remaining targets until the supposed amount of
|
||||
* targets for the group is reached. Targets are added to a group when they
|
||||
* match the overall {@link Rollout#getTargetFilterQuery()} and the
|
||||
* {@link RolloutGroup#getTargetFilterQuery()} and not more than
|
||||
* {@link RolloutGroup#getTargetPercentage()} are assigned to the group.
|
||||
*
|
||||
* @param rollout
|
||||
* the rollout
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
||||
void fillRolloutGroupsWithTargets(@NotNull Long rollout);
|
||||
|
||||
/**
|
||||
* Retrieves all rollouts.
|
||||
*
|
||||
* @param pageable
|
||||
* the page request to sort and limit the result
|
||||
* @param deleted
|
||||
* flag if deleted rollouts should be included
|
||||
* @return a page of found rollouts
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Page<Rollout> findAll(@NotNull Pageable pageable);
|
||||
Page<Rollout> findAll(@NotNull Pageable pageable, boolean deleted);
|
||||
|
||||
/**
|
||||
* Get count of targets in different status in rollout.
|
||||
*
|
||||
* @param pageable
|
||||
* the page request to sort and limit the result
|
||||
* @param deleted
|
||||
* flag if deleted rollouts should be included
|
||||
* @return a list of rollouts with details of targets count for different
|
||||
* statuses
|
||||
*
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Page<Rollout> findAllRolloutsWithDetailedStatus(@NotNull Pageable pageable);
|
||||
Page<Rollout> findAllRolloutsWithDetailedStatus(@NotNull Pageable pageable, boolean deleted);
|
||||
|
||||
/**
|
||||
* Retrieves all rollouts found by the given specification.
|
||||
@@ -258,6 +210,8 @@ public interface RolloutManagement {
|
||||
* the specification to filter rollouts
|
||||
* @param pageable
|
||||
* the page request to sort and limit the result
|
||||
* @param deleted
|
||||
* flag if deleted rollouts should be included
|
||||
* @return a page of found rollouts
|
||||
*
|
||||
* @throws RSQLParameterUnsupportedFieldException
|
||||
@@ -267,7 +221,7 @@ public interface RolloutManagement {
|
||||
* if the RSQL syntax is wrong
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Page<Rollout> findAllByPredicate(@NotNull String rsqlParam, @NotNull Pageable pageable);
|
||||
Page<Rollout> findAllByPredicate(@NotNull String rsqlParam, @NotNull Pageable pageable, boolean deleted);
|
||||
|
||||
/**
|
||||
* Finds rollouts by given text in name or description.
|
||||
@@ -276,11 +230,14 @@ public interface RolloutManagement {
|
||||
* the page request to sort and limit the result
|
||||
* @param searchText
|
||||
* search text which matches name or description of rollout
|
||||
* @param deleted
|
||||
* flag if deleted rollouts should be included
|
||||
* @return the founded rollout or {@code null} if rollout with given ID does
|
||||
* not exists
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Slice<Rollout> findRolloutWithDetailedStatusByFilters(@NotNull Pageable pageable, @NotEmpty String searchText);
|
||||
Slice<Rollout> findRolloutWithDetailedStatusByFilters(@NotNull Pageable pageable, @NotEmpty String searchText,
|
||||
boolean deleted);
|
||||
|
||||
/**
|
||||
* Retrieves a specific rollout by its ID.
|
||||
@@ -309,6 +266,8 @@ public interface RolloutManagement {
|
||||
*
|
||||
* @param rolloutId
|
||||
* rollout id
|
||||
* @param deleted
|
||||
* flag if deleted rollouts should be included
|
||||
* @return rollout details of targets count for different statuses
|
||||
*
|
||||
*
|
||||
@@ -417,4 +376,15 @@ public interface RolloutManagement {
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
||||
Rollout updateRollout(@NotNull RolloutUpdate update);
|
||||
|
||||
/**
|
||||
* Deletes a rollout. A rollout might be deleted asynchronously by
|
||||
* indicating the rollout by {@link RolloutStatus#DELETING}
|
||||
*
|
||||
*
|
||||
* @param rolloutId
|
||||
* the ID of the rollout to be deleted
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
||||
void deleteRollout(long rolloutId);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Rollout Management properties.
|
||||
*
|
||||
*/
|
||||
@ConfigurationProperties("hawkbit.rollout")
|
||||
public class RolloutProperties {
|
||||
// used by @Scheduled annotation which needs constant
|
||||
public static final String PROP_SCHEDULER_DELAY_PLACEHOLDER = "${hawkbit.rollout.scheduler.fixedDelay:30000}";
|
||||
|
||||
// used by @Scheduled annotation which needs constant
|
||||
public static final String PROP_CREATING_SCHEDULER_DELAY_PLACEHOLDER = "${hawkbit.rollout.creatingScheduler.fixedDelay:2000}";
|
||||
|
||||
// used by @Scheduled annotation which needs constant
|
||||
public static final String PROP_STARTING_SCHEDULER_DELAY_PLACEHOLDER = "${hawkbit.rollout.startingScheduler.fixedDelay:2000}";
|
||||
|
||||
// used by @Scheduled annotation which needs constant
|
||||
public static final String PROP_READY_SCHEDULER_DELAY_PLACEHOLDER = "${hawkbit.rollout.readyScheduler.fixedDelay:30000}";
|
||||
|
||||
/**
|
||||
* Rollout scheduler configuration.
|
||||
*/
|
||||
public static class Scheduler {
|
||||
|
||||
/**
|
||||
* Schedule where the rollout scheduler looks necessary state changes in
|
||||
* milliseconds.
|
||||
*/
|
||||
private long fixedDelay;
|
||||
|
||||
private boolean enabled = true;
|
||||
|
||||
public Scheduler(final long fixedDelay) {
|
||||
this.fixedDelay = fixedDelay;
|
||||
}
|
||||
|
||||
public long getFixedDelay() {
|
||||
return fixedDelay;
|
||||
}
|
||||
|
||||
public void setFixedDelay(final long fixedDelay) {
|
||||
this.fixedDelay = fixedDelay;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(final boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
private final Scheduler scheduler = new Scheduler(30000L);
|
||||
|
||||
private final Scheduler creatingScheduler = new Scheduler(2000L);
|
||||
|
||||
private final Scheduler startingScheduler = new Scheduler(2000L);
|
||||
|
||||
private final Scheduler readyScheduler = new Scheduler(30000L);
|
||||
|
||||
public Scheduler getScheduler() {
|
||||
return scheduler;
|
||||
}
|
||||
|
||||
public Scheduler getCreatingScheduler() {
|
||||
return creatingScheduler;
|
||||
}
|
||||
|
||||
public Scheduler getStartingScheduler() {
|
||||
return startingScheduler;
|
||||
}
|
||||
|
||||
public Scheduler getReadyScheduler() {
|
||||
return readyScheduler;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote;
|
||||
|
||||
import org.eclipse.hawkbit.repository.event.remote.RemoteIdEvent;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
|
||||
/**
|
||||
*
|
||||
* Defines the remote event of deleting a {@link Rollout}.
|
||||
*/
|
||||
public class RolloutDeletedEvent extends RemoteIdEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public RolloutDeletedEvent() {
|
||||
// for serialization libs like jackson
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for json serialization.
|
||||
*
|
||||
* @param tenant
|
||||
* the tenant
|
||||
* @param entityId
|
||||
* the entity id
|
||||
* @param entityClass
|
||||
* the entity class
|
||||
* @param applicationId
|
||||
* the origin application id
|
||||
*/
|
||||
public RolloutDeletedEvent(final String tenant, final Long entityId, final String entityClass,
|
||||
final String applicationId) {
|
||||
super(entityId, tenant, entityClass, applicationId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote.entity;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
|
||||
/**
|
||||
* Defines the remote event of creating a new {@link Action}.
|
||||
*/
|
||||
public abstract class AbstractActionEvent extends RemoteEntityEvent<Action> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long rolloutId;
|
||||
private Long rolloutGroupId;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public AbstractActionEvent() {
|
||||
// for serialization libs like jackson
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param action
|
||||
* the created action
|
||||
* @param rolloutId
|
||||
* rollout identifier (optional)
|
||||
* @param rolloutGroupId
|
||||
* rollout group identifier (optional)
|
||||
* @param applicationId
|
||||
* the origin application id
|
||||
*/
|
||||
public AbstractActionEvent(final Action action, final Long rolloutId, final Long rolloutGroupId,
|
||||
final String applicationId) {
|
||||
super(action, applicationId);
|
||||
this.rolloutId = rolloutId;
|
||||
this.rolloutGroupId = rolloutGroupId;
|
||||
}
|
||||
|
||||
public Long getRolloutId() {
|
||||
return rolloutId;
|
||||
}
|
||||
|
||||
public Long getRolloutGroupId() {
|
||||
return rolloutGroupId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote.entity;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||
|
||||
/**
|
||||
* TenantAwareEvent definition which is been published in case a rollout group
|
||||
* has been created for a specific rollout or updated.
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractRolloutGroupEvent extends RemoteEntityEvent<RolloutGroup> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long rolloutId;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public AbstractRolloutGroupEvent() {
|
||||
// for serialization libs like jackson
|
||||
}
|
||||
|
||||
public AbstractRolloutGroupEvent(final RolloutGroup rolloutGroup, final Long rolloutId,
|
||||
final String applicationId) {
|
||||
super(rolloutGroup, applicationId);
|
||||
this.rolloutId = rolloutId;
|
||||
}
|
||||
|
||||
public Long getRolloutId() {
|
||||
return rolloutId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,8 +13,8 @@ import org.eclipse.hawkbit.repository.model.Action;
|
||||
/**
|
||||
* Defines the remote event of creating a new {@link Action}.
|
||||
*/
|
||||
public class ActionCreatedEvent extends RemoteEntityEvent<Action> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public class ActionCreatedEvent extends AbstractActionEvent {
|
||||
private static final long serialVersionUID = 2L;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
@@ -28,11 +28,16 @@ public class ActionCreatedEvent extends RemoteEntityEvent<Action> {
|
||||
*
|
||||
* @param action
|
||||
* the created action
|
||||
* @param rolloutId
|
||||
* rollout identifier (optional)
|
||||
* @param rolloutGroupId
|
||||
* rollout group identifier (optional)
|
||||
* @param applicationId
|
||||
* the origin application id
|
||||
*/
|
||||
public ActionCreatedEvent(final Action action, final String applicationId) {
|
||||
super(action, applicationId);
|
||||
public ActionCreatedEvent(final Action action, final Long rolloutId, final Long rolloutGroupId,
|
||||
final String applicationId) {
|
||||
super(action, rolloutId, rolloutGroupId, applicationId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ import org.eclipse.hawkbit.repository.model.Action;
|
||||
/**
|
||||
* Defines the remote event of updated a {@link Action}.
|
||||
*/
|
||||
public class ActionUpdatedEvent extends RemoteEntityEvent<Action> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public class ActionUpdatedEvent extends AbstractActionEvent {
|
||||
private static final long serialVersionUID = 2L;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
@@ -28,11 +28,16 @@ public class ActionUpdatedEvent extends RemoteEntityEvent<Action> {
|
||||
*
|
||||
* @param action
|
||||
* the updated action
|
||||
* @param rolloutId
|
||||
* rollout identifier (optional)
|
||||
* @param rolloutGroupId
|
||||
* rollout group identifier (optional)
|
||||
* @param applicationId
|
||||
* the origin application id
|
||||
*/
|
||||
public ActionUpdatedEvent(final Action action, final String applicationId) {
|
||||
super(action, applicationId);
|
||||
public ActionUpdatedEvent(final Action action, final Long rolloutId, final Long rolloutGroupId,
|
||||
final String applicationId) {
|
||||
super(action, rolloutId, rolloutGroupId, applicationId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,12 +15,9 @@ import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||
* has been created for a specific rollout.
|
||||
*
|
||||
*/
|
||||
public class RolloutGroupCreatedEvent extends RemoteEntityEvent<RolloutGroup> {
|
||||
|
||||
public class RolloutGroupCreatedEvent extends AbstractRolloutGroupEvent {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long rolloutId;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
@@ -33,16 +30,12 @@ public class RolloutGroupCreatedEvent extends RemoteEntityEvent<RolloutGroup> {
|
||||
*
|
||||
* @param rolloutGroup
|
||||
* the updated rolloutGroup
|
||||
* @param rolloutId
|
||||
* of the related rollout
|
||||
* @param applicationId
|
||||
* the origin application id
|
||||
*/
|
||||
public RolloutGroupCreatedEvent(final RolloutGroup rolloutGroup, final String applicationId) {
|
||||
super(rolloutGroup, applicationId);
|
||||
this.rolloutId = rolloutGroup.getRollout().getId();
|
||||
public RolloutGroupCreatedEvent(final RolloutGroup rolloutGroup, final Long rolloutId, final String applicationId) {
|
||||
super(rolloutGroup, rolloutId, applicationId);
|
||||
}
|
||||
|
||||
public Long getRolloutId() {
|
||||
return rolloutId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,9 +13,9 @@ import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||
/**
|
||||
* Defines the remote event of updated a {@link RolloutGroup}.
|
||||
*/
|
||||
public class RolloutGroupUpdatedEvent extends RemoteEntityEvent<RolloutGroup> {
|
||||
public class RolloutGroupUpdatedEvent extends AbstractRolloutGroupEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 2L;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
@@ -29,11 +29,13 @@ public class RolloutGroupUpdatedEvent extends RemoteEntityEvent<RolloutGroup> {
|
||||
*
|
||||
* @param rolloutGroup
|
||||
* the updated rolloutGroup
|
||||
* @param rolloutId
|
||||
* of the related rollout
|
||||
* @param applicationId
|
||||
* the origin application id
|
||||
*/
|
||||
public RolloutGroupUpdatedEvent(final RolloutGroup rolloutGroup, final String applicationId) {
|
||||
super(rolloutGroup, applicationId);
|
||||
public RolloutGroupUpdatedEvent(final RolloutGroup rolloutGroup, final Long rolloutId, final String applicationId) {
|
||||
super(rolloutGroup, rolloutId, applicationId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,9 +18,6 @@ import org.eclipse.hawkbit.exception.SpServerError;
|
||||
*/
|
||||
public final class ArtifactUploadFailedException extends AbstractServerRtException {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,6 +19,10 @@ import org.springframework.hateoas.Identifiable;
|
||||
*/
|
||||
public interface BaseEntity extends Serializable, Identifiable<Long> {
|
||||
|
||||
static Long getIdOrNull(final BaseEntity entity) {
|
||||
return entity == null ? null : entity.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return time in {@link TimeUnit#MILLISECONDS} when the {@link BaseEntity}
|
||||
* was created.
|
||||
|
||||
@@ -26,6 +26,12 @@ import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus.Status;
|
||||
*/
|
||||
public interface Rollout extends NamedEntity {
|
||||
|
||||
/**
|
||||
* @return <code>true</code> if the rollout is deleted and only kept for
|
||||
* history purposes.
|
||||
*/
|
||||
boolean isDeleted();
|
||||
|
||||
/**
|
||||
* @return {@link DistributionSet} that is rolled out
|
||||
*/
|
||||
@@ -60,11 +66,11 @@ public interface Rollout extends NamedEntity {
|
||||
long getForcedTime();
|
||||
|
||||
/**
|
||||
* @return Timestamp when the rollout should be started automatically. Can be null.
|
||||
* @return Timestamp when the rollout should be started automatically. Can
|
||||
* be null.
|
||||
*/
|
||||
Long getStartAt();
|
||||
|
||||
|
||||
/**
|
||||
* @return number of {@link Target}s in this rollout.
|
||||
*/
|
||||
@@ -123,9 +129,22 @@ public interface Rollout extends NamedEntity {
|
||||
*/
|
||||
FINISHED,
|
||||
|
||||
/**
|
||||
* Rollout is under deletion.
|
||||
*/
|
||||
DELETING,
|
||||
|
||||
/**
|
||||
* Rollout has been deleted. This state is only set in case of a
|
||||
* soft-deletion of the rollout which keeps references, in case of an
|
||||
* hard-deletion of a rollout the rollout-entry itself is deleted.
|
||||
*/
|
||||
DELETED,
|
||||
|
||||
/**
|
||||
* Rollout could not be created due to errors, might be a database
|
||||
* problem during asynchronous creating.
|
||||
*
|
||||
* @deprecated legacy status is not used anymore
|
||||
*/
|
||||
@Deprecated
|
||||
@@ -134,6 +153,7 @@ public interface Rollout extends NamedEntity {
|
||||
/**
|
||||
* Rollout could not be started due to errors, might be database problem
|
||||
* during asynchronous starting.
|
||||
*
|
||||
* @deprecated legacy status is not used anymore
|
||||
*/
|
||||
@Deprecated
|
||||
|
||||
Reference in New Issue
Block a user