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:
@@ -23,37 +23,21 @@ public class ControllerPollProperties {
|
|||||||
* Recommended target polling time for DDI API. Final choice is up to the
|
* Recommended target polling time for DDI API. Final choice is up to the
|
||||||
* target.
|
* target.
|
||||||
*/
|
*/
|
||||||
private String pollingTime = "00:05:00";
|
private String pollingTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assumed time frame where the target is considered overdue when no DDI
|
* Assumed time frame where the target is considered overdue when no DDI
|
||||||
* polling has been registered by the update server.
|
* 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 maxPollingTime = "23:59:00";
|
||||||
private String minPollingTime = "00:00:30";
|
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() {
|
public String getMaxPollingTime() {
|
||||||
return maxPollingTime;
|
return maxPollingTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxPollingTime(String maxPollingTime) {
|
public void setMaxPollingTime(final String maxPollingTime) {
|
||||||
this.maxPollingTime = maxPollingTime;
|
this.maxPollingTime = maxPollingTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +45,7 @@ public class ControllerPollProperties {
|
|||||||
return minPollingTime;
|
return minPollingTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMinPollingTime(String minPollingTime) {
|
public void setMinPollingTime(final String minPollingTime) {
|
||||||
this.minPollingTime = minPollingTime;
|
this.minPollingTime = minPollingTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.ControllerPollProperties;
|
|
||||||
import org.eclipse.hawkbit.artifact.repository.model.DbArtifact;
|
import org.eclipse.hawkbit.artifact.repository.model.DbArtifact;
|
||||||
import org.eclipse.hawkbit.cache.CacheWriteNotify;
|
import org.eclipse.hawkbit.cache.CacheWriteNotify;
|
||||||
import org.eclipse.hawkbit.controller.model.ActionFeedback;
|
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.ArtifactManagement;
|
||||||
import org.eclipse.hawkbit.repository.ControllerManagement;
|
import org.eclipse.hawkbit.repository.ControllerManagement;
|
||||||
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
||||||
|
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
|
||||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||||
import org.eclipse.hawkbit.repository.model.Action;
|
import org.eclipse.hawkbit.repository.model.Action;
|
||||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
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.rest.resource.helper.RestResourceConversionHelper;
|
||||||
import org.eclipse.hawkbit.security.HawkbitSecurityProperties;
|
import org.eclipse.hawkbit.security.HawkbitSecurityProperties;
|
||||||
import org.eclipse.hawkbit.tenancy.TenantAware;
|
import org.eclipse.hawkbit.tenancy.TenantAware;
|
||||||
|
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
|
||||||
import org.eclipse.hawkbit.util.IpUtil;
|
import org.eclipse.hawkbit.util.IpUtil;
|
||||||
import org.hibernate.validator.constraints.NotEmpty;
|
import org.hibernate.validator.constraints.NotEmpty;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -77,8 +78,6 @@ public class RootController {
|
|||||||
private static final Logger LOG = LoggerFactory.getLogger(RootController.class);
|
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 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
|
@Autowired
|
||||||
private ControllerManagement controllerManagement;
|
private ControllerManagement controllerManagement;
|
||||||
|
|
||||||
@@ -88,15 +87,15 @@ public class RootController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ArtifactManagement artifactManagement;
|
private ArtifactManagement artifactManagement;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ControllerPollProperties controllerPollProperties;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CacheWriteNotify cacheWriteNotify;
|
private CacheWriteNotify cacheWriteNotify;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TenantAware tenantAware;
|
private TenantAware tenantAware;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TenantConfigurationManagement tenantConfigurationManagement;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private HawkbitSecurityProperties securityProperties;
|
private HawkbitSecurityProperties securityProperties;
|
||||||
|
|
||||||
@@ -154,10 +153,11 @@ public class RootController {
|
|||||||
IpUtil.getClientIpFromRequest(request, securityProperties.getClients().getRemoteIpHeader()));
|
IpUtil.getClientIpFromRequest(request, securityProperties.getClients().getRemoteIpHeader()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ResponseEntity<>(
|
final String pollingTime = tenantConfigurationManagement
|
||||||
DataConversionHelper.fromTarget(target, controllerManagement.findActionByTargetAndActive(target),
|
.getConfigurationValue(TenantConfigurationKey.POLLING_TIME_INTERVAL, String.class).getValue();
|
||||||
controllerPollProperties.getPollingTime(), tenantAware),
|
|
||||||
HttpStatus.OK);
|
return new ResponseEntity<>(DataConversionHelper.fromTarget(target,
|
||||||
|
controllerManagement.findActionByTargetAndActive(target), pollingTime, tenantAware), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
|
|||||||
import org.eclipse.hawkbit.repository.model.Target;
|
import org.eclipse.hawkbit.repository.model.Target;
|
||||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||||
import org.eclipse.hawkbit.rest.resource.JsonBuilder;
|
import org.eclipse.hawkbit.rest.resource.JsonBuilder;
|
||||||
|
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
|
||||||
import org.eclipse.hawkbit.util.IpUtil;
|
import org.eclipse.hawkbit.util.IpUtil;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.hateoas.MediaTypes;
|
import org.springframework.hateoas.MediaTypes;
|
||||||
@@ -133,6 +134,19 @@ public class RootControllerTest extends AbstractIntegrationTestWithMongoDB {
|
|||||||
.andExpect(status().isMethodNotAllowed());
|
.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
|
@Test
|
||||||
@Description("Ensures that etag check results in not modified response if provided etag by client is identical to entity in repository.")
|
@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 {
|
public void rootRsNotModified() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user