001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase; 019 020import org.apache.yetus.audience.InterfaceAudience; 021 022/** 023 * Thrown when a replica cluster attempts to disable read-only mode while another active cluster 024 * already exists on the same storage location. 025 */ 026@InterfaceAudience.Public 027public class ReadOnlyTransitionException extends DoNotRetryIOException { 028 029 private static final long serialVersionUID = 1L; 030 031 private final String activeClusterId; 032 033 public ReadOnlyTransitionException() { 034 super(); 035 this.activeClusterId = null; 036 } 037 038 /** 039 * @param message the message for this exception 040 */ 041 public ReadOnlyTransitionException(String message) { 042 super(message); 043 this.activeClusterId = null; 044 } 045 046 /** 047 * @param message the message for this exception 048 * @param activeClusterId the ID of the cluster that is currently active 049 */ 050 public ReadOnlyTransitionException(String message, String activeClusterId) { 051 super(message); 052 this.activeClusterId = activeClusterId; 053 } 054 055 /** 056 * @param message the message for this exception 057 * @param throwable the {@link Throwable} to use for this exception 058 */ 059 public ReadOnlyTransitionException(String message, Throwable throwable) { 060 super(message, throwable); 061 this.activeClusterId = null; 062 } 063 064 /** 065 * @param throwable the {@link Throwable} to use for this exception 066 */ 067 public ReadOnlyTransitionException(Throwable throwable) { 068 super(throwable); 069 this.activeClusterId = null; 070 } 071 072 /** Returns the ID of the cluster that is currently active, or null if unknown */ 073 public String getActiveClusterId() { 074 return activeClusterId; 075 } 076 077 @Override 078 public String getMessage() { 079 if (activeClusterId != null) { 080 return super.getMessage() + " Current active cluster ID: " + activeClusterId; 081 } 082 return super.getMessage(); 083 } 084}