Search in sources :

Example 16 with DbusKeyFilter

use of com.linkedin.databus2.core.filter.DbusKeyFilter in project databus by linkedin.

the class MockRemoteExceptionHandler method testRelayPullerThreadV3WithFilter.

// make sure the filter is passed along to the doRequestStream call
@Test
public void testRelayPullerThreadV3WithFilter() throws Exception {
    RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
    // create filter
    DbusKeyCompositeFilterConfig filterConfig = createFakeFilter();
    bldr.setFilterConfig(filterConfig);
    RelayPullThread relayPuller = bldr.createRelayPullThread();
    relayPuller.getComponentStatus().start();
    ConnectionState connState = relayPuller.getConnectionState();
    connState.switchToPickServer();
    testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
    // get the created connection
    MockRelayConnection conn = (MockRelayConnection) relayPuller.getLastOpenConnection();
    conn.setProtocolVersion(3);
    relayPuller.getMessageQueue().clear();
    testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
    relayPuller.getMessageQueue().clear();
    testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
    relayPuller.getMessageQueue().clear();
    testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
    relayPuller.getMessageQueue().clear();
    testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
    relayPuller.getMessageQueue().clear();
    testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
    DbusKeyCompositeFilter filter = conn.getRelayFilter();
    Assert.assertNotNull(filter);
    // get DbusKeyFilter that we put in
    KeyFilterConfigHolder configHolder = filterConfig.getConfigMap().values().iterator().next();
    DbusKeyFilter inFilter = new DbusKeyFilter(configHolder);
    // get filter from the connection
    Assert.assertEquals(filter.getFilterMap().size(), 1, "1 filter in the composite filter");
    Assert.assertTrue(filter.getFilterMap().entrySet().iterator().hasNext(), "has one filter");
    DbusKeyFilter newFilter = filter.getFilterMap().values().iterator().next();
    //compare them
    boolean eq = inFilter.getPartitionType() == newFilter.getPartitionType() && inFilter.getFilters().size() == newFilter.getFilters().size();
    Assert.assertTrue(eq, "Same Filter");
}
Also used : DbusKeyCompositeFilterConfig(com.linkedin.databus2.core.filter.DbusKeyCompositeFilterConfig) KeyFilterConfigHolder(com.linkedin.databus2.core.filter.KeyFilterConfigHolder) DbusKeyCompositeFilter(com.linkedin.databus2.core.filter.DbusKeyCompositeFilter) DbusKeyFilter(com.linkedin.databus2.core.filter.DbusKeyFilter) Test(org.testng.annotations.Test)

Aggregations

DbusKeyFilter (com.linkedin.databus2.core.filter.DbusKeyFilter)16 KeyFilterConfigHolder (com.linkedin.databus2.core.filter.KeyFilterConfigHolder)13 Test (org.testng.annotations.Test)12 KeyModFilterConfig (com.linkedin.databus2.core.filter.KeyModFilterConfig)10 KeyRangeFilterConfig (com.linkedin.databus2.core.filter.KeyRangeFilterConfig)10 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)8 ArrayList (java.util.ArrayList)7 DbusKeyCompositeFilter (com.linkedin.databus2.core.filter.DbusKeyCompositeFilter)4 Checkpoint (com.linkedin.databus.core.Checkpoint)3 IOException (java.io.IOException)3 BootstrapConfig (com.linkedin.databus.bootstrap.common.BootstrapConfig)2 BootstrapReadOnlyConfig (com.linkedin.databus.bootstrap.common.BootstrapReadOnlyConfig)2 BootstrapServerConfig (com.linkedin.databus.bootstrap.server.BootstrapServerConfig)2 BootstrapServerStaticConfig (com.linkedin.databus.bootstrap.server.BootstrapServerStaticConfig)2 Encoding (com.linkedin.databus.core.Encoding)2 DbusEventsStatisticsCollector (com.linkedin.databus.core.monitoring.mbean.DbusEventsStatisticsCollector)2 InvalidConfigException (com.linkedin.databus.core.util.InvalidConfigException)2 RequestProcessingException (com.linkedin.databus2.core.container.request.RequestProcessingException)2 DbusKeyCompositeFilterConfig (com.linkedin.databus2.core.filter.DbusKeyCompositeFilterConfig)2 BootstrapProcessingException (com.linkedin.databus.bootstrap.api.BootstrapProcessingException)1