use of org.neo4j.com.IllegalProtocolVersionException in project neo4j by neo4j.
the class MasterClientResolverTest method shouldResolveMasterClientFactory.
@Test
public void shouldResolveMasterClientFactory() throws Exception {
// Given
LogEntryReader<ReadableClosablePositionAwareChannel> logEntryReader = new VersionAwareLogEntryReader<>();
MasterClientResolver resolver = new MasterClientResolver(NullLogProvider.getInstance(), ResponseUnpacker.NO_OP_RESPONSE_UNPACKER, mock(InvalidEpochExceptionHandler.class), 1, 1, 1, 1024, Suppliers.singleton(logEntryReader));
LifeSupport life = new LifeSupport();
try {
life.start();
MasterClient masterClient1 = resolver.instantiate("cluster://localhost", 44, null, new Monitors(), StoreId.DEFAULT, life);
assertThat(masterClient1, instanceOf(MasterClient320.class));
} finally {
life.shutdown();
}
IllegalProtocolVersionException illegalProtocolVersionException = new IllegalProtocolVersionException(MasterClient214.PROTOCOL_VERSION.getApplicationProtocol(), MasterClient310.PROTOCOL_VERSION.getApplicationProtocol(), "Protocol is too modern");
// When
resolver.handle(illegalProtocolVersionException);
// Then
life = new LifeSupport();
try {
life.start();
MasterClient masterClient2 = resolver.instantiate("cluster://localhost", 55, null, new Monitors(), StoreId.DEFAULT, life);
assertThat(masterClient2, instanceOf(MasterClient214.class));
} finally {
life.shutdown();
}
}
use of org.neo4j.com.IllegalProtocolVersionException in project neo4j by neo4j.
the class MasterClientResolver method handle.
@Override
public void handle(ComException exception) {
exception.traceComException(log, "MasterClientResolver.handle");
if (exception instanceof IllegalProtocolVersionException) {
log.info("Handling " + exception + ", will pick new master client");
IllegalProtocolVersionException illegalProtocolVersion = (IllegalProtocolVersionException) exception;
ProtocolVersion requiredProtocolVersion = new ProtocolVersion(illegalProtocolVersion.getReceived(), ProtocolVersion.INTERNAL_PROTOCOL_VERSION);
getFor(requiredProtocolVersion);
} else if (exception instanceof InvalidEpochException) {
log.info("Handling " + exception + ", will go to PENDING and ask for election");
invalidEpochHandler.handle();
} else {
log.debug("Ignoring " + exception + ".");
}
}
Aggregations