CPD Results

The following document contains the results of PMD's CPD 4.3.

Duplications

FileLine
goldengate\commandexec\client\test\LocalExecClientTest.java211
goldengate\commandexec\ssl\client\test\LocalExecSslClient.java242
    public void runOnce() {
     // Initialize the command context
        LocalExecClientHandler clientHandler =
            (LocalExecClientHandler) channel.getPipeline().getLast();
        clientHandler.initExecClient();
        // Command to execute

        ChannelFuture lastWriteFuture = null;
        String line = command+"\n";
        if (line != null) {
            // Sends the received line to the server.
            lastWriteFuture = channel.write(line);
            // Wait until all messages are flushed before closing the channel.
            if (lastWriteFuture != null) {
                try {
                    lastWriteFuture.await();
                } catch (InterruptedException e) {
                }
            }
            // Wait for the end of the exec command
            LocalExecResult localExecResult = clientHandler.waitFor(10000);
            int status = localExecResult.status;
            if (status < 0) {
                System.err.println("Status: " + status + "\nResult: " +
                        localExecResult.result);
                ko++;
            } else {
                ok++;
                result = localExecResult;
            }
        }
    }
    /**
     * Run method for closing Server
     */
    private void runFinal() {
        // Initialize the command context
        LocalExecClientHandler clientHandler =
            (LocalExecClientHandler) channel.getPipeline().getLast();
        clientHandler.initExecClient();
        // Command to execute

        ChannelFuture lastWriteFuture = null;
        String line = "-1000 stop\n";
        if (line != null) {
            // Sends the received line to the server.
            lastWriteFuture = channel.write(line);
            // Wait until all messages are flushed before closing the channel.
            if (lastWriteFuture != null) {
                try {
                    lastWriteFuture.await();
                } catch (InterruptedException e) {
                }
            }
            // Wait for the end of the exec command
            LocalExecResult localExecResult = clientHandler.waitFor(10000);
            int status = localExecResult.status;
            if (status < 0) {
                System.err.println("Status: " + status + "\nResult: " +
                        localExecResult.result);
                ko++;
            } else {
                ok++;
                result = localExecResult;
            }
        }
    }
}
FileLine
goldengate\commandexec\client\test\LocalExecClientTest.java96
goldengate\commandexec\ssl\client\test\LocalExecSslClient.java126
            LocalExecClientTest client = new LocalExecClientTest();
            // run once
            long first = System.currentTimeMillis();
            client.connect();
            client.runOnce();
            client.disconnect();
            long second = System.currentTimeMillis();
            // print time for one exec
            System.err.println("1=Total time in ms: "+(second-first)+" or "+(1*1000/(second-first))+" exec/s");
            System.err.println("Result: " + ok+":"+ko);
            ok = 0;
            ko = 0;
            // Now run multiple within one thread
            first = System.currentTimeMillis();
            for (int i = 0; i < nit; i ++) {
                client.connect();
                client.runOnce();
                client.disconnect();
            }
            second = System.currentTimeMillis();
            // print time for one exec
            System.err.println(nit+"=Total time in ms: "+(second-first)+" or "+(nit*1000/(second-first))+" exec/s");
            System.err.println("Result: " + ok+":"+ko);
            ok = 0;
            ko = 0;
            // Now run multiple within multiple threads
            // Create multiple threads
            ExecutorService executorService = Executors.newFixedThreadPool(nth);
            first = System.currentTimeMillis();
            // Starts all thread with a default number of execution
            for (int i = 0; i < nth; i ++) {
                executorService.submit(new LocalExecClientTest());
FileLine
goldengate\commandexec\client\test\LocalExecClientTest.java127
goldengate\commandexec\ssl\client\test\LocalExecSslClient.java159
                executorService.submit(new LocalExecClientTest());
            }
            Thread.sleep(500);
            executorService.shutdown();
            while (! executorService.awaitTermination(200, TimeUnit.MILLISECONDS)) {
                Thread.sleep(50);
            }
            second = System.currentTimeMillis();

            // print time for one exec
            System.err.println((nit*nth)+"=Total time in ms: "+(second-first)+" or "+(nit*nth*1000/(second-first))+" exec/s");
            System.err.println("Result: " + ok+":"+ko);
            ok = 0;
            ko = 0;

            // run once
            first = System.currentTimeMillis();
            client.connect();
            client.runFinal();
            client.disconnect();
            second = System.currentTimeMillis();
            // print time for one exec
            System.err.println("1=Total time in ms: "+(second-first)+" or "+(1*1000/(second-first))+" exec/s");
            System.err.println("Result: " + ok+":"+ko);
            ok = 0;
            ko = 0;
        } finally {
            // Shut down all thread pools to exit.
            bootstrap.releaseExternalResources();
            localExecClientPipelineFactory.releaseResources();
        }
    }

    /**
     * Simple constructor
     */
    public LocalExecClientTest() {
FileLine
goldengate\commandexec\client\test\LocalExecClientTest.java163
goldengate\commandexec\ssl\client\test\LocalExecSslClient.java195
    public LocalExecClientTest() {
    }

    private Channel channel;
    /**
     * Run method for thread
     */
    public void run() {
        connect();
        for (int i = 0; i < nit; i ++) {
            this.runOnce();
        }
        disconnect();
    }

    /**
     * Connect to the Server
     */
    private void connect() {
        // Start the connection attempt.
        ChannelFuture future = bootstrap.connect(address);

        // Wait until the connection attempt succeeds or fails.
        try {
            channel = future.await().getChannel();
        } catch (InterruptedException e) {
        }
        if (!future.isSuccess()) {
            System.err.println("Client Not Connected");
            future.getCause().printStackTrace();
            return;
        }
    }
    /**
     * Disconnect from the server
     */
    private void disconnect() {
     // Close the connection. Make sure the close operation ends because
        // all I/O operations are asynchronous in Netty.
        try {
            channel.close().await();
        } catch (InterruptedException e) {
        }
    }