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

@@ -8,6 +8,8 @@
*/
package org.eclipse.hawkbit.repository;
import java.util.concurrent.TimeUnit;
import org.eclipse.hawkbit.repository.event.remote.TargetPollEvent;
import org.eclipse.hawkbit.repository.model.ActionStatus;
import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -34,6 +36,45 @@ public class RepositoryProperties {
*/
private boolean publishTargetPollEvent = true;
/**
* Maximum number of poll operations queued before flush.
*/
private int pollPersistenceQueueSize = 10_000;
/**
* Maximum time before queue is flushed in {@link TimeUnit#MILLISECONDS}.
*/
private long pollPersistenceFlushTime = TimeUnit.SECONDS.toMillis(10);
/**
* Set to true to persist polls immediately.
*/
private boolean eagerPollPersistence;
public boolean isEagerPollPersistence() {
return eagerPollPersistence;
}
public void setEagerPollPersistence(final boolean eagerPollPersistence) {
this.eagerPollPersistence = eagerPollPersistence;
}
public long getPollPersistenceFlushTime() {
return pollPersistenceFlushTime;
}
public void setPollPersistenceFlushTime(final long pollPersistenceFlushTime) {
this.pollPersistenceFlushTime = pollPersistenceFlushTime;
}
public int getPollPersistenceQueueSize() {
return pollPersistenceQueueSize;
}
public void setPollPersistenceQueueSize(final int pollPersistenceQueueSize) {
this.pollPersistenceQueueSize = pollPersistenceQueueSize;
}
public boolean isRejectActionStatusForClosedAction() {
return rejectActionStatusForClosedAction;
}

View File

@@ -26,6 +26,11 @@ public class TargetPollEvent extends RemoteTenantAwareEvent {
// for serialization libs like jackson
}
public TargetPollEvent(final String controllerId, final String tenant, final String applicationId) {
super(controllerId, tenant, applicationId);
this.controllerId = controllerId;
}
public TargetPollEvent(final Target target, final String applicationId) {
super(target.getControllerId(), target.getTenant(), applicationId);
this.controllerId = target.getControllerId();

View File

@@ -25,7 +25,7 @@ public interface ActionStatus extends TenantAwareBaseEntity {
* @return time in {@link TimeUnit#MILLISECONDS} when the status was
* reported.
*/
Long getOccurredAt();
long getOccurredAt();
/**
* @return {@link Action} this {@link ActionStatus} belongs to.