Search in sources :

Example 1 with MasterClient214

use of org.neo4j.kernel.ha.MasterClient214 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)

Aggregations

Test (org.junit.Test)1 IllegalProtocolVersionException (org.neo4j.com.IllegalProtocolVersionException)1 MasterClient214 (org.neo4j.kernel.ha.MasterClient214)1 MasterClient320 (org.neo4j.kernel.ha.MasterClient320)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