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

com.github.andyshaox.zk.election.ZkMasterElectAlgorithm Maven / Gradle / Ivy

There is a newer version: 1.0.0.RELEASE
Show newest version
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