Search in sources :

Example 11 with EventBus

use of com.datastax.oss.driver.internal.core.context.EventBus in project java-driver by datastax.

the class NodeStateManagerTest method setup.

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    // Disable debouncing by default, tests that need it will override
    when(defaultProfile.getDuration(DefaultDriverOption.METADATA_TOPOLOGY_WINDOW)).thenReturn(Duration.ofSeconds(0));
    when(defaultProfile.getInt(DefaultDriverOption.METADATA_TOPOLOGY_MAX_EVENTS)).thenReturn(1);
    when(config.getDefaultProfile()).thenReturn(defaultProfile);
    when(context.getConfig()).thenReturn(config);
    this.eventBus = spy(new EventBus("test"));
    when(context.getEventBus()).thenReturn(eventBus);
    adminEventLoopGroup = new DefaultEventLoopGroup(1, new BlockingOperation.SafeThreadFactory());
    when(nettyOptions.adminEventExecutorGroup()).thenReturn(adminEventLoopGroup);
    when(context.getNettyOptions()).thenReturn(nettyOptions);
    when(context.getMetricsFactory()).thenReturn(metricsFactory);
    node1 = TestNodeFactory.newNode(1, context);
    node2 = TestNodeFactory.newNode(2, context);
    ImmutableMap<UUID, Node> nodes = ImmutableMap.<UUID, Node>builder().put(node1.getHostId(), node1).put(node2.getHostId(), node2).build();
    Metadata metadata = new DefaultMetadata(nodes, Collections.emptyMap(), null, null);
    when(metadataManager.getMetadata()).thenReturn(metadata);
    when(metadataManager.refreshNode(any(Node.class))).thenReturn(CompletableFuture.completedFuture(null));
    when(context.getMetadataManager()).thenReturn(metadataManager);
}
Also used : Node(com.datastax.oss.driver.api.core.metadata.Node) Metadata(com.datastax.oss.driver.api.core.metadata.Metadata) EventBus(com.datastax.oss.driver.internal.core.context.EventBus) UUID(java.util.UUID) DefaultEventLoopGroup(io.netty.channel.DefaultEventLoopGroup) Before(org.junit.Before)

Aggregations

EventBus (com.datastax.oss.driver.internal.core.context.EventBus)11 Before (org.junit.Before)8 DefaultEventLoopGroup (io.netty.channel.DefaultEventLoopGroup)6 Node (com.datastax.oss.driver.api.core.metadata.Node)5 DefaultNode (com.datastax.oss.driver.internal.core.metadata.DefaultNode)5 InternalDriverContext (com.datastax.oss.driver.internal.core.context.InternalDriverContext)4 CqlSession (com.datastax.oss.driver.api.core.CqlSession)3 Duration (java.time.Duration)3 Test (org.junit.Test)3 DriverConfigLoader (com.datastax.oss.driver.api.core.config.DriverConfigLoader)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 ProtocolVersion (com.datastax.oss.driver.api.core.ProtocolVersion)1 DefaultDriverOption (com.datastax.oss.driver.api.core.config.DefaultDriverOption)1 DriverConfig (com.datastax.oss.driver.api.core.config.DriverConfig)1 DriverExecutionProfile (com.datastax.oss.driver.api.core.config.DriverExecutionProfile)1 EndPoint (com.datastax.oss.driver.api.core.metadata.EndPoint)1 Metadata (com.datastax.oss.driver.api.core.metadata.Metadata)1 ProtocolVersionRegistry (com.datastax.oss.driver.internal.core.ProtocolVersionRegistry)1 TestResponses (com.datastax.oss.driver.internal.core.TestResponses)1 DriverChannel (com.datastax.oss.driver.internal.core.channel.DriverChannel)1