@Test public void removeOrphanSubscription_whenManyPresent() { final Connector connector = createConnector(); newConnection( connector ); pauseScheduler(); connector.pauseMessageScheduler(); final ChannelAddress address = new ChannelAddress( 1, 0 ); safeAction( () -> { Replicant.context().createOrUpdateAreaOfInterest( new ChannelAddress( 1, 1, 1 ), null ); Replicant.context().createOrUpdateAreaOfInterest( new ChannelAddress( 1, 1, 2 ), null ); Replicant.context().createOrUpdateAreaOfInterest( new ChannelAddress( 1, 1, 3 ), null ); Replicant.context().createOrUpdateAreaOfInterest( new ChannelAddress( 1, 1, 4 ), null ); Replicant.context().createOrUpdateAreaOfInterest( new ChannelAddress( 1, 1, 5 ), null ); final Subscription subscription = createSubscription( address, null, true ); connector.setState( ConnectorState.CONNECTED ); final TestSpyEventHandler handler = registerTestSpyEventHandler(); Replicant.context().getConverger().removeOrphanSubscriptions(); final List<AreaOfInterestRequest> requests = connector.ensureConnection().getPendingAreaOfInterestRequests(); assertEquals( requests.size(), 1 ); final AreaOfInterestRequest request = requests.get( 0 ); assertEquals( request.getType(), AreaOfInterestRequest.Type.REMOVE ); assertEquals( request.getAddress(), address ); handler.assertEventCount( 2 ); handler.assertNextEvent( SubscriptionOrphanedEvent.class, e -> assertEquals( e.getSubscription(), subscription ) ); handler.assertNextEvent( UnsubscribeRequestQueuedEvent.class, e -> assertEquals( e.getAddress(), address ) ); } ); }
@arez.annotations.Action void removeOrphanSubscriptions() { final HashSet<ChannelAddress> expected = new HashSet<>(); getReplicantContext().getAreasOfInterest().forEach( aoi -> expected.add( aoi.getAddress() ) ); final SubscriptionService subscriptionService = getReplicantContext().getSubscriptionService(); removeOrphanSubscriptions( subscriptionService.getTypeSubscriptions(), expected ); removeOrphanSubscriptions( subscriptionService.getInstanceSubscriptions(), expected ); }
Converger extends ReplicantService { @arez.annotations.Action void removeOrphanSubscriptions() { final HashSet<ChannelAddress> expected = new HashSet<>(); getReplicantContext().getAreasOfInterest().forEach( aoi -> expected.add( aoi.getAddress() ) ); final SubscriptionService subscriptionService = getReplicantContext().getSubscriptionService(); removeOrphanSubscriptions( subscriptionService.getTypeSubscriptions(), expected ); removeOrphanSubscriptions( subscriptionService.getInstanceSubscriptions(), expected ); } }
Converger extends ReplicantService { @arez.annotations.Action void removeOrphanSubscriptions() { final HashSet<ChannelAddress> expected = new HashSet<>(); getReplicantContext().getAreasOfInterest().forEach( aoi -> expected.add( aoi.getAddress() ) ); final SubscriptionService subscriptionService = getReplicantContext().getSubscriptionService(); removeOrphanSubscriptions( subscriptionService.getTypeSubscriptions(), expected ); removeOrphanSubscriptions( subscriptionService.getInstanceSubscriptions(), expected ); } Converger( @Nullable final ReplicantContext context ); }
Converger extends ReplicantService { @arez.annotations.Action void removeOrphanSubscriptions() { final HashSet<ChannelAddress> expected = new HashSet<>(); getReplicantContext().getAreasOfInterest().forEach( aoi -> expected.add( aoi.getAddress() ) ); final SubscriptionService subscriptionService = getReplicantContext().getSubscriptionService(); removeOrphanSubscriptions( subscriptionService.getTypeSubscriptions(), expected ); removeOrphanSubscriptions( subscriptionService.getInstanceSubscriptions(), expected ); } Converger( @Nullable final ReplicantContext context );  }
Converger extends ReplicantService { @arez.annotations.Action void removeOrphanSubscriptions() { final HashSet<ChannelAddress> expected = new HashSet<>(); getReplicantContext().getAreasOfInterest().forEach( aoi -> expected.add( aoi.getAddress() ) ); final SubscriptionService subscriptionService = getReplicantContext().getSubscriptionService(); removeOrphanSubscriptions( subscriptionService.getTypeSubscriptions(), expected ); removeOrphanSubscriptions( subscriptionService.getInstanceSubscriptions(), expected ); } Converger( @Nullable final ReplicantContext context );   }