<commit_before>package org.jgroups.tests.adaptjms;

import org.apache.log4j.Logger;
import org.jgroups.log.Trace;

import javax.jms.*;
import javax.naming.InitialContext;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

/**  You start the test by running this class.
 *    It only parses the initial params from the config.txt
 *    file (or any other file you wish to pass as the argument)
 *    and instantiates a new JGroupsTester object.<br>
 * Use parameters -Xbatch -Xconcurrentio (Solaris specific)
 * @author <NAME> (<EMAIL>)
 * @author <NAME> (<EMAIL>)

 */
public class Test {
    public static int mcast_port=7777;
    public static String mcast_addr="172.16.58.3";
    public static int grpMembers=4;

    public static void main(String[] args) {
        String config="config.txt";
        BufferedReader fileReader;
        String line;

        boolean sender=false;
        int num_msgs=1000;
        int msg_size=500;

        int num_senders=1;
        long   log_interval=1000;
        ConnectionFactory factory;
        InitialContext ctx;
        TopicConnection conn;
        TopicSession session;
        TopicPublisher pub;
        Topic topic;
        String topic_name="PerfTopic";

        for(int i=0; i < args.length; i++) {
            if(args[i].equals("-sender")) {
                sender=true;
                continue;
            }
            if(args[i].equals("-receiver")) {
                sender=false;
                continue;
            }
            if(args[i].equals("-config")) {
                config=args[++i];
                continue;
            }
            help();
            return;
        }

        Trace.init();

        try {
            fileReader=new BufferedReader(new FileReader(config));
            while((line=fileReader.readLine()) != null) {
                if(line.startsWith("#"))
                    continue;
                else if(line.startsWith("NUM_MSGS=")) {
                    num_msgs=Integer.parseInt(line.substring(line.indexOf('=') + 1,
                            line.indexOf(';')));
                }
                else if(line.startsWith("MSG_SIZE=")) {
                    msg_size=Integer.parseInt(line.substring(line.indexOf('=') + 1,
                            line.indexOf(';')));
                }
                else if(line.startsWith("GRPMEMBERS=")) {
                    grpMembers=Integer.parseInt(line.substring(line.indexOf('=') + 1,
                            line.indexOf(';')));
                }
                else if(line.startsWith("NUM_SENDERS=")) {
                    num_senders=Integer.parseInt(line.substring(line.indexOf('=') + 1,
                            line.indexOf(';')));
                }
                else if(line.startsWith("LOG_INTERVAL=")) {
                    log_interval=Long.parseLong(line.substring(line.indexOf('=') + 1,
                            line.indexOf(';')));
                }
                else if(line.startsWith("GNUPLOT_OUTPUT=")) {
                    // only parse if not yet set by -Dgnuplot_output=true option (overrides file)
                    if(System.getProperty("gnuplot_output") == null) {
                        String gnuplot_output=line.substring(line.indexOf('=') + 1,
                                line.indexOf(';')).trim();
                        if(gnuplot_output != null)
                            System.setProperty("gnuplot_output", gnuplot_output);
                    }
                }
            }
            fileReader.close();

            System.out.println("Javagroups test:");
            String s="Initial params parsing completed. Starting test"
                    + " with these values:\n"
                    + "Sender:" + sender + "  num_msgs:" + num_msgs
                    + "  Size(bytes):" + msg_size + "  # Mbrs:" + grpMembers
                    + "  Senders: " + num_senders
                    + "\nLog interval: " + log_interval + "\n";

            System.out.println(s);
            Logger.getLogger(Test.class).info("main(): " + s);

            ctx=new InitialContext();
            factory=(ConnectionFactory)ctx.lookup("JmsXA");
            conn=((TopicConnectionFactory)factory).createTopicConnection();
            session=conn.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
            topic=(Topic)ctx.lookup(topic_name);
            pub=session.createPublisher(topic);<commit_msg>added removeNotification<commit_after>package org.jgroups.tests.adaptjms;

import org.apache.log4j.Logger;
import org.jgroups.log.Trace;

import javax.jms.*;
import javax.naming.InitialContext;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

/**  You start the test by running this class.
 *    It only parses the initial params from the config.txt
 *    file (or any other file you wish to pass as the argument)
 *    and instantiates a new JGroupsTester object.<br>
 * Use parameters -Xbatch -Xconcurrentio (Solaris specific)
 * @author <NAME> (<EMAIL>)
 * @author <NAME> (<EMAIL>)

 */
public class Test {
    public static int mcast_port=7777;
    public static String mcast_addr="172.16.58.3";
    public static int grpMembers=4;

    public static void main(String[] args) {
        String config="config.txt";
        BufferedReader fileReader;
        String line;

        boolean sender=false;
        int num_msgs=1000;
        int msg_size=500;

        int num_senders=1;
        long   log_interval=1000;
        ConnectionFactory factory;
        InitialContext ctx;
        TopicConnection conn;
        TopicSession session;
        TopicPublisher pub;
        Topic topic;
        String topic_name="topic/testTopic";

        for(int i=0; i < args.length; i++) {
            if(args[i].equals("-sender")) {
                sender=true;
                continue;
            }
            if(args[i].equals("-receiver")) {
                sender=false;
                continue;
            }
            if(args[i].equals("-config")) {
                config=args[++i];
                continue;
            }
            help();
            return;
        }

        Trace.init();

        try {
            fileReader=new BufferedReader(new FileReader(config));
            while((line=fileReader.readLine()) != null) {
                if(line.startsWith("#"))
                    continue;
                else if(line.startsWith("NUM_MSGS=")) {
                    num_msgs=Integer.parseInt(line.substring(line.indexOf('=') + 1,
                            line.indexOf(';')));
                }
                else if(line.startsWith("MSG_SIZE=")) {
                    msg_size=Integer.parseInt(line.substring(line.indexOf('=') + 1,
                            line.indexOf(';')));
                }
                else if(line.startsWith("GRPMEMBERS=")) {
                    grpMembers=Integer.parseInt(line.substring(line.indexOf('=') + 1,
                            line.indexOf(';')));
                }
                else if(line.startsWith("NUM_SENDERS=")) {
                    num_senders=Integer.parseInt(line.substring(line.indexOf('=') + 1,
                            line.indexOf(';')));
                }
                else if(line.startsWith("LOG_INTERVAL=")) {
                    log_interval=Long.parseLong(line.substring(line.indexOf('=') + 1,
                            line.indexOf(';')));
                }
                else if(line.startsWith("TOPIC=")) {
                   topic_name=new String(line.substring(line.indexOf('=') + 1, line.indexOf(';')));
                }
                else if(line.startsWith("GNUPLOT_OUTPUT=")) {
                    // only parse if not yet set by -Dgnuplot_output=true option (overrides file)
                    if(System.getProperty("gnuplot_output") == null) {
                        String gnuplot_output=line.substring(line.indexOf('=') + 1,
                                line.indexOf(';')).trim();
                        if(gnuplot_output != null)
                            System.setProperty("gnuplot_output", gnuplot_output);
                    }
                }
            }
            fileReader.close();

            System.out.println("Javagroups test:");
            String s="Initial params parsing completed. Starting test"
                    + " with these values:\n"
                    + "Sender:" + sender + "  num_msgs:" + num_msgs
                    + "  Size(bytes):" + msg_size + "  # Mbrs:" + grpMembers
                    + "  Senders: " + num_senders
                    + "\nLog interval: " + log_interval + "\n";

            System.out.println(s);
            Logger.getLogger(Test.class).info("main(): " + s);

            ctx=new InitialContext();
            factory=(ConnectionFactory)ctx.lookup("ConnectionFactory");
            conn=((TopicConnectionFactory)factory).createTopicConnection();
            session=conn.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
            topic=(Topic)ctx.lookup(topic_name);
            pub=session.createPublisher(topic);
{'fraction_non_alphanumeric': 0.12276975361087511, 'fraction_numerical': 0.007115548003398471, 'mean_word_length': 1.706812302385743, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '247658', 'n_tokens_mistral': 2641, 'n_tokens_neox': 2514, 'n_words': 474}