![JAR search and dependency download from the Maven repository](/logo.png)
com.github.andyshaox.zk.election.ZkMasterElectAlgorithm Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of GearEE-ZK Show documentation
Show all versions of GearEE-ZK Show documentation
GearEE for Zookeeper support
package com.github.andyshaox.zk.election;
import java.util.List;
import java.util.Optional;
import com.github.andyshao.distribution.election.ElectionNode;
import com.github.andyshao.distribution.election.MasterElectAlgorithm;
import com.github.andyshao.lang.StringOperation;
/**
*
* Title:
* Descript:
* Copyright: Copryright(c) Mar 28, 2018
* Encoding: UNIX UTF-8
* @author weichuang.shao
*
*/
public class ZkMasterElectAlgorithm implements MasterElectAlgorithm {
@Override
public Optional findMaster(List nodes) {
return nodes.stream()
.filter(item -> item != null)
.filter(item -> !(item.getName() == null || item.getName().trim().isEmpty()))
.sorted((left, right) -> StringOperation.COMPARATOR.compare(left.getName() , right.getName()))
.findFirst();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy