Search in sources :

Example 16 with SystemAdmin

use of org.apache.samza.system.SystemAdmin in project samza by apache.

the class StreamManager method getStreamPartitionCounts.

Map<String, Integer> getStreamPartitionCounts(String systemName, Set<String> streamNames) {
    Map<String, Integer> streamToPartitionCount = new HashMap<>();
    SystemAdmin systemAdmin = sysAdmins.get(systemName);
    if (systemAdmin == null) {
        throw new SamzaException(String.format("System %s does not exist.", systemName));
    }
    // retrieve the metadata for the streams in this system
    Map<String, SystemStreamMetadata> streamToMetadata = systemAdmin.getSystemStreamMetadata(streamNames);
    // set the partitions of a stream to its StreamEdge
    streamToMetadata.forEach((stream, data) -> streamToPartitionCount.put(stream, data.getSystemStreamPartitionMetadata().size()));
    return streamToPartitionCount;
}
Also used : HashMap(java.util.HashMap) SystemStreamMetadata(org.apache.samza.system.SystemStreamMetadata) SystemAdmin(org.apache.samza.system.SystemAdmin) SamzaException(org.apache.samza.SamzaException)

Aggregations

SystemAdmin (org.apache.samza.system.SystemAdmin)16 StreamSpec (org.apache.samza.system.StreamSpec)12 HashMap (java.util.HashMap)10 Test (org.junit.Test)10 Properties (java.util.Properties)4 Map (java.util.Map)3 MapConfig (org.apache.samza.config.MapConfig)3 SamzaException (org.apache.samza.SamzaException)2 Config (org.apache.samza.config.Config)2 JobConfig (org.apache.samza.config.JobConfig)2 ApplicationRunner (org.apache.samza.runtime.ApplicationRunner)2 StreamMetadataCache (org.apache.samza.system.StreamMetadataCache)2 SystemStreamMetadata (org.apache.samza.system.SystemStreamMetadata)2 Duration (java.time.Duration)1 Collection (java.util.Collection)1 Set (java.util.Set)1 BiFunction (java.util.function.BiFunction)1 Function (java.util.function.Function)1 Partition (org.apache.samza.Partition)1 JavaSystemConfig (org.apache.samza.config.JavaSystemConfig)1