List of usage examples for java.util Set forEach
default void forEach(Consumer<? super T> action)
From source file:org.apache.nifi.web.api.VersionsResource.java
@POST @Consumes(MediaType.APPLICATION_JSON)/*from ww w.j a v a2 s .co m*/ @Produces(MediaType.APPLICATION_JSON) @Path("revert-requests/process-groups/{id}") @ApiOperation(value = "Initiate the Revert Request of a Process Group with the given ID", response = VersionedFlowUpdateRequestEntity.class, notes = "For a Process Group that is already under Version Control, this will initiate the action of reverting " + "any local changes that have been made to the Process Group since it was last synchronized with the Flow Registry. This will result in the " + "flow matching the Versioned Flow that exists in the Flow Registry. This can be a lengthy " + "process, as it will stop any Processors and disable any Controller Services necessary to perform the action and then restart them. As a result, " + "the endpoint will immediately return a VersionedFlowUpdateRequestEntity, and the process of updating the flow will occur " + "asynchronously in the background. The client may then periodically poll the status of the request by issuing a GET request to " + "/versions/revert-requests/{requestId}. Once the request is completed, the client is expected to issue a DELETE request to " + "/versions/revert-requests/{requestId}. " + NON_GUARANTEED_ENDPOINT, authorizations = { @Authorization(value = "Read - /process-groups/{uuid}"), @Authorization(value = "Write - /process-groups/{uuid}"), @Authorization(value = "Read - /{component-type}/{uuid} - For all encapsulated components"), @Authorization(value = "Write - /{component-type}/{uuid} - For all encapsulated components"), @Authorization(value = "Write - if the template contains any restricted components - /restricted-components") }) @ApiResponses(value = { @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), @ApiResponse(code = 401, message = "Client could not be authenticated."), @ApiResponse(code = 403, message = "Client is not authorized to make this request."), @ApiResponse(code = 404, message = "The specified resource could not be found."), @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") }) public Response initiateRevertFlowVersion( @ApiParam("The process group id.") @PathParam("id") final String groupId, @ApiParam(value = "The controller service configuration details.", required = true) final VersionControlInformationEntity requestEntity) throws IOException { // Verify the request final RevisionDTO revisionDto = requestEntity.getProcessGroupRevision(); if (revisionDto == null) { throw new IllegalArgumentException("Process Group Revision must be specified"); } final VersionControlInformationDTO requestVersionControlInfoDto = requestEntity .getVersionControlInformation(); if (requestVersionControlInfoDto == null) { throw new IllegalArgumentException("Version Control Information must be supplied."); } if (requestVersionControlInfoDto.getGroupId() == null) { throw new IllegalArgumentException("The Process Group ID must be supplied."); } if (!requestVersionControlInfoDto.getGroupId().equals(groupId)) { throw new IllegalArgumentException( "The Process Group ID in the request body does not match the Process Group ID of the requested resource."); } if (requestVersionControlInfoDto.getBucketId() == null) { throw new IllegalArgumentException("The Bucket ID must be supplied."); } if (requestVersionControlInfoDto.getFlowId() == null) { throw new IllegalArgumentException("The Flow ID must be supplied."); } if (requestVersionControlInfoDto.getRegistryId() == null) { throw new IllegalArgumentException("The Registry ID must be supplied."); } if (requestVersionControlInfoDto.getVersion() == null) { throw new IllegalArgumentException("The Version of the flow must be supplied."); } if (isDisconnectedFromCluster()) { verifyDisconnectedNodeModification(requestEntity.isDisconnectedNodeAcknowledged()); } // We will perform the updating of the Versioned Flow in a background thread because it can be a long-running process. // In order to do this, we will need some parameters that are only available as Thread-Local variables to the current // thread, so we will gather the values for these parameters up front. final boolean replicateRequest = isReplicateRequest(); final ComponentLifecycle componentLifecycle = replicateRequest ? clusterComponentLifecycle : localComponentLifecycle; final NiFiUser user = NiFiUserUtils.getNiFiUser(); // Step 0: Get the Versioned Flow Snapshot from the Flow Registry final VersionedFlowSnapshot flowSnapshot = serviceFacade .getVersionedFlowSnapshot(requestEntity.getVersionControlInformation(), true); // The flow in the registry may not contain the same versions of components that we have in our flow. As a result, we need to update // the flow snapshot to contain compatible bundles. serviceFacade.discoverCompatibleBundles(flowSnapshot.getFlowContents()); // Step 1: Determine which components will be affected by updating the version final Set<AffectedComponentEntity> affectedComponents = serviceFacade .getComponentsAffectedByVersionChange(groupId, flowSnapshot); // build a request wrapper final InitiateChangeFlowVersionRequestWrapper requestWrapper = new InitiateChangeFlowVersionRequestWrapper( requestEntity, componentLifecycle, getAbsolutePath(), affectedComponents, replicateRequest, flowSnapshot); final Revision requestRevision = getRevision(requestEntity.getProcessGroupRevision(), groupId); return withWriteLock(serviceFacade, requestWrapper, requestRevision, lookup -> { // Step 2: Verify READ and WRITE permissions for user, for every component. final ProcessGroupAuthorizable groupAuthorizable = lookup.getProcessGroup(groupId); authorizeProcessGroup(groupAuthorizable, authorizer, lookup, RequestAction.READ, true, false, true, true); authorizeProcessGroup(groupAuthorizable, authorizer, lookup, RequestAction.WRITE, true, false, true, true); final VersionedProcessGroup groupContents = flowSnapshot.getFlowContents(); final Set<ConfigurableComponent> restrictedComponents = FlowRegistryUtils .getRestrictedComponents(groupContents, serviceFacade); restrictedComponents.forEach(restrictedComponent -> { final ComponentAuthorizable restrictedComponentAuthorizable = lookup .getConfigurableComponent(restrictedComponent); authorizeRestrictions(authorizer, restrictedComponentAuthorizable); }); }, () -> { // Step 3: Verify that all components in the snapshot exist on all nodes // Step 4: Verify that Process Group is already under version control. If not, must start Version Control instead of updating flow serviceFacade.verifyCanRevertLocalModifications(groupId, flowSnapshot); }, (revision, wrapper) -> { final VersionControlInformationEntity versionControlInformationEntity = wrapper .getVersionControlInformationEntity(); final VersionControlInformationDTO versionControlInformationDTO = versionControlInformationEntity .getVersionControlInformation(); // Ensure that the information passed in is correct final VersionControlInformationEntity currentVersionEntity = serviceFacade .getVersionControlInformation(groupId); if (currentVersionEntity == null) { throw new IllegalStateException( "Process Group cannot be reverted to the previous version of the flow because Process Group is not under Version Control."); } final VersionControlInformationDTO currentVersion = currentVersionEntity.getVersionControlInformation(); if (!currentVersion.getBucketId().equals(versionControlInformationDTO.getBucketId())) { throw new IllegalArgumentException( "The Version Control Information provided does not match the flow that the Process Group is currently synchronized with."); } if (!currentVersion.getFlowId().equals(versionControlInformationDTO.getFlowId())) { throw new IllegalArgumentException( "The Version Control Information provided does not match the flow that the Process Group is currently synchronized with."); } if (!currentVersion.getRegistryId().equals(versionControlInformationDTO.getRegistryId())) { throw new IllegalArgumentException( "The Version Control Information provided does not match the flow that the Process Group is currently synchronized with."); } if (!currentVersion.getVersion().equals(versionControlInformationDTO.getVersion())) { throw new IllegalArgumentException( "The Version Control Information provided does not match the flow that the Process Group is currently synchronized with."); } final String idGenerationSeed = getIdGenerationSeed().orElse(null); // Create an asynchronous request that will occur in the background, because this request may // result in stopping components, which can take an indeterminate amount of time. final String requestId = UUID.randomUUID().toString(); final AsynchronousWebRequest<VersionControlInformationEntity> request = new StandardAsynchronousWebRequest<>( requestId, groupId, user, "Stopping Affected Processors"); // Submit the request to be performed in the background final Consumer<AsynchronousWebRequest<VersionControlInformationEntity>> updateTask = vcur -> { try { final VersionControlInformationEntity updatedVersionControlEntity = updateFlowVersion(groupId, wrapper.getComponentLifecycle(), wrapper.getExampleUri(), wrapper.getAffectedComponents(), wrapper.isReplicateRequest(), revision, versionControlInformationEntity, wrapper.getFlowSnapshot(), request, idGenerationSeed, false, true); vcur.markComplete(updatedVersionControlEntity); } catch (final ResumeFlowException rfe) { // Treat ResumeFlowException differently because we don't want to include a message that we couldn't update the flow // since in this case the flow was successfully updated - we just couldn't re-enable the components. logger.error(rfe.getMessage(), rfe); vcur.setFailureReason(rfe.getMessage()); } catch (final Exception e) { logger.error("Failed to update flow to new version", e); vcur.setFailureReason("Failed to update flow to new version due to " + e.getMessage()); } }; requestManager.submitRequest("revert-requests", requestId, request, updateTask); // Generate the response. final VersionedFlowUpdateRequestDTO updateRequestDto = new VersionedFlowUpdateRequestDTO(); updateRequestDto.setComplete(request.isComplete()); updateRequestDto.setFailureReason(request.getFailureReason()); updateRequestDto.setLastUpdated(request.getLastUpdated()); updateRequestDto.setProcessGroupId(groupId); updateRequestDto.setRequestId(requestId); updateRequestDto.setState(request.getState()); updateRequestDto.setPercentCompleted(request.getPercentComplete()); updateRequestDto.setUri(generateResourceUri("versions", "revert-requests", requestId)); final VersionedFlowUpdateRequestEntity updateRequestEntity = new VersionedFlowUpdateRequestEntity(); final RevisionDTO groupRevision = serviceFacade.getProcessGroup(groupId).getRevision(); updateRequestEntity.setProcessGroupRevision(groupRevision); updateRequestEntity.setRequest(updateRequestDto); return generateOkResponse(updateRequestEntity).build(); }); }
From source file:jp.co.opentone.bsol.linkbinder.service.correspon.impl.LearningTagServiceImpl.java
@Override public void saveLearningTags(Correspon correspon) throws ServiceAbortException { List<LearningTag> tags = correspon.getLearningTag(); Set<LearningTag> deleteCandidateTags = new HashSet<>(); LearningTagDao dao = getDao(LearningTagDao.class); CorresponLearningTagDao ctDao = getDao(CorresponLearningTagDao.class); try {/*from w w w . ja v a 2 s .c om*/ List<CorresponLearningTag> exists = ctDao.findByCorresponId(correspon.getId()); // ?????????? for (CorresponLearningTag ct : exists) { LearningTag found = (LearningTag) CollectionUtils.find(tags, o -> ((LearningTag) o).getId().equals(ct.getTagId())); if (found == null) { ctDao.delete(ct); LearningTag t = new LearningTag(); t.setId(ct.getTagId()); deleteCandidateTags.add(t); } } // ?? for (LearningTag t : correspon.getLearningTag()) { if (t.getId() < 0) { t.setCreatedBy(getCurrentUser()); t.setUpdatedBy(getCurrentUser()); Long id = dao.create(t); t.setId(id); } // ? CorresponLearningTag found = (CorresponLearningTag) CollectionUtils.find(exists, o -> ((CorresponLearningTag) o).getTagId().equals(t.getId())); if (found == null) { CorresponLearningTag ct = new CorresponLearningTag(); ct.setCorresponId(correspon.getId()); ct.setTagId(t.getId()); ct.setCreatedBy(getCurrentUser()); ct.setUpdatedBy(getCurrentUser()); ctDao.create(ct); } } // ????????? deleteCandidateTags.forEach(dao::deleteIfUnused); } catch (StaleRecordException e) { throw new ServiceAbortException( ApplicationMessageCode.CANNOT_PERFORM_BECAUSE_CORRESPON_ALREADY_UPDATED); } catch (KeyDuplicateException e) { throw new ServiceAbortException(e); } }
From source file:org.hawkular.inventory.impl.tinkerpop.test.BasicTest.java
@Test public void testRelationshipServiceNamed2() throws Exception { Set<Relationship> contains = inventory.tenants().get("com.example.tenant").environments().get("test") .relationships().named("contains").entities(); assert contains.stream().anyMatch(rel -> "playroom1" .equals(rel.getTarget().getId())) : "Environment 'test' must contain 'playroom1'."; assert contains.stream().anyMatch(rel -> "playroom2" .equals(rel.getTarget().getId())) : "Environment 'test' must contain 'playroom2'."; assert contains.stream().anyMatch(rel -> "playroom2_size" .equals(rel.getTarget().getId())) : "Environment 'test' must contain 'playroom2_size'."; assert contains.stream().anyMatch(rel -> "playroom1_size" .equals(rel.getTarget().getId())) : "Environment 'test' must contain 'playroom1_size'."; assert contains.stream().allMatch(rel -> !"production".equals( rel.getSource().getId())) : "Environment 'production' cant be the source of these relationships."; contains.forEach((r) -> { assert r.getId() != null; });//from w ww . jav a2s . c o m }
From source file:nu.yona.server.device.service.DeviceServiceTestConfiguration.java
private void removeDuplicateDefaultDevicesFirstOrSecond(int indexToRetain) { // Add devices String deviceName1 = "First"; OperatingSystem operatingSystem1 = OperatingSystem.ANDROID; LocalDateTime startTime = TimeUtil.utcNow(); UserDevice device1 = addDeviceToRichard(0, deviceName1, operatingSystem1); ActivityData activity1 = new ActivityData("WhatsApp", 10, 2); ActivityData activity2 = new ActivityData("WhatsApp", 5, 1); Set<Activity> device1Activities = addActivities(device1, startTime, activity1, activity2); String deviceName2 = "Second"; OperatingSystem operatingSystem2 = OperatingSystem.IOS; ActivityData activity3 = new ActivityData("WhatsApp", 9, 2); ActivityData activity4 = new ActivityData("WhatsApp", 3, 1); UserDevice device2 = addDeviceToRichard(0, deviceName2, operatingSystem2); Set<Activity> device2Activities = addActivities(device2, startTime, activity3, activity4); List<UserDevice> createdDevices = Arrays.asList(device1, device2); // Verify two devices are present Set<UserDevice> devices = richard.getDevices(); assertThat(devices.stream().map(UserDevice::getName).collect(Collectors.toSet()), containsInAnyOrder(deviceName1, deviceName2)); service.removeDuplicateDefaultDevices(createRichardUserDto(), createdDevices.get(indexToRetain).getId()); // Assert success assertThat(devices.stream().map(UserDevice::getName).collect(Collectors.toSet()), containsInAnyOrder(createdDevices.get(indexToRetain).getName())); device1Activities.forEach(a -> assertThat(a.getDeviceAnonymized().get(), sameInstance(createdDevices.get(indexToRetain).getDeviceAnonymized()))); device2Activities.forEach(a -> assertThat(a.getDeviceAnonymized().get(), sameInstance(createdDevices.get(indexToRetain).getDeviceAnonymized()))); }
From source file:org.eclipse.che.git.impl.jgit.JGitConnection.java
/** To add deleted files in index it is required to perform git rm on them */ private void addDeletedFilesToIndex(List<String> filePatterns) throws GitAPIException { Set<String> deletedFiles = getGit().status().call().getMissing(); if (!deletedFiles.isEmpty()) { RmCommand rmCommand = getGit().rm(); if (filePatterns.contains(".")) { deletedFiles.forEach(rmCommand::addFilepattern); } else {/*from ww w.ja va 2 s . c o m*/ filePatterns.forEach(filePattern -> deletedFiles.stream() .filter(deletedFile -> deletedFile.startsWith(filePattern)) .forEach(rmCommand::addFilepattern)); } rmCommand.call(); } }
From source file:org.wso2.carbon.apimgt.core.impl.APIPublisherImpl.java
/** * Notify each registered {@link org.wso2.carbon.apimgt.core.api.EventObserver}. * This calls/*w w w . ja v a 2 s.c om*/ * {@link org.wso2.carbon.apimgt.core.api.EventObserver#captureEvent(Event, String, ZonedDateTime, Map)} * method of that {@link org.wso2.carbon.apimgt.core.api.EventObserver}. * <p> * {@inheritDoc} */ @Override public void notifyObservers(Event event, String username, ZonedDateTime eventTime, Map<String, String> metaData) { Set<Map.Entry<String, EventObserver>> eventObserverEntrySet = eventObservers.entrySet(); eventObserverEntrySet.forEach(eventObserverEntry -> eventObserverEntry.getValue().captureEvent(event, username, eventTime, metaData)); }
From source file:jp.co.opentone.bsol.linkbinder.service.correspon.impl.LearningLabelServiceImpl.java
@Override public void saveLearningLabels(Correspon correspon) throws ServiceAbortException { List<LearningLabel> labels = correspon.getLearningLabel(); Set<LearningLabel> deleteCandidateLabels = new HashSet<>(); LearningLabelDao dao = getDao(LearningLabelDao.class); CorresponLearningLabelDao clDao = getDao(CorresponLearningLabelDao.class); try {// w w w. j a v a2 s. c o m List<CorresponLearningLabel> exists = clDao.findByCorresponId(correspon.getId()); // ?????????? for (CorresponLearningLabel cl : exists) { LearningLabel found = (LearningLabel) CollectionUtils.find(labels, o -> ((LearningLabel) o).getId().equals(cl.getLabelId())); if (found == null) { clDao.delete(cl); LearningLabel l = new LearningLabel(); l.setId(cl.getLabelId()); deleteCandidateLabels.add(l); } } // ?? for (LearningLabel l : correspon.getLearningLabel()) { if (l.getId() < 0) { l.setCreatedBy(getCurrentUser()); l.setUpdatedBy(getCurrentUser()); Long id = dao.create(l); l.setId(id); } // ? CorresponLearningLabel found = (CorresponLearningLabel) CollectionUtils.find(exists, o -> ((CorresponLearningLabel) o).getLabelId().equals(l.getId())); if (found == null) { CorresponLearningLabel cl = new CorresponLearningLabel(); cl.setCorresponId(correspon.getId()); cl.setLabelId(l.getId()); cl.setCreatedBy(getCurrentUser()); cl.setUpdatedBy(getCurrentUser()); clDao.create(cl); } } // ????????? deleteCandidateLabels.forEach(dao::deleteIfUnused); } catch (StaleRecordException e) { throw new ServiceAbortException( ApplicationMessageCode.CANNOT_PERFORM_BECAUSE_CORRESPON_ALREADY_UPDATED); } catch (KeyDuplicateException e) { throw new ServiceAbortException(e); } }
From source file:org.apache.storm.daemon.worker.WorkerState.java
public void refreshConnections() { Assignment assignment = null;//from ww w . j av a 2 s .c o m try { assignment = getLocalAssignment(stormClusterState, topologyId); } catch (Exception e) { LOG.warn("Failed to read assignment. This should only happen when topology is shutting down.", e); } Set<NodeInfo> neededConnections = new HashSet<>(); Map<Integer, NodeInfo> newTaskToNodePort = new HashMap<>(); if (null != assignment) { Map<Integer, NodeInfo> taskToNodePort = StormCommon.taskToNodeport(assignment.get_executor_node_port()); for (Map.Entry<Integer, NodeInfo> taskToNodePortEntry : taskToNodePort.entrySet()) { Integer task = taskToNodePortEntry.getKey(); if (outboundTasks.contains(task)) { newTaskToNodePort.put(task, taskToNodePortEntry.getValue()); if (!localTaskIds.contains(task)) { neededConnections.add(taskToNodePortEntry.getValue()); } } } } Set<NodeInfo> currentConnections = cachedNodeToPortSocket.get().keySet(); Set<NodeInfo> newConnections = Sets.difference(neededConnections, currentConnections); Set<NodeInfo> removeConnections = Sets.difference(currentConnections, neededConnections); Map<String, String> nodeHost = assignment != null ? assignment.get_node_host() : null; // Add new connections atomically cachedNodeToPortSocket.getAndUpdate(prev -> { Map<NodeInfo, IConnection> next = new HashMap<>(prev); for (NodeInfo nodeInfo : newConnections) { next.put(nodeInfo, mqContext.connect(topologyId, //nodeHost is not null here, as newConnections is only non-empty if assignment was not null above. nodeHost.get(nodeInfo.get_node()), // Host nodeInfo.get_port().iterator().next().intValue(), // Port workerTransfer.getRemoteBackPressureStatus())); } return next; }); try { endpointSocketLock.writeLock().lock(); cachedTaskToNodePort.set(newTaskToNodePort); } finally { endpointSocketLock.writeLock().unlock(); } for (NodeInfo nodeInfo : removeConnections) { cachedNodeToPortSocket.get().get(nodeInfo).close(); } // Remove old connections atomically cachedNodeToPortSocket.getAndUpdate(prev -> { Map<NodeInfo, IConnection> next = new HashMap<>(prev); removeConnections.forEach(next::remove); return next; }); }
From source file:org.apache.zookeeper.MockZooKeeper.java
@Override public void create(final String path, final byte[] data, final List<ACL> acl, CreateMode createMode, final StringCallback cb, final Object ctx) { if (stopped) { cb.processResult(KeeperException.Code.CONNECTIONLOSS.intValue(), path, ctx, null); return;/*from w ww. j a v a 2 s .co m*/ } final Set<Watcher> toNotifyCreate = Sets.newHashSet(); toNotifyCreate.addAll(watchers.get(path)); final Set<Watcher> toNotifyParent = Sets.newHashSet(); final String parent = path.substring(0, path.lastIndexOf("/")); if (!parent.isEmpty()) { toNotifyParent.addAll(watchers.get(parent)); } watchers.removeAll(path); executor.execute(() -> { mutex.lock(); if (getProgrammedFailStatus()) { mutex.unlock(); cb.processResult(failReturnCode.intValue(), path, ctx, null); } else if (stopped) { mutex.unlock(); cb.processResult(KeeperException.Code.CONNECTIONLOSS.intValue(), path, ctx, null); } else if (tree.containsKey(path)) { mutex.unlock(); cb.processResult(KeeperException.Code.NODEEXISTS.intValue(), path, ctx, null); } else if (!parent.isEmpty() && !tree.containsKey(parent)) { mutex.unlock(); cb.processResult(KeeperException.Code.NONODE.intValue(), path, ctx, null); } else { tree.put(path, Pair.of(data, 0)); mutex.unlock(); cb.processResult(0, path, ctx, null); toNotifyCreate.forEach(watcher -> watcher .process(new WatchedEvent(EventType.NodeCreated, KeeperState.SyncConnected, path))); toNotifyParent.forEach(watcher -> watcher.process( new WatchedEvent(EventType.NodeChildrenChanged, KeeperState.SyncConnected, parent))); } }); }
From source file:io.gravitee.repository.redis.management.internal.impl.EventRedisRepositoryImpl.java
@Override public Page<RedisEvent> search(EventCriteria filter, Pageable pageable) { Set<String> filterKeys = new HashSet<>(); String tempDestination = "tmp-" + Math.abs(filter.hashCode()); // Implement OR clause for event type if (!filter.getTypes().isEmpty()) { filter.getTypes().forEach(type -> filterKeys.add(REDIS_KEY + ":type:" + type)); redisTemplate.opsForZSet().unionAndStore(null, filterKeys, tempDestination); filterKeys.clear();//from w ww . ja va 2 s . c om filterKeys.add(tempDestination); } // Add clause based on event properties Set<String> internalUnionFilter = new HashSet<>(); filter.getProperties().forEach((propertyKey, propertyValue) -> { if (propertyValue instanceof Collection) { Set<String> collectionFilter = new HashSet<>(((Collection) propertyValue).size()); String collectionTempDestination = "tmp-" + propertyKey + ":" + propertyValue.hashCode(); ((Collection) propertyValue) .forEach(value -> collectionFilter.add(REDIS_KEY + ":" + propertyKey + ":" + value)); redisTemplate.opsForZSet().unionAndStore(null, collectionFilter, collectionTempDestination); internalUnionFilter.add(collectionTempDestination); filterKeys.add(collectionTempDestination); } else { filterKeys.add(REDIS_KEY + ":" + propertyKey + ":" + propertyValue); } }); // And finally add clause based on event update date filterKeys.add(REDIS_KEY + ":updated_at"); redisTemplate.opsForZSet().intersectAndStore(null, filterKeys, tempDestination); Set<Object> keys; if (filter.getFrom() != 0 && filter.getTo() != 0) { if (pageable != null) { keys = redisTemplate.opsForZSet().reverseRangeByScore(tempDestination, filter.getFrom(), filter.getTo(), pageable.from(), pageable.pageSize()); } else { keys = redisTemplate.opsForZSet().reverseRangeByScore(tempDestination, filter.getFrom(), filter.getTo()); } } else { if (pageable != null) { keys = redisTemplate.opsForZSet().reverseRangeByScore(tempDestination, 0, Long.MAX_VALUE, pageable.from(), pageable.pageSize()); } else { keys = redisTemplate.opsForZSet().reverseRangeByScore(tempDestination, 0, Long.MAX_VALUE); } } redisTemplate.opsForZSet().removeRange(tempDestination, 0, -1); internalUnionFilter.forEach(dest -> redisTemplate.opsForZSet().removeRange(dest, 0, -1)); List<Object> eventObjects = redisTemplate.opsForHash().multiGet(REDIS_KEY, keys); return new Page<>( eventObjects.stream().map(event -> convert(event, RedisEvent.class)).collect(Collectors.toList()), (pageable != null) ? pageable.pageNumber() : 0, (pageable != null) ? pageable.pageSize() : 0, keys.size()); }