public void submitLoggingTask(Collection<Member> connectedMembers, Collection<Member> allMembers) {
        if (delayPeriodSeconds <= 0) {
            return;
        }

        if ((submittedLoggingTask != null && !submittedLoggingTask.isDone())) {
            submittedLoggingTask.cancel(true);
        }

        submittedLoggingTask = executor.schedule(()
                        -> logger.info(connectivityLog(connectedMembers, allMembers)),
                delayPeriodSeconds, SECONDS);

    }
@Test
    void assertTaskCancelledIfSubmittedDuringRunningTask() {
        ScheduledFuture mockFuture = mock(ScheduledFuture.class);
        List<Member> mockMembers = createMockMembers(2);
        HazelcastProperties hzProps = createMockProperties(10);
        ClientConnectivityLogger clientConnectivityLogger = new ClientConnectivityLogger(loggingService, executor, hzProps);
        when(executor.schedule((Runnable) any(), anyLong(), any())).thenReturn(mockFuture);
        clientConnectivityLogger.submitLoggingTask(List.of(mockMembers.get(0)), mockMembers);
        //submit another task while the first one is running
        clientConnectivityLogger.submitLoggingTask(List.of(mockMembers.get(0)), mockMembers);
        verify(mockFuture, times(1)).cancel(true);

        verify(executor, times(2)).schedule((Runnable) any(), anyLong(), any());
    }