Get the log if exists or return null

@param topic     topic name
@param partition partition index
@return a log for the topic or null if not exist
349791
public ILog getLog(String topic, int partition) {
        TopicNameValidator.validate(topic);
        Pool<Integer, Log> p = getLogPool(topic, partition);
        return p == null ? null : p.get(partition);
    }
1222174
def _fetch_partition_state(self, topic_id, partition_id):
        """"""
        state_path = "/brokers/topics/{topic_id}/partitions/{p_id}/state"
        try:
            partition_state = self.get(
                state_path.format(topic_id=topic_id, p_id=partition_id),
            )
            return partition_state
        except NoNodeError:
            return {}
595431
public ErrorLogger getLog(final String name) {
        return hasLog(name) ? logs.get(name) : null;
    }
529598
public ProxyDataSourceBuilder logSlowQueryByCommons(long thresholdTime, TimeUnit timeUnit, String logName) {
        return logSlowQueryByCommons(thresholdTime, timeUnit, null, logName);
    }
405983
public synchronized Topic getTopic(String topicName) {
        if (topicName == null || topicName.length() == 0) {
            throw new JavametricsException("Topic names must not be null or 0 length");
        }
        if (topics.containsKey(topicName)) {
            return topics.get(topicName);
        } else {
            Topic topic = new TopicImpl(topicName);
            topics.put(topicName, topic);
            return topic;
        }
    }
206738
public Topic getTopic(String topicName) throws ServiceLocatorException {
    Topic topic = null;
    try {
      if (cache.containsKey(topicName)) {
        topic = (Topic) cache.get(topicName);
      } else {
        topic = (Topic) ic.lookup(topicName);
        cache.put(topicName, topic);
      }
    } catch (NamingException ne) {
      throw new ServiceLocatorException(ne);
    } catch (Exception e) {
      throw new ServiceLocatorException(e);
    }
    return topic;
  }
184150
@Nullable
    public String getLoggerLevel(@Nullable String loggerName) {
        try {
            loggerName = loggerName == null ? "" : loggerName;
            if (loggerName.isEmpty()) {
                return LogManager.getRootLogger().getLevel().toString();
            }

            Logger logger = LogManager.exists(loggerName);
            if (logger == null) {
                return null;
            } else {
                Level level = logger.getLevel();
                if (level == null) {
                    return null;
                }
                return level.toString();
            }
        } catch (RuntimeException e) {
            logger.warn("Exception getting effective logger level " + loggerName, e);
            throw e;
        }
    }
124195
public Class<? extends Message> getMessageClass(String topic) {
        return allTopics ? messageClassForAll : messageClassByTopic.get(topic);
    }
183548
def paused?(topic, partition)
      pause = pause_for(topic, partition)
      pause.paused? && !pause.expired?
    end
658999
@Override
	public TopicPartition createKafkaPartitionHandle(KafkaTopicPartition partition) {
		return new TopicPartition(partition.getTopic(), partition.getPartition());
	}
445261
public static <C extends Model> void logClusterSizes(Clustering<C> c) {
    if(!LOG.isStatistics()) {
      return;
    }
    final List<Cluster<C>> clusters = c.getAllClusters();
    final int numc = clusters.size();
    LOG.statistics(new StringStatistic(PREFIX + "name", c.getLongName()));
    LOG.statistics(new LongStatistic(PREFIX + "clusters", numc));
    Hierarchy<Cluster<C>> h = c.getClusterHierarchy();
    int cnum = 0;

    for(Cluster<C> clu : clusters) {
      final String p = PREFIX + "cluster-" + cnum + ".";
      if(clu.getName() != null) {
        LOG.statistics(new StringStatistic(p + "name", clu.getName()));
      }
      LOG.statistics(new LongStatistic(p + "size", clu.size()));
      if(clu.isNoise()) {
        LOG.statistics(new StringStatistic(p + "noise", "true"));
      }
      if(h.numChildren(clu) > 0) {
        // TODO: this only works if we have cluster names!
        StringBuilder buf = new StringBuilder();
        for(It<Cluster<C>> it = h.iterChildren(clu); it.valid(); it.advance()) {
          if(buf.length() > 0) {
            buf.append(", ");
          }
          buf.append(it.get().getName());
        }
        LOG.statistics(new StringStatistic(p + "children", buf.toString()));
      }
      // TODO: also log parents?
      ++cnum;
    }
  }
552360
public int createLogs(String topic, final int partitions, final boolean forceEnlarge) {
        TopicNameValidator.validate(topic);
        synchronized (logCreationLock) {
            final int configPartitions = getPartition(topic);
            if (configPartitions >= partitions || !forceEnlarge) {
                return configPartitions;
            }
            topicPartitionsMap.put(topic, partitions);
            if (config.getEnableZookeeper()) {
                if (getLogPool(topic, 0) != null) {//created already
                    topicRegisterTasks.add(new TopicTask(TopicTask.TaskType.ENLARGE, topic));
                } else {
                    topicRegisterTasks.add(new TopicTask(TopicTask.TaskType.CREATE, topic));
                }
            }
            return partitions;
        }
    }
744055
public Cluster get(int index){
        if(index < clusters.size()){
            return clusters.get(index);
        }
        return null;
    }
887241
def get_offset_topic_partition_count(kafka_config):
    """"""
    metadata = get_topic_partition_metadata(kafka_config.broker_list)
    if CONSUMER_OFFSET_TOPIC not in metadata:
        raise UnknownTopic("Consumer offset topic is missing.")
    return len(metadata[CONSUMER_OFFSET_TOPIC])
167202
def check_topics(client, req_topics):
    """"""
    client.update_cluster()
    logger.debug('Found topics: %r', client.topics.keys())

    for req_topic in req_topics:
        if req_topic not in client.topics.keys():
            err_topic_not_found = 'Topic not found: {}'.format(req_topic)
            logger.warning(err_topic_not_found)
            raise TopicNotFound(err_topic_not_found)

        topic = client.topics[req_topic]
        if not topic.partitions:
            err_topic_no_part = 'Topic has no partitions: {}'.format(req_topic)
            logger.warning(err_topic_no_part)
            raise TopicNoPartition(err_topic_no_part)

        logger.info('Topic is ready: %s', req_topic)
667722
JournalSegment<E> getNextSegment(long index) {
    Map.Entry<Long, JournalSegment<E>> nextSegment = segments.higherEntry(index);
    return nextSegment != null ? nextSegment.getValue() : null;
  }
1081393
@Override
    public SpecTopic getClosestTopic(final SpecTopic topic, final SpecNode callerNode, final boolean checkParentNode) {
        final SpecTopic retValue = super.getClosestTopic(topic, callerNode, checkParentNode);
        if (retValue != null) {
            return retValue;
        } else {
            // Look up the metadata topics
            final ContentSpec contentSpec = getContentSpec();
            for (final Node contentSpecNode : contentSpec.getNodes()) {
                if (contentSpecNode instanceof KeyValueNode && ((KeyValueNode) contentSpecNode).getValue() instanceof SpecTopic) {
                    final SpecTopic childTopic = (SpecTopic) ((KeyValueNode) contentSpecNode).getValue();
                    if (childTopic == topic || childTopic.getId().equals(topic.getId())) {
                        return childTopic;
                    }
                }
            }

            return null;
        }
    }