Search in sources :

Example 1 with IllegalProtocolVersionException

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();
    }
}
Also used : MasterClient320(org.neo4j.kernel.ha.MasterClient320) Monitors(org.neo4j.kernel.monitoring.Monitors) IllegalProtocolVersionException(org.neo4j.com.IllegalProtocolVersionException) VersionAwareLogEntryReader(org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) MasterClient214(org.neo4j.kernel.ha.MasterClient214) ReadableClosablePositionAwareChannel(org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel) Test(org.junit.Test)

Example 2 with IllegalProtocolVersionException

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 + ".");
    }
}
Also used : IllegalProtocolVersionException(org.neo4j.com.IllegalProtocolVersionException) InvalidEpochException(org.neo4j.kernel.ha.com.master.InvalidEpochException) ProtocolVersion(org.neo4j.com.ProtocolVersion)

Aggregations

IllegalProtocolVersionException (org.neo4j.com.IllegalProtocolVersionException)2 Test (org.junit.Test)1 ProtocolVersion (org.neo4j.com.ProtocolVersion)1 MasterClient214 (org.neo4j.kernel.ha.MasterClient214)1 MasterClient320 (org.neo4j.kernel.ha.MasterClient320)1 InvalidEpochException (org.neo4j.kernel.ha.com.master.InvalidEpochException)1 ReadableClosablePositionAwareChannel (org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel)1 VersionAwareLogEntryReader (org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader)1 LifeSupport (org.neo4j.kernel.lifecycle.LifeSupport)1 Monitors (org.neo4j.kernel.monitoring.Monitors)1