org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException Java Examples
The following examples show how to use
org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomModelBuilder.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public CustomModelBuilder(Model model) { ExecuteManager executeManager = new ExecuteManagerImpl(); setProp(executeManager.getClass(), executeManager, "log", new PlexusLoggerAdapter(LoggerFactory.getLogger(ExecuteManagerImpl.class))); setProp(ModelBuilder.class, this, "executeManager", executeManager); setProp(ModelBuilder.class, this, "log", new PlexusLoggerAdapter(LoggerFactory.getLogger(ModelBuilder.class))); try { initialize(); } catch (InitializationException e) { throw new RuntimeException(e); } Map factories = (Map) getProp(FactoryBuilderSupport.class, this, "factories"); factories.remove("project"); ModelFactory modelFactory = new ModelFactory(model); registerFactory(modelFactory.getName(), null, modelFactory); }
Example #2
Source File: CustomModelBuilder.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public CustomModelBuilder(Model model) { ExecuteManager executeManager = new ExecuteManagerImpl(); setProp(executeManager.getClass(), executeManager, "log", new PlexusLoggerAdapter(LoggerFactory.getLogger(ExecuteManagerImpl.class))); setProp(ModelBuilder.class, this, "executeManager", executeManager); setProp(ModelBuilder.class, this, "log", new PlexusLoggerAdapter(LoggerFactory.getLogger(ModelBuilder.class))); try { initialize(); } catch (InitializationException e) { throw new RuntimeException(e); } Map factories = (Map) getProp(FactoryBuilderSupport.class, this, "factories"); factories.remove("project"); ModelFactory modelFactory = new ModelFactory(model); registerFactory(modelFactory.getName(), null, modelFactory); }
Example #3
Source File: CustomModelBuilder.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public CustomModelBuilder(Model model) { ExecuteManager executeManager = new ExecuteManagerImpl(); setProp(executeManager.getClass(), executeManager, "log", new PlexusLoggerAdapter(LoggerFactory.getLogger(ExecuteManagerImpl.class))); setProp(ModelBuilder.class, this, "executeManager", executeManager); setProp(ModelBuilder.class, this, "log", new PlexusLoggerAdapter(LoggerFactory.getLogger(ModelBuilder.class))); try { initialize(); } catch (InitializationException e) { throw new RuntimeException(e); } Map factories = (Map) getProp(FactoryBuilderSupport.class, this, "factories"); factories.remove("project"); ModelFactory modelFactory = new ModelFactory(model); registerFactory(modelFactory.getName(), null, modelFactory); }
Example #4
Source File: XpipeDataSourceProvider.java From x-pipe with Apache License 2.0 | 6 votes |
@Override public void initialize() throws InitializationException { if (qconfigDataSourceProviderPresent) { try { m_delegate = (DataSourceProvider)(Class.forName(qconfigDataSourceProviderClass).newInstance()); } catch (Throwable ex) { m_logger.error("Loading qconfig datasource provider failed", ex); } } if (m_delegate == null) { m_delegate = createDefaultDataSourceProvider(); } if (m_delegate instanceof LogEnabled) { ((LogEnabled)m_delegate).enableLogging(m_logger); } logger.info("[initialize][DataSourceProvider]{}", m_delegate); }
Example #5
Source File: DefaultBrokerRegistry.java From hermes with Apache License 2.0 | 6 votes |
@Override public void initialize() throws InitializationException { try { thisInstance = ServiceInstance.<Void> builder()// .name(m_config.getRegistryName(null))// .address(Networks.forIp().getLocalHostAddress())// .port(m_config.getListeningPort())// .id(m_config.getSessionId())// .build(); m_serviceDiscovery = ServiceDiscoveryBuilder.builder(Void.class)// .client(m_client.get())// .basePath(m_config.getRegistryBasePath())// .thisInstance(thisInstance)// .build(); } catch (Exception e) { throw new InitializationException("Failed to init broker registry.", e); } }
Example #6
Source File: MySQLMessageQueueStorage.java From hermes with Apache License 2.0 | 6 votes |
@Override public void initialize() throws InitializationException { try { m_bufFieldOfByteArrayInputStream = ByteArrayInputStream.class.getDeclaredField("buf"); m_bufFieldOfByteArrayInputStream.setAccessible(true); } catch (Exception e) { throw new InitializationException("Failed to get field \"buf\" from ByteArrayInputStream.", e); } if (m_config.getMySQLCacheConfig().isEnabled()) { m_msgDao = CachedMessagePriorityDaoInterceptor.createProxy(m_msgDao, m_config.getMySQLCacheConfig()); } m_catSelectorByPriorityMetrics.put(1, CatConstants.TYPE_MESSAGE_PRODUCE_BY_PRIORITY + "1"); m_catSelectorByPriorityMetrics.put(10, CatConstants.TYPE_MESSAGE_PRODUCE_BY_PRIORITY + "2-10"); m_catSelectorByPriorityMetrics.put(50, CatConstants.TYPE_MESSAGE_PRODUCE_BY_PRIORITY + "11-50"); m_catSelectorByPriorityMetrics.put(Integer.MAX_VALUE, CatConstants.TYPE_MESSAGE_PRODUCE_BY_PRIORITY + "gt-50"); m_catSelectorByNonPriorityMetrics.put(1, CatConstants.TYPE_MESSAGE_PRODUCE_BY_NONPRIORITY + "1"); m_catSelectorByNonPriorityMetrics.put(10, CatConstants.TYPE_MESSAGE_PRODUCE_BY_NONPRIORITY + "2-10"); m_catSelectorByNonPriorityMetrics.put(50, CatConstants.TYPE_MESSAGE_PRODUCE_BY_NONPRIORITY + "11-50"); m_catSelectorByNonPriorityMetrics.put(Integer.MAX_VALUE, CatConstants.TYPE_MESSAGE_PRODUCE_BY_NONPRIORITY + "gt-50"); }
Example #7
Source File: DefaultLongPollingService.java From hermes with Apache License 2.0 | 6 votes |
@Override public void initialize() throws InitializationException { m_catSelectorByPriorityMetrics.put(0, CatConstants.TYPE_MESSAGE_DELIVER_BY_PRIORITY + "0"); m_catSelectorByPriorityMetrics.put(1, CatConstants.TYPE_MESSAGE_DELIVER_BY_PRIORITY + "1"); m_catSelectorByPriorityMetrics.put(10, CatConstants.TYPE_MESSAGE_DELIVER_BY_PRIORITY + "2-10"); m_catSelectorByPriorityMetrics.put(50, CatConstants.TYPE_MESSAGE_DELIVER_BY_PRIORITY + "11-50"); m_catSelectorByPriorityMetrics.put(Integer.MAX_VALUE, CatConstants.TYPE_MESSAGE_DELIVER_BY_PRIORITY + "gt-50"); m_catSelectorByNonPriorityMetrics.put(0, CatConstants.TYPE_MESSAGE_DELIVER_BY_NONPRIORITY + "0"); m_catSelectorByNonPriorityMetrics.put(1, CatConstants.TYPE_MESSAGE_DELIVER_BY_NONPRIORITY + "1"); m_catSelectorByNonPriorityMetrics.put(10, CatConstants.TYPE_MESSAGE_DELIVER_BY_NONPRIORITY + "2-10"); m_catSelectorByNonPriorityMetrics.put(50, CatConstants.TYPE_MESSAGE_DELIVER_BY_NONPRIORITY + "11-50"); m_catSelectorByNonPriorityMetrics.put(Integer.MAX_VALUE, CatConstants.TYPE_MESSAGE_DELIVER_BY_NONPRIORITY + "gt-50"); m_catSelectorBySafeTriggerMetrics.put(0, CatConstants.TYPE_MESSAGE_DELIVER_BY_SAFE + "0"); m_catSelectorBySafeTriggerMetrics.put(1, CatConstants.TYPE_MESSAGE_DELIVER_BY_SAFE + "1"); m_catSelectorBySafeTriggerMetrics.put(10, CatConstants.TYPE_MESSAGE_DELIVER_BY_SAFE + "2-10"); m_catSelectorBySafeTriggerMetrics.put(50, CatConstants.TYPE_MESSAGE_DELIVER_BY_SAFE + "11-50"); m_catSelectorBySafeTriggerMetrics.put(Integer.MAX_VALUE, CatConstants.TYPE_MESSAGE_DELIVER_BY_SAFE + "gt-50"); }
Example #8
Source File: DefaultEndpointManager.java From hermes with Apache License 2.0 | 6 votes |
@Override public void initialize() throws InitializationException { Executors.newSingleThreadScheduledExecutor(HermesThreadFactory.create("EndpointCacheHouseKeeper", true)) .scheduleWithFixedDelay(new Runnable() { @Override public void run() { try { long now = System.currentTimeMillis(); if (!m_tpEndpointCache.isEmpty()) { for (Map.Entry<Pair<String, Integer>, EndpointCacheValue> entry : m_tpEndpointCache.entrySet()) { if (now - entry.getValue().getAccessTime() > m_config.getEndpointCacheMillis()) { m_tpEndpointCache.remove(entry.getKey()); } } } } catch (Exception e) { log.warn("Exception occurred in EndpointCacheCleaner", e); } } }, 3, 3, TimeUnit.MINUTES); }
Example #9
Source File: RunningStatusStatisticsService.java From hermes with Apache License 2.0 | 6 votes |
@Override public void initialize() throws InitializationException { String runningStatusStatSwitch = System.getProperty("runningStatusStat", "false"); if ("true".equalsIgnoreCase(runningStatusStatSwitch)) { Executors.newSingleThreadScheduledExecutor(HermesThreadFactory.create("RunningStatusStat", true)) .scheduleWithFixedDelay(new Runnable() { @Override public void run() { try { printAllThreads(); } catch (Exception e) { // ignore it } } }, 0, m_config.getRunningStatusStatInterval(), TimeUnit.SECONDS); } }
Example #10
Source File: DefaultCMessagingConfigService.java From hermes with Apache License 2.0 | 6 votes |
@Override public void initialize() throws InitializationException { boolean initSuccess = false; try { initSuccess = updateConfig(); } catch (Exception e) { throw new InitializationException("Can not fetch cmessaging config from any meta server", e); } if (!initSuccess) { throw new InitializationException("Can not fetch cmessaging config from any meta server"); } HermesThreadFactory.create("CMessagingConfigUpdater", true).newThread(new ConfigUpdateTask()).start(); }
Example #11
Source File: DefaultManualConfigService.java From hermes with Apache License 2.0 | 6 votes |
private void registerConfigFetcher() throws InitializationException { Map<String, ManualConfigFetcher> configFetchers = lookupMap(ManualConfigFetcher.class); if (!configFetchers.isEmpty()) { if (configFetchers.size() == 1) { m_configFetcher = configFetchers.values().iterator().next(); } else { for (Map.Entry<String, ManualConfigFetcher> entry : configFetchers.entrySet()) { if (!DefaultManualConfigFetcher.ID.equals(entry.getKey())) { m_configFetcher = entry.getValue(); break; } } } } if (m_configFetcher == null) { throw new InitializationException("ManualConfigFetcher not found."); } }
Example #12
Source File: DefaultManualConfigService.java From hermes with Apache License 2.0 | 6 votes |
@Override public void initialize() throws InitializationException { registerConfigFetcher(); checkManualConfigureMode(); Executors.newSingleThreadScheduledExecutor(HermesThreadFactory.create("ManualConfigFetcher", true)) .scheduleWithFixedDelay(new Runnable() { @Override public void run() { try { checkManualConfigureMode(); } catch (Exception e) { log.warn("Check manual config failed."); } } }, 5, 5, TimeUnit.SECONDS); }
Example #13
Source File: ZKSuppportTestCase.java From hermes with Apache License 2.0 | 6 votes |
protected void configureCurator() throws Exception { Builder builder = CuratorFrameworkFactory.builder(); builder.connectionTimeoutMs(50); builder.connectString(getZkConnectionString()); builder.maxCloseWaitMs(50); builder.namespace("hermes"); builder.retryPolicy(new ExponentialBackoffRetry(5, 3)); builder.sessionTimeoutMs(50); m_curator = builder.build(); m_curator.start(); try { m_curator.blockUntilConnected(); } catch (InterruptedException e) { throw new InitializationException(e.getMessage(), e); } }
Example #14
Source File: Test.java From hermes with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { Builder builder = CuratorFrameworkFactory.builder(); builder.connectionTimeoutMs(1000); builder.connectString("127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183"); builder.retryPolicy(new RetryNTimes(1, 1000)); builder.sessionTimeoutMs(5000); CuratorFramework framework = builder.build(); framework.start(); try { framework.blockUntilConnected(); } catch (InterruptedException e) { throw new InitializationException(e.getMessage(), e); } System.in.read(); }
Example #15
Source File: CustomModelBuilder.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public CustomModelBuilder(Model model) { ExecuteManager executeManager = new ExecuteManagerImpl(); setProp(executeManager.getClass(), executeManager, "log", new PlexusLoggerAdapter(LoggerFactory.getLogger(ExecuteManagerImpl.class))); setProp(ModelBuilder.class, this, "executeManager", executeManager); setProp(ModelBuilder.class, this, "log", new PlexusLoggerAdapter(LoggerFactory.getLogger(ModelBuilder.class))); try { initialize(); } catch (InitializationException e) { throw new RuntimeException(e); } Map factories = (Map) getProp(FactoryBuilderSupport.class, this, "factories"); factories.remove("project"); ModelFactory modelFactory = new ModelFactory(model); registerFactory(modelFactory.getName(), null, modelFactory); }
Example #16
Source File: MetaServerAssignmentHolder.java From hermes with Apache License 2.0 | 6 votes |
private void initPathChildrenCache() throws InitializationException { m_pathChildrenCache = new PathChildrenCache(m_zkClient.get(), ZKPathUtils.getMetaServerAssignmentRootZkPath(), true); m_pathChildrenCache.getListenable().addListener(new PathChildrenCacheListener() { @Override public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception { if (event.getType() == PathChildrenCacheEvent.Type.CHILD_ADDED || event.getType() == PathChildrenCacheEvent.Type.CHILD_REMOVED || event.getType() == PathChildrenCacheEvent.Type.CHILD_UPDATED) { String topic = ZKPathUtils.lastSegment(event.getData().getPath()); m_topiAssignmentCache.invalidate(topic); } } }); try { m_pathChildrenCache.start(StartMode.BUILD_INITIAL_CACHE); } catch (Exception e) { throw new InitializationException("Init metaServerAssignmentHolder failed.", e); } }
Example #17
Source File: KafkaMessageSender.java From hermes with Apache License 2.0 | 5 votes |
@Override public void initialize() throws InitializationException { Executors.newSingleThreadScheduledExecutor(HermesThreadFactory.create("CheckIdcPolicyChangesExecutor", true)) .scheduleWithFixedDelay(new Runnable() { @Override public void run() { try { for (Entry<String, Pair<KafkaProducer<String, byte[]>, Properties>> producer : m_producers.entrySet()) { Properties newProps = getProducerProperties(producer.getKey()); Properties currentProps = producer.getValue().getValue(); String newBootstrapServersProperty = newProps .getProperty(KafkaConstants.BOOTSTRAP_SERVERS_PROPERTY_NAME); String currentBootstrapServersProperty = currentProps .getProperty(KafkaConstants.BOOTSTRAP_SERVERS_PROPERTY_NAME); if (!(newBootstrapServersProperty != null && currentBootstrapServersProperty != null && newBootstrapServersProperty .equals(currentBootstrapServersProperty))) { synchronized (m_producers) { if (m_producers.containsKey(producer.getKey())) { m_logger.info("Sending messages to topic:{} on new kafka cluster:{} instead of :{}.", producer.getKey(), newBootstrapServersProperty, currentBootstrapServersProperty); Pair<KafkaProducer<String, byte[]>, Properties> removedProducer = m_producers .remove(producer.getKey()); removedProducer.getKey().close(); } } } } } catch (Exception e) { m_logger.warn("Check idc policy changes failed!", e); } } }, 5, 20, TimeUnit.SECONDS); }
Example #18
Source File: ZKClient.java From hermes with Apache License 2.0 | 5 votes |
private void startCuratorFramework(ZookeeperEnsemble primaryEnsemble) throws InitializationException { Builder builder = CuratorFrameworkFactory.builder(); builder.connectionTimeoutMs(m_config.getZkConnectionTimeoutMillis()); builder.maxCloseWaitMs(m_config.getZkCloseWaitMillis()); builder.namespace(m_config.getZkNamespace()); builder.retryPolicy(new RetryNTimes(m_config.getZkRetries(), m_config.getSleepMsBetweenRetries())); builder.sessionTimeoutMs(m_config.getZkSessionTimeoutMillis()); builder.threadFactory(HermesThreadFactory.create("Broker-Zk", true)); builder.ensembleProvider(new EnsembleProvider() { @Override public void start() throws Exception { } @Override public String getConnectionString() { return m_primaryZookeeperEnsemble.get().getConnectionString(); } @Override public void close() throws IOException { } }); m_client = builder.build(); m_client.start(); try { m_client.blockUntilConnected(); log.info("Conneted to zookeeper({}).", JSON.toJSONString(primaryEnsemble)); } catch (InterruptedException e) { throw new InitializationException(e.getMessage(), e); } }
Example #19
Source File: DefaultMessageQueueManager.java From hermes with Apache License 2.0 | 5 votes |
@Override public void initialize() throws InitializationException { m_ackOpExecutor = Executors.newScheduledThreadPool(m_config.getAckOpExecutorThreadCount(), HermesThreadFactory.create("AckOp", true)); m_ackMessagesTaskExecutor = Executors.newScheduledThreadPool(m_config.getAckMessagesTaskExecutorThreadCount(), HermesThreadFactory.create("AckMessagesTaskExecutor", true)); }
Example #20
Source File: BaseLeaseHolder.java From hermes with Apache License 2.0 | 5 votes |
@Override public void initialize() throws InitializationException { try { doInitialize(); startDetailPrinterThread(); m_inited.set(true); } catch (Exception e) { log.error("Failed to init LeaseHolder", e); throw new InitializationException("Failed to init LeaseHolder", e); } }
Example #21
Source File: MetaHolder.java From hermes with Apache License 2.0 | 5 votes |
@Override public void initialize() throws InitializationException { m_updateTaskExecutor = Executors.newSingleThreadExecutor(HermesThreadFactory.create("MetaUpdater", true)); m_updateTaskExecutor.submit(new Runnable() { @Override public void run() { while (true) { try { int skipped = 0; Runnable task = m_updateTaskQueue.take(); if (!m_updateTaskQueue.isEmpty()) { LinkedList<Runnable> queuedTasks = new LinkedList<>(); m_updateTaskQueue.drainTo(queuedTasks); skipped = queuedTasks.size(); task = queuedTasks.getLast(); } try { task.run(); } finally { if (skipped > 0) { log.info("Skipped {} meta update tasks.", skipped); } } } catch (Throwable e) { log.error("Exeception occurred in MetaHolder's updateTaskExecutor loop", e); } } } }); m_configedMetaServers = new AtomicReference<>(); m_configedMetaServers.set(new HashMap<Pair<String, Integer>, Server>()); m_idcs = new AtomicReference<>(); m_idcs.set(new HashMap<String, Idc>()); }
Example #22
Source File: DefaultCommandProcessorRegistry.java From hermes with Apache License 2.0 | 5 votes |
@Override public void initialize() throws InitializationException { List<CommandProcessor> processors = lookupList(CommandProcessor.class); for (CommandProcessor p : processors) { for (CommandType type : p.commandTypes()) { registerProcessor(type, p); } } }
Example #23
Source File: DefaultClientEnvironment.java From hermes with Apache License 2.0 | 5 votes |
@Override public void initialize() throws InitializationException { try { m_producerDefault = readConfigFile(PRODUCER_DEFAULT_FILE); m_consumerDefault = readConfigFile(CONSUMER_DEFAULT_FILE); m_globalDefault = readConfigFile(GLOBAL_DEFAULT_FILE); } catch (IOException e) { throw new InitializationException("Error read producer default config file", e); } m_envProvider.initialize(m_globalDefault); }
Example #24
Source File: DefaultEventHandlerRegistry.java From hermes with Apache License 2.0 | 5 votes |
@Override public void initialize() throws InitializationException { List<EventHandler> handlers = lookupList(EventHandler.class); for (EventHandler handler : handlers) { EventType eventType = handler.eventType(); if (!m_handlers.containsKey(eventType)) { m_handlers.put(eventType, new ArrayList<EventHandler>()); } m_handlers.get(eventType).add(handler); } }
Example #25
Source File: AvroPayloadCodec.java From hermes with Apache License 2.0 | 5 votes |
@Override public void initialize() throws InitializationException { Map<String, String> configs = new HashMap<String, String>(); avroSerializer.configure(configs, false); configs.put(KafkaAvroDeserializerConfig.SPECIFIC_AVRO_READER_CONFIG, Boolean.TRUE.toString()); specificDeserializer.configure(configs, false); configs.put(KafkaAvroDeserializerConfig.SPECIFIC_AVRO_READER_CONFIG, Boolean.FALSE.toString()); genericDeserializer.configure(configs, false); }
Example #26
Source File: ClusterStateHolder.java From hermes with Apache License 2.0 | 5 votes |
@Override public void initialize() throws InitializationException { m_roleChangeExecutor = Executors.newSingleThreadExecutor(HermesThreadFactory.create("ClusterRoleChangeExecutor", true)); m_eventBus.start(this); addConnectionStateListener(); startLeaderLatchPathChildrenCache(); }
Example #27
Source File: ClusterStateHolder.java From hermes with Apache License 2.0 | 5 votes |
private void startLeaderLatchPathChildrenCache() throws InitializationException { try { m_leaderLatchPathChildrenCache = new PathChildrenCache(m_client.get(), ZKPathUtils.getMetaServersZkPath(), true); m_leaderLatchPathChildrenCache.getListenable().addListener( new PathChildrenCacheListener() { @Override public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception { if (event.getType() == PathChildrenCacheEvent.Type.CHILD_ADDED || event.getType() == PathChildrenCacheEvent.Type.CHILD_REMOVED || event.getType() == PathChildrenCacheEvent.Type.CHILD_UPDATED) { updateLeaderInfo(); } } }, Executors.newSingleThreadExecutor(HermesThreadFactory.create( "LeaderLatchPathChildrenCacheListenerExecutor", true))); m_leaderLatchPathChildrenCache.start(StartMode.BUILD_INITIAL_CACHE); } catch (Exception e) { throw new InitializationException("Init metaServer leaderLatch parent pathChildrenCache failed.", e); } updateLeaderInfo(); }
Example #28
Source File: DefaultConsumingRegistry.java From hermes with Apache License 2.0 | 5 votes |
@Override public void initialize() throws InitializationException { Map<String, ConsumingStrategy> strategies = lookupMap(ConsumingStrategy.class); for (Map.Entry<String, ConsumingStrategy> entry : strategies.entrySet()) { m_strategies.put(ConsumerType.valueOf(entry.getKey()), entry.getValue()); } }
Example #29
Source File: DefaultConsumerBootstrapRegistry.java From hermes with Apache License 2.0 | 5 votes |
@Override public void initialize() throws InitializationException { Map<String, ConsumerBootstrap> bootstraps = lookupMap(ConsumerBootstrap.class); for (Map.Entry<String, ConsumerBootstrap> entry : bootstraps.entrySet()) { m_bootstraps.put(entry.getKey(), entry.getValue()); } }
Example #30
Source File: KafkaConsumerBootstrap.java From hermes with Apache License 2.0 | 5 votes |
@Override public void initialize() throws InitializationException { Executors.newSingleThreadScheduledExecutor(HermesThreadFactory.create("CheckIdcPolicyChangesExecutor", true)) .scheduleWithFixedDelay(new Runnable() { @Override public void run() { try { for (Entry<ConsumerContext, KafkaConsumerThread> entry : consumers.entrySet()) { Properties newConsumerProperties = getConsumerProperties(entry.getKey().getTopic().getName(), entry.getKey().getGroup().getName()); Properties currentConsumerProperties = entry.getValue().getProps(); String newZookeeperConnectProperty = newConsumerProperties.getProperty(KafkaConstants.ZOOKEEPER_CONNECT_PROPERTY_NAME); String currentZookeeperConnectProperty = currentConsumerProperties .getProperty(KafkaConstants.ZOOKEEPER_CONNECT_PROPERTY_NAME); String newBootstrapServersProperty = newConsumerProperties .getProperty(KafkaConstants.BOOTSTRAP_SERVERS_PROPERTY_NAME); String currentBootstrapServersProperty = currentConsumerProperties .getProperty(KafkaConstants.BOOTSTRAP_SERVERS_PROPERTY_NAME); if (!(newZookeeperConnectProperty != null && currentConsumerProperties != null && newZookeeperConnectProperty.equals(currentZookeeperConnectProperty) && newBootstrapServersProperty != null && currentBootstrapServersProperty != null && newBootstrapServersProperty .equals(currentBootstrapServersProperty))) { synchronized (consumers) { if (consumers.containsKey(entry.getKey())) { m_logger.info("Restart consumer:{}, topic:{}, as target kafka cluster changed to {}.", entry.getKey().getGroupId(), entry.getKey().getTopic().getName(), newBootstrapServersProperty); restart(entry.getKey()); } } } } } catch (Exception e) { m_logger.warn("Check idc policy changes failed!", e); } } }, 5, 20, TimeUnit.SECONDS); }