Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -417,11 +417,11 @@ public void onNext(BidiWriteObjectResponse value) {
} else if (persistedSize < totalSentBytes) {
writeCtx.getConfirmedBytes().set(persistedSize);
clientDetectedError(
ResumableSessionFailureScenario.SCENARIO_9.toStorageException(
UploadFailureScenario.SCENARIO_9.toStorageException(
ImmutableList.of(lastWrittenRequest), value, context, null));
} else {
clientDetectedError(
ResumableSessionFailureScenario.SCENARIO_7.toStorageException(
UploadFailureScenario.SCENARIO_7.toStorageException(
ImmutableList.of(lastWrittenRequest), value, context, null));
}
} else if (finalizing && value.hasResource()) {
Expand All @@ -432,11 +432,11 @@ public void onNext(BidiWriteObjectResponse value) {
ok(value);
} else if (finalSize < totalSentBytes) {
clientDetectedError(
ResumableSessionFailureScenario.SCENARIO_4_1.toStorageException(
UploadFailureScenario.SCENARIO_4_1.toStorageException(
ImmutableList.of(lastWrittenRequest), value, context, null));
} else {
clientDetectedError(
ResumableSessionFailureScenario.SCENARIO_4_2.toStorageException(
UploadFailureScenario.SCENARIO_4_2.toStorageException(
ImmutableList.of(lastWrittenRequest), value, context, null));
}
} else if (finalizing && value.hasPersistedSize()) {
Expand All @@ -449,16 +449,16 @@ public void onNext(BidiWriteObjectResponse value) {
writeCtx.getConfirmedBytes().set(persistedSize);
} else if (persistedSize < totalSentBytes) {
clientDetectedError(
ResumableSessionFailureScenario.SCENARIO_3.toStorageException(
UploadFailureScenario.SCENARIO_3.toStorageException(
ImmutableList.of(lastWrittenRequest), value, context, null));
} else {
clientDetectedError(
ResumableSessionFailureScenario.SCENARIO_2.toStorageException(
UploadFailureScenario.SCENARIO_2.toStorageException(
ImmutableList.of(lastWrittenRequest), value, context, null));
}
} else {
clientDetectedError(
ResumableSessionFailureScenario.SCENARIO_0.toStorageException(
UploadFailureScenario.SCENARIO_0.toStorageException(
ImmutableList.of(lastWrittenRequest), value, context, null));
}
}
Expand All @@ -472,7 +472,7 @@ public void onError(Throwable t) {
&& ed.getErrorInfo() != null
&& ed.getErrorInfo().getReason().equals("GRPC_MISMATCHED_UPLOAD_SIZE"))) {
clientDetectedError(
ResumableSessionFailureScenario.SCENARIO_5.toStorageException(
UploadFailureScenario.SCENARIO_5.toStorageException(
ImmutableList.of(lastWrittenRequest), null, context, oore));
return;
}
Expand All @@ -484,7 +484,7 @@ public void onError(Throwable t) {
// unusual case, and it should not cause a significant overhead given its rarity.
StorageException tmp = StorageException.asStorageException((ApiException) t);
previousError =
ResumableSessionFailureScenario.toStorageException(
UploadFailureScenario.toStorageException(
tmp.getCode(),
tmp.getMessage(),
tmp.getReason(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public void onNext(BidiWriteObjectResponse value) {
ok(value);
} else {
clientDetectedError(
ResumableSessionFailureScenario.SCENARIO_7.toStorageException(
UploadFailureScenario.SCENARIO_7.toStorageException(
nullSafeList(lastWrittenRequest), value, context, null));
}
} else if (finalizing && value.hasResource()) {
Expand All @@ -301,16 +301,16 @@ public void onNext(BidiWriteObjectResponse value) {
ok(value);
} else if (finalSize < totalSentBytes) {
clientDetectedError(
ResumableSessionFailureScenario.SCENARIO_4_1.toStorageException(
UploadFailureScenario.SCENARIO_4_1.toStorageException(
nullSafeList(lastWrittenRequest), value, context, null));
} else {
clientDetectedError(
ResumableSessionFailureScenario.SCENARIO_4_2.toStorageException(
UploadFailureScenario.SCENARIO_4_2.toStorageException(
nullSafeList(lastWrittenRequest), value, context, null));
}
} else if (!finalizing && value.hasResource()) {
clientDetectedError(
ResumableSessionFailureScenario.SCENARIO_1.toStorageException(
UploadFailureScenario.SCENARIO_1.toStorageException(
nullSafeList(lastWrittenRequest), value, context, null));
} else if (finalizing && value.hasPersistedSize()) {
long totalSentBytes = writeCtx.getTotalSentBytes().get();
Expand All @@ -322,16 +322,16 @@ public void onNext(BidiWriteObjectResponse value) {
writeCtx.getConfirmedBytes().set(persistedSize);
} else if (persistedSize < totalSentBytes) {
clientDetectedError(
ResumableSessionFailureScenario.SCENARIO_3.toStorageException(
UploadFailureScenario.SCENARIO_3.toStorageException(
nullSafeList(lastWrittenRequest), value, context, null));
} else {
clientDetectedError(
ResumableSessionFailureScenario.SCENARIO_2.toStorageException(
UploadFailureScenario.SCENARIO_2.toStorageException(
nullSafeList(lastWrittenRequest), value, context, null));
}
} else {
clientDetectedError(
ResumableSessionFailureScenario.SCENARIO_0.toStorageException(
UploadFailureScenario.SCENARIO_0.toStorageException(
nullSafeList(lastWrittenRequest), value, context, null));
}
}
Expand All @@ -345,7 +345,7 @@ public void onError(Throwable t) {
&& ed.getErrorInfo() != null
&& ed.getErrorInfo().getReason().equals("GRPC_MISMATCHED_UPLOAD_SIZE"))) {
clientDetectedError(
ResumableSessionFailureScenario.SCENARIO_5.toStorageException(
UploadFailureScenario.SCENARIO_5.toStorageException(
nullSafeList(lastWrittenRequest), null, context, oore));
return;
}
Expand All @@ -357,7 +357,7 @@ public void onError(Throwable t) {
// unusual case, and it should not cause a significant overhead given its rarity.
StorageException tmp = StorageException.asStorageException((ApiException) t);
previousError =
ResumableSessionFailureScenario.toStorageException(
UploadFailureScenario.toStorageException(
tmp.getCode(),
tmp.getMessage(),
tmp.getReason(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,7 @@ public void onError(Throwable t) {
&& ed.getErrorInfo() != null
&& ed.getErrorInfo().getReason().equals("GRPC_MISMATCHED_UPLOAD_SIZE"))) {
StorageException storageException =
ResumableSessionFailureScenario.SCENARIO_5.toStorageException(
segments, null, context, oore);
UploadFailureScenario.SCENARIO_5.toStorageException(segments, null, context, oore);
invocationHandle.setException(storageException);
return;
}
Expand All @@ -280,7 +279,7 @@ public void onError(Throwable t) {
// unusual case, and it should not cause a significant overhead given its rarity.
StorageException tmp = StorageException.asStorageException((ApiException) t);
StorageException storageException =
ResumableSessionFailureScenario.toStorageException(
UploadFailureScenario.toStorageException(
tmp.getCode(), tmp.getMessage(), tmp.getReason(), segments, null, context, t);
invocationHandle.setException(storageException);
}
Expand All @@ -305,7 +304,7 @@ public void onCompleted() {
writeCtx.getTotalSentBytes().set(persistedSize);
writeCtx.getConfirmedBytes().set(persistedSize);
} else {
throw ResumableSessionFailureScenario.SCENARIO_7.toStorageException(
throw UploadFailureScenario.SCENARIO_7.toStorageException(
segments, last, context, null);
}
} else if (finalizing && last.hasResource()) {
Expand All @@ -315,28 +314,26 @@ public void onCompleted() {
writeCtx.getConfirmedBytes().set(finalSize);
resultFuture.set(last);
} else if (finalSize < totalSentBytes) {
throw ResumableSessionFailureScenario.SCENARIO_4_1.toStorageException(
throw UploadFailureScenario.SCENARIO_4_1.toStorageException(
segments, last, context, null);
} else {
throw ResumableSessionFailureScenario.SCENARIO_4_2.toStorageException(
throw UploadFailureScenario.SCENARIO_4_2.toStorageException(
segments, last, context, null);
}
} else if (!finalizing && last.hasResource()) {
throw ResumableSessionFailureScenario.SCENARIO_1.toStorageException(
segments, last, context, null);
throw UploadFailureScenario.SCENARIO_1.toStorageException(segments, last, context, null);
} else if (finalizing && last.hasPersistedSize()) {
long totalSentBytes = writeCtx.getTotalSentBytes().get();
long persistedSize = last.getPersistedSize();
if (persistedSize < totalSentBytes) {
throw ResumableSessionFailureScenario.SCENARIO_3.toStorageException(
throw UploadFailureScenario.SCENARIO_3.toStorageException(
segments, last, context, null);
} else {
throw ResumableSessionFailureScenario.SCENARIO_2.toStorageException(
throw UploadFailureScenario.SCENARIO_2.toStorageException(
segments, last, context, null);
}
} else {
throw ResumableSessionFailureScenario.SCENARIO_0.toStorageException(
segments, last, context, null);
throw UploadFailureScenario.SCENARIO_0.toStorageException(segments, last, context, null);
}
} catch (Throwable se) {
open = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public void onError(Throwable t) {
// unusual case, and it should not cause a significant overhead given its rarity.
StorageException tmp = StorageException.asStorageException((ApiException) t);
StorageException storageException =
ResumableSessionFailureScenario.toStorageException(
UploadFailureScenario.toStorageException(
tmp.getCode(), tmp.getMessage(), tmp.getReason(), getRequests(), null, context, t);
invocationHandle.setException(storageException);
} else {
Expand All @@ -243,14 +243,14 @@ public void onCompleted() {
writeCtx.getConfirmedBytes().set(finalSize);
resultFuture.set(last);
} else if (finalSize < totalSentBytes) {
throw ResumableSessionFailureScenario.SCENARIO_4_1.toStorageException(
throw UploadFailureScenario.SCENARIO_4_1.toStorageException(
getRequests(), last, context, null);
} else {
throw ResumableSessionFailureScenario.SCENARIO_4_2.toStorageException(
throw UploadFailureScenario.SCENARIO_4_2.toStorageException(
getRequests(), last, context, null);
}
} else {
throw ResumableSessionFailureScenario.SCENARIO_0.toStorageException(
throw UploadFailureScenario.SCENARIO_0.toStorageException(
getRequests(), last, context, null);
}
} catch (Throwable se) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public void onError(Throwable t) {
// unusual case, and it should not cause a significant overhead given its rarity.
StorageException tmp = StorageException.asStorageException((ApiException) t);
StorageException storageException =
ResumableSessionFailureScenario.toStorageException(
UploadFailureScenario.toStorageException(
tmp.getCode(),
tmp.getMessage(),
tmp.getReason(),
Expand All @@ -247,7 +247,7 @@ public void onCompleted() {
boolean finalizing = lastWrittenRequest.getFinishWrite();
if (last == null) {
clientDetectedError(
ResumableSessionFailureScenario.toStorageException(
UploadFailureScenario.toStorageException(
0,
"onComplete without preceding onNext, unable to determine success.",
"invalid",
Expand All @@ -262,16 +262,16 @@ public void onCompleted() {
ok(finalSize);
} else if (finalSize < totalSentBytes) {
clientDetectedError(
ResumableSessionFailureScenario.SCENARIO_4_1.toStorageException(
UploadFailureScenario.SCENARIO_4_1.toStorageException(
nullSafeList(lastWrittenRequest), last, context, null));
} else {
clientDetectedError(
ResumableSessionFailureScenario.SCENARIO_4_2.toStorageException(
UploadFailureScenario.SCENARIO_4_2.toStorageException(
nullSafeList(lastWrittenRequest), last, context, null));
}
} else if (!finalizing || last.hasPersistedSize()) { // unexpected incremental response
clientDetectedError(
ResumableSessionFailureScenario.toStorageException(
UploadFailureScenario.toStorageException(
0,
"Unexpected incremental response for finalizing request.",
"invalid",
Expand All @@ -281,7 +281,7 @@ public void onCompleted() {
null));
} else {
clientDetectedError(
ResumableSessionFailureScenario.SCENARIO_0.toStorageException(
UploadFailureScenario.SCENARIO_0.toStorageException(
nullSafeList(lastWrittenRequest), last, context, null));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void rewindTo(long offset) {

int code = response.getStatusCode();

if (!finalizing && ResumableSessionFailureScenario.isContinue(code)) {
if (!finalizing && UploadFailureScenario.isContinue(code)) {
long effectiveEnd = ((HttpContentRange.HasRange<?>) contentRange).range().endOffset();
@Nullable String range = response.getHeaders().getRange();
ByteRangeSpec ackRange = ByteRangeSpec.parse(range);
Expand All @@ -121,11 +121,11 @@ public void rewindTo(long offset) {
return ResumableOperationResult.incremental(ackRange.endOffset());
} else {
StorageException se =
ResumableSessionFailureScenario.SCENARIO_7.toStorageException(uploadId, response);
UploadFailureScenario.SCENARIO_7.toStorageException(uploadId, response);
span.setStatus(Status.UNKNOWN.withDescription(se.getMessage()));
throw se;
}
} else if (finalizing && ResumableSessionFailureScenario.isOk(code)) {
} else if (finalizing && UploadFailureScenario.isOk(code)) {
@Nullable StorageObject storageObject;
BigInteger actualSize = BigInteger.ZERO;

Expand All @@ -152,7 +152,7 @@ public void rewindTo(long offset) {
} else {
response.ignore();
StorageException se =
ResumableSessionFailureScenario.SCENARIO_0_1.toStorageException(
UploadFailureScenario.SCENARIO_0_1.toStorageException(
uploadId, response, null, () -> null);
span.setStatus(Status.UNKNOWN.withDescription(se.getMessage()));
throw se;
Expand All @@ -165,35 +165,35 @@ public void rewindTo(long offset) {
return ResumableOperationResult.complete(storageObject, actualSize.longValue());
} else if (compare > 0) {
StorageException se =
ResumableSessionFailureScenario.SCENARIO_4_1.toStorageException(
UploadFailureScenario.SCENARIO_4_1.toStorageException(
uploadId, response, null, toString(storageObject));
span.setStatus(Status.UNKNOWN.withDescription(se.getMessage()));
throw se;
} else {
StorageException se =
ResumableSessionFailureScenario.SCENARIO_4_2.toStorageException(
UploadFailureScenario.SCENARIO_4_2.toStorageException(
uploadId, response, null, toString(storageObject));
span.setStatus(Status.UNKNOWN.withDescription(se.getMessage()));
throw se;
}
} else if (!finalizing && ResumableSessionFailureScenario.isOk(code)) {
} else if (!finalizing && UploadFailureScenario.isOk(code)) {
StorageException se =
ResumableSessionFailureScenario.SCENARIO_1.toStorageException(uploadId, response);
UploadFailureScenario.SCENARIO_1.toStorageException(uploadId, response);
span.setStatus(Status.UNKNOWN.withDescription(se.getMessage()));
throw se;
} else if (finalizing && ResumableSessionFailureScenario.isContinue(code)) {
} else if (finalizing && UploadFailureScenario.isContinue(code)) {
// in order to finalize the content range must have a size, cast down to read it
HttpContentRange.HasSize size = (HttpContentRange.HasSize) contentRange;

ByteRangeSpec range = ByteRangeSpec.parse(response.getHeaders().getRange());
if (range.endOffsetInclusive() < size.getSize()) {
StorageException se =
ResumableSessionFailureScenario.SCENARIO_3.toStorageException(uploadId, response);
UploadFailureScenario.SCENARIO_3.toStorageException(uploadId, response);
span.setStatus(Status.UNKNOWN.withDescription(se.getMessage()));
throw se;
} else {
StorageException se =
ResumableSessionFailureScenario.SCENARIO_2.toStorageException(uploadId, response);
UploadFailureScenario.SCENARIO_2.toStorageException(uploadId, response);
span.setStatus(Status.UNKNOWN.withDescription(se.getMessage()));
throw se;
}
Expand All @@ -205,8 +205,7 @@ public void rewindTo(long offset) {
// a 503 with plain text content
// Attempt to detect this very loosely as to minimize impact of modified error message
// This is accurate circa 2023-06
if ((!ResumableSessionFailureScenario.isOk(code)
&& !ResumableSessionFailureScenario.isContinue(code))
if ((!UploadFailureScenario.isOk(code) && !UploadFailureScenario.isContinue(code))
&& contentType != null
&& contentType.startsWith("text/plain")
&& contentLength != null
Expand All @@ -215,14 +214,13 @@ public void rewindTo(long offset) {
if (errorMessage.contains("content-range")
&& !errorMessage.contains("earlier")) { // TODO: exclude "earlier request"
StorageException se =
ResumableSessionFailureScenario.SCENARIO_5.toStorageException(
UploadFailureScenario.SCENARIO_5.toStorageException(
uploadId, response, cause, cause::getContent);
span.setStatus(Status.UNKNOWN.withDescription(se.getMessage()));
throw se;
}
}
StorageException se =
ResumableSessionFailureScenario.toStorageException(response, cause, uploadId);
StorageException se = UploadFailureScenario.toStorageException(response, cause, uploadId);
span.setStatus(Status.UNKNOWN.withDescription(se.getMessage()));
throw se;
}
Expand All @@ -235,7 +233,7 @@ public void rewindTo(long offset) {
throw e;
} catch (Exception e) {
StorageException se =
ResumableSessionFailureScenario.SCENARIO_0.toStorageException(uploadId, response, e);
UploadFailureScenario.SCENARIO_0.toStorageException(uploadId, response, e);
span.setStatus(Status.UNKNOWN.withDescription(se.getMessage()));
throw se;
} finally {
Expand Down
Loading
Loading