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

com.gemstone.gemfire.cache.CustomEvictionAttributes Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you
 * may not use this file except in compliance with the License. You
 * may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * permissions and limitations under the License. See accompanying
 * LICENSE file.
 */

package com.gemstone.gemfire.cache;

/**
 * Custom eviction attributes including {@link EvictionCriteria} and evictor
 * start time and frequency, if any.
 * 
 * @author swale
 * @since gfxd 1.0
 */
public abstract class CustomEvictionAttributes {

  private final EvictionCriteria criteria;

  private final long evictorStartTime;
  private final long evictorInterval;

  private final boolean evictIncoming;

  protected CustomEvictionAttributes(EvictionCriteria criteria,
      long startTime, long interval, boolean evictIncoming) {
    this.criteria = criteria;
    this.evictorStartTime = startTime;
    this.evictorInterval = interval;
    this.evictIncoming = evictIncoming;
  }

  /**
   * Get the {@link EvictionCriteria} for this custom eviction. The criteria
   * will be applied to the region entries either periodically as per
   * {@link #getEvictorStartTime()} and {@link #getEvictorInterval()}, or on
   * incoming puts if {@link #isEvictIncoming()} is true.
   */
  @SuppressWarnings({ "rawtypes", "unchecked" })
  public  EvictionCriteria getCriteria() {
    return (EvictionCriteria)this.criteria;
  }

  /**
   * The absolute start time in milliseconds (as returned by
   * {@link System#currentTimeMillis()}) when the evictor will be first fired.
   * Thereafter the evictor will be fired periodically every
   * {@link #getEvictorInterval()} milliseconds.
   */
  public final long getEvictorStartTime() {
    return this.evictorStartTime;
  }

  /**
   * The intervals at which the periodic evictor task is fired and
   * {@link EvictionCriteria} evaluated to evict entries.
   */
  public final long getEvictorInterval() {
    return this.evictorInterval;
  }

  /**
   * If this returns true, then the criteria should always be applied to
   * incoming entries and never as a periodic task.
   */
  public final boolean isEvictIncoming() {
    return this.evictIncoming;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy