class HostQuotaEnforcer extends Processor {

    protected ServerCache serverCache;
    public ServerCache getServerCache() {
        return this.serverCache;
    }
    @Autowired
    public void setServerCache(ServerCache serverCache) {
        this.serverCache = serverCache;
    }

    protected String host;
    public String getHost() {
        return host;
    }
    public void setHost(String host) {
        this.host = host;
    }

    protected boolean applyToSubdomains = false;
    public boolean getApplyToSubdomains() {
        return applyToSubdomains;
    }
    /**
     * Whether to apply the quotas to each subdomain of {@link #host}
     * (separately, not cumulatively).
     */
    public void setApplyToSubdomains(boolean applyToSubdomains) {
        this.applyToSubdomains = applyToSubdomains;
    }

    protected Map<String,Long> quotas = new HashMap<String, Long>();
    public Map<String, Long> getQuotas() {
        return quotas;
    }
    /**
     * Keys can be any of the {@link FetchStats} keys.
     */
    public void setQuotas(Map<String, Long> quotas) {
        this.quotas = quotas;
    }

    @Override
    protected boolean shouldProcess(CrawlURI curi) {<FILL_FUNCTION_BODY>}

    @Override
    protected void innerProcess(CrawlURI curi) throws InterruptedException {
        throw new AssertionError();
    }

    @Override
    protected ProcessResult innerProcessResult(CrawlURI curi) throws InterruptedException {
        if (!shouldProcess(curi)) {
            return ProcessResult.PROCEED;
        }

        final CrawlHost host = serverCache.getHostFor(curi.getUURI());

        for (String k: quotas.keySet()) {
            if (host.getSubstats().get(k) >= quotas.get(k)) {
                curi.getAnnotations().add("hostQuota:" + k);
                curi.setFetchStatus(FetchStatusCodes.S_BLOCKED_BY_QUOTA);
                return ProcessResult.FINISH;
            }
        }

        return ProcessResult.PROCEED;
    }

}

        String uriHostname = serverCache.getHostFor(curi.getUURI()).getHostName();
        if (getApplyToSubdomains() && InternetDomainName.isValid(host) && InternetDomainName.isValid(uriHostname)) {
            InternetDomainName h = InternetDomainName.from(host);
            InternetDomainName uriHostOrAncestor = InternetDomainName.from(uriHostname);
            while (true) {
                if (uriHostOrAncestor.equals(h)) {
                    return true;
                }
                if (uriHostOrAncestor.hasParent()) {
                    uriHostOrAncestor = uriHostOrAncestor.parent();
                } else {
                    break;
                }
            }

            return false;
        } else {
            return serverCache.getHostFor(curi.getUURI()) == serverCache.getHostFor(host);
        }

    
<methods>public non-sealed void <init>() ,public void doCheckpoint(org.archive.checkpointing.Checkpoint) throws java.io.IOException,public void finishCheckpoint(org.archive.checkpointing.Checkpoint) ,public static java.lang.String flattenVia(org.archive.modules.CrawlURI) ,public java.lang.String getBeanName() ,public boolean getEnabled() ,public org.archive.spring.KeyedProperties getKeyedProperties() ,public static long getRecordedSize(org.archive.modules.CrawlURI) ,public org.archive.modules.deciderules.DecideRule getShouldProcessRule() ,public long getURICount() ,public static boolean hasHttpAuthenticationCredential(org.archive.modules.CrawlURI) ,public boolean isRunning() ,public static boolean isSuccess(org.archive.modules.CrawlURI) ,public org.archive.modules.ProcessResult process(org.archive.modules.CrawlURI) throws java.lang.InterruptedException,public java.lang.String report() ,public void setBeanName(java.lang.String) ,public void setEnabled(boolean) ,public void setRecoveryCheckpoint(org.archive.checkpointing.Checkpoint) ,public void setShouldProcessRule(org.archive.modules.deciderules.DecideRule) ,public void start() ,public void startCheckpoint(org.archive.checkpointing.Checkpoint) ,public void stop() <variables>protected java.lang.String beanName,protected boolean isRunning,protected org.archive.spring.KeyedProperties kp,protected org.archive.checkpointing.Checkpoint recoveryCheckpoint,protected java.util.concurrent.atomic.AtomicLong uriCount