Move event and metadata handling into abstract base class.
[sonitus.git] / src / main / java / net / pterodactylus / sonitus / data / Pipeline.java
index 975c21c..c24502f 100644 (file)
@@ -46,7 +46,7 @@ import com.google.common.util.concurrent.MoreExecutors;
  *
  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
-public class Pipeline implements Iterable<Controlled> {
+public class Pipeline implements Iterable<ControlledComponent> {
 
        /** The logger. */
        private static final Logger logger = Logger.getLogger(Pipeline.class.getName());
@@ -102,18 +102,18 @@ public class Pipeline implements Iterable<Controlled> {
        /**
         * Returns the traffic counters of the given controlled component.
         *
-        * @param controlled
+        * @param controlledComponent
         *              The controlled component to get the traffic counters for
         * @return The traffic counters for the given controlled component
         */
-       public TrafficCounter trafficCounter(Controlled controlled) {
+       public TrafficCounter trafficCounter(ControlledComponent controlledComponent) {
                long input = -1;
                long output = -1;
                for (Connection connection : connections) {
                        /* the connection where the source matches knows the output. */
-                       if (connection.source.equals(controlled)) {
+                       if (connection.source.equals(controlledComponent)) {
                                output = connection.counter();
-                       } else if (connection.sinks.contains(controlled)) {
+                       } else if (connection.sinks.contains(controlledComponent)) {
                                input = connection.counter();
                        }
                }
@@ -171,8 +171,8 @@ public class Pipeline implements Iterable<Controlled> {
        //
 
        @Override
-       public Iterator<Controlled> iterator() {
-               return ImmutableSet.<Controlled>builder().add(source).addAll(sinks.values()).build().iterator();
+       public Iterator<ControlledComponent> iterator() {
+               return ImmutableSet.<ControlledComponent>builder().add(source).addAll(sinks.values()).build().iterator();
        }
 
        //
@@ -335,8 +335,6 @@ public class Pipeline implements Iterable<Controlled> {
                        Metadata firstMetadata = null;
                        while (!stopped.get()) {
                                try {
-                                       final Metadata lastMetadata = firstMetadata;
-                                       final Metadata metadata = firstMetadata = source.metadata();
                                        final byte[] buffer;
                                        try {
                                                logger.finest(String.format("Getting %d bytes from %s...", 4096, source));
@@ -353,9 +351,6 @@ public class Pipeline implements Iterable<Controlled> {
 
                                                                @Override
                                                                public Void call() throws Exception {
-                                                                       if (!metadata.equals(lastMetadata)) {
-                                                                               sink.metadataUpdated(metadata);
-                                                                       }
                                                                        try {
                                                                                logger.finest(String.format("Sending %d bytes to %s.", buffer.length, sink));
                                                                                sink.process(buffer);