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

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

There is a newer version: 2.0-BETA
Show 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;

import java.io.IOException;

import com.gemstone.gemfire.internal.i18n.LocalizedStrings;

/**
 * Indicates that an IOException during a disk region operation.
 *
 * @author Darrel Schneider
 *
 *
 * @since 3.2
 */
public class DiskAccessException extends CacheRuntimeException {

  private static final long serialVersionUID = 5799100281147167888L;

  private transient boolean isRemote;

  /**
   * Constructs a new DiskAccessException.
   */
  public DiskAccessException() {
    super();
  }
  
  /**
   * Constructs a new DiskAccessException with a message string.
   *
   * @param msg a message string
   * @param r The Region for which the disk operation failed
   */
  public DiskAccessException(String msg, Region r) {
    this(msg, null, r == null ? null : r.getFullPath());
  }
  
  /**
   * Constructs a new DiskAccessException with a message string.
   *
   * @param msg a message string
   * @param regionName The name of the Region for which the disk operation failed
   * @since 6.5
   */
  public DiskAccessException(String msg, String regionName) {
    this(msg, null, regionName);
  }

  /**
   * Constructs a new DiskAccessException with a message string.
   *
   * @param msg a message string
   * @param ds The disk store for which the disk operation failed
   * @since 6.5
   */
  public DiskAccessException(String msg, DiskStore ds) {
    this(msg, null, ds);
  }

  /**
   * Constructs a new DiskAccessException with a message string
   * and a cause.
   *
   * @param msg the message string
   * @param cause a causal Throwable
   * @param regionName The name of the Region for which the disk operation failed
   * @since 6.5
   */
  public DiskAccessException(String msg, Throwable cause, String regionName) {
    super((regionName!=null ? "For Region: " + regionName + ": " : "") + msg, cause);
  }

  /**
   * Constructs a new DiskAccessException with a message string
   * and a cause.
   *
   * @param msg the message string
   * @param cause a causal Throwable
   * @param ds The disk store for which the disk operation failed
   * @since 6.5
   */
  public DiskAccessException(String msg, Throwable cause, DiskStore ds) {
    super((ds != null ? "For DiskStore '" + ds.getName() + "': " : "") + msg,
        cause);
  }

  /**
   * Constructs a new DiskAccessException with a cause.
   *
   * @param cause a causal Throwable
   */
  public DiskAccessException(Throwable cause) {
    super(cause);
  }
  
  /**
   * Constructs a new DiskAccessException with a message string
   * and a cause.
   *
   * @param msg the message string
   * @param cause a causal Throwable
   * @since gfxd 1.0.1
   */
  public DiskAccessException(String msg, Throwable cause) {
    super(msg, cause);
  }

  /**
   * Returns true if this exception originated from a remote node.
   */
  public final boolean isRemote() {
    return this.isRemote;
  }

  public final void setNotRemote() {
    this.isRemote = false;
  }

  // Overrides to set "isRemote" flag after deserialization

  private synchronized void writeObject(final java.io.ObjectOutputStream out)
      throws IOException {
    getStackTrace(); // Ensure that stackTrace field is initialized.
    out.defaultWriteObject();
  }

  private void readObject(final java.io.ObjectInputStream in)
      throws IOException, ClassNotFoundException {
    in.defaultReadObject();
    this.isRemote = true;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy