-
Notifications
You must be signed in to change notification settings - Fork 100
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
PROD-39429 PART-2 Make REST API(/channels/status) call which acts as Channel Exi… #737
Conversation
84e089d
to
638bcc3
Compare
638bcc3
to
ca5b448
Compare
private static final KCLogger LOGGER = | ||
new KCLogger(StreamingChannelExistenceChecker.class.getName()); | ||
|
||
private static final String DEBUG_PREFIX = "Channel Existence Checker - Kafka Connector"; |
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.
private static final String DEBUG_PREFIX = "Channel Existence Checker - Kafka Connector"; | |
private static final String DEBUG_PREFIX = "StreamingChannelExistenceChecker"; |
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.
ack!
|
||
try { | ||
ObjectMapper objectMapper = new ObjectMapper(); | ||
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); |
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.
what is this?
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.
good catch, not needed!
|
||
ChannelExistenceCheckerResponse channelExistenceCheckerResponse; | ||
try (CloseableHttpResponse closeableHttpResponse = httpClient.execute(request)) { | ||
|
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.
nit: extra line
LOGGER.warn( | ||
"Null response obtained in {} for channel:{}", CHANNEL_STATUS_ENDPOINT, channelName); |
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.
why we need a log if we're going to throw?
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.
to know which channel name had this issue.
.equals(SUCCESS.getStatusCode())) { | ||
// We check two status codes, one for invalid client sequencers and one for a valid client | ||
// Sequencer | ||
LOGGER.debug(String.format("%s Channel:%s does exist", DEBUG_PREFIX, channelName)); |
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.
duplicate with above?
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.
it's Does and doesn't for channel.
"{} Error Getting a valid response for ChannelName:{} error:{}", | ||
DEBUG_PREFIX, | ||
channelName, | ||
e.getMessage()); |
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.
any issue with returning here instead of thrown an error?
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 think that's ok, being unable to get a channel basically means it doesnt exist. We should add that behavior to the javadoc though: @return True if it exists, false if it doesn't or failed to get status
* @param channelName Name of Channel to Check for Existence | ||
* @return True if it exists, false if it doesn't. | ||
*/ | ||
public boolean checkChannelExistence(final String channelName) { |
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.
nit: checkChannelExists so that it's easier to intuit that returning TRUE means the channel 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.
makes sense, will do!
"{} Error Getting a valid response for ChannelName:{} error:{}", | ||
DEBUG_PREFIX, | ||
channelName, | ||
e.getMessage()); |
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 think that's ok, being unable to get a channel basically means it doesnt exist. We should add that behavior to the javadoc though: @return True if it exists, false if it doesn't or failed to get status
switch (statusLine.getStatusCode()) { | ||
// If we have a 503, BACKOFF | ||
case HttpStatus.SC_SERVICE_UNAVAILABLE: | ||
throw new BackOffException(); |
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.
Do we want to retry for this BackOffException? We don't retry in checkChannelExistance
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.
good catch, I copied this function from sdk and I do see we dont have retries in channelexistence, I plan to add retries, but let me check this..
…stence Checker
What
Why
show channels iliike '<channelName>' in table <tableName>
is an expensive operation and is not optimal and also doesnt get away from opening a channel.If interested, take a look at this algorithm: (Internal employees only)
Tests
Added tests.