Reduce dependency on Guava 2 (#1590)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -14,15 +14,12 @@ import java.io.IOException;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.eclipse.hawkbit.artifact.repository.model.AbstractDbArtifact;
|
import org.eclipse.hawkbit.artifact.repository.model.AbstractDbArtifact;
|
||||||
import org.eclipse.hawkbit.artifact.repository.model.DbArtifactHash;
|
import org.eclipse.hawkbit.artifact.repository.model.DbArtifactHash;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import com.google.common.base.Splitter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the {@link ArtifactRepository} to store artifacts on the
|
* Implementation of the {@link ArtifactRepository} to store artifacts on the
|
||||||
* file-system. The files are stored by their SHA1 hash of the artifact binary.
|
* file-system. The files are stored by their SHA1 hash of the artifact binary.
|
||||||
@@ -94,9 +91,8 @@ public class ArtifactFilesystemRepository extends AbstractArtifactRepository {
|
|||||||
|
|
||||||
private Path getSha1DirectoryPath(final String tenant, final String sha1) {
|
private Path getSha1DirectoryPath(final String tenant, final String sha1) {
|
||||||
final int length = sha1.length();
|
final int length = sha1.length();
|
||||||
final List<String> folders = Splitter.fixedLength(2).splitToList(sha1.substring(length - 4, length));
|
final String folder1 = sha1.substring(length - 4, length - 2);
|
||||||
final String folder1 = folders.get(0);
|
final String folder2 = sha1.substring(length - 2, length);
|
||||||
final String folder2 = folders.get(1);
|
|
||||||
return Paths.get(artifactResourceProperties.getPath(), sanitizeTenant(tenant), folder1, folder2);
|
return Paths.get(artifactResourceProperties.getPath(), sanitizeTenant(tenant), folder1, folder2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,15 +9,19 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.autoconfigure.scheduling;
|
package org.eclipse.hawkbit.autoconfigure.scheduling;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.concurrent.ArrayBlockingQueue;
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import java.util.concurrent.ThreadFactory;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
import java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy;
|
import java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -34,7 +38,7 @@ import org.springframework.security.concurrent.DelegatingSecurityContextExecutor
|
|||||||
import org.springframework.security.concurrent.DelegatingSecurityContextExecutorService;
|
import org.springframework.security.concurrent.DelegatingSecurityContextExecutorService;
|
||||||
import org.springframework.security.concurrent.DelegatingSecurityContextScheduledExecutorService;
|
import org.springframework.security.concurrent.DelegatingSecurityContextScheduledExecutorService;
|
||||||
|
|
||||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Central event processors inside update server.
|
* Central event processors inside update server.
|
||||||
@@ -78,7 +82,7 @@ public class ExecutorAutoConfiguration {
|
|||||||
return new ThreadPoolExecutor(asyncConfigurerProperties.getCorethreads(),
|
return new ThreadPoolExecutor(asyncConfigurerProperties.getCorethreads(),
|
||||||
asyncConfigurerProperties.getMaxthreads(), asyncConfigurerProperties.getIdletimeout(),
|
asyncConfigurerProperties.getMaxthreads(), asyncConfigurerProperties.getIdletimeout(),
|
||||||
TimeUnit.MILLISECONDS, blockingQueue,
|
TimeUnit.MILLISECONDS, blockingQueue,
|
||||||
new ThreadFactoryBuilder().setNameFormat("central-executor-pool-%d").build(),
|
threadFactory("central-executor-pool-%d"),
|
||||||
new PoolSizeExceededPolicy());
|
new PoolSizeExceededPolicy());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +104,7 @@ public class ExecutorAutoConfiguration {
|
|||||||
public Executor uiExecutor() {
|
public Executor uiExecutor() {
|
||||||
final BlockingQueue<Runnable> blockingQueue = new ArrayBlockingQueue<>(20);
|
final BlockingQueue<Runnable> blockingQueue = new ArrayBlockingQueue<>(20);
|
||||||
final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 20, 10000, TimeUnit.MILLISECONDS,
|
final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 20, 10000, TimeUnit.MILLISECONDS,
|
||||||
blockingQueue, new ThreadFactoryBuilder().setNameFormat("ui-executor-pool-%d").build());
|
blockingQueue, threadFactory("ui-executor-pool-%d"));
|
||||||
threadPoolExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
threadPoolExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||||
return new DelegatingSecurityContextExecutor(threadPoolExecutor);
|
return new DelegatingSecurityContextExecutor(threadPoolExecutor);
|
||||||
}
|
}
|
||||||
@@ -114,7 +118,7 @@ public class ExecutorAutoConfiguration {
|
|||||||
public ScheduledExecutorService scheduledExecutorService() {
|
public ScheduledExecutorService scheduledExecutorService() {
|
||||||
return new DelegatingSecurityContextScheduledExecutorService(
|
return new DelegatingSecurityContextScheduledExecutorService(
|
||||||
Executors.newScheduledThreadPool(asyncConfigurerProperties.getSchedulerThreads(),
|
Executors.newScheduledThreadPool(asyncConfigurerProperties.getSchedulerThreads(),
|
||||||
new ThreadFactoryBuilder().setNameFormat("central-scheduled-executor-pool-%d").build()));
|
threadFactory("central-scheduled-executor-pool-%d")));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -126,4 +130,12 @@ public class ExecutorAutoConfiguration {
|
|||||||
return new ConcurrentTaskScheduler(scheduledExecutorService());
|
return new ConcurrentTaskScheduler(scheduledExecutorService());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static ThreadFactory threadFactory(final String format) {
|
||||||
|
final AtomicLong count = new AtomicLong(0);
|
||||||
|
return (runnable) -> {
|
||||||
|
final Thread thread = Executors.defaultThreadFactory().newThread(runnable);
|
||||||
|
thread.setName(String.format(Locale.ROOT, format, count.getAndIncrement()));
|
||||||
|
return thread;
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,6 +70,10 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-logging</artifactId>
|
<artifactId>spring-boot-starter-logging</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-collections4</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<!-- Test -->
|
<!-- Test -->
|
||||||
@@ -90,5 +94,4 @@
|
|||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@@ -25,7 +25,8 @@ import java.util.function.Supplier;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.StreamSupport;
|
import java.util.stream.StreamSupport;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import org.apache.commons.collections4.IterableUtils;
|
||||||
|
import org.apache.commons.collections4.ListUtils;
|
||||||
import org.eclipse.hawkbit.api.ApiType;
|
import org.eclipse.hawkbit.api.ApiType;
|
||||||
import org.eclipse.hawkbit.api.ArtifactUrl;
|
import org.eclipse.hawkbit.api.ArtifactUrl;
|
||||||
import org.eclipse.hawkbit.api.ArtifactUrlHandler;
|
import org.eclipse.hawkbit.api.ArtifactUrlHandler;
|
||||||
@@ -368,7 +369,7 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
|
|||||||
// Ensure not exceeding the max value of MAX_PROCESSING_SIZE
|
// Ensure not exceeding the max value of MAX_PROCESSING_SIZE
|
||||||
if (controllerIds.size() > MAX_PROCESSING_SIZE) {
|
if (controllerIds.size() > MAX_PROCESSING_SIZE) {
|
||||||
// Split the provided collection
|
// Split the provided collection
|
||||||
final Iterable<List<T>> partitions = Iterables.partition(controllerIds, MAX_PROCESSING_SIZE);
|
final Iterable<List<T>> partitions = ListUtils.partition(IterableUtils.toList(controllerIds), MAX_PROCESSING_SIZE);
|
||||||
// Preserve the security context because it gets lost when executing
|
// Preserve the security context because it gets lost when executing
|
||||||
// loading calls in new threads
|
// loading calls in new threads
|
||||||
final SecurityContext context = SecurityContextHolder.getContext();
|
final SecurityContext context = SecurityContextHolder.getContext();
|
||||||
|
|||||||
@@ -81,6 +81,10 @@
|
|||||||
<groupId>org.hibernate.validator</groupId>
|
<groupId>org.hibernate.validator</groupId>
|
||||||
<artifactId>hibernate-validator</artifactId>
|
<artifactId>hibernate-validator</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-collections4</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Test -->
|
<!-- Test -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -33,15 +33,14 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
import jakarta.persistence.Query;
|
import jakarta.persistence.Query;
|
||||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||||
import jakarta.persistence.criteria.CriteriaQuery;
|
import jakarta.persistence.criteria.CriteriaQuery;
|
||||||
import jakarta.persistence.criteria.Root;
|
import jakarta.persistence.criteria.Root;
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
|
import org.apache.commons.collections4.ListUtils;
|
||||||
import org.eclipse.hawkbit.repository.ConfirmationManagement;
|
import org.eclipse.hawkbit.repository.ConfirmationManagement;
|
||||||
import org.eclipse.hawkbit.repository.ControllerManagement;
|
import org.eclipse.hawkbit.repository.ControllerManagement;
|
||||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||||
@@ -473,7 +472,7 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
|
|||||||
private Void updateLastTargetQueries(final String tenant, final List<TargetPoll> polls) {
|
private Void updateLastTargetQueries(final String tenant, final List<TargetPoll> polls) {
|
||||||
LOG.debug("Persist {} targetqueries.", polls.size());
|
LOG.debug("Persist {} targetqueries.", polls.size());
|
||||||
|
|
||||||
final List<List<String>> pollChunks = Lists.partition(
|
final List<List<String>> pollChunks = ListUtils.partition(
|
||||||
polls.stream().map(TargetPoll::getControllerId).collect(Collectors.toList()),
|
polls.stream().map(TargetPoll::getControllerId).collect(Collectors.toList()),
|
||||||
Constants.MAX_ENTRIES_IN_STATEMENT);
|
Constants.MAX_ENTRIES_IN_STATEMENT);
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import java.util.function.Function;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
import jakarta.persistence.Query;
|
import jakarta.persistence.Query;
|
||||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||||
@@ -37,6 +36,7 @@ import jakarta.persistence.criteria.JoinType;
|
|||||||
import jakarta.persistence.criteria.ListJoin;
|
import jakarta.persistence.criteria.ListJoin;
|
||||||
import jakarta.persistence.criteria.Root;
|
import jakarta.persistence.criteria.Root;
|
||||||
|
|
||||||
|
import org.apache.commons.collections4.ListUtils;
|
||||||
import org.eclipse.hawkbit.repository.ActionFields;
|
import org.eclipse.hawkbit.repository.ActionFields;
|
||||||
import org.eclipse.hawkbit.repository.DeploymentManagement;
|
import org.eclipse.hawkbit.repository.DeploymentManagement;
|
||||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||||
@@ -281,7 +281,7 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
|||||||
|
|
||||||
private void checkCompatibilityForSingleDsAssignment(final Long distSetId, final List<String> controllerIds) {
|
private void checkCompatibilityForSingleDsAssignment(final Long distSetId, final List<String> controllerIds) {
|
||||||
final DistributionSetType distSetType = distributionSetManagement.getValidAndComplete(distSetId).getType();
|
final DistributionSetType distSetType = distributionSetManagement.getValidAndComplete(distSetId).getType();
|
||||||
final Set<String> incompatibleTargetTypes = Lists.partition(controllerIds, Constants.MAX_ENTRIES_IN_STATEMENT)
|
final Set<String> incompatibleTargetTypes = ListUtils.partition(controllerIds, Constants.MAX_ENTRIES_IN_STATEMENT)
|
||||||
.stream()
|
.stream()
|
||||||
.map(ids -> targetRepository.findAll(TargetSpecifications.hasControllerIdIn(ids)
|
.map(ids -> targetRepository.findAll(TargetSpecifications.hasControllerIdIn(ids)
|
||||||
.and(TargetSpecifications.notCompatibleWithDistributionSetType(distSetType.getId()))))
|
.and(TargetSpecifications.notCompatibleWithDistributionSetType(distSetType.getId()))))
|
||||||
@@ -377,7 +377,7 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
|||||||
final List<String> providedTargetIds = targetsWithActionType.stream().map(TargetWithActionType::getControllerId)
|
final List<String> providedTargetIds = targetsWithActionType.stream().map(TargetWithActionType::getControllerId)
|
||||||
.distinct().toList();
|
.distinct().toList();
|
||||||
|
|
||||||
final List<String> existingTargetIds = Lists.partition(providedTargetIds, Constants.MAX_ENTRIES_IN_STATEMENT)
|
final List<String> existingTargetIds = ListUtils.partition(providedTargetIds, Constants.MAX_ENTRIES_IN_STATEMENT)
|
||||||
.stream()
|
.stream()
|
||||||
.map(ids -> targetRepository.findAll(AccessController.Operation.UPDATE,
|
.map(ids -> targetRepository.findAll(AccessController.Operation.UPDATE,
|
||||||
TargetSpecifications.hasControllerIdIn(ids)))
|
TargetSpecifications.hasControllerIdIn(ids)))
|
||||||
@@ -442,7 +442,7 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
|||||||
* statements
|
* statements
|
||||||
*/
|
*/
|
||||||
private static List<List<Long>> getTargetEntitiesAsChunks(final List<JpaTarget> targetEntities) {
|
private static List<List<Long>> getTargetEntitiesAsChunks(final List<JpaTarget> targetEntities) {
|
||||||
return Lists.partition(targetEntities.stream().map(Target::getId).collect(Collectors.toList()),
|
return ListUtils.partition(targetEntities.stream().map(Target::getId).collect(Collectors.toList()),
|
||||||
Constants.MAX_ENTRIES_IN_STATEMENT);
|
Constants.MAX_ENTRIES_IN_STATEMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import java.util.Objects;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||||
import jakarta.persistence.criteria.CriteriaQuery;
|
import jakarta.persistence.criteria.CriteriaQuery;
|
||||||
@@ -29,6 +28,7 @@ import jakarta.persistence.criteria.MapJoin;
|
|||||||
import jakarta.persistence.criteria.Root;
|
import jakarta.persistence.criteria.Root;
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
|
||||||
|
import org.apache.commons.collections4.ListUtils;
|
||||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||||
import org.eclipse.hawkbit.repository.FilterParams;
|
import org.eclipse.hawkbit.repository.FilterParams;
|
||||||
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
|
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
|
||||||
@@ -40,7 +40,6 @@ import org.eclipse.hawkbit.repository.TimestampCalculator;
|
|||||||
import org.eclipse.hawkbit.repository.builder.TargetCreate;
|
import org.eclipse.hawkbit.repository.builder.TargetCreate;
|
||||||
import org.eclipse.hawkbit.repository.builder.TargetUpdate;
|
import org.eclipse.hawkbit.repository.builder.TargetUpdate;
|
||||||
import org.eclipse.hawkbit.repository.event.remote.TargetAttributesRequestedEvent;
|
import org.eclipse.hawkbit.repository.event.remote.TargetAttributesRequestedEvent;
|
||||||
import org.eclipse.hawkbit.repository.event.remote.TargetDeletedEvent;
|
|
||||||
import org.eclipse.hawkbit.repository.event.remote.entity.TargetUpdatedEvent;
|
import org.eclipse.hawkbit.repository.event.remote.entity.TargetUpdatedEvent;
|
||||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||||
@@ -49,7 +48,6 @@ import org.eclipse.hawkbit.repository.jpa.acm.AccessController;
|
|||||||
import org.eclipse.hawkbit.repository.jpa.builder.JpaTargetCreate;
|
import org.eclipse.hawkbit.repository.jpa.builder.JpaTargetCreate;
|
||||||
import org.eclipse.hawkbit.repository.jpa.builder.JpaTargetUpdate;
|
import org.eclipse.hawkbit.repository.jpa.builder.JpaTargetUpdate;
|
||||||
import org.eclipse.hawkbit.repository.jpa.configuration.Constants;
|
import org.eclipse.hawkbit.repository.jpa.configuration.Constants;
|
||||||
import org.eclipse.hawkbit.repository.jpa.executor.AfterTransactionCommitExecutor;
|
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetMetadata;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetMetadata;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetMetadata_;
|
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetMetadata_;
|
||||||
@@ -553,7 +551,7 @@ public class JpaTargetManagement implements TargetManagement {
|
|||||||
|
|
||||||
private List<JpaTarget> findTargetsByInSpecification(final Collection<String> controllerIds,
|
private List<JpaTarget> findTargetsByInSpecification(final Collection<String> controllerIds,
|
||||||
final Specification<JpaTarget> specification) {
|
final Specification<JpaTarget> specification) {
|
||||||
return Lists.partition(new ArrayList<>(controllerIds), Constants.MAX_ENTRIES_IN_STATEMENT).stream()
|
return ListUtils.partition(new ArrayList<>(controllerIds), Constants.MAX_ENTRIES_IN_STATEMENT).stream()
|
||||||
.map(ids -> targetRepository.findAll(TargetSpecifications.hasControllerIdIn(ids).and(specification)))
|
.map(ids -> targetRepository.findAll(TargetSpecifications.hasControllerIdIn(ids).and(specification)))
|
||||||
.flatMap(List::stream).toList();
|
.flatMap(List::stream).toList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import java.util.function.BooleanSupplier;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import org.apache.commons.collections4.ListUtils;
|
||||||
import org.eclipse.hawkbit.repository.QuotaManagement;
|
import org.eclipse.hawkbit.repository.QuotaManagement;
|
||||||
import org.eclipse.hawkbit.repository.RepositoryConstants;
|
import org.eclipse.hawkbit.repository.RepositoryConstants;
|
||||||
import org.eclipse.hawkbit.repository.RepositoryProperties;
|
import org.eclipse.hawkbit.repository.RepositoryProperties;
|
||||||
@@ -75,7 +75,7 @@ public class OfflineDsAssignmentStrategy extends AbstractDsAssignmentStrategy {
|
|||||||
Arrays.asList(TargetSpecifications.hasControllerIdAndAssignedDistributionSetIdNot(ids, setId),
|
Arrays.asList(TargetSpecifications.hasControllerIdAndAssignedDistributionSetIdNot(ids, setId),
|
||||||
TargetSpecifications.notEqualToTargetUpdateStatus(TargetUpdateStatus.PENDING))));
|
TargetSpecifications.notEqualToTargetUpdateStatus(TargetUpdateStatus.PENDING))));
|
||||||
}
|
}
|
||||||
return Lists.partition(controllerIDs, Constants.MAX_ENTRIES_IN_STATEMENT).stream().map(mapper)
|
return ListUtils.partition(controllerIDs, Constants.MAX_ENTRIES_IN_STATEMENT).stream().map(mapper)
|
||||||
.flatMap(List::stream).collect(Collectors.toList());
|
.flatMap(List::stream).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import java.util.function.Function;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import org.apache.commons.collections4.ListUtils;
|
||||||
import org.eclipse.hawkbit.repository.QuotaManagement;
|
import org.eclipse.hawkbit.repository.QuotaManagement;
|
||||||
import org.eclipse.hawkbit.repository.RepositoryProperties;
|
import org.eclipse.hawkbit.repository.RepositoryProperties;
|
||||||
import org.eclipse.hawkbit.repository.event.remote.MultiActionAssignEvent;
|
import org.eclipse.hawkbit.repository.event.remote.MultiActionAssignEvent;
|
||||||
@@ -109,7 +109,7 @@ public class OnlineDsAssignmentStrategy extends AbstractDsAssignmentStrategy {
|
|||||||
mapper = ids -> targetRepository
|
mapper = ids -> targetRepository
|
||||||
.findAll(TargetSpecifications.hasControllerIdAndAssignedDistributionSetIdNot(ids, setId));
|
.findAll(TargetSpecifications.hasControllerIdAndAssignedDistributionSetIdNot(ids, setId));
|
||||||
}
|
}
|
||||||
return Lists.partition(controllerIDs, Constants.MAX_ENTRIES_IN_STATEMENT).stream().map(mapper)
|
return ListUtils.partition(controllerIDs, Constants.MAX_ENTRIES_IN_STATEMENT).stream().map(mapper)
|
||||||
.flatMap(List::stream).collect(Collectors.toList());
|
.flatMap(List::stream).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.google.common.base.Splitter;
|
|
||||||
import jakarta.persistence.CollectionTable;
|
import jakarta.persistence.CollectionTable;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.ConstraintMode;
|
import jakarta.persistence.ConstraintMode;
|
||||||
@@ -159,7 +159,20 @@ public class JpaActionStatus extends AbstractJpaTenantAwareBaseEntity implements
|
|||||||
if (messages == null) {
|
if (messages == null) {
|
||||||
messages = new ArrayList<>((message.length() / MESSAGE_ENTRY_LENGTH) + 1);
|
messages = new ArrayList<>((message.length() / MESSAGE_ENTRY_LENGTH) + 1);
|
||||||
}
|
}
|
||||||
Splitter.fixedLength(MESSAGE_ENTRY_LENGTH).split(message).forEach(messages::add);
|
if (message.length() > MESSAGE_ENTRY_LENGTH) {
|
||||||
|
// split
|
||||||
|
for (int off = 0; off < message.length();) {
|
||||||
|
final int end = off + MESSAGE_ENTRY_LENGTH;
|
||||||
|
if (end < message.length()) {
|
||||||
|
messages.add(message.substring(off, end));
|
||||||
|
} else {
|
||||||
|
messages.add(message.substring(off));
|
||||||
|
}
|
||||||
|
off = end;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
messages.add(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -36,9 +37,6 @@ import org.slf4j.LoggerFactory;
|
|||||||
import org.springframework.orm.jpa.JpaSystemException;
|
import org.springframework.orm.jpa.JpaSystemException;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import com.google.common.collect.ArrayListMultimap;
|
|
||||||
import com.google.common.collect.Multimap;
|
|
||||||
|
|
||||||
import cz.jirutka.rsql.parser.ParseException;
|
import cz.jirutka.rsql.parser.ParseException;
|
||||||
import cz.jirutka.rsql.parser.RSQLParserException;
|
import cz.jirutka.rsql.parser.RSQLParserException;
|
||||||
|
|
||||||
@@ -254,22 +252,14 @@ public class RsqlParserValidationOracle implements RsqlValidationOracle {
|
|||||||
// sensitive help on search query.
|
// sensitive help on search query.
|
||||||
private static final class TokenDescription {
|
private static final class TokenDescription {
|
||||||
|
|
||||||
private static final Multimap<Integer, String> TOKEN_MAP = ArrayListMultimap.create();
|
private static final Map<Integer, List<String>> TOKEN_MAP = new HashMap<>();
|
||||||
|
|
||||||
private static final int LOGICAL_OP = 8;
|
private static final int LOGICAL_OP = 8;
|
||||||
private static final int COMPARATOR = 12;
|
private static final int COMPARATOR = 12;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
TOKEN_MAP.put(LOGICAL_OP, "and");
|
TOKEN_MAP.put(LOGICAL_OP, List.of("and", "or"));
|
||||||
TOKEN_MAP.put(LOGICAL_OP, "or");
|
TOKEN_MAP.put(COMPARATOR, List.of("==", "!=", "=ge=", "=le=", "=gt=", "=lt=", "=in=", "=out="));
|
||||||
TOKEN_MAP.put(COMPARATOR, "==");
|
|
||||||
TOKEN_MAP.put(COMPARATOR, "!=");
|
|
||||||
TOKEN_MAP.put(COMPARATOR, "=ge=");
|
|
||||||
TOKEN_MAP.put(COMPARATOR, "=le=");
|
|
||||||
TOKEN_MAP.put(COMPARATOR, "=gt=");
|
|
||||||
TOKEN_MAP.put(COMPARATOR, "=lt=");
|
|
||||||
TOKEN_MAP.put(COMPARATOR, "=in=");
|
|
||||||
TOKEN_MAP.put(COMPARATOR, "=out=");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private TokenDescription() {
|
private TokenDescription() {
|
||||||
@@ -279,7 +269,6 @@ public class RsqlParserValidationOracle implements RsqlValidationOracle {
|
|||||||
private static Collection<String> getTokenImage(final int tokenIndex) {
|
private static Collection<String> getTokenImage(final int tokenIndex) {
|
||||||
return TOKEN_MAP.get(tokenIndex);
|
return TOKEN_MAP.get(tokenIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class FieldNameDescription {
|
private static final class FieldNameDescription {
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ import org.springframework.data.domain.Slice;
|
|||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.data.domain.Sort.Direction;
|
import org.springframework.data.domain.Sort.Direction;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
|
|
||||||
import io.qameta.allure.Description;
|
import io.qameta.allure.Description;
|
||||||
|
|||||||
@@ -10,9 +10,11 @@
|
|||||||
package org.eclipse.hawkbit.repository.test;
|
package org.eclipse.hawkbit.repository.test;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.ContextAware;
|
import org.eclipse.hawkbit.ContextAware;
|
||||||
import org.eclipse.hawkbit.ControllerPollProperties;
|
import org.eclipse.hawkbit.ControllerPollProperties;
|
||||||
@@ -69,7 +71,7 @@ import org.springframework.security.concurrent.DelegatingSecurityContextExecutor
|
|||||||
import org.springframework.security.concurrent.DelegatingSecurityContextScheduledExecutorService;
|
import org.springframework.security.concurrent.DelegatingSecurityContextScheduledExecutorService;
|
||||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||||
|
|
||||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spring context configuration required for Dev.Environment.
|
* Spring context configuration required for Dev.Environment.
|
||||||
@@ -209,8 +211,15 @@ public class TestConfiguration implements AsyncConfigurer {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ScheduledExecutorService scheduledExecutorService() {
|
public ScheduledExecutorService scheduledExecutorService() {
|
||||||
return new DelegatingSecurityContextScheduledExecutorService(Executors.newScheduledThreadPool(1,
|
final AtomicLong count = new AtomicLong(0);
|
||||||
new ThreadFactoryBuilder().setNameFormat("central-scheduled-executor-pool-%d").build()));
|
return new DelegatingSecurityContextScheduledExecutorService(
|
||||||
|
Executors.newScheduledThreadPool(1, (runnable) -> {
|
||||||
|
final Thread thread = Executors.defaultThreadFactory().newThread(runnable);
|
||||||
|
thread.setName(
|
||||||
|
String.format(
|
||||||
|
Locale.ROOT, "central-scheduled-executor-pool-%d", count.getAndIncrement()));
|
||||||
|
return thread;
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -15,16 +15,15 @@ import static org.hamcrest.Matchers.equalTo;
|
|||||||
import static org.junit.jupiter.api.Assertions.fail;
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import com.google.common.collect.ConcurrentHashMultiset;
|
|
||||||
import com.google.common.collect.Multiset;
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
import org.awaitility.Awaitility;
|
import org.awaitility.Awaitility;
|
||||||
import org.awaitility.core.ConditionTimeoutException;
|
import org.awaitility.core.ConditionTimeoutException;
|
||||||
import org.eclipse.hawkbit.repository.event.remote.RemoteIdEvent;
|
import org.eclipse.hawkbit.repository.event.remote.RemoteIdEvent;
|
||||||
@@ -137,7 +136,7 @@ public class EventVerifier extends AbstractTestExecutionListener {
|
|||||||
|
|
||||||
private static class EventCaptor implements ApplicationListener<RemoteApplicationEvent> {
|
private static class EventCaptor implements ApplicationListener<RemoteApplicationEvent> {
|
||||||
|
|
||||||
private final Multiset<Class<?>> capturedEvents = ConcurrentHashMultiset.create();
|
private final ConcurrentHashMap<Class<?>, Integer> capturedEvents = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onApplicationEvent(final RemoteApplicationEvent event) {
|
public void onApplicationEvent(final RemoteApplicationEvent event) {
|
||||||
@@ -162,18 +161,18 @@ public class EventVerifier extends AbstractTestExecutionListener {
|
|||||||
assertThat(((TargetAssignDistributionSetEvent) event).getDistributionSetId()).isNotNull();
|
assertThat(((TargetAssignDistributionSetEvent) event).getDistributionSetId()).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
capturedEvents.add(event.getClass());
|
capturedEvents.compute(event.getClass(), (k, v) -> v == null ? 1 : v + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCountFor(final Class<?> expectedEvent) {
|
public int getCountFor(final Class<?> expectedEvent) {
|
||||||
return capturedEvents.count(expectedEvent);
|
return Optional.ofNullable(capturedEvents.get(expectedEvent)).orElse(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Class<?>> diff(final Expect[] allEvents) {
|
public Set<Class<?>> diff(final Expect[] allEvents) {
|
||||||
return Sets.difference(capturedEvents.elementSet(),
|
final Set<Class<?>> keys = new HashSet<>(capturedEvents.keySet());
|
||||||
Stream.of(allEvents).map(Expect::type).collect(Collectors.toSet()));
|
keys.removeAll(Stream.of(allEvents).map(Expect::type).collect(Collectors.toSet()));
|
||||||
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class ResetCounterMarkerEvent extends RemoteApplicationEvent {
|
private static final class ResetCounterMarkerEvent extends RemoteApplicationEvent {
|
||||||
|
|||||||
Reference in New Issue
Block a user