-
Notifications
You must be signed in to change notification settings - Fork 155
Update routing according to specification #314
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
Conversation
2a9469a
to
a332bdf
Compare
…t no long needed after the change
a332bdf
to
14f1701
Compare
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.
@zhenlineo review round completed. Made some comments.
@@ -120,7 +67,11 @@ private ClusterComposition( long expirationTimestamp ) | |||
|
|||
public boolean isValid() |
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.
Maybe we can name this method #hasWriters()
to be less ambiguous?
return !routers.isEmpty() && !writers.isEmpty(); | ||
return !writers.isEmpty(); | ||
} | ||
public boolean isIllegalResponse() |
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'd vote for #hasRoutersAndReaders()
name to be more explicit
{ | ||
if ( record == null ) | ||
{ | ||
return null; | ||
} | ||
try | ||
|
||
final ClusterComposition result; |
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.
Declaration can be joined with the assignment
{ | ||
GetClusterCompositionResponse getClusterComposition( Connection connection ); | ||
|
||
class Default implements ClusterCompositionProvider |
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.
Let's move this implementation to a separate file, I think it deserves this :)
*/ | ||
public class ProtocolException extends Neo4jException | ||
{ | ||
private static String CODE = "Protocol violation: "; |
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.
Field should be final
|
||
import static java.util.Arrays.asList; | ||
|
||
public class ClusterCompositionUtil |
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 is probably good to make this class final and add a private constructor
events.registerHandler( StubConnectionPool.EventSink.class, new StubConnectionPool.EventSink.Adapter() | ||
{ | ||
// given & when | ||
final AtomicInteger ensureRoutingCounter = new AtomicInteger( 0 ); |
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 do you think about using Mockito#spy()
instead of atomic integers and runnables? Invocations could then be verified as with regular mockito mocks.
public class RediscoveryTest | ||
{ | ||
|
||
private static GetClusterCompositionResponse.Success Success( ClusterComposition cluster ) |
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.
Methods Success\Failure
should be named success\failure
. Would it be valuable to move them to GetClusterCompositionResponse
?
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
import org.junit.runners.Parameterized.Parameters; | ||
import sun.reflect.generics.reflectiveObjects.NotImplementedException; |
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.
We should probably not use this exception. Prefer java.lang.UnsupportedOperationException
public void removeRouter( BoltServerAddress toRemove ) | ||
{ | ||
removedRouters.add( toRemove ); | ||
// throw new UnsupportedOperationException( "Should never remove any router from routing table" ); |
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.
Can this comment be removed?
fd2bd15
to
9fef3cc
Compare
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.
@zhenlineo changes look good. Made couple minor comments about naming.
|
||
import static java.lang.String.format; | ||
|
||
public class GetServersProcedureClusterCompositionProvider implements ClusterCompositionProvider |
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 do you think about ClusterCompositionProviderImpl
name for this class?
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 like this long name better, as it allows us to have other providers such as FileClusterCompositionProvider
or GetServers2ProcedureClusterCompositionProvider
@@ -65,14 +64,14 @@ | |||
public class RediscoveryTest | |||
{ | |||
|
|||
private static GetClusterCompositionResponse.Success Success( ClusterComposition cluster ) | |||
private static ClusterCompositionResponse.Success Success( ClusterComposition cluster ) |
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.
Method should be named success
} | ||
|
||
private static GetClusterCompositionResponse.Failure Failure( RuntimeException e ) | ||
private static ClusterCompositionResponse.Failure Failure( RuntimeException e ) |
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.
Method should be named failure
No description provided.