Gets number of partitions of a topic.

@param topicName
@return topic's number of partitions, or {@code 0} if the topic does not
exist
@since 1.2.0
342213
public int getNumPartitions(String topicName) {
        Map<String, List<PartitionInfo>> topicInfo = getTopicInfo();
        List<PartitionInfo> partitionInfo = topicInfo != null ? topicInfo.get(topicName) : null;
        return partitionInfo != null ? partitionInfo.size() : 0;
    }
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 {}
238082
def count_partitions(self, topic):
        """"""
        return sum(1 for p in topic.partitions if p in self.partitions)
1166863
public static void checkTopicName( String topicName ) throws JMSException
    {
        if (topicName == null)
            throw new FFMQException("Topic name is not set","INVALID_DESTINATION_NAME");      
        if (topicName.length() > FFMQConstants.MAX_TOPIC_NAME_SIZE)
            throw new FFMQException("Topic name '"+topicName+"' is too long ("+topicName.length()+" > "+FFMQConstants.MAX_TOPIC_NAME_SIZE+")","INVALID_DESTINATION_NAME");
        checkDestinationName(topicName);
    }
1313682
public List<ITopicNode> getAllTopicNodes() {
        final ArrayList<ITopicNode> topicNodes = new ArrayList<ITopicNode>();
        for (final Entry<Integer, List<ITopicNode>> topicEntry : topics.entrySet()) {
            topicNodes.addAll(topicEntry.getValue());
        }

        return topicNodes;
    }
617114
public java.util.List<Topic> getTopics() {
        if (topics == null) {
            topics = new com.amazonaws.internal.SdkInternalList<Topic>();
        }
        return topics;
    }
250632
def get_number_of_messages_in_topics(self, topics):
        

        if not isinstance(topics, list):
            topics = [topics]

        number_of_messages = 0
        for t in topics:
            part = self.get_kafka_partitions_for_topic(topic=t)
            Partitions = map(lambda p: TopicPartition(topic=t, partition=p), part)
            number_of_messages += self.get_number_of_messages_in_topicpartition(Partitions)

        return number_of_messages
745475
public boolean isEnabled(String topicName) {
        if (topicName == null || topicName.length() == 0) {
            throw new JavametricsException("Topic names must not be null or 0 length");
        }
        return getTopic(topicName).isEnabled();
    }
1006630
@Override
  public String getSchema() throws IOException {
    try {
      return this.kafkaSchemaRegistry.getLatestSchemaByTopic(this.topicName);
    } catch (SchemaRegistryException e) {
      throw new RuntimeException(e);
    }
  }
101808
public int[][] getClusterLabel() {
        if (y == null) {
           throw new IllegalStateException("Neuron cluster labels are not available. Call partition() first.");
        }

        int[][] clusterLabels = new int[height][width];
        for (int i = 0, l = 0; i < height; i++) {
            for (int j = 0; j < width; j++) {
                clusterLabels[i][j] = y[i*width + j];
            }
        }
        return clusterLabels;
    }
297423
def assign_to_topic_partition(self, topic_partition=None):
        

        if isinstance(topic_partition, TopicPartition):
            topic_partition = [topic_partition]
        if not self._is_assigned(topic_partition):
            self.consumer.assign(topic_partition)
282364
@Override
	public int getNumberSubscribers(String topic) {
		if (map.containsKey(topic)) {
			return map.get(topic).size();
		}
		return 0;
	}
894961
@Synchronized
    public int getNumberOfSegments() {
        return assignedSegments.values().stream().mapToInt(Map::size).sum() + unassignedSegments.size();
    }
189537
public Topic getTopic(String topicName) throws ServiceLocatorException {
		Topic topic = null;
		try {
			topic = (Topic) ic.lookup(topicName);
		} catch (NamingException ne) {
			throw new ServiceLocatorException(ne);
		} catch (Exception e) {
			throw new ServiceLocatorException(e);
		}
		return topic;
	}
15471
@Override
    public Map<String, Optional<Partition>> getPartitionsByNames(String databaseName, String tableName, List<String> partitionNames)
    {
        requireNonNull(partitionNames, "partitionNames is null");
        if (partitionNames.isEmpty()) {
            return ImmutableMap.of();
        }

        List<Partition> partitions = batchGetPartition(databaseName, tableName, partitionNames);

        Map<String, List<String>> partitionNameToPartitionValuesMap = partitionNames.stream()
                .collect(toMap(identity(), HiveUtil::toPartitionValues));
        Map<List<String>, Partition> partitionValuesToPartitionMap = partitions.stream()
                .collect(toMap(Partition::getValues, identity()));

        ImmutableMap.Builder<String, Optional<Partition>> resultBuilder = ImmutableMap.builder();
        for (Entry<String, List<String>> entry : partitionNameToPartitionValuesMap.entrySet()) {
            Partition partition = partitionValuesToPartitionMap.get(entry.getValue());
            resultBuilder.put(entry.getKey(), Optional.ofNullable(partition));
        }
        return resultBuilder.build();
    }
1202747
public static Map<String, List<String>> getPartitionsForTopics(ZkClient zkClient, Collection<String> topics) {
        Map<String, List<String>> ret = new HashMap<String, List<String>>();
        for (String topic : topics) {
            List<String> partList = new ArrayList<String>();
            List<String> brokers = getChildrenParentMayNotExist(zkClient, BrokerTopicsPath + "/" + topic);
            if (brokers != null) {
                for (String broker : brokers) {
                    final String parts = readData(zkClient, BrokerTopicsPath + "/" + topic + "/" + broker);
                    int nParts = Integer.parseInt(parts);
                    for (int i = 0; i < nParts; i++) {
                        partList.add(broker + "-" + i);
                    }
                }
            }
            Collections.sort(partList);
            ret.put(topic, partList);
        }
        return ret;
    }
449712
public TopicConnectionFactory getTopicConnectionFactory(String
      topicConnFactoryName) throws ServiceLocatorException {
    TopicConnectionFactory factory = null;
    try {
      if (cache.containsKey(topicConnFactoryName)) {
        factory = (TopicConnectionFactory) cache.get(topicConnFactoryName);
      } else {
        factory = (TopicConnectionFactory) ic.lookup(topicConnFactoryName);
        cache.put(topicConnFactoryName, factory);
      }
    } catch (NamingException ne) {
      throw new ServiceLocatorException(ne);
    } catch (Exception e) {
      throw new ServiceLocatorException(e);
    }
    return factory;
  }