diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSet.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSet.java index 5747b38f3..b0bff56cb 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSet.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSet.java @@ -26,10 +26,25 @@ import org.eclipse.hawkbit.repository.DistributionSetManagement; public interface DistributionSet extends NamedVersionedEntity { /** - * @return {@link Set} of assigned {@link DistributionSetTag}s. + * @return immutable {@link Set} of assigned {@link DistributionSetTag}s. */ Set getTags(); + /** + * @param tag + * to add + * @return true if tag could be added sucessfully (i.e. was not + * already in the list). + */ + boolean addTag(final DistributionSetTag tag); + + /** + * @param tag + * to remove + * @return true if tag was in the list and removed + */ + boolean removeTag(final DistributionSetTag tag); + /** * @return true if the set is deleted and only kept for history * purposes. diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSet.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSet.java index 8e12967c5..9e6efe826 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSet.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/JpaDistributionSet.java @@ -158,6 +158,7 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen return Collections.unmodifiableSet(tags); } + @Override public boolean addTag(final DistributionSetTag tag) { if (tags == null) { tags = new HashSet<>(); @@ -166,6 +167,7 @@ public class JpaDistributionSet extends AbstractJpaNamedVersionedEntity implemen return tags.add(tag); } + @Override public boolean removeTag(final DistributionSetTag tag) { if (tags == null) { return false; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/DelayedEventBusPushStrategy.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/DelayedEventBusPushStrategy.java index 5f72478cb..31de959ae 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/DelayedEventBusPushStrategy.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/push/DelayedEventBusPushStrategy.java @@ -59,7 +59,7 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy { private static final int BLOCK_SIZE = 10_000; private final ScheduledExecutorService executorService; - private final BlockingDeque queue = new LinkedBlockingDeque<>(BLOCK_SIZE); + private final BlockingDeque queue = new LinkedBlockingDeque<>(BLOCK_SIZE); private final EventBus.SessionEventBus eventBus; private final com.google.common.eventbus.EventBus systemEventBus; private int uiid = -1; @@ -173,26 +173,20 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy { @Override 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 int size = queue.size(); 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; } final List events = new ArrayList<>(size); - for (int i = 0; i < size; i++) { - final Event pollEvent = queue.poll(); - if (pollEvent == null) { - continue; - } - events.add(pollEvent); - } + final int eventsSize = queue.drainTo(events); 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; } @@ -201,15 +195,13 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy { return; } - final int eventsSize = events.size(); - LOG.debug("UI EventBus aggregator dispatches {} events for session {} for UI {}", eventsSize, vaadinSession, - uiid); + vaadinUI.getUIId()); doDispatch(events, wrappedSession); 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()); }).get(); } 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 { SecurityContextHolder.setContext(oldContext); } @@ -240,7 +232,7 @@ public class DelayedEventBusPushStrategy implements EventPushStrategy { final Set> filterBulkEvenTypes = eventProvider.getFilteredBulkEventsType(events); for (final Class bulkType : filterBulkEvenTypes) { - final List listBulkEvents = events.stream() + final List listBulkEvents = events.stream() .filter(event -> DelayedEventBusPushStrategy.eventSecurityCheck(userContext, event) && bulkType.isInstance(event)) .collect(Collectors.toList());