Skip to content

Commit

Permalink
io error logging (sofastack#708)
Browse files Browse the repository at this point in the history
  • Loading branch information
Block authored Nov 10, 2021
1 parent 72b71ba commit a764587
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public boolean init(final RaftMetaStorageOptions opts) {
try {
FileUtils.forceMkdir(new File(this.path));
} catch (final IOException e) {
LOG.error("Fail to mkdir {}", this.path);
LOG.error("Fail to mkdir {}", this.path, e);
return false;
}
if (load()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ long getReaderId() {
public boolean init(final Void v) {
final File dir = new File(this.path);
if (!dir.exists()) {
LOG.error("No such path %s for snapshot reader.", this.path);
LOG.error("No such path {} for snapshot reader.", this.path);
setError(RaftError.ENOENT, "No such path %s for snapshot reader", this.path);
return false;
}
final String metaPath = this.path + File.separator + JRAFT_SNAPSHOT_META_FILE;
try {
return this.metaTable.loadFromFile(metaPath);
} catch (final IOException e) {
LOG.error("Fail to load snapshot meta {}.", metaPath);
LOG.error("Fail to load snapshot meta {}.", metaPath, e);
setError(RaftError.EIO, "Fail to load snapshot meta from path %s", metaPath);
return false;
}
Expand Down Expand Up @@ -136,7 +136,7 @@ public String generateURIForCopy() {
}
}

return String.format(REMOTE_SNAPSHOT_URI_SCHEME + "%s/%d", this.addr.toString(), this.readerId);
return String.format(REMOTE_SNAPSHOT_URI_SCHEME + "%s/%d", this.addr, this.readerId);
}

private void destroyReaderInFileService() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public boolean init(final Void v) {
try {
FileUtils.forceMkdir(dir);
} catch (final IOException e) {
LOG.error("Fail to create directory {}.", this.path);
LOG.error("Fail to create directory {}.", this.path, e);
return false;
}

Expand All @@ -114,7 +114,7 @@ public boolean init(final Void v) {
try {
FileUtils.forceDelete(tempFile);
} catch (final IOException e) {
LOG.error("Fail to delete temp snapshot path {}.", tempSnapshotPath);
LOG.error("Fail to delete temp snapshot path {}.", tempSnapshotPath, e);
return false;
}
}
Expand Down Expand Up @@ -170,7 +170,7 @@ private boolean destroySnapshot(final String path) {
FileUtils.deleteDirectory(file);
return true;
} catch (final IOException e) {
LOG.error("Fail to destroy snapshot {}.", path);
LOG.error("Fail to destroy snapshot {}.", path, e);
return false;
}
}
Expand Down Expand Up @@ -209,7 +209,7 @@ void close(final LocalSnapshotWriter writer, final boolean keepDataOnError) thro
break;
}
} catch (final IOException e) {
LOG.error("Fail to sync writer {}.", writer.getPath());
LOG.error("Fail to sync writer {}.", writer.getPath(), e);
ret = RaftError.EIO.getNumber();
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public boolean init(final Void v) {
try {
FileUtils.forceMkdir(dir);
} catch (final IOException e) {
LOG.error("Fail to create directory {}.", this.path);
LOG.error("Fail to create directory {}.", this.path, e);
setError(RaftError.EIO, "Fail to create directory %s", this.path);
return false;
}
Expand All @@ -72,7 +72,7 @@ public boolean init(final Void v) {
return metaTable.loadFromFile(metaPath);
}
} catch (final IOException e) {
LOG.error("Fail to load snapshot meta from {}.", metaPath);
LOG.error("Fail to load snapshot meta from {}.", metaPath, e);
setError(RaftError.EIO, "Fail to load snapshot meta from %s", metaPath);
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ void onRpcReturned(final Status status, final GetFileResponse response) {
try {
response.getData().writeTo(this.outputStream);
} catch (final IOException e) {
LOG.error("Fail to write into file {}", this.destPath);
LOG.error("Fail to write into file {}", this.destPath, e);
this.st.setError(RaftError.EIO, RaftError.EIO.name());
onFinished();
return;
Expand Down

0 comments on commit a764587

Please sign in to comment.