HBASE-15608 Remove PB references from SnapShot related Exceptions (ram)
This commit is contained in:
parent
0d252918f6
commit
bec81b1977
|
@ -2333,7 +2333,7 @@ public class HBaseAdmin implements Admin {
|
|||
}
|
||||
if (!done.getDone()) {
|
||||
throw new SnapshotCreationException("Snapshot '" + snapshot.getName()
|
||||
+ "' wasn't completed in expectedTime:" + max + " ms", snapshot);
|
||||
+ "' wasn't completed in expectedTime:" + max + " ms", snapshotDesc);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -81,4 +81,12 @@ public class SnapshotDescription {
|
|||
public int getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SnapshotDescription: name = " + ((name != null) ? name : null) + "/table = "
|
||||
+ ((table != null) ? table : null) + " /owner = " + ((owner != null) ? owner : null)
|
||||
+ (creationTime != -1 ? ("/creationtime = " + creationTime) : "")
|
||||
+ (version != -1 ? ("/version = " + version) : "");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3472,4 +3472,18 @@ public final class ProtobufUtil {
|
|||
HBaseProtos.SnapshotDescription snapshot = builder.build();
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert from
|
||||
* {@link org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription} to
|
||||
* {@link SnapshotDescription}
|
||||
* @param snapshotDesc the protobuf SnapshotDescription
|
||||
* @return the POJO SnapshotDescription
|
||||
*/
|
||||
public static SnapshotDescription
|
||||
createSnapshotDesc(HBaseProtos.SnapshotDescription snapshotDesc) {
|
||||
return new SnapshotDescription(snapshotDesc.getName(), snapshotDesc.getTable(),
|
||||
createSnapshotType(snapshotDesc.getType()), snapshotDesc.getOwner(),
|
||||
snapshotDesc.getCreationTime(), snapshotDesc.getVersion());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.hadoop.hbase.snapshot;
|
|||
|
||||
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.hbase.classification.InterfaceStability;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
|
||||
import org.apache.hadoop.hbase.client.SnapshotDescription;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.hadoop.hbase.snapshot;
|
|||
import org.apache.hadoop.hbase.DoNotRetryIOException;
|
||||
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.hbase.classification.InterfaceStability;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
|
||||
import org.apache.hadoop.hbase.client.SnapshotDescription;
|
||||
|
||||
/**
|
||||
* General exception base class for when a snapshot fails
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.hadoop.hbase.snapshot;
|
|||
|
||||
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.hbase.classification.InterfaceStability;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
|
||||
import org.apache.hadoop.hbase.client.SnapshotDescription;
|
||||
|
||||
/**
|
||||
* Thrown when a snapshot could not be restored due to a server-side error when restoring it.
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.hadoop.hbase.snapshot;
|
|||
|
||||
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.hbase.classification.InterfaceStability;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
|
||||
import org.apache.hadoop.hbase.client.SnapshotDescription;
|
||||
|
||||
/**
|
||||
* Thrown when a snapshot could not be created due to a server-side error when
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.hadoop.hbase.snapshot;
|
|||
|
||||
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.hbase.classification.InterfaceStability;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
|
||||
import org.apache.hadoop.hbase.client.SnapshotDescription;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.hadoop.hbase.snapshot;
|
|||
|
||||
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.hbase.classification.InterfaceStability;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
|
||||
import org.apache.hadoop.hbase.client.SnapshotDescription;
|
||||
|
||||
/**
|
||||
* Thrown when a snapshot exists but should not
|
||||
|
|
|
@ -455,7 +455,8 @@ public class CloneSnapshotProcedure
|
|||
String msg = "clone snapshot=" + ClientSnapshotDescriptionUtils.toString(snapshot) +
|
||||
" failed because " + e.getMessage();
|
||||
LOG.error(msg, e);
|
||||
IOException rse = new RestoreSnapshotException(msg, e, snapshot);
|
||||
IOException rse = new RestoreSnapshotException(msg, e,
|
||||
ProtobufUtil.createSnapshotDesc(snapshot));
|
||||
|
||||
// these handlers aren't futures so we need to register the error here.
|
||||
monitorException.receive(new ForeignException("Master CloneSnapshotProcedure", rse));
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.apache.hadoop.hbase.client.RegionReplicaUtil;
|
|||
import org.apache.hadoop.hbase.MetaTableAccessor;
|
||||
import org.apache.hadoop.hbase.master.MasterServices;
|
||||
import org.apache.hadoop.hbase.mob.MobUtils;
|
||||
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.SnapshotProtos.SnapshotRegionManifest;
|
||||
import org.apache.hadoop.hbase.snapshot.ClientSnapshotDescriptionUtils;
|
||||
|
@ -125,8 +126,9 @@ public final class MasterSnapshotVerifier {
|
|||
private void verifySnapshotDescription(Path snapshotDir) throws CorruptedSnapshotException {
|
||||
SnapshotDescription found = SnapshotDescriptionUtils.readSnapshotInfo(fs, snapshotDir);
|
||||
if (!this.snapshot.equals(found)) {
|
||||
throw new CorruptedSnapshotException("Snapshot read (" + found
|
||||
+ ") doesn't equal snapshot we ran (" + snapshot + ").", snapshot);
|
||||
throw new CorruptedSnapshotException(
|
||||
"Snapshot read (" + found + ") doesn't equal snapshot we ran (" + snapshot + ").",
|
||||
ProtobufUtil.createSnapshotDesc(snapshot));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,12 +139,14 @@ public final class MasterSnapshotVerifier {
|
|||
private void verifyTableInfo(final SnapshotManifest manifest) throws IOException {
|
||||
HTableDescriptor htd = manifest.getTableDescriptor();
|
||||
if (htd == null) {
|
||||
throw new CorruptedSnapshotException("Missing Table Descriptor", snapshot);
|
||||
throw new CorruptedSnapshotException("Missing Table Descriptor",
|
||||
ProtobufUtil.createSnapshotDesc(snapshot));
|
||||
}
|
||||
|
||||
if (!htd.getNameAsString().equals(snapshot.getTable())) {
|
||||
throw new CorruptedSnapshotException("Invalid Table Descriptor. Expected "
|
||||
+ snapshot.getTable() + " name, got " + htd.getNameAsString(), snapshot);
|
||||
throw new CorruptedSnapshotException(
|
||||
"Invalid Table Descriptor. Expected " + snapshot.getTable() + " name, got "
|
||||
+ htd.getNameAsString(), ProtobufUtil.createSnapshotDesc(snapshot));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -216,7 +220,7 @@ public final class MasterSnapshotVerifier {
|
|||
if (!region.equals(manifestRegionInfo)) {
|
||||
String msg = "Manifest region info " + manifestRegionInfo +
|
||||
"doesn't match expected region:" + region;
|
||||
throw new CorruptedSnapshotException(msg, snapshot);
|
||||
throw new CorruptedSnapshotException(msg, ProtobufUtil.createSnapshotDesc(snapshot));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ import org.apache.hadoop.hbase.procedure.ProcedureCoordinator;
|
|||
import org.apache.hadoop.hbase.procedure.ProcedureCoordinatorRpcs;
|
||||
import org.apache.hadoop.hbase.procedure.ZKProcedureCoordinatorRpcs;
|
||||
import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
|
||||
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameStringPair;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.ProcedureDescription;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
|
||||
|
@ -275,7 +276,7 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable
|
|||
public void deleteSnapshot(SnapshotDescription snapshot) throws SnapshotDoesNotExistException, IOException {
|
||||
// check to see if it is completed
|
||||
if (!isSnapshotCompleted(snapshot)) {
|
||||
throw new SnapshotDoesNotExistException(snapshot);
|
||||
throw new SnapshotDoesNotExistException(ProtobufUtil.createSnapshotDesc(snapshot));
|
||||
}
|
||||
|
||||
String snapshotName = snapshot.getName();
|
||||
|
@ -357,7 +358,7 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable
|
|||
status = expected.getName() + " not found in proclist " + coordinator.getProcedureNames();
|
||||
}
|
||||
throw new HBaseSnapshotException("Snapshot " + ssString + " had an error. " + status, e,
|
||||
expected);
|
||||
ProtobufUtil.createSnapshotDesc(expected));
|
||||
}
|
||||
|
||||
// check to see if we are done
|
||||
|
@ -426,7 +427,7 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable
|
|||
+ " because we are already running another snapshot "
|
||||
+ (handler != null ? ("on the same table " +
|
||||
ClientSnapshotDescriptionUtils.toString(handler.getSnapshot()))
|
||||
: "with the same name"), snapshot);
|
||||
: "with the same name"), ProtobufUtil.createSnapshotDesc(snapshot));
|
||||
}
|
||||
|
||||
// make sure we aren't running a restore on the same table
|
||||
|
@ -443,14 +444,16 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable
|
|||
|
||||
// recreate the working directory for the snapshot
|
||||
if (!fs.mkdirs(workingDir)) {
|
||||
throw new SnapshotCreationException("Couldn't create working directory (" + workingDir
|
||||
+ ") for snapshot" , snapshot);
|
||||
throw new SnapshotCreationException(
|
||||
"Couldn't create working directory (" + workingDir + ") for snapshot",
|
||||
ProtobufUtil.createSnapshotDesc(snapshot));
|
||||
}
|
||||
} catch (HBaseSnapshotException e) {
|
||||
throw e;
|
||||
} catch (IOException e) {
|
||||
throw new SnapshotCreationException(
|
||||
"Exception while checking to see if snapshot could be started.", e, snapshot);
|
||||
"Exception while checking to see if snapshot could be started.", e,
|
||||
ProtobufUtil.createSnapshotDesc(snapshot));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -516,7 +519,8 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable
|
|||
ClientSnapshotDescriptionUtils.toString(snapshot));
|
||||
}
|
||||
// fail the snapshot
|
||||
throw new SnapshotCreationException("Could not build snapshot handler", e, snapshot);
|
||||
throw new SnapshotCreationException("Could not build snapshot handler", e,
|
||||
ProtobufUtil.createSnapshotDesc(snapshot));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -530,8 +534,9 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable
|
|||
public void takeSnapshot(SnapshotDescription snapshot) throws IOException {
|
||||
// check to see if we already completed the snapshot
|
||||
if (isSnapshotCompleted(snapshot)) {
|
||||
throw new SnapshotExistsException("Snapshot '" + snapshot.getName()
|
||||
+ "' already stored on the filesystem.", snapshot);
|
||||
throw new SnapshotExistsException(
|
||||
"Snapshot '" + snapshot.getName() + "' already stored on the filesystem.",
|
||||
ProtobufUtil.createSnapshotDesc(snapshot));
|
||||
}
|
||||
|
||||
LOG.debug("No existing snapshot, attempting snapshot...");
|
||||
|
@ -547,14 +552,16 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable
|
|||
} catch (FileNotFoundException e) {
|
||||
String msg = "Table:" + snapshot.getTable() + " info doesn't exist!";
|
||||
LOG.error(msg);
|
||||
throw new SnapshotCreationException(msg, e, snapshot);
|
||||
throw new SnapshotCreationException(msg, e, ProtobufUtil.createSnapshotDesc(snapshot));
|
||||
} catch (IOException e) {
|
||||
throw new SnapshotCreationException("Error while geting table description for table "
|
||||
+ snapshot.getTable(), e, snapshot);
|
||||
throw new SnapshotCreationException(
|
||||
"Error while geting table description for table " + snapshot.getTable(), e,
|
||||
ProtobufUtil.createSnapshotDesc(snapshot));
|
||||
}
|
||||
if (desc == null) {
|
||||
throw new SnapshotCreationException("Table '" + snapshot.getTable()
|
||||
+ "' doesn't exist, can't take snapshot.", snapshot);
|
||||
throw new SnapshotCreationException(
|
||||
"Table '" + snapshot.getTable() + "' doesn't exist, can't take snapshot.",
|
||||
ProtobufUtil.createSnapshotDesc(snapshot));
|
||||
}
|
||||
SnapshotDescription.Builder builder = snapshot.toBuilder();
|
||||
// if not specified, set the snapshot format
|
||||
|
@ -593,7 +600,8 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable
|
|||
+ "', isn't open or closed, we don't know what to do!");
|
||||
TablePartiallyOpenException tpoe = new TablePartiallyOpenException(snapshot.getTable()
|
||||
+ " isn't fully open.");
|
||||
throw new SnapshotCreationException("Table is not entirely open or closed", tpoe, snapshot);
|
||||
throw new SnapshotCreationException("Table is not entirely open or closed", tpoe,
|
||||
ProtobufUtil.createSnapshotDesc(snapshot));
|
||||
}
|
||||
|
||||
// call post coproc hook
|
||||
|
@ -750,7 +758,8 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable
|
|||
// check if the snapshot exists
|
||||
if (!fs.exists(snapshotDir)) {
|
||||
LOG.error("A Snapshot named '" + reqSnapshot.getName() + "' does not exist.");
|
||||
throw new SnapshotDoesNotExistException(reqSnapshot);
|
||||
throw new SnapshotDoesNotExistException(
|
||||
ProtobufUtil.createSnapshotDesc(reqSnapshot));
|
||||
}
|
||||
|
||||
// Get snapshot info from file system. The reqSnapshot is a "fake" snapshotInfo with
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.apache.hadoop.fs.FileSystem;
|
|||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.hadoop.fs.permission.FsPermission;
|
||||
import org.apache.hadoop.hbase.HConstants;
|
||||
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
|
||||
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
|
||||
import org.apache.hadoop.hbase.security.User;
|
||||
|
@ -333,8 +334,9 @@ public final class SnapshotDescriptionUtils {
|
|||
LOG.debug("Snapshot is done, just moving the snapshot from " + workingDir + " to "
|
||||
+ finishedDir);
|
||||
if (!fs.rename(workingDir, finishedDir)) {
|
||||
throw new SnapshotCreationException("Failed to move working directory(" + workingDir
|
||||
+ ") to completed directory(" + finishedDir + ").", snapshot);
|
||||
throw new SnapshotCreationException(
|
||||
"Failed to move working directory(" + workingDir + ") to completed directory("
|
||||
+ finishedDir + ").", ProtobufUtil.createSnapshotDesc(snapshot));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -158,7 +158,8 @@ public final class SnapshotManifest {
|
|||
case SnapshotManifestV2.DESCRIPTOR_VERSION:
|
||||
return new SnapshotManifestV2.ManifestBuilder(conf, fs, workingDir);
|
||||
default:
|
||||
throw new CorruptedSnapshotException("Invalid Snapshot version: "+ desc.getVersion(), desc);
|
||||
throw new CorruptedSnapshotException("Invalid Snapshot version: " + desc.getVersion(),
|
||||
ProtobufUtil.createSnapshotDesc(desc));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -391,7 +392,8 @@ public final class SnapshotManifest {
|
|||
break;
|
||||
}
|
||||
default:
|
||||
throw new CorruptedSnapshotException("Invalid Snapshot version: "+ desc.getVersion(), desc);
|
||||
throw new CorruptedSnapshotException("Invalid Snapshot version: " + desc.getVersion(),
|
||||
ProtobufUtil.createSnapshotDesc(desc));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ import org.apache.hadoop.hbase.HRegionInfo;
|
|||
import org.apache.hadoop.hbase.TableName;
|
||||
import org.apache.hadoop.hbase.io.HFileLink;
|
||||
import org.apache.hadoop.hbase.mob.MobUtils;
|
||||
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.SnapshotProtos.SnapshotRegionManifest;
|
||||
import org.apache.hadoop.hbase.regionserver.StoreFileInfo;
|
||||
|
@ -209,7 +210,8 @@ public final class SnapshotReferenceUtil {
|
|||
throw new InterruptedIOException(e.getMessage());
|
||||
} catch (ExecutionException e) {
|
||||
if (e.getCause() instanceof CorruptedSnapshotException) {
|
||||
throw new CorruptedSnapshotException(e.getCause().getMessage(), snapshotDesc);
|
||||
throw new CorruptedSnapshotException(e.getCause().getMessage(),
|
||||
ProtobufUtil.createSnapshotDesc(snapshotDesc));
|
||||
} else {
|
||||
IOException ex = new IOException();
|
||||
ex.initCause(e.getCause());
|
||||
|
@ -248,8 +250,9 @@ public final class SnapshotReferenceUtil {
|
|||
String refRegion = refPath.getParent().getParent().getName();
|
||||
refPath = HFileLink.createPath(table, refRegion, family, refPath.getName());
|
||||
if (!HFileLink.buildFromHFileLinkPattern(conf, refPath).exists(fs)) {
|
||||
throw new CorruptedSnapshotException("Missing parent hfile for: " + fileName +
|
||||
" path=" + refPath, snapshot);
|
||||
throw new CorruptedSnapshotException(
|
||||
"Missing parent hfile for: " + fileName + " path=" + refPath,
|
||||
ProtobufUtil.createSnapshotDesc(snapshot));
|
||||
}
|
||||
|
||||
if (storeFile.hasReference()) {
|
||||
|
@ -285,14 +288,16 @@ public final class SnapshotReferenceUtil {
|
|||
String msg = "hfile: " + fileName + " size does not match with the expected one. " +
|
||||
" found=" + fstat.getLen() + " expected=" + storeFile.getFileSize();
|
||||
LOG.error(msg);
|
||||
throw new CorruptedSnapshotException(msg, snapshot);
|
||||
throw new CorruptedSnapshotException(msg,
|
||||
ProtobufUtil.createSnapshotDesc(snapshot));
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
String msg = "Can't find hfile: " + fileName + " in the real (" +
|
||||
link.getOriginPath() + ") or archive (" + link.getArchivePath()
|
||||
+ ") directory for the primary table.";
|
||||
LOG.error(msg);
|
||||
throw new CorruptedSnapshotException(msg, snapshot);
|
||||
throw new CorruptedSnapshotException(msg,
|
||||
ProtobufUtil.createSnapshotDesc(snapshot));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue