TargetPollEvent optional (#580)

* TargetPollEvent can be disabled.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Fixed test.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Central filter introduced.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Fix sonar issue.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Add property to standard runtime.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Add property to standard runtime.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2017-09-26 14:29:55 +02:00
committed by GitHub
parent 879c85fd63
commit 3d32d1d1c3
9 changed files with 132 additions and 25 deletions

View File

@@ -48,7 +48,6 @@ import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.security.SystemSecurityContext;
import org.eclipse.hawkbit.tenancy.TenantAware;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -101,9 +100,6 @@ public class JpaControllerManagement implements ControllerManagement {
@Autowired
private TenantConfigurationManagement tenantConfigurationManagement;
@Autowired
private TenantAware tenantAware;
@Autowired
private SystemSecurityContext systemSecurityContext;

View File

@@ -23,6 +23,7 @@ import org.eclipse.hawkbit.repository.DistributionSetTypeManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.PropertiesQuotaManagement;
import org.eclipse.hawkbit.repository.RepositoryDefaultConfiguration;
import org.eclipse.hawkbit.repository.RepositoryProperties;
import org.eclipse.hawkbit.repository.RolloutGroupManagement;
import org.eclipse.hawkbit.repository.RolloutManagement;
import org.eclipse.hawkbit.repository.RolloutStatusCache;
@@ -39,8 +40,10 @@ import org.eclipse.hawkbit.repository.builder.DistributionSetTypeBuilder;
import org.eclipse.hawkbit.repository.builder.RolloutBuilder;
import org.eclipse.hawkbit.repository.builder.SoftwareModuleBuilder;
import org.eclipse.hawkbit.repository.builder.TargetFilterQueryBuilder;
import org.eclipse.hawkbit.repository.event.ApplicationEventFilter;
import org.eclipse.hawkbit.repository.event.remote.EventEntityManager;
import org.eclipse.hawkbit.repository.event.remote.EventEntityManagerHolder;
import org.eclipse.hawkbit.repository.event.remote.TargetPollEvent;
import org.eclipse.hawkbit.repository.jpa.aspects.ExceptionMappingAspectHandler;
import org.eclipse.hawkbit.repository.jpa.autoassign.AutoAssignChecker;
import org.eclipse.hawkbit.repository.jpa.autoassign.AutoAssignScheduler;
@@ -145,6 +148,12 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
return new RolloutStatusCache(tenantAware);
}
@Bean
@ConditionalOnMissingBean
ApplicationEventFilter applicationEventFilter(final RepositoryProperties repositoryProperties) {
return e -> (e instanceof TargetPollEvent) && !repositoryProperties.isPublishTargetPollEvent();
}
/**
* @param distributionSetTypeManagement
* to loading the {@link DistributionSetType}

View File

@@ -432,6 +432,16 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
.as("register target with empty controllerId should fail");
}
@Test
@Description("Verify that controller registration does not result in a TargetPollEvent if feature is disabled")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 0) })
public void targetPollEventNotSendIfDisabled() {
repositoryProperties.setPublishTargetPollEvent(false);
controllerManagement.findOrRegisterTargetIfItDoesNotexist("AA", LOCALHOST);
repositoryProperties.setPublishTargetPollEvent(true);
}
@Test
@Description("Controller trys to finish an update process after it has been finished by an error action status.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),