private void createRefreshTask()

in emr-user-role-mapper-application/src/main/java/com/amazon/aws/emr/mapping/MappingInvoker.java [124:142]


    private void createRefreshTask(int refreshIntervalMins) {
        ThreadFactory threadFactory = new ThreadFactoryBuilder()
                .setNameFormat("refresh-mapping-%d")
                .setDaemon(true)
                .build();
        ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor(threadFactory);
        exec.scheduleAtFixedRate(() -> {
            writeLockInRwLock.lock();
            try {
                log.debug("Refreshing the user role mapping.");
                roleMapperProvider.refresh();
            } catch (Throwable t) {
                // We are running some custom code that could throw anything.
                log.error("Got an error while refreshing", t);
            } finally {
                writeLockInRwLock.unlock();
            }
        }, 0, refreshIntervalMins, TimeUnit.MINUTES);
    }