Remove the controller properties for polling time and overdue time and

use the new tenant configuration management, which handle the tenant
specific polling time.

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
SirWayne
2016-03-14 15:13:51 +01:00
parent 807aaf629c
commit 57c722ea11
3 changed files with 28 additions and 30 deletions

View File

@@ -23,37 +23,21 @@ public class ControllerPollProperties {
* Recommended target polling time for DDI API. Final choice is up to the
* target.
*/
private String pollingTime = "00:05:00";
private String pollingTime;
/**
* Assumed time frame where the target is considered overdue when no DDI
* polling has been registered by the update server.
*/
private String pollingOverdueTime = "00:05:00";
private String pollingOverdueTime;
private String maxPollingTime = "23:59:00";
private String minPollingTime = "00:00:30";
public String getPollingTime() {
return pollingTime;
}
public void setPollingTime(final String pollingTime) {
this.pollingTime = pollingTime;
}
public String getPollingOverdueTime() {
return pollingOverdueTime;
}
public void setPollingOverdueTime(final String pollingOverdue) {
this.pollingOverdueTime = pollingOverdue;
}
public String getMaxPollingTime() {
return maxPollingTime;
}
public void setMaxPollingTime(String maxPollingTime) {
public void setMaxPollingTime(final String maxPollingTime) {
this.maxPollingTime = maxPollingTime;
}
@@ -61,7 +45,7 @@ public class ControllerPollProperties {
return minPollingTime;
}
public void setMinPollingTime(String minPollingTime) {
public void setMinPollingTime(final String minPollingTime) {
this.minPollingTime = minPollingTime;
}

View File

@@ -15,7 +15,6 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import org.eclipse.hawkbit.ControllerPollProperties;
import org.eclipse.hawkbit.artifact.repository.model.DbArtifact;
import org.eclipse.hawkbit.cache.CacheWriteNotify;
import org.eclipse.hawkbit.controller.model.ActionFeedback;
@@ -31,6 +30,7 @@ import org.eclipse.hawkbit.controller.model.Result.FinalResult;
import org.eclipse.hawkbit.repository.ArtifactManagement;
import org.eclipse.hawkbit.repository.ControllerManagement;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.Action.Status;
@@ -43,6 +43,7 @@ import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.rest.resource.helper.RestResourceConversionHelper;
import org.eclipse.hawkbit.security.HawkbitSecurityProperties;
import org.eclipse.hawkbit.tenancy.TenantAware;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
import org.eclipse.hawkbit.util.IpUtil;
import org.hibernate.validator.constraints.NotEmpty;
import org.slf4j.Logger;
@@ -77,8 +78,6 @@ public class RootController {
private static final Logger LOG = LoggerFactory.getLogger(RootController.class);
private static final String GIVEN_ACTION_IS_NOT_ASSIGNED_TO_GIVEN_TARGET = "given action ({}) is not assigned to given target ({}).";
private static final String SP_SERVER_CONFIG_PREFIX = "hawkbit.server.";
@Autowired
private ControllerManagement controllerManagement;
@@ -88,15 +87,15 @@ public class RootController {
@Autowired
private ArtifactManagement artifactManagement;
@Autowired
private ControllerPollProperties controllerPollProperties;
@Autowired
private CacheWriteNotify cacheWriteNotify;
@Autowired
private TenantAware tenantAware;
@Autowired
private TenantConfigurationManagement tenantConfigurationManagement;
@Autowired
private HawkbitSecurityProperties securityProperties;
@@ -154,10 +153,11 @@ public class RootController {
IpUtil.getClientIpFromRequest(request, securityProperties.getClients().getRemoteIpHeader()));
}
return new ResponseEntity<>(
DataConversionHelper.fromTarget(target, controllerManagement.findActionByTargetAndActive(target),
controllerPollProperties.getPollingTime(), tenantAware),
HttpStatus.OK);
final String pollingTime = tenantConfigurationManagement
.getConfigurationValue(TenantConfigurationKey.POLLING_TIME_INTERVAL, String.class).getValue();
return new ResponseEntity<>(DataConversionHelper.fromTarget(target,
controllerManagement.findActionByTargetAndActive(target), pollingTime, tenantAware), HttpStatus.OK);
}
/**

View File

@@ -34,6 +34,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.rest.resource.JsonBuilder;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
import org.eclipse.hawkbit.util.IpUtil;
import org.junit.Test;
import org.springframework.hateoas.MediaTypes;
@@ -133,6 +134,19 @@ public class RootControllerTest extends AbstractIntegrationTestWithMongoDB {
.andExpect(status().isMethodNotAllowed());
}
@Test
@Description("Ensures that tenant polling time, which is save in the db, exists.")
public void testModifyGloablPollingTime() throws Exception {
tenantConfigurationManagement.addOrUpdateConfiguration(TenantConfigurationKey.POLLING_TIME_INTERVAL,
"00:02:00");
mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant()))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
.andExpect(content().contentType(MediaTypes.HAL_JSON))
.andExpect(jsonPath("$config.polling.sleep", equalTo("00:02:00")));
}
@Test
@Description("Ensures that etag check results in not modified response if provided etag by client is identical to entity in repository.")
public void rootRsNotModified() throws Exception {