Return the current subscription to topics and partitions

 @raise [RdkafkaError] When getting the subscription fails.

 @return [TopicPartitionList]
334568
def subscription
      tpl = FFI::MemoryPointer.new(:pointer)
      response = Rdkafka::Bindings.rd_kafka_subscription(@native_kafka, tpl)
      if response != 0
        raise Rdkafka::RdkafkaError.new(response)
      end
      tpl = tpl.read(:pointer).tap { |it| it.autorelease = false }

      begin
        Rdkafka::Consumer::TopicPartitionList.from_native_tpl(tpl)
      ensure
        Rdkafka::Bindings.rd_kafka_topic_partition_list_destroy(tpl)
      end
    end
1016691
public java.util.List<Subscription> getSubscriptions() {
        if (subscriptions == null) {
            subscriptions = new com.amazonaws.internal.SdkInternalList<Subscription>();
        }
        return subscriptions;
    }
1308657
def community_topic_subscriptions(self, topic_id, **kwargs):
        ""
        api_path = "/api/v2/community/topics/{topic_id}/subscriptions.json"
        api_path = api_path.format(topic_id=topic_id)
        return self.call(api_path, **kwargs)
465255
def _get_leader_for_partition(self, topic, partition):
        

        key = TopicAndPartition(topic, partition)
        # reload metadata whether the partition is not available
        # or has no leader (broker is None)
        if self.topics_to_brokers.get(key) is None:
            yield self.load_metadata_for_topics(topic)

        if key not in self.topics_to_brokers:
            raise PartitionUnavailableError("%s not available" % str(key))

        returnValue(self.topics_to_brokers[key])
230219
def get_unavailable_brokers(zk, partition_metadata):
    
    topic_data = zk.get_topics(partition_metadata.topic)
    topic = partition_metadata.topic
    partition = partition_metadata.partition
    expected_replicas = set(topic_data[topic]['partitions'][str(partition)]['replicas'])
    available_replicas = set(partition_metadata.replicas)
    return expected_replicas - available_replicas
751832
def topics(preload: Kazoo::Topic::DEFAULT_PRELOAD_METHODS)
      @topics_mutex.synchronize do
        @topics ||= begin
          topics = zk.get_children(path: "/brokers/topics")
          raise Kazoo::Error, "Failed to list topics. Error code: #{topics.fetch(:rc)}" unless topics.fetch(:rc) == Zookeeper::Constants::ZOK
          preload_topics_from_names(topics.fetch(:children), preload: preload)
        end
      end
    end
1162625
public List<SpecNode> getAllSpecNodes() {
        final ArrayList<SpecNode> retValue = new ArrayList<SpecNode>();

        // Add all the levels
        retValue.addAll(levels);

        // Add all the topics
        for (final Entry<Integer, List<ITopicNode>> topicEntry : topics.entrySet()) {
            for (final ITopicNode topic : topicEntry.getValue()) {
                if (topic instanceof SpecNode) {
                    retValue.add((SpecNode) topic);
                }
            }
        }

        return retValue;
    }
1272345
def get_topics(self):
        '''
            
        '''
        result = self.api_call('topic/')
        topics_json = json.loads(result.content)
        topics = [Topic(name=topic_json["topic"]["name"])
                  for topic_json in topics_json["objects"]]
        return topics
792771
def _get_kafka_consumer_offsets(self, instance, consumer_groups):
        
        consumer_offsets = {}
        topics = defaultdict(set)

        cli = self._get_kafka_client(instance)

        for consumer_group, topic_partitions in iteritems(consumer_groups):
            try:
                coordinator_id = self._get_group_coordinator(cli, consumer_group)
                if coordinator_id:
                    offsets = self._get_consumer_offsets(cli, consumer_group, topic_partitions, coordinator_id)
                else:
                    offsets = self._get_consumer_offsets(cli, consumer_group, topic_partitions)
                    self.log.info("unable to find group coordinator for %s", consumer_group)

                for (topic, partition), offset in iteritems(offsets):
                    topics[topic].update([partition])
                    key = (consumer_group, topic, partition)
                    consumer_offsets[key] = offset
            except Exception:
                self.log.exception('Could not read consumer offsets from kafka.')

        return consumer_offsets, topics
198085
@VisibleForTesting
  synchronized void consumerSubscriptionRebalance() {
    log.debug("Subscribed Topics " + this.consumer.subscription());
    if (!this.subscribedTopics.isEmpty()) {
      final Iterator<String> iter = this.subscribedTopics.iterator();
      final List<String> topics = new ArrayList<>();
      while (iter.hasNext()) {
        topics.add(iter.next());
      }
      this.subscribedTopics.clear();
      //re-subscribe topics that are needed
      this.consumer.subscribe(topics);
    }
  }
617114
public java.util.List<Topic> getTopics() {
        if (topics == null) {
            topics = new com.amazonaws.internal.SdkInternalList<Topic>();
        }
        return topics;
    }
370738
def subscriptions(self):
        """"""
        if not hasattr(self, '_subscriptions'):
            subscriptions_resource = self.resource.subscriptions
            self._subscriptions = Subscriptions(
                subscriptions_resource, self.client)
        return self._subscriptions
1201507
def commit(self, partitions=None):
        

        # short circuit if nothing happened. This check is kept outside
        # to prevent un-necessarily acquiring a lock for checking the state
        if self.count_since_commit == 0:
            return

        with self.commit_lock:
            # Do this check again, just in case the state has changed
            # during the lock acquiring timeout
            if self.count_since_commit == 0:
                return

            reqs = []
            if partitions is None:  # commit all partitions
                partitions = list(self.offsets.keys())

            log.debug('Committing new offsets for %s, partitions %s',
                      self.topic, partitions)
            for partition in partitions:
                offset = self.offsets[partition]
                log.debug('Commit offset %d in SimpleConsumer: '
                          'group=%s, topic=%s, partition=%s',
                          offset, self.group, self.topic, partition)

                reqs.append(OffsetCommitRequest(self.topic, partition,
                                                offset, None))

            try:
                self.client.send_offset_commit_request(self.group, reqs)
            except KafkaError as e:
                log.error('%s saving offsets: %s', e.__class__.__name__, e)
                return False
            else:
                self.count_since_commit = 0
                return True
101336
public synchronized List<String> getTopicList() {
    final List<String> res = new ArrayList<>(this.topicEventMap.keySet());
    return res;
  }
222921
public int getNumPartitions(String topicName) {
        List<PartitionInfo> partitionList = getPartitionInfo(topicName);
        return partitionList != null ? partitionList.size() : 0;
    }
833272
@GET
    @Timed
    public Response getPartitions(@Context final UriInfo uriInfo, @Context final HttpHeaders headers) {

        final IRI identifier = rdf.createIRI(
                properties.getProperty("baseUrl", uriInfo.getBaseUri().toString()));

        LOGGER.debug("Request for root resource at: {}", identifier.getIRIString());

        final List<Triple> graph = new ArrayList<>();
        partitions.entrySet().stream().map(e -> rdf.createIRI(e.getValue() + e.getKey()))
            .map(obj -> rdf.createTriple(identifier, LDP.contains, obj)).forEach(graph::add);

        properties.stringPropertyNames().stream().filter(propMapping::containsKey)
            .map(name -> rdf.createTriple(identifier, propMapping.get(name), isUrl(properties.getProperty(name)) ?
                        rdf.createIRI(properties.getProperty(name)) :
                        rdf.createLiteral(properties.getProperty(name))))
            .forEach(graph::add);

        final RDFSyntax syntax = getSyntax(headers.getAcceptableMediaTypes(), empty())
            .orElseThrow(NotAcceptableException::new);

        final IRI profile = ofNullable(getProfile(headers.getAcceptableMediaTypes(), syntax))
            .orElseGet(() -> getDefaultProfile(syntax, identifier));

        final StreamingOutput stream = new StreamingOutput() {
            @Override
            public void write(final OutputStream out) throws IOException {
                ioService.write(graph.stream(), out, syntax, profile);
            }
        };

        return ok().header(ALLOW, join(",", HttpMethod.GET, HEAD, OPTIONS))
                    .link(LDP.Resource.getIRIString(), "type")
                    .link(LDP.RDFSource.getIRIString(), "type")
                    .type(syntax.mediaType).entity(stream).build();
    }
1297074
public Observable<Page<TopicInner>> listAsync() {
        return listWithServiceResponseAsync().map(new Func1<ServiceResponse<List<TopicInner>>, Page<TopicInner>>() {
            @Override
            public Page<TopicInner> call(ServiceResponse<List<TopicInner>> response) {
                PageImpl<TopicInner> page = new PageImpl<>();
                page.setItems(response.body());
                return page;
            }
        });
    }