Search in sources :

Example 1 with NoopNodeStateListener

use of com.datastax.oss.driver.internal.core.metadata.NoopNodeStateListener in project java-driver by datastax.

the class DefaultDriverContext method buildNodeStateListener.

protected NodeStateListener buildNodeStateListener(NodeStateListener nodeStateListenerFromBuilder) {
    List<NodeStateListener> listeners = new ArrayList<>();
    if (nodeStateListenerFromBuilder != null) {
        listeners.add(nodeStateListenerFromBuilder);
    }
    DefaultDriverOption newOption = DefaultDriverOption.METADATA_NODE_STATE_LISTENER_CLASSES;
    @SuppressWarnings("deprecation") DefaultDriverOption legacyOption = DefaultDriverOption.METADATA_NODE_STATE_LISTENER_CLASS;
    DriverExecutionProfile profile = config.getDefaultProfile();
    if (profile.isDefined(newOption)) {
        listeners.addAll(Reflection.buildFromConfigList(this, newOption, NodeStateListener.class, "com.datastax.oss.driver.internal.core.metadata"));
    }
    if (profile.isDefined(legacyOption)) {
        LOG.warn("Option {} has been deprecated and will be removed in a future release; please use option {} instead.", legacyOption, newOption);
        Reflection.buildFromConfig(this, legacyOption, NodeStateListener.class, "com.datastax.oss.driver.internal.core.metadata").ifPresent(listeners::add);
    }
    if (listeners.isEmpty()) {
        return new NoopNodeStateListener(this);
    } else if (listeners.size() == 1) {
        return listeners.get(0);
    } else {
        return new MultiplexingNodeStateListener(listeners);
    }
}
Also used : NoopNodeStateListener(com.datastax.oss.driver.internal.core.metadata.NoopNodeStateListener) MultiplexingNodeStateListener(com.datastax.oss.driver.internal.core.metadata.MultiplexingNodeStateListener) NodeStateListener(com.datastax.oss.driver.api.core.metadata.NodeStateListener) MultiplexingNodeStateListener(com.datastax.oss.driver.internal.core.metadata.MultiplexingNodeStateListener) NoopNodeStateListener(com.datastax.oss.driver.internal.core.metadata.NoopNodeStateListener) DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile) DefaultDriverOption(com.datastax.oss.driver.api.core.config.DefaultDriverOption) ArrayList(java.util.ArrayList)

Aggregations

DefaultDriverOption (com.datastax.oss.driver.api.core.config.DefaultDriverOption)1 DriverExecutionProfile (com.datastax.oss.driver.api.core.config.DriverExecutionProfile)1 NodeStateListener (com.datastax.oss.driver.api.core.metadata.NodeStateListener)1 MultiplexingNodeStateListener (com.datastax.oss.driver.internal.core.metadata.MultiplexingNodeStateListener)1 NoopNodeStateListener (com.datastax.oss.driver.internal.core.metadata.NoopNodeStateListener)1 ArrayList (java.util.ArrayList)1