io.appform.ranger.zookeeper.servicefinderhub.ZKUnshardedServiceFinderFactory Maven / Gradle / Ivy
/*
* Copyright 2024 Authors, Flipkart Internet Pvt. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.appform.ranger.zookeeper.servicefinderhub;
import io.appform.ranger.core.finder.SimpleUnshardedServiceFinder;
import io.appform.ranger.core.finder.serviceregistry.ListBasedServiceRegistry;
import io.appform.ranger.core.finderhub.ServiceFinderFactory;
import io.appform.ranger.core.model.Service;
import io.appform.ranger.core.model.ServiceNodeSelector;
import io.appform.ranger.core.model.ShardSelector;
import io.appform.ranger.zookeeper.serde.ZkNodeDataDeserializer;
import io.appform.ranger.zookeeper.servicefinder.ZkSimpleUnshardedServiceFinderBuilder;
import lombok.Builder;
import lombok.val;
import org.apache.curator.framework.CuratorFramework;
public class ZKUnshardedServiceFinderFactory implements ServiceFinderFactory>{
private final CuratorFramework curatorFramework;
private final String connectionString;
private final int nodeRefreshIntervalMs;
private final boolean disablePushUpdaters;
private final ZkNodeDataDeserializer deserializer;
private final ShardSelector> shardSelector;
private final ServiceNodeSelector nodeSelector;
@Builder
public ZKUnshardedServiceFinderFactory(
CuratorFramework curatorFramework,
String connectionString,
int nodeRefreshIntervalMs,
boolean disablePushUpdaters,
ZkNodeDataDeserializer deserializer,
ShardSelector> shardSelector,
ServiceNodeSelector nodeSelector) {
this.curatorFramework = curatorFramework;
this.connectionString = connectionString;
this.nodeRefreshIntervalMs = nodeRefreshIntervalMs;
this.disablePushUpdaters = disablePushUpdaters;
this.deserializer = deserializer;
this.shardSelector = shardSelector;
this.nodeSelector = nodeSelector;
}
@Override
public SimpleUnshardedServiceFinder buildFinder(Service service) {
val finder = new ZkSimpleUnshardedServiceFinderBuilder()
.withDeserializer(deserializer)
.withNamespace(service.getNamespace())
.withServiceName(service.getServiceName())
.withNodeRefreshIntervalMs(nodeRefreshIntervalMs)
.withDisableWatchers(disablePushUpdaters)
.withShardSelector(shardSelector)
.withNodeSelector(nodeSelector)
.withConnectionString(connectionString)
.withCuratorFramework(curatorFramework)
.build();
finder.start();
return finder;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy