@Override
  public void invalidate() {
    isTrue("open", !isClosed());

    serverStateListener.stateChanged(
        new ChangeEvent<ServerDescription>(
            description,
            ServerDescription.builder().state(CONNECTING).address(serverAddress).build()));
    connectionPool.invalidate();
    serverMonitor.invalidate();
  }
 public DefaultServer(
     final ServerAddress serverAddress,
     final ClusterConnectionMode clusterConnectionMode,
     final ConnectionPool connectionPool,
     final ConnectionFactory connectionFactory,
     final ServerMonitorFactory serverMonitorFactory) {
   notNull("serverMonitorFactory", serverMonitorFactory);
   this.clusterConnectionMode = notNull("clusterConnectionMode", clusterConnectionMode);
   this.connectionFactory = notNull("connectionFactory", connectionFactory);
   this.serverAddress = notNull("serverAddress", serverAddress);
   this.connectionPool = notNull("connectionPool", connectionPool);
   this.serverStateListener = new DefaultServerStateListener();
   description = ServerDescription.builder().state(CONNECTING).address(serverAddress).build();
   serverMonitor = serverMonitorFactory.create(serverStateListener);
   serverMonitor.start();
 }