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

org.ehcache.exceptions.BulkCacheLoadingException Maven / Gradle / Ivy

/*
 * Copyright Terracotta, Inc.
 *
 * 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.
 */

package org.ehcache.exceptions;

import java.util.Collections;
import java.util.Map;
import org.ehcache.spi.loaderwriter.CacheLoaderWriter;

/**
 * Exception thrown by a {@link org.ehcache.Cache} when the {@link CacheLoaderWriter} it uses threw an
 * {@link java.lang.RuntimeException} while bulk loading values for a given set of keys
 *
 * @author Alex Snaps
 */
public class BulkCacheLoadingException extends CacheLoadingException {

  private static final long serialVersionUID = -5296309607929568779L;

  private final Map failures;
  private final Map successes;

  /**
   * Constructs a new BulkCacheLoadingException providing the key set that failed, including the exception loading these
   * threw, as well as all keys we managed to load a value for, including the value loaded. This latter set of keys was
   * loaded successfully into the {@link org.ehcache.Cache}.
   *
   * @param failures the map of keys to failure encountered while loading the values
   * @param successes the map of keys successfully loaded and their associated values
   */
  public BulkCacheLoadingException(final Map failures, final Map successes) {
    this.failures = Collections.unmodifiableMap(failures);
    this.successes = Collections.unmodifiableMap(successes);
  }

  /**
   * Constructs a new BulkCacheLoadingException providing a message, the key set that failed, including the exception
   * loading these threw, as well as all keys we managed to load a value for, including the value loaded. This latter
   * set of keys was loaded successfully into the {@link org.ehcache.Cache}.
   *
   * @param message the message
   * @param failures the map of keys to failure encountered while loading the values
   * @param successes the map of keys successfully loaded and their associated values
   * @see #BulkCacheLoadingException(java.util.Map, java.util.Map)
   */
  public BulkCacheLoadingException(final String message, final Map failures, final Map successes) {
    super(message);
    this.failures = Collections.unmodifiableMap(failures);
    this.successes = Collections.unmodifiableMap(successes);
  }

  /**
   * Accessor to all keys that failed loading during a bulk load operation, with the associated
   * {@link java.lang.Exception} encountered
   * @return a map of keys to exception encountered during bulk load
   */
  public Map getFailures() {
    return failures;
  }

  /**
   * Accessor to all keys that were successfully loaded during a bulk load operation, with the associated
   * loaded value
   * @return a map of keys to value loaded and installed in the {@link org.ehcache.Cache}
   */
  public Map getSuccesses() {
    return successes;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy