org.apache.curator.framework.recipes.locks.StandardLockInternalsDriver Java Examples

The following examples show how to use org.apache.curator.framework.recipes.locks.StandardLockInternalsDriver. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClusterStateHolder.java    From hermes with Apache License 2.0 6 votes vote down vote up
private void updateLeaderInfo() {
	List<ChildData> children = m_leaderLatchPathChildrenCache.getCurrentData();

	if (children != null && !children.isEmpty()) {
		List<String> childrenNames = new ArrayList<>(children.size());
		Map<String, byte[]> nameDataMapping = new HashMap<>(children.size());
		for (ChildData child : children) {
			if (child.getData() != null && child.getData().length > 0) {
				String name = ZKPathUtils.lastSegment(child.getPath());
				childrenNames.add(name);
				nameDataMapping.put(name, child.getData());
			}
		}

		List<String> sortedChildren = LockInternals.getSortedChildren("latch-", new LockInternalsSorter() {

			@Override
			public String fixForSorting(String str, String lockName) {
				return StandardLockInternalsDriver.standardFixForSorting(str, lockName);
			}
		}, childrenNames);

		m_leader.set(ZKSerializeUtils.deserialize(nameDataMapping.get(sortedChildren.get(0)), HostPort.class));
	}
}
 
Example #2
Source File: DefaultKeeperElectorManager.java    From x-pipe with Apache License 2.0 4 votes vote down vote up
@Override
public String fixForSorting(String str, String lockName) {
	return StandardLockInternalsDriver.standardFixForSorting(str, lockName);
}
 
Example #3
Source File: AbstractLeaderElector.java    From x-pipe with Apache License 2.0 4 votes vote down vote up
@Override
public String fixForSorting(String str, String lockName) {
    return StandardLockInternalsDriver.standardFixForSorting(str, lockName);
}