Final: Question 3 - I don't understand the question

Hi,
Could someone help me understand what the “Final: Question 3” means? I don’t understand the question: “Which of the following variables contained the associated value?”
Thank you!

Hi @imremy,

Think about it in these terms:

which of the following are true

sslSettings.isInvalidHostNameAllowed() == true
readConcern.asDocument().toString() == "{ }"
sslSettings.isEnabled() == false
writeConcern.asDocument().toString() == "{ w : 1 }"
readPreference.toString() == "primary"

Does this make more sense ?

N.

Hmm not really, because since we don’t have the URI in the question, we don’t know what connection options are set to what value…

@imremy

Let’s take the following code, where URI is a connection to your Atlas cluster using an SRV record.

Would that be more clear ?

Since URI is not there in the question, How can we assume the settings are there. Please someone clarify?

Because you are the one who built or adjusted the code. In order to make it run, you ensured the right settings in the first week of the course.

I also think that this particular exam question is very vague. Since URI is not exactly specified as part of the question, then listed answers can be misleading. And even if I consider that the “URI” here is what we used in our mflix throughout the course, is it the initial URI or the URI that I ended up with right before taking this exam?

From my own experience, vague questions tend to lead to vague answers…but the exam grading here, on the other hand, is “exact science” with no gray area.

Hi all,
take a look at MongoClientLesson.java and just check all statements under debugger.

3 Likes

I think the idea is which of the following could be set from the URI.

Any tips for this question ?

The question is not very clear because URI or SRV are missing.

From the first sentence of the question: where URI is a connection to your Atlas cluster using an SRV record. I have emboldened ‘your atlas cluster’ from the original text.

Personally, I look at the code to find where ConnectionString is used by mflix and I added traces to see what are the values.

MongoDB Documentation for:
Connection String URI Format - DNS Seedlist Connection Format

In addition, use of the +srv connection string modifier automatically sets the ssl option to true for the connection. You can override this behavior by explicitly setting the ssl option to false with ssl=false in the query string.

You really don’t need to know the content of options on the URI or the SRV record in DNS, since the documentation points out some facts that are defaults.

This is basically the point raised by the quotation of the question text included by @Norberto much earlier in the thread.

Do we have to assume there are no ?options in the URI string? Otherwise, it seems every choices (except for sslSettings.isInvalidHostNameAllowed()) can be set with the URI string which is unknown.

The question is ambiguous for me, but for omission, I consider my string connection used in practice. I think there is no other option.

in my case the last state of the connection string used to connect to M. Atlas is: mongodb+srv://mflixAppUser:mflixAppPwd@mflix-fgtce.mongodb.net/mflix?maxPoolSize=50&w=majority&wtimeoutMS=2500&connectTimeoutMS=2000, it is not clear which version of the connection must we work with, whether it is the default or the latest version.

@rfjuarez, given the selectable options, it shouldn’t matter if you are using the final version of your URI SRV string or the initial string you’ve picked up from Atlas.

N.

Thank you very much for your reply!

I was thinking to create a topic about this myself. Thanks for that.

According to the docs about line 4, I believe it should print like so but I’m receiving another output. I didn’t have a look at what’s actually happening in class methods but I think I should change my answer.

Anyone has the same thought about it?

I went back to Atlas to use the original connection string. My $.02 - If we were sitting in a class, I don’t think one would reflect back to some homework assignment’s particular configuration to answer this question.

Add to the Application.java:

MongoClientSettings settings = MongoClientSettings.builder()
.applyConnectionString(new ConnectionString(“mongodb+srv://m220student:m220password@[SERVER]?retryWrites=true”)).build();
MongoClient mongoClient = MongoClients.create(settings);
SslSettings sslSettings = settings.getSslSettings();
ReadPreference readPreference = settings.getReadPreference();
ReadConcern readConcern = settings.getReadConcern();
WriteConcern writeConcern = settings.getWriteConcern();
System.out.println(sslSettings.isInvalidHostNameAllowed());
System.out.println(sslSettings.isEnabled());
System.out.println(readPreference.toString());
System.out.println(readConcern.asDocument().toString());
System.out.println(writeConcern.asDocument().toString());

2 Likes