autoscale/analytical samples; DB/container CRUD; queries; template for usermanagement sample#11
Conversation
moderakh
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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.
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.
remove print stacktrace in favour of passing e to logger
No description provided.