JavaDoc and performance
Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -26,10 +26,25 @@ import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
|||||||
public interface DistributionSet extends NamedVersionedEntity {
|
public interface DistributionSet extends NamedVersionedEntity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {@link Set} of assigned {@link DistributionSetTag}s.
|
* @return immutable {@link Set} of assigned {@link DistributionSetTag}s.
|
||||||
*/
|
*/
|
||||||
Set<DistributionSetTag> getTags();
|
Set<DistributionSetTag> getTags();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param tag
|
||||||
|
* to add
|
||||||
|
* @return <code>true</code> if tag could be added sucessfully (i.e. was not
|
||||||
|
* already in the list).
|
||||||
|
*/
|
||||||
|
boolean addTag(final DistributionSetTag tag);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param tag
|
||||||
|
* to remove
|
||||||
|
* @return <code>true</code> if tag was in the list and removed
|
||||||
|
*/
|
||||||
|
boolean removeTag(final DistributionSetTag tag);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return <code>true</code> if the set is deleted and only kept for history
|
* @return <code>true</code> if the set is deleted and only kept for history
|
||||||
* purposes.
|
* purposes.
|
||||||
|
|||||||
@@ -158,6 +158,7 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
|
|||||||
return Collections.unmodifiableSet(tags);
|
return Collections.unmodifiableSet(tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean addTag(final DistributionSetTag tag) {
|
public boolean addTag(final DistributionSetTag tag) {
|
||||||
if (tags == null) {
|
if (tags == null) {
|
||||||
tags = new HashSet<>();
|
tags = new HashSet<>();
|
||||||
@@ -166,6 +167,7 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen
|
|||||||
return tags.add(tag);
|
return tags.add(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean removeTag(final DistributionSetTag tag) {
|
public boolean removeTag(final DistributionSetTag tag) {
|
||||||
if (tags == null) {
|
if (tags == null) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy {
|
|||||||
|
|
||||||
private static final int BLOCK_SIZE = 10_000;
|
private static final int BLOCK_SIZE = 10_000;
|
||||||
private final ScheduledExecutorService executorService;
|
private final ScheduledExecutorService executorService;
|
||||||
private final BlockingDeque<org.eclipse.hawkbit.eventbus.event.Event> queue = new LinkedBlockingDeque<>(BLOCK_SIZE);
|
private final BlockingDeque<Event> queue = new LinkedBlockingDeque<>(BLOCK_SIZE);
|
||||||
private final EventBus.SessionEventBus eventBus;
|
private final EventBus.SessionEventBus eventBus;
|
||||||
private final com.google.common.eventbus.EventBus systemEventBus;
|
private final com.google.common.eventbus.EventBus systemEventBus;
|
||||||
private int uiid = -1;
|
private int uiid = -1;
|
||||||
@@ -173,26 +173,20 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
LOG.debug("UI EventBus aggregator started for UI {}", uiid);
|
LOG.debug("UI EventBus aggregator started for UI {}", vaadinUI.getUIId());
|
||||||
final long timestamp = System.currentTimeMillis();
|
final long timestamp = System.currentTimeMillis();
|
||||||
|
|
||||||
final int size = queue.size();
|
final int size = queue.size();
|
||||||
if (size <= 0) {
|
if (size <= 0) {
|
||||||
LOG.debug("UI EventBus aggregator for UI {} has nothing to do.", uiid);
|
LOG.debug("UI EventBus aggregator for UI {} has nothing to do.", vaadinUI.getUIId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Event> events = new ArrayList<>(size);
|
final List<Event> events = new ArrayList<>(size);
|
||||||
for (int i = 0; i < size; i++) {
|
final int eventsSize = queue.drainTo(events);
|
||||||
final Event pollEvent = queue.poll();
|
|
||||||
if (pollEvent == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
events.add(pollEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (events.isEmpty()) {
|
if (events.isEmpty()) {
|
||||||
LOG.debug("UI EventBus aggregator for UI {} has nothing to do.", uiid);
|
LOG.debug("UI EventBus aggregator for UI {} has nothing to do.", vaadinUI.getUIId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,15 +195,13 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int eventsSize = events.size();
|
|
||||||
|
|
||||||
LOG.debug("UI EventBus aggregator dispatches {} events for session {} for UI {}", eventsSize, vaadinSession,
|
LOG.debug("UI EventBus aggregator dispatches {} events for session {} for UI {}", eventsSize, vaadinSession,
|
||||||
uiid);
|
vaadinUI.getUIId());
|
||||||
|
|
||||||
doDispatch(events, wrappedSession);
|
doDispatch(events, wrappedSession);
|
||||||
|
|
||||||
LOG.debug("UI EventBus aggregator done with sending {} events in {} ms for UI {}", eventsSize,
|
LOG.debug("UI EventBus aggregator done with sending {} events in {} ms for UI {}", eventsSize,
|
||||||
System.currentTimeMillis() - timestamp, uiid);
|
System.currentTimeMillis() - timestamp, vaadinUI.getUIId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,7 +222,7 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy {
|
|||||||
LOG.debug("UI EventBus aggregator of UI {} left lock on session.", vaadinUI.getUIId());
|
LOG.debug("UI EventBus aggregator of UI {} left lock on session.", vaadinUI.getUIId());
|
||||||
}).get();
|
}).get();
|
||||||
} catch (InterruptedException | ExecutionException e) {
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
LOG.error("Wait for Vaadin session for UI {} interrupted!", uiid, e);
|
LOG.error("Wait for Vaadin session for UI {} interrupted!", vaadinUI.getUIId(), e);
|
||||||
} finally {
|
} finally {
|
||||||
SecurityContextHolder.setContext(oldContext);
|
SecurityContextHolder.setContext(oldContext);
|
||||||
}
|
}
|
||||||
@@ -240,7 +232,7 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy {
|
|||||||
final Set<Class<?>> filterBulkEvenTypes = eventProvider.getFilteredBulkEventsType(events);
|
final Set<Class<?>> filterBulkEvenTypes = eventProvider.getFilteredBulkEventsType(events);
|
||||||
|
|
||||||
for (final Class<?> bulkType : filterBulkEvenTypes) {
|
for (final Class<?> bulkType : filterBulkEvenTypes) {
|
||||||
final List<org.eclipse.hawkbit.eventbus.event.Event> listBulkEvents = events.stream()
|
final List<Event> listBulkEvents = events.stream()
|
||||||
.filter(event -> DelayedEventBusPushStrategy.eventSecurityCheck(userContext, event)
|
.filter(event -> DelayedEventBusPushStrategy.eventSecurityCheck(userContext, event)
|
||||||
&& bulkType.isInstance(event))
|
&& bulkType.isInstance(event))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|||||||
Reference in New Issue
Block a user