-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add java-storage implementation for createBucket. #1074
Add java-storage implementation for createBucket. #1074
Conversation
6e2ef4b
to
4de20bc
Compare
/gcbrun |
4de20bc
to
164ac47
Compare
/gcbrun |
164ac47
to
bb250c6
Compare
bb250c6
to
3456edf
Compare
gcsio/src/main/java/com/google/cloud/hadoop/gcsio/GoogleCloudStorageClientImpl.java
Show resolved
Hide resolved
gcsio/src/main/java/com/google/cloud/hadoop/gcsio/GoogleCloudStorageClientImpl.java
Show resolved
Hide resolved
gcsio/src/main/java/com/google/cloud/hadoop/gcsio/GoogleCloudStorageClientWriteChannel.java
Show resolved
Hide resolved
gcsio/src/main/java/com/google/cloud/hadoop/gcsio/GoogleCloudStorageClientImpl.java
Show resolved
Hide resolved
/gcbrun |
/gcbrun |
1 similar comment
/gcbrun |
gRPC API throws a FAILED_PRECONDITION status code for bucket already exists condition on create bucket as opposed to the JSON API.
5a15f0e
to
abd8db4
Compare
@Override | ||
public boolean bucketAlreadyExists(Exception e) { | ||
ErrorType errorType = getErrorType(e); | ||
if (errorType == ErrorType.ALREADY_EXISTS) return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid single line if statements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -25,6 +27,9 @@ public class GrpcErrorTypeExtractor implements ErrorTypeExtractor { | |||
|
|||
public static final GrpcErrorTypeExtractor INSTANCE = new GrpcErrorTypeExtractor(); | |||
|
|||
public static final String BUCKET_ALREADY_EXISTS_MESSAGE = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be private?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@Nullable | ||
private StatusRuntimeException getStatusRuntimeException(Exception e) { | ||
Throwable cause = e; | ||
while (cause != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this go into an infinite loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, Added check for self-reference so it doesnt go into infinite loop.
util/src/main/java/com/google/cloud/hadoop/util/GrpcErrorTypeExtractor.java
Show resolved
Hide resolved
else if (errorType == ErrorType.FAILED_PRECONDITION) { | ||
StatusRuntimeException statusRuntimeException = getStatusRuntimeException(e); | ||
return statusRuntimeException != null | ||
&& BUCKET_ALREADY_EXISTS_MESSAGE.equals(statusRuntimeException.getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an error code? Checking for error message is not fool proof. Can it return different error message based on caller locale?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are checking the status code on line 58, but it is a generic FAILED_PRECONDITION code so added another level of check via error message. I dont think it returns different message based on caller locale as we have similar message check for json api as well -
hadoop-connectors/util/src/main/java/com/google/cloud/hadoop/util/ApiErrorExtractor.java
Line 224 in fabf01d
&& USER_PROJECT_MISSING_MESSAGE.equals(jsonError.getMessage()); |
/gcbrun |
return (StatusRuntimeException) cause; | ||
} | ||
cause = cause.getCause(); | ||
} while (cause != null && cause != e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will catch only self loops, correct? Why not have a counter of say 1000 and break after that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
/gcbrun |
77edfcb
to
40b40c5
Compare
/gcbrun |
3ab7546
into
GoogleCloudDataproc:master
No description provided.