Skip to content
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

Redis and Minor Optimization #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

JoooJooo
Copy link
Collaborator

@JoooJooo JoooJooo commented Jun 4, 2019

No description provided.

Copy link
Owner

@devvsda devvsda left a comment

Choose a reason for hiding this comment

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

Please address given comments.

@@ -68,7 +68,7 @@ public Response registerEndpoint(@NotNull EndpointRequest registerEndpointReques
try {
log.info(String.format("Processing register endpoint for %s", registerEndpointRequest));

Integer endpointId = clientRegisterationService.registerEndpoint(registerEndpointRequest);
String endpointId = clientRegisterationService.registerEndpoint(registerEndpointRequest);
Copy link
Owner

Choose a reason for hiding this comment

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

Why conversion ?

Copy link
Owner

Choose a reason for hiding this comment

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

If converting to string, then use UUID, and change .sql file as well.

@@ -78,7 +84,7 @@ public Graph getGraphJSON(String clientName, String endpointName) throws Excepti
int clientId = clientDetails.getClientId();


EndpointDetails endpointDetails = registerationDao.getEndpointDetails(clientId, endpointName);
Copy link
Owner

Choose a reason for hiding this comment

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

+1 for moving this to DocumentDB from MySQL.

@@ -46,14 +45,15 @@

// validate.
// Get ClientId , and EndpointId.
ClientDetails clientDetails = registerationDao.getClientDetails(executeWorkflowRequest.getClientName());
ClientDetails clientDetails = executeWorkflowServiceHelper.getClientDetailsAndSave(executeWorkflowRequest.getClientName());
Copy link
Owner

Choose a reason for hiding this comment

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

Why this name ? getAndSave ?

@@ -36,6 +40,15 @@
@Inject
private RabbitMQOperation rabbitMQOperation;

@Inject
private RedisCache redisCache;
Copy link
Owner

Choose a reason for hiding this comment

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

Ideally any caching service should not be composite in any class. It will create problem, if we want to move away from Redis in future.

Its always recommended to put all caching logic in one class, and inject that class in required classes.

We can take it later, but just mark it as TODO.

* @return EndpointDetails
*/
public ClientDetails getClientDetailsAndSave(String clientName) {
String cacheKey = clientName;
Copy link
Owner

Choose a reason for hiding this comment

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

Remove this.

dbObjectInput.append(ExecutionDocumentConstants.Fields.ENDPOINT_NAME, endpointDetails.getEndpointName());
dbObjectInput.append(ExecutionDocumentConstants.Fields.ENDPOINT_DETAILS, JSONLoader.stringify(endpointDetails));
collection.insertOne(dbObjectInput);
log.debug(String.format("EndPoint details are inserted : %s inserted successfully in \n collection : %s and db : %s", endpointDetails, "graph_endpoint", "shepherd_graph_endpoint"));
Copy link
Owner

Choose a reason for hiding this comment

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

Remove all the hardcoded strings. Please make this habit from day#1. Use root level constants file for the same.

}
}
} catch (MongoWriteException e) {
log.error(e.getMessage(), e);
Copy link
Owner

Choose a reason for hiding this comment

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

improve logging. please use logging written as reference. Try to use single standard throughtout the service.

@@ -36,7 +36,7 @@ public static Connection createQueueConnection(String userName, String password,
virtualHost, hostName, portNumber);
log.info(String.format("created a new Connection Id %s on %s:%d/%s",consumerConnection.getId(),hostName,portNumber,virtualHost));
}else{
log.warn("Connection is already established, No new connection created");
log.warn("Connection is already established, Using already present consumer connection");
Copy link
Owner

Choose a reason for hiding this comment

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

Either move it to debug or info.

@@ -172,11 +172,11 @@ public void handleDelivery(String consumerTag,
log.debug(String.format("Message received : %s. delivery Tag : %s.", message, deliveryTag));
} catch (Exception e) {
log.error("Node-message processing failed.", e);
// TODO : NACK
channel.basicNack(deliveryTag,false,true);
Copy link
Owner

Choose a reason for hiding this comment

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

Did you tested this NAck ? Is it pushing back to queue ? Also, we need to check feature like visibility timeout in rabbit. Reference : https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html

If there is no such feature in Rabbit, then it may harm Shepherd threads. We need to come with some approach for the same.

import java.security.NoSuchAlgorithmException;
import java.util.concurrent.TimeoutException;

public class RedisCacheTest {
Copy link
Owner

Choose a reason for hiding this comment

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

+1 for adding UTs. Awesome :-)

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.

None yet

3 participants