Skip to content

Re-use RestClient across DataStores ... only need 1 per host:port:user#113

Open
halfstein wants to merge 3 commits into
ngageoint:masterfrom
halfstein:scroll
Open

Re-use RestClient across DataStores ... only need 1 per host:port:user#113
halfstein wants to merge 3 commits into
ngageoint:masterfrom
halfstein:scroll

Conversation

@halfstein
Copy link
Copy Markdown

OK, starting with smaller simpler updates and I'll see how the Travis CI goes.

Copy link
Copy Markdown
Contributor

@sjudeng sjudeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates. Couple minor comments and question.

final String clientKey = String.format("%s @ %s:%d", user, hostName, defaultPort);

/* if we already have the client ... just return it so we don't needlessly create the builder */
if(clients.containsKey(clientKey))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you include {} for consistency? Also include space after if for consistency.

return clients.get(clientKey);

/* creating the builder can throw IOException so we can't do it in the following functional call */
RestClientBuilder rcb = createClientBuilder(user, password, type, hostName.split(","), defaultPort, sslRejectUnauthorized);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this block can be unindented

};

/**
* The ES RestClient instances created by this factory. We don't want to create
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can unindent these comment lines by two spaces for consistency with other formatting elsewhere

final Boolean sslRejectUnauthorized = getValue(SSL_REJECT_UNAUTHORIZED, params);
final int defaultPort = getValue(HOSTPORT, params);
final String adminUser = getValue(USER, params);
final boolean sslRejectUnauthorized = getValue(SSL_REJECT_UNAUTHORIZED, params);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does changing these to primitives make them required parameters?


@Test
public void testGetRestClientSameClientKey() throws IOException {
/* multiple calls with same host:port:user should call builder once */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation here and below


/* note: ConcurrentHashMap performs this atomically ... only once per key */
return this.clients.computeIfAbsent(clientKey, (key) -> {
LOGGER.info(String.format("Building a %s RestClient for", type, key));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this missing a format string for key?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants