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

de.mklinger.qetcher.client.impl.lookup.NodeLookupQetcherClientImpl Maven / Gradle / Ivy

There is a newer version: 2.0.42.rc
Show newest version
package de.mklinger.qetcher.client.impl.lookup;

import de.mklinger.micro.closeables.Closeables;
import de.mklinger.qetcher.client.impl.QetcherClientBuilderImpl;
import de.mklinger.qetcher.client.impl.retry.RetryingQetcherClientImpl;

/**
 * @author Marc Klinger - mklinger[at]mklinger[dot]de
 */
public class NodeLookupQetcherClientImpl extends RetryingQetcherClientImpl {
	private final ScheduledNodesLookup nodesLookup;

	public NodeLookupQetcherClientImpl(final QetcherClientBuilderImpl builder) {
		super(builder, newDynamicServiceUriSupplier(builder));
		this.nodesLookup = new ScheduledNodesLookup(
				this,
				getServiceUriSupplier().getNodesHolder());
		this.nodesLookup.startDelayed();
	}

	private static ServiceUriSupplier newDynamicServiceUriSupplier(final QetcherClientBuilderImpl builder) {
		return new DynamicServiceUriSupplier(builder.getServiceUris());
	}

	@Override
	public DynamicServiceUriSupplier getServiceUriSupplier() {
		return (DynamicServiceUriSupplier) super.getServiceUriSupplier();
	}

	@Override
	public void close() {
		Closeables.closeUnchecked(nodesLookup, super::close);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy