DatabusSourcesConnection { public static DatabusSourcesConnection createDatabusSourcesConnectionForTesting() { DatabusSourcesConnection dsc = new DatabusSourcesConnection(); return dsc; } DatabusSourcesConnection(StaticConfig connConfig,
                                  List<DatabusSubscription> subscriptions,
                                  Set<ServerInfo> relays,
                                  Set<ServerInfo> bootstrapServices,
                                  List<DatabusV2ConsumerRegistration> registrations,
                                  List<DatabusV2ConsumerRegistration> bootstrapRegistrations,
                                  DbusEventBuffer dataEventsBuffer,
                                  DbusEventBuffer bootstrapEventsBuffer,
                                  ExecutorService ioThreadPool,
                                  ContainerStatisticsCollector containerStatsCollector,
                                  DbusEventsStatisticsCollector inboundEventsStatsCollector,
                                  DbusEventsStatisticsCollector bootstrapEventsStatsCollector,
                                  ConsumerCallbackStats relayCallbackStats,
                                  ConsumerCallbackStats bootstrapCallbackStats,
                                  UnifiedClientStats unifiedClientStats,
                                  CheckpointPersistenceProvider checkpointPersistenceProvider,
                                  DatabusRelayConnectionFactory relayConnFactory,
                                  DatabusBootstrapConnectionFactory bootstrapConnFactory,
                                  HttpStatisticsCollector relayCallsStatsCollector,
                                  RegistrationId registrationId,
                                  DatabusHttpClientImpl serverHandle,
                                  DbusEventFactory eventFactory,
                                  ConnectionStateFactory connStateFactory);  DatabusSourcesConnection(DatabusSourcesConnection.StaticConfig connConfig,
                                  List<DatabusSubscription> subscriptions,
                                  Set<ServerInfo> relays,
                                  Set<ServerInfo> bootstrapServices,
                                  List<DatabusV2ConsumerRegistration> registrations,
                                  List<DatabusV2ConsumerRegistration> bootstrapRegistrations,
                                  DbusEventBuffer dataEventsBuffer,
                                  DbusEventBuffer bootstrapEventsBuffer,
                                  ExecutorService ioThreadPool,
                                  ContainerStatisticsCollector containerStatsCollector,
                                  DbusEventsStatisticsCollector inboundEventsStatsCollector,
                                  DbusEventsStatisticsCollector bootstrapEventsStatsCollector,
                                  ConsumerCallbackStats relayCallbackStats,
                                  ConsumerCallbackStats bootstrapCallbackStats,
                                  UnifiedClientStats unifiedClientStats,
                                  CheckpointPersistenceProvider checkpointPersistenceProvider,
                                  DatabusRelayConnectionFactory relayConnFactory,
                                  DatabusBootstrapConnectionFactory bootstrapConnFactory,
                                  HttpStatisticsCollector relayCallsStatsCollector,
                                  RegistrationId registrationId, DatabusHttpClientImpl serverHandle,
                                  String connRawId, // Unique Name to be used for generating mbean and logger names.
                                  DbusEventFactory eventFactory,
                                  ReentrantLock v3BootstrapLock,
                                  ConnectionStateFactory connStateFactory); private  DatabusSourcesConnection(); ExecutorService getIoThreadPool(); static DatabusSourcesConnection createDatabusSourcesConnectionForTesting(); boolean isBootstrapEnabled(); void start(); boolean isRunning(); void await(); void stop(); List<String> getSourcesNames(); List<DatabusSubscription> getSubscriptions(); ConsumerCallbackStats getRelayConsumerStats(); ConsumerCallbackStats getBootstrapConsumerStats(); UnifiedClientStats getUnifiedClientStats(); static void main(String args[]); DatabusComponentStatus getConnectionStatus(); BootstrapPullThread getBootstrapPuller(); GenericDispatcher<DatabusCombinedConsumer> getBootstrapDispatcher(); CheckpointPersistenceProvider getCheckpointPersistenceProvider(); ContainerStatisticsCollector getContainerStatisticsCollector(); Set<ServerInfo> getRelays(); Set<ServerInfo> getBootstrapServices(); DbusEventsStatisticsCollector getInboundEventsStatsCollector(); GenericDispatcher<DatabusCombinedConsumer> getRelayDispatcher(); DatabusRelayConnectionFactory getRelayConnFactory(); DatabusBootstrapConnectionFactory getBootstrapConnFactory(); DbusEventBuffer getDataEventsBuffer(); DbusEventBuffer getBootstrapEventsBuffer(); Checkpoint loadPersistentCheckpoint(); List<DatabusV2ConsumerRegistration> getBootstrapRegistrations(); DatabusSourcesConnection.StaticConfig getConnectionConfig(); List<DatabusV2ConsumerRegistration> getRelayRegistrations(); DbusEventsStatisticsCollector getBootstrapEventsStatsCollector(); HttpStatisticsCollector getRelayCallsStatsCollector(); HttpStatisticsCollector getLocalRelayCallsStatsCollector(); RelayPullThread getRelayPullThread(); BootstrapPullThread getBootstrapPullThread(); void removeRegistration(DatabusV2ConsumerRegistration reg); void unregisterMbeans(); String constructPrettyNameForLogging(List<DatabusSubscription> subscriptions, String regId); static final int MAX_QUEUED_MESSAGES; static final long MESSAGE_QUEUE_POLL_TIMEOUT_MS; static final int MAX_CONNECT_RETRY_NUM; static final long CONNECT_TIMEOUT_MS; static final long REGISTER_TIMEOUT_MS; static final int MAX_CONSUMER_AWAIT_SHUTDOWN_MS; final Logger _log; }
@Test public void testLoggerNameV2_1() throws InvocationTargetException,NoSuchMethodException,IllegalAccessException { String source = "com.linkedin.events.dbName.tableName"; List<DatabusSubscription> ds = DatabusSubscription.createSubscriptionList(Arrays.asList(source)); DatabusSourcesConnection dsc = DatabusSourcesConnection.createDatabusSourcesConnectionForTesting(); String partName = DatabusSubscription.getPrettyNameForListOfSubscriptions(ds); Assert.assertEquals(partName, "dbName_tableName"); Class<?>[] arg1 = new Class<?>[] {List.class, String.class}; Method constructPrettyNameForLogging = DatabusSourcesConnection.class.getDeclaredMethod("constructPrettyNameForLogging", arg1); constructPrettyNameForLogging.setAccessible(true); Object prettyName = constructPrettyNameForLogging.invoke(dsc, ds, "test_1234"); Assert.assertEquals(prettyName, "dbName_tableName_test_1234"); }
@Test public void testLoggerNameV2_2() throws InvocationTargetException,NoSuchMethodException,IllegalAccessException { String source1 = "com.linkedin.events.db.dbPrefix1.tableName1"; String source2 = "com.linkedin.events.db.dbPrefix2.tableName2"; List<String> ls = new ArrayList<String>(); ls.add(source1); ls.add(source2); List<DatabusSubscription> ds = DatabusSubscription.createSubscriptionList(ls); DatabusSourcesConnection dsc = DatabusSourcesConnection.createDatabusSourcesConnectionForTesting(); String partName = DatabusSubscription.getPrettyNameForListOfSubscriptions(ds); Assert.assertEquals(partName, "dbPrefix1_tableName1_dbPrefix2_tableName2"); Class<?>[] arg1 = new Class<?>[] {List.class, String.class}; Method constructPrettyNameForLogging = DatabusSourcesConnection.class.getDeclaredMethod("constructPrettyNameForLogging", arg1); constructPrettyNameForLogging.setAccessible(true); Object prettyName = constructPrettyNameForLogging.invoke(dsc, ds, "test_1234"); Assert.assertEquals(prettyName, "dbPrefix1_tableName1_dbPrefix2_tableName2_test_1234"); }