class ApplicationCellRouter implements CellRouter {

    @Override
    public Optional<Cell> routeKey(JobDescriptor jobDescriptor) {
        Optional<Cell> pinnedCell = getCellPinnedToJob(jobDescriptor);
        if (pinnedCell.isPresent()) {
            return pinnedCell;
        }

        String routeKey = routeKeyFor(jobDescriptor);
        Set<String> antiAffinityNames = StringExt.splitByCommaIntoSet(
                jobDescriptor.getAttributesMap().get(JobAttributes.JOB_PARAMETER_ATTRIBUTES_CELL_AVOID)
        );

        Optional<Cell> found = selector.select(routeKey, cell -> !antiAffinityNames.contains(cell.getName()));
        if (found.isPresent()) {
            return found;
        }

        // fallback to any cell that is not in the anti affinity list, or the default when all available cells are rejected
        return cellInfoResolver.resolve().stream()
                .filter(cell -> !antiAffinityNames.contains(cell.getName()))
                .findAny();
    }

    public  ApplicationCellRouter(CellInfoResolver cellInfoResolver, TitusFederationConfiguration federationConfiguration);

}