Package javaflow.network.utils

Examples of javaflow.network.utils.PacketCountInComponent


                component("dropper", Drop.class);

                from("generator").to("substream").to("assembler").to("disassembler").to("dropper");
            }
        });
        final PacketCountInComponent listener = new PacketCountInComponent(network.components().size());
        network.addPacketListener(listener);
        network.runInCurrentThread();
        for (NetworkComponent component : network.components()) {
            Assert.assertEquals(listener.getCount(component.componentId()), 0, component.componentName() + " has wrong message count.");
        }
    }
View Full Code Here


        if (networkRunning.compareAndSet(false, true)) {
            try {
                executor = Executors.newCachedThreadPool();
                closeAllUnconnectedInputs();
                final int componentsCount = components.size();
                PacketCountInComponent packetCounter = new PacketCountInComponent(componentsCount);
                addPacketListener(packetCounter);
                for (AbstractRunnableComponent r : components) {
                    if (shouldRun(r)) {
                        startComponent(r);
                    }
                }
                componentStates.waitForComponentsStop();
                if (alivePacketsCount.get() > 0) {
                    StringBuilder builder = new StringBuilder();
                    builder.append("There are " + alivePacketsCount.get() + " packets left and no components are running.\n");
                    builder.append("Components failed due error:\n");
                    for (int i = 0; i < componentsCount; i++) {
                        final AbstractRunnableComponent component = components.get(i);
                        if (component.getError()     != null){
                            Throwable t = component.getError();
                            builder.append("    ");
                            builder.append(component.componentName() + ": ");
                            ByteArrayOutputStream bout = new ByteArrayOutputStream();
                            PrintStream print = new PrintStream(bout);
                            t.printStackTrace(print);
                            builder.append(new String(bout.toByteArray()));
                            builder.append("\n");
                        }
                    }
                    builder.append("Components suspended or messages inside:\n");
                    for (int i = 0; i < componentsCount; i++) {
                        final AbstractRunnableComponent component = components.get(i);
                        if (component.state() == 0 && packetCounter.getCount(i) == 0) {
                            continue;
                        }
                        String state = component.getStateString();
                        final int count = packetCounter.getCount(i);
                        builder.append("    ");
                        builder.append(component.componentName() + " (" + state + ")" + ": " + count + " in component\n");
                    }
                    builder.append("\nPorts with messages:\n");
                    for (int i = 0; i < componentsCount; i++) {
View Full Code Here

TOP

Related Classes of javaflow.network.utils.PacketCountInComponent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.