-
Notifications
You must be signed in to change notification settings - Fork 23
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
Issue 227 add type in case it's not provided #228
base: master
Are you sure you want to change the base?
Issue 227 add type in case it's not provided #228
Conversation
Further update is that the update entries via the wirecommand fails if the "type" is not provided and this call is inside a retriable block and hence the code retries on fail and keeps on repeating the same unless the Server closes the connection with HTTP 504. |
server/src/main/java/io/pravega/schemaregistry/storage/client/TableStore.java
Outdated
Show resolved
Hide resolved
server/src/main/java/io/pravega/schemaregistry/storage/client/TableStore.java
Outdated
Show resolved
Hide resolved
server/src/main/java/io/pravega/schemaregistry/storage/client/WireCommandClient.java
Outdated
Show resolved
Hide resolved
server/src/main/java/io/pravega/schemaregistry/storage/impl/schemas/PravegaKeyValueSchemas.java
Outdated
Show resolved
Hide resolved
server/src/main/java/io/pravega/schemaregistry/storage/impl/SchemaStoreImpl.java
Outdated
Show resolved
Hide resolved
server/src/main/java/io/pravega/schemaregistry/service/SchemaRegistryService.java
Show resolved
Hide resolved
server/src/main/java/io/pravega/schemaregistry/service/SchemaRegistryService.java
Outdated
Show resolved
Hide resolved
server/src/main/java/io/pravega/schemaregistry/service/SchemaRegistryService.java
Show resolved
Hide resolved
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.
LGTM apart from a comment making the log lines more precise.
server/src/main/java/io/pravega/schemaregistry/storage/impl/schemas/PravegaKeyValueSchemas.java
Outdated
Show resolved
Hide resolved
Do we know why |
server/src/main/java/io/pravega/schemaregistry/service/SchemaRegistryService.java
Show resolved
Hide resolved
* @param namespace the namespace for the schema | ||
* @return Provided name or Created name for type in SchemaInfo | ||
*/ | ||
public static String createTypeIfAbsent(String type, String groupName, String namespace) { |
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.
I don;t see the need for this new method.
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 removes the redundancy in the earlier code. Further, if need be this can be utilized in future too
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.
IMO, this method is unnecessary. We could do with directly using NameUtil.qualifiedName(...);
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.
Shashwat and me had tested this on a live cluster and didn't get any 504 error while creating a schema without type/name.
server/src/main/java/io/pravega/schemaregistry/service/SchemaRegistryService.java
Outdated
Show resolved
Hide resolved
server/src/test/java/io/pravega/schemaregistry/service/SchemaRegistryServiceTest.java
Show resolved
Hide resolved
@@ -133,7 +135,8 @@ public SchemaStoreImpl(Groups<T> groups, Schemas<T> schemas) { | |||
@Override | |||
public CompletableFuture<VersionInfo> addSchema(String namespace, String groupId, SchemaInfo schemaInfo, SchemaInfo normalized, | |||
BigInteger fingerprint, GroupProperties prop, Etag etag) { | |||
// Store normalized form of schema with the global schemas while the original form is stored within the group. | |||
// Store normalized form of schema with the global schemas while the original form is stored within the group. | |||
log.info("Add schema called to add a new schema in namespace {} and groupId {}", namespace, groupId); |
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.
Here namespace passed by user may be an empty string, but we're adding the schema to default namespace in this case. So the log message should indicate that. Infact this is the best place to set the namespace string to its default value if the user has provided an empty String.
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.
Not allowing empty String as value for any parameter can be enforced by specifying the minLength
parameter in swagger .yaml
file.
See: https://swagger.io/docs/specification/data-models/data-types/
@shshashwat The real root cause here is that the SchemaInfo.type field that comes in from the user is empty (not null but empty) and while its fine to handle this in the backend a better thing to do would be to force the user to provide a value for this field using some swagger functionality. |
common/src/main/java/io/pravega/schemaregistry/common/NameUtil.java
Outdated
Show resolved
Hide resolved
* @param namespace the namespace for the schema | ||
* @return Provided name or Created name for type in SchemaInfo | ||
*/ | ||
public static String createTypeIfAbsent(String type, String groupName, String namespace) { |
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.
IMO, this method is unnecessary. We could do with directly using NameUtil.qualifiedName(...);
Signed-off-by: Shashwat Sharma <[email protected]>
Signed-off-by: Shashwat Sharma <[email protected]>
Signed-off-by: Shashwat Sharma <[email protected]>
Signed-off-by: Shashwat Sharma <[email protected]>
Signed-off-by: Shashwat Sharma <[email protected]>
Signed-off-by: Shashwat Sharma <[email protected]>
Signed-off-by: Shashwat Sharma <[email protected]>
Signed-off-by: Shashwat Sharma <[email protected]>
db04b58
to
1c8021f
Compare
Signed-off-by: Shashwat Sharma <[email protected]>
Signed-off-by: Shashwat Sharma <[email protected]>
The schemaInfo object is an autogenerated file. It takes all parameters from the request payload form UI or even the API. From UI we pass |
common/src/main/java/io/pravega/schemaregistry/common/NameUtil.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Shashwat Sharma <[email protected]>
Signed-off-by: Shashwat Sharma <[email protected]>
Signed-off-by: Shashwat Sharma [email protected]
Change log description
Currently if the type is not provided with addSchema call, for Protobuf and Avro it's being updated after parsing the file but in case of JSON and Custom it's not implemented and it throws retriable exception and keeps on retrying and ultimately after 1 minute the server returns with http status 504.
Purpose of the change
Fixes #227
What the code does
Implement similar behavior to Avro and Protobuf and update type if the same has not been provided with the API call addSchema
How to verify it
addSchema of JSON or Custom type without providing the argument "type" but the same should be reflected