DefaultRedisSlave implements RedisSlave { @Override public void close() { close(0); } DefaultRedisSlave(RedisClient redisClient); @Override void waitForRdbDumping(); @Override SLAVE_STATE getSlaveState(); @Override void ack(Long ackOff); @Override ChannelFuture writeFile(ReferenceFileRegion referenceFileRegion); @Override Long getAck(); @Override Long getAckTime(); @Override void beginWriteRdb(EofType eofType, long rdbFileOffset); @Override void rdbWriteComplete(); @Override void beginWriteCommands(long beginOffset); @Override ChannelFuture onCommand(ReferenceFileRegion referenceFileRegion); @Override String info(); @Override String ip(); @Override PARTIAL_STATE partialState(); @Override void partialSync(); @Override void processPsyncSequentially(Runnable runnable); @Override void markPsyncProcessed(); @Override String metaInfo(); @Override boolean isOpen(); @Override void close(); @Override void beforeCommand(); void addObserver(Observer observer); void removeObserver(Observer observer); RedisSlave becomeSlave(); RedisKeeperServer getRedisKeeperServer(); void setSlaveListeningPort(int port); int getSlaveListeningPort(); @Override void setClientIpAddress(String host); @Override String getClientIpAddress(); void capa(CAPA capa); @Override Set<CAPA> getCapas(); String[] readCommands(ByteBuf byteBuf); Channel channel(); void sendMessage(ByteBuf byteBuf); void sendMessage(byte[] bytes); void addChannelCloseReleaseResources(Releasable releasable); @Override void setClientEndpoint(Endpoint endpoint); @Override Endpoint getClientEndpoint(); @Override String toString(); @Override void release(); @Override boolean capaOf(CAPA capa); @Override boolean isKeeper(); @Override void setKeeper(); static final String KEY_RDB_DUMP_MAX_WAIT_MILLI; }
@Test public void testClose() throws IOException { redisSlave.close(); redisSlave.sendMessage(randomString(10).getBytes()); redisSlave.sendMessage(Unpooled.wrappedBuffer(randomString(10).getBytes())); shouldThrowException(() -> redisSlave.onCommand(mock(ReferenceFileRegion.class))); shouldThrowException(() -> redisSlave.beginWriteRdb(mock(EofType.class), 0L)); shouldThrowException(() -> redisSlave.beginWriteCommands(0L)); redisSlave.markPsyncProcessed(); shouldThrowException(() -> redisSlave.sendMessage(randomString(10).getBytes())); shouldThrowException(() -> redisSlave.sendMessage(Unpooled.wrappedBuffer(randomString(10).getBytes()))); shouldThrowException(() -> redisSlave.onCommand(mock(ReferenceFileRegion.class))); shouldThrowException(() -> redisSlave.beginWriteRdb(mock(EofType.class), 0L)); shouldThrowException(() -> redisSlave.beginWriteCommands(0L)); }