protected DistributionSetAssignmentResult assignDistributionSetWithMaintenanceWindowTimeForced(final long dsID, final String controllerId, final String maintenanceWindowSchedule, final String maintenanceWindowDuration, final String maintenanceWindowTimeZone) { return deploymentManagement.assignDistributionSet(dsID, Arrays.asList(new TargetWithActionType(controllerId, ActionType.TIMEFORCED, System.currentTimeMillis(), maintenanceWindowSchedule, maintenanceWindowDuration, maintenanceWindowTimeZone))); }
/** * @return {@link TargetWithActionType} with default settings */ default TargetWithActionType getTargetWithActionType() { return new TargetWithActionType(getControllerId()); }
protected DistributionSetAssignmentResult assignDistributionSetWithMaintenanceWindowTimeForced(final long dsID, final String controllerId, final String maintenanceWindowSchedule, final String maintenanceWindowDuration, final String maintenanceWindowTimeZone) { return deploymentManagement.assignDistributionSet(dsID, Arrays.asList(new TargetWithActionType(controllerId, ActionType.TIMEFORCED, System.currentTimeMillis(), maintenanceWindowSchedule, maintenanceWindowDuration, maintenanceWindowTimeZone))); }
protected DistributionSetAssignmentResult assignDistributionSet(final long dsID, final String controllerId) { return deploymentManagement.assignDistributionSet(dsID, Arrays.asList( new TargetWithActionType(controllerId, ActionType.FORCED, RepositoryModelConstants.NO_FORCE_TIME))); }
protected DistributionSetAssignmentResult assignDistributionSet(final long dsID, final String controllerId) { return deploymentManagement.assignDistributionSet(dsID, Arrays.asList( new TargetWithActionType(controllerId, ActionType.FORCED, RepositoryModelConstants.NO_FORCE_TIME))); }
@Override @Transactional(isolation = Isolation.READ_COMMITTED) @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) public DistributionSetAssignmentResult assignDistributionSet(final long dsID, final ActionType actionType, final long forcedTimestamp, final Collection<String> controllerIDs) { return assignDistributionSetToTargets(dsID, controllerIDs.stream() .map(controllerId -> new TargetWithActionType(controllerId, actionType, forcedTimestamp)) .collect(Collectors.toList()), null, onlineDsAssignmentStrategy); }
@Override @Transactional(isolation = Isolation.READ_COMMITTED) @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) public DistributionSetAssignmentResult assignDistributionSet(final long dsID, final ActionType actionType, final long forcedTimestamp, final Collection<String> controllerIDs) { return assignDistributionSetToTargets(dsID, controllerIDs.stream() .map(controllerId -> new TargetWithActionType(controllerId, actionType, forcedTimestamp)) .collect(Collectors.toList()), null, onlineDsAssignmentStrategy); }
@Override @Transactional(isolation = Isolation.READ_COMMITTED) @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) public DistributionSetAssignmentResult offlineAssignedDistributionSet(final Long dsID, final Collection<String> controllerIDs) { return assignDistributionSetToTargets(dsID, controllerIDs.stream() .map(controllerId -> new TargetWithActionType(controllerId, ActionType.FORCED, -1)) .collect(Collectors.toList()), null, offlineDsAssignmentStrategy); }
@Override @Transactional(isolation = Isolation.READ_COMMITTED) @Retryable(include = { ConcurrencyFailureException.class }, maxAttempts = Constants.TX_RT_MAX, backoff = @Backoff(delay = Constants.TX_RT_DELAY)) public DistributionSetAssignmentResult offlineAssignedDistributionSet(final Long dsID, final Collection<String> controllerIDs) { return assignDistributionSetToTargets(dsID, controllerIDs.stream() .map(controllerId -> new TargetWithActionType(controllerId, ActionType.FORCED, -1)) .collect(Collectors.toList()), null, offlineDsAssignmentStrategy); }
protected DistributionSetAssignmentResult assignDistributionSetTimeForced(final DistributionSet pset, final Target target) { return deploymentManagement.assignDistributionSet(pset.getId(), Arrays.asList( new TargetWithActionType(target.getControllerId(), ActionType.TIMEFORCED, System.currentTimeMillis()))); }
final String maintenanceWindowTimeZone) { return deploymentManagement.assignDistributionSet(dsID, Arrays.asList(new TargetWithActionType(controllerId, ActionType.FORCED, RepositoryModelConstants.NO_FORCE_TIME, maintenanceWindowSchedule, maintenanceWindowDuration, maintenanceWindowTimeZone)));
protected DistributionSetAssignmentResult assignDistributionSetTimeForced(final DistributionSet pset, final Target target) { return deploymentManagement.assignDistributionSet(pset.getId(), Arrays.asList( new TargetWithActionType(target.getControllerId(), ActionType.TIMEFORCED, System.currentTimeMillis()))); }
final String maintenanceWindowTimeZone) { return deploymentManagement.assignDistributionSet(dsID, Arrays.asList(new TargetWithActionType(controllerId, ActionType.FORCED, RepositoryModelConstants.NO_FORCE_TIME, maintenanceWindowSchedule, maintenanceWindowDuration, maintenanceWindowTimeZone)));
/** * Gets all matching targets with the designated action from the target * management * * @param targetFilterQuery * the query the targets have to match * @param dsId * dsId the targets are not allowed to have in their action * history * @param count * maximum amount of targets to retrieve * @return list of targets with action type */ private List<TargetWithActionType> getTargetsWithActionType(final String targetFilterQuery, final Long dsId, final int count) { final Page<Target> targets = targetManagement .findByTargetFilterQueryAndNonDS(PageRequest.of(0, count), dsId, targetFilterQuery); return targets.getContent().stream().map(t -> new TargetWithActionType(t.getControllerId(), Action.ActionType.FORCED, RepositoryModelConstants.NO_FORCE_TIME)).collect(Collectors.toList()); }
/** * Gets all matching targets with the designated action from the target * management * * @param targetFilterQuery * the query the targets have to match * @param dsId * dsId the targets are not allowed to have in their action * history * @param count * maximum amount of targets to retrieve * @return list of targets with action type */ private List<TargetWithActionType> getTargetsWithActionType(final String targetFilterQuery, final Long dsId, final int count) { final Page<Target> targets = targetManagement .findByTargetFilterQueryAndNonDS(new PageRequest(0, count), dsId, targetFilterQuery); return targets.getContent().stream().map(t -> new TargetWithActionType(t.getControllerId(), Action.ActionType.FORCED, RepositoryModelConstants.NO_FORCE_TIME)).collect(Collectors.toList()); }
@Override public ResponseEntity<MgmtTargetAssignmentResponseBody> createAssignedTarget( @PathVariable("distributionSetId") final Long distributionSetId, @RequestBody final List<MgmtTargetAssignmentRequestBody> assignments, @RequestParam(value = "offline", required = false) final boolean offline) { if (offline) { return ResponseEntity.ok(MgmtDistributionSetMapper .toResponse(this.deployManagament.offlineAssignedDistributionSet(distributionSetId, assignments .stream().map(MgmtTargetAssignmentRequestBody::getId).collect(Collectors.toList())))); } final DistributionSetAssignmentResult assignDistributionSet = this.deployManagament .assignDistributionSet(distributionSetId, assignments.stream().map(t -> { final MgmtMaintenanceWindowRequestBody maintenanceWindow = t.getMaintenanceWindow(); if (maintenanceWindow == null) { return new TargetWithActionType(t.getId(), MgmtRestModelMapper.convertActionType(t.getType()), t.getForcetime()); } final String cronSchedule = maintenanceWindow.getSchedule(); final String duration = maintenanceWindow.getDuration(); final String timezone = maintenanceWindow.getTimezone(); MaintenanceScheduleHelper.validateMaintenanceSchedule(cronSchedule, duration, timezone); return new TargetWithActionType(t.getId(), MgmtRestModelMapper.convertActionType(t.getType()), t.getForcetime(), cronSchedule, duration, timezone); }).collect(Collectors.toList())); return ResponseEntity.ok(MgmtDistributionSetMapper.toResponse(assignDistributionSet)); }
@Override public ResponseEntity<MgmtTargetAssignmentResponseBody> postAssignedDistributionSet( @PathVariable("targetId") final String targetId, @RequestBody final MgmtDistributionSetAssignment dsId, @RequestParam(value = "offline", required = false) final boolean offline) { if (offline) { return ResponseEntity.ok(MgmtDistributionSetMapper.toResponse( deploymentManagement.offlineAssignedDistributionSet(dsId.getId(), Arrays.asList(targetId)))); } findTargetWithExceptionIfNotFound(targetId); final MgmtMaintenanceWindowRequestBody maintenanceWindow = dsId.getMaintenanceWindow(); if (maintenanceWindow == null) { return ResponseEntity.ok(MgmtDistributionSetMapper.toResponse(this.deploymentManagement .assignDistributionSet(dsId.getId(), Arrays.asList(new TargetWithActionType(targetId, MgmtRestModelMapper.convertActionType(dsId.getType()), dsId.getForcetime()))))); } final String cronSchedule = maintenanceWindow.getSchedule(); final String duration = maintenanceWindow.getDuration(); final String timezone = maintenanceWindow.getTimezone(); MaintenanceScheduleHelper.validateMaintenanceSchedule(cronSchedule, duration, timezone); return ResponseEntity .ok(MgmtDistributionSetMapper.toResponse(this.deploymentManagement.assignDistributionSet(dsId.getId(), Arrays.asList(new TargetWithActionType(targetId, MgmtRestModelMapper.convertActionType(dsId.getType()), dsId.getForcetime(), cronSchedule, duration, timezone))))); }
.assignDistributionSet(mapEntry.getKey(), tempIdList.stream().map(t -> maintenanceWindowLayout.isEnabled() ? new TargetWithActionType(t.getControllerId(), actionType, forcedTimeStamp, maintenanceSchedule, maintenanceDuration, maintenanceTimeZone) : new TargetWithActionType(t.getControllerId(), actionType, forcedTimeStamp)) .collect(Collectors.toList()));
.assignDistributionSet(mapEntry.getKey(), tempIdList.stream().map(t -> maintenanceWindowLayout.isEnabled() ? new TargetWithActionType(t.getControllerId(), actionType, forcedTimeStamp, maintenanceSchedule, maintenanceDuration, maintenanceTimeZone) : new TargetWithActionType(t.getControllerId(), actionType, forcedTimeStamp)) .collect(Collectors.toList()));
.assignDistributionSet(mapEntry.getKey(), tempIdList.stream().map(t -> maintenanceWindowLayout.isEnabled() ? new TargetWithActionType(t.getControllerId(), actionType, forcedTimeStamp, maintenanceSchedule, maintenanceDuration, maintenanceTimeZone) : new TargetWithActionType(t.getControllerId(), actionType, forcedTimeStamp)) .collect(Collectors.toList()));