-
Notifications
You must be signed in to change notification settings - Fork 75
autoscale/analytical samples; DB/container CRUD; queries; template for usermanagement sample #11
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
Conversation
moderakh
left a comment
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.
great work Andy, some minor comments:
1- fix the code style, intellj has auto-format
2- use slf4j param place holder instead of string concat
3- use slf4j for exception logging rather than e.printStackTrace()
see this
String.format(
|
|
||
| public void close() { | ||
| client.close(); | ||
| } |
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 move the implementation methods like close() to the bottom of the sample.
|
|
||
| // Database Create | ||
| private void createDatabaseIfNotExists() throws Exception { | ||
| logger.info("Create database " + databaseName + " if not exists..."); |
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.
use slf4j placeholder rather than string concat
|
|
||
| // Container create | ||
| private void createContainerIfNotExists() throws Exception { | ||
| logger.info("Create container " + containerName + " if not exists."); |
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.
ditto here and other places.
| deleteADatabase(); | ||
| } catch (Exception err) { | ||
| logger.error("Deleting Cosmos DB resources failed, will still attempt to close the client. See stack trace below."); | ||
| err.printStackTrace(); |
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.
error needs to be passed to slf4j logger rather than directing to stderr'
| err.printStackTrace(); | |
| logger.error("Deleting Cosmos DB resources failed, will still attempt to close the client. See stack trace below., e); |
|
|
||
| private void autoscaleContainerCRUDDemo() throws Exception { | ||
|
|
||
| logger.info("Using Azure Cosmos DB endpoint: " + AccountSettings.HOST); |
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.
http://www.slf4j.org/faq.html#paramException
use slfrj place holder rather than string concat. here and other places.
http://www.slf4j.org/faq.html#paramException
| logger.info("Demo complete, please hold while resources are released"); | ||
| } catch (Exception e) { | ||
| e.printStackTrace(); | ||
| logger.error(String.format("Cosmos getStarted failed with %s", 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.
don't mix STring.format with slf4j logger
see this for how to do logging for error using slf4j
http://www.slf4j.org/faq.html#paramException
| logger.error(String.format("Cosmos getStarted failed with %s", e)); | |
| logger.error("Cosmos getStarted failed", e); |
| p.autoscaleDatabaseCRUDDemo(); | ||
| logger.info("Demo complete, please hold while resources are released"); | ||
| } catch (Exception e) { | ||
| e.printStackTrace(); |
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.
remove print stacktrace in favour of passing e to logger
No description provided.