<commit_before>package org.jgroups.tests;

import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

/**
 * @author <NAME>
 * @version $Id: StressTester.java,v 1.1 2006/09/04 06:19:49 belaban Exp $
 */
public class StressTester implements Runnable
{
   private URL url;
   private String name;

   StressTester(URL url, String name)
   {
      this.url = url;
      this.name = name;
   }

   public void run()
   {
      System.out.println(name + " starting");

      String cookie = null;
      int count = 0;
      while (true)
      {
         count++;

         try
         {
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            if (cookie != null)
               conn.addRequestProperty("Cookie", cookie);
            conn.connect();

            int rc = conn.getResponseCode();

            if (cookie == null)
            {
               String header = conn.getHeaderField("Set-Cookie");
               if (header != null)
               {
                  int semi = header.indexOf(';');
                  if (semi > 0)
                  {
                     cookie = header.substring(0, semi);
                  }
                  else
                  {
                     cookie = header;
                  }
               }
            }
            InputStream is = conn.getInputStream();
             while (is.read() != -1) {
                 ;
             }
             is.close();

            if (rc != 200 || count % 100 == 0)
            {
               StringBuffer sb = new StringBuffer(name);
               sb.append('-');
               sb.append(count);
               sb.append('-');
               sb.append(rc);
               sb.append('-');
               sb.append(cookie);
               System.out.println(sb.toString());
            }

            conn.disconnect();
         }
         catch (Exception e)
         {
            System.out.println(e.getMessage());
         }

      }
   }

   /**
    * Args are:
    *
    * 1) hostname:port of node 0; e.g 192.168.1.164:8080
    * 2) hostname:port of node 1
    * 3) # of client threads to create
    *
    * @param args
    */
   public static void main(String[] args)
   {
      try
      {
         URL  u1 = new URL("http://" + args[0] + "/jbento-httpsession/SetListOfString16");
         URL  u2 = new URL("http://" + args[1] + "/jbento-httpsession/SetListOfString16");

         int count = Integer.parseInt(args[2]);

         for (int i = 0; i < count; i++)
         {
            StressTester tester = new StressTester((i % 2 == 0 ? u1 : u2), "Thread"+i);
            Thread t = new Thread(tester);
            t.start();
         }
      }
      catch (Exception e)
      {
         e.printStackTrace();
      }
   }

}
<commit_msg>Encourage keep-alive by getting rid of disconnect() call<commit_after>package org.jgroups.tests;

import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

/**
 * Test driver for testing JGroups-based HttpSession replication.
 * 
 * @author <NAME>
 * @version $Id: StressTester.java,v 1.2 2006/09/05 02:22:08 bstansberry Exp $
 */
public class StressTester implements Runnable
{
   private URL url;
   private String name;

   StressTester(URL url, String name)
   {
      this.url = url;
      this.name = name;
   }

   public void run()
   {
      System.out.println(name + " starting");

      String cookie = null;
      int count = 0;
      while (true)
      {
         count++;

         try
         {
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            if (cookie != null)
               conn.addRequestProperty("Cookie", cookie);
            conn.connect();

            int rc = conn.getResponseCode();

            if (cookie == null)
            {
               String header = conn.getHeaderField("Set-Cookie");
               if (header != null)
               {
                  int semi = header.indexOf(';');
                  if (semi > 0)
                  {
                     cookie = header.substring(0, semi);
                  }
                  else
                  {
                     cookie = header;
                  }
               }
            }
            InputStream is = conn.getInputStream();
             while (is.read() != -1) {
                 ;
             }
             is.close();

            if (rc != 200 || count % 100 == 0)
            {
               StringBuffer sb = new StringBuffer(name);
               sb.append('-');
               sb.append(count);
               sb.append('-');
               sb.append(rc);
               sb.append('-');
               sb.append(cookie);
               System.out.println(sb.toString());
            }
         }
         catch (Exception e)
         {
            System.out.println(e.getMessage());
         }

      }
   }

   /**
    * Args are:
    *
    * 1) hostname:port of node 0; e.g 192.168.1.164:8080
    * 2) hostname:port of node 1
    * 3) # of client threads to create
    *
    * @param args
    */
   public static void main(String[] args)
   {
      try
      {
         URL  u1 = new URL("http://" + args[0] + "/jbento-httpsession/SetListOfString16");
         URL  u2 = new URL("http://" + args[1] + "/jbento-httpsession/SetListOfString16");

         int count = Integer.parseInt(args[2]);

         for (int i = 0; i < count; i++)
         {
            StressTester tester = new StressTester((i % 2 == 0 ? u1 : u2), "Thread"+i);
            Thread t = new Thread(tester);
            t.start();
         }
      }
      catch (Exception e)
      {
         e.printStackTrace();
      }
   }

}

{'fraction_non_alphanumeric': 0.1252847380410023, 'fraction_numerical': 0.021026809181706674, 'mean_word_length': 1.2886928628708902, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5892986', 'n_tokens_mistral': 1731, 'n_tokens_neox': 1595, 'n_words': 379}