All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vertx.up.uca.micro.discovery.EtcdEraser Maven / Gradle / Ivy

There is a newer version: 0.9.0
Show newest version
package io.vertx.up.uca.micro.discovery;

import io.vertx.servicediscovery.Record;
import io.vertx.up.util.Ut;
import io.vertx.up.runtime.Runner;

import java.util.concurrent.ConcurrentMap;

/**
 * Delete/Clean Up the service/ipc node that are not OK
 */
public class EtcdEraser {

    private static EtcdEraser INSTANCE;

    public static EtcdEraser create() {
        if (null == INSTANCE) {
            INSTANCE = new EtcdEraser();
        }
        return INSTANCE;
    }

    public void start() {
        // Services
        Runner.run(this::eraseApi, "endpoint-eraser");
        // Ipc
        Runner.run(this::eraseIpc, "ipc-eraser");
    }

    private void eraseApi() {
        final Origin origin = Ut.singleton(ApiOrigin.class);
        final ConcurrentMap records = origin.getRegistryData();
        records.forEach((key, value) -> origin.erasing(value));
    }

    private void eraseIpc() {
        final Origin origin = Ut.singleton(IpcOrigin.class);
        final ConcurrentMap records = origin.getRegistryData();
        records.forEach((key, value) -> origin.erasing(value));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy