@Test public void testGetOrCreateMessageClient() throws Exception { when(messageClientMock.getScheduleInfo(any(GetScheduleInfoRequest.class))).thenReturn(responseMock); when(responseMock.getScheduleInfo()).thenReturn(topicScheduleInfoMap1); when(talosClientFactoryMock.newMessageClient("http: when(talosClientFactoryMock.newMessageClient("http: when(talosClientFactoryMock.newMessageClient("http: ScheduleInfoCache scheduleInfoCache = ScheduleInfoCache.getScheduleInfoCache(new TopicTalosResourceName(resourceName2), talosClientConfig, messageClientMock, talosClientFactoryMock); assertEquals(messageClientMock, scheduleInfoCache.getOrCreateMessageClient(topicAndPartition)); assertEquals(messageClientMock1, scheduleInfoCache.getOrCreateMessageClient(topicAndPartition1)); when(responseMock.getScheduleInfo()).thenReturn(topicScheduleInfoMap2); scheduleInfoCache.updatescheduleInfoCache(); Thread.sleep(10); assertEquals(messageClientMock0, scheduleInfoCache.getOrCreateMessageClient(topicAndPartition1)); }
public MessageService.Iface getOrCreateMessageClient(TopicAndPartition topicAndPartition) { if (scheduleInfoMap == null){ updatescheduleInfoCache(); return this.messageClient; } String host = scheduleInfoMap.get(topicAndPartition); if (host == null) { updatescheduleInfoCache(); return this.messageClient; } MessageService.Iface messageClient = messageClientMap.get(host); if (messageClient == null) { messageClient = talosClientFactory.newMessageClient("http: messageClientMap.put(host, messageClient); } return messageClient; }
ScheduleInfoCache { public MessageService.Iface getOrCreateMessageClient(TopicAndPartition topicAndPartition) { if (scheduleInfoMap == null){ updatescheduleInfoCache(); return this.messageClient; } String host = scheduleInfoMap.get(topicAndPartition); if (host == null) { updatescheduleInfoCache(); return this.messageClient; } MessageService.Iface messageClient = messageClientMap.get(host); if (messageClient == null) { messageClient = talosClientFactory.newMessageClient("http: messageClientMap.put(host, messageClient); } return messageClient; } }
ScheduleInfoCache { public MessageService.Iface getOrCreateMessageClient(TopicAndPartition topicAndPartition) { if (scheduleInfoMap == null){ updatescheduleInfoCache(); return this.messageClient; } String host = scheduleInfoMap.get(topicAndPartition); if (host == null) { updatescheduleInfoCache(); return this.messageClient; } MessageService.Iface messageClient = messageClientMap.get(host); if (messageClient == null) { messageClient = talosClientFactory.newMessageClient("http: messageClientMap.put(host, messageClient); } return messageClient; } private  ScheduleInfoCache(TopicTalosResourceName topicTalosResourceName,
      TalosClientConfig talosClientConfig, MessageService.Iface messageClient,
      TalosClientFactory talosClientFactory); private  ScheduleInfoCache(TopicTalosResourceName topicTalosResourceName,
      TalosClientConfig talosClientConfig, MessageService.Iface messageClient); }
ScheduleInfoCache { public MessageService.Iface getOrCreateMessageClient(TopicAndPartition topicAndPartition) { if (scheduleInfoMap == null){ updatescheduleInfoCache(); return this.messageClient; } String host = scheduleInfoMap.get(topicAndPartition); if (host == null) { updatescheduleInfoCache(); return this.messageClient; } MessageService.Iface messageClient = messageClientMap.get(host); if (messageClient == null) { messageClient = talosClientFactory.newMessageClient("http: messageClientMap.put(host, messageClient); } return messageClient; } private  ScheduleInfoCache(TopicTalosResourceName topicTalosResourceName,
      TalosClientConfig talosClientConfig, MessageService.Iface messageClient,
      TalosClientFactory talosClientFactory); private  ScheduleInfoCache(TopicTalosResourceName topicTalosResourceName,
      TalosClientConfig talosClientConfig, MessageService.Iface messageClient); static synchronized ScheduleInfoCache getScheduleInfoCache(TopicTalosResourceName
      topicTalosResourceName, TalosClientConfig talosClientConfig,
      MessageService.Iface messageClient, TalosClientFactory talosClientFactory); MessageService.Iface getOrCreateMessageClient(TopicAndPartition topicAndPartition); void updatescheduleInfoCache(); boolean getIsAutoLocation(); synchronized void shutDown(TopicTalosResourceName topicTalosResourceName); void shutDownAll(); }
ScheduleInfoCache { public MessageService.Iface getOrCreateMessageClient(TopicAndPartition topicAndPartition) { if (scheduleInfoMap == null){ updatescheduleInfoCache(); return this.messageClient; } String host = scheduleInfoMap.get(topicAndPartition); if (host == null) { updatescheduleInfoCache(); return this.messageClient; } MessageService.Iface messageClient = messageClientMap.get(host); if (messageClient == null) { messageClient = talosClientFactory.newMessageClient("http: messageClientMap.put(host, messageClient); } return messageClient; } private  ScheduleInfoCache(TopicTalosResourceName topicTalosResourceName,
      TalosClientConfig talosClientConfig, MessageService.Iface messageClient,
      TalosClientFactory talosClientFactory); private  ScheduleInfoCache(TopicTalosResourceName topicTalosResourceName,
      TalosClientConfig talosClientConfig, MessageService.Iface messageClient); static synchronized ScheduleInfoCache getScheduleInfoCache(TopicTalosResourceName
      topicTalosResourceName, TalosClientConfig talosClientConfig,
      MessageService.Iface messageClient, TalosClientFactory talosClientFactory); MessageService.Iface getOrCreateMessageClient(TopicAndPartition topicAndPartition); void updatescheduleInfoCache(); boolean getIsAutoLocation(); synchronized void shutDown(TopicTalosResourceName topicTalosResourceName); void shutDownAll();  }