public boolean onDemandUpdate() {
        if (rateLimiter.acquire(burstSize, allowedRatePerMinute)) {
            if (!scheduler.isShutdown()) {
                scheduler.submit(new Runnable() {
                    @Override
                    public void run() {
                        logger.debug("Executing on-demand update of local InstanceInfo");
    
                        Future latestPeriodic = scheduledPeriodicRef.get();
                        if (latestPeriodic != null && !latestPeriodic.isDone()) {
                            logger.debug("Canceling the latest scheduled update, it will be rescheduled at the end of on demand update");
                            latestPeriodic.cancel(false);
                        }
    
                        InstanceInfoReplicator.this.run();
                    }
                });
                return true;
            } else {
                logger.warn("Ignoring onDemand update due to stopped scheduler");
                return false;
            }
        } else {
            logger.warn("Ignoring onDemand update due to rate limiter");
            return false;
        }
    }
@Test
    public void testOnDemandUpdateRateLimiting() throws Throwable {
        assertTrue(replicator.onDemandUpdate());
        Thread.sleep(10);  // give some time for execution
        assertTrue(replicator.onDemandUpdate());
        Thread.sleep(10);  // give some time for execution
        assertFalse(replicator.onDemandUpdate());
        Thread.sleep(1000);

        verify(discoveryClient, times(2)).refreshInstanceInfo();
        verify(discoveryClient, times(1)).register();
    }