Target poll DB performance improvements (#613)

* Async update on last target query.

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

* 10 seconds

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

* Completed batch and optimzed schema.

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

* Cleanup and test.

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

* readibility.

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

* Batch update.

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

* Sonar issue fixed.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2017-12-18 13:50:25 +01:00
committed by GitHub
parent 80d9f1b8fc
commit 7d0bf3a162
22 changed files with 513 additions and 75 deletions

View File

@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.repository.test;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import org.eclipse.hawkbit.ControllerPollProperties;
import org.eclipse.hawkbit.HawkbitServerProperties;
@@ -60,9 +61,12 @@ import org.springframework.integration.support.locks.LockRegistry;
import org.springframework.messaging.converter.MessageConverter;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.security.concurrent.DelegatingSecurityContextExecutorService;
import org.springframework.security.concurrent.DelegatingSecurityContextScheduledExecutorService;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.util.AntPathMatcher;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
/**
* Spring context configuration required for Dev.Environment.
*/
@@ -186,6 +190,12 @@ public class TestConfiguration implements AsyncConfigurer {
return new SimpleAsyncUncaughtExceptionHandler();
}
@Bean
public ScheduledExecutorService scheduledExecutorService() {
return new DelegatingSecurityContextScheduledExecutorService(Executors.newScheduledThreadPool(1,
new ThreadFactoryBuilder().setNameFormat("central-scheduled-executor-pool-%d").build()));
}
/**
*
* @return returns a VirtualPropertyReplacer

View File

@@ -21,7 +21,6 @@ import java.util.stream.Collectors;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.eclipse.hawkbit.artifact.repository.ArtifactFilesystemProperties;
import org.eclipse.hawkbit.artifact.repository.ArtifactRepository;
import org.eclipse.hawkbit.cache.TenantAwareCacheManager;
import org.eclipse.hawkbit.repository.ArtifactManagement;
@@ -176,9 +175,6 @@ public abstract class AbstractIntegrationTest {
@Autowired
protected SystemSecurityContext systemSecurityContext;
@Autowired
private ArtifactFilesystemProperties artifactFilesystemProperties;
@Autowired
protected ArtifactRepository binaryArtifactRepository;
@@ -271,18 +267,18 @@ public abstract class AbstractIntegrationTest {
osType = securityRule
.runAsPrivileged(() -> testdataFactory.findOrCreateSoftwareModuleType(TestdataFactory.SM_TYPE_OS));
osType = securityRule.runAsPrivileged(() -> softwareModuleTypeManagement.update(
entityFactory.softwareModuleType().update(osType.getId()).description(description)));
osType = securityRule.runAsPrivileged(() -> softwareModuleTypeManagement
.update(entityFactory.softwareModuleType().update(osType.getId()).description(description)));
appType = securityRule.runAsPrivileged(
() -> testdataFactory.findOrCreateSoftwareModuleType(TestdataFactory.SM_TYPE_APP, Integer.MAX_VALUE));
appType = securityRule.runAsPrivileged(() -> softwareModuleTypeManagement.update(
entityFactory.softwareModuleType().update(appType.getId()).description(description)));
appType = securityRule.runAsPrivileged(() -> softwareModuleTypeManagement
.update(entityFactory.softwareModuleType().update(appType.getId()).description(description)));
runtimeType = securityRule
.runAsPrivileged(() -> testdataFactory.findOrCreateSoftwareModuleType(TestdataFactory.SM_TYPE_RT));
runtimeType = securityRule.runAsPrivileged(() -> softwareModuleTypeManagement.update(
entityFactory.softwareModuleType().update(runtimeType.getId()).description(description)));
runtimeType = securityRule.runAsPrivileged(() -> softwareModuleTypeManagement
.update(entityFactory.softwareModuleType().update(runtimeType.getId()).description(description)));
standardDsType = securityRule.runAsPrivileged(() -> testdataFactory.findOrCreateDefaultTestDsType());
}

View File

@@ -23,6 +23,10 @@ spring.jpa.properties.eclipselink.logging.parameters=true
## JPA Repository - START
spring.datasource.url=jdbc:h2:mem:sp-db;DB_CLOSE_ON_EXIT=FALSE
## JPA Repository - END
# Enforce persistence of targetpolls for test predictability.
hawkbit.server.repository.eagerPollPersistence=true
# Default properties for test that can be overridden during test run - END
# Properties that are managed by autoconfigure module at runtime and not available during test - START