Package EDU.oswego.cs.dl.util.concurrent

Examples of EDU.oswego.cs.dl.util.concurrent.CopyOnWriteArrayList


   /**
    * Defines the concurrent list implementation
    */
   public static final List createCopyOnWriteList()
   {
      return new CopyOnWriteArrayList();
   }
View Full Code Here


   /**
    * Defines the list implementation
    */
   public static final List createCopyOnWriteList()
   {
      return new CopyOnWriteArrayList();
   }
View Full Code Here

      }  
   }

   private void runTest(final int iterations, int numOfClients, final boolean printTime)
   {
      final CopyOnWriteArrayList timesList = new CopyOnWriteArrayList();
      final Counter counter = new Counter();
      long start = System.currentTimeMillis();

      System.out.println("Starting run now with " + numOfClients + " clients and " + iterations + " iterations.");

      for (int x = 0; x < numOfClients; x++)
      {
         new Thread()
         {
            public void run()
            {
               try
               {
                  for (int i = 0; i < iterations; i++)
                  {
                     long startTime = System.currentTimeMillis();
                     HATestClient client = new HATestClient();
                     Object o = client.lookup(BINDKEY, HABindingObject.class);
                     long endTime = System.currentTimeMillis();
                     timesList.add(new Long(endTime - startTime));
                     if (printTime)
                        System.out.println(endTime - startTime);
                     counter.increment();
                     long value = counter.getValue();
                     if (value % 10000 == 0)
                     {
                        System.out.println("Executed " + value + " times so far.");
                     }
                  }
               }
               catch (Exception e)
               {
                  System.out.println("Error calling test client to do hajndi_binding lookup");
                  e.printStackTrace();
               }
            }
         }.start();
      }

      while (timesList.size() < (iterations * numOfClients))
      {
         try
         {
            Thread.sleep(1000);
         }
         catch (InterruptedException e)
         {
            e.printStackTrace()//TODO: -TME Implement
         }
      }

      long end = System.currentTimeMillis();

      System.out.println("Ran test with total of " + timesList.size() + " (iterations: " + iterations +
                         ", number of clients: " + numOfClients + ") in " + (end - start) / 1000 + " seconds.");

      long total = 0;
      for (int i = 0; i < timesList.size(); i++)
      {
         total += ((Long) timesList.get(i)).longValue();
      }

      System.out.println("Average time to make lookup is " + (total / (iterations * numOfClients)) + " milliseconds.");
   }
View Full Code Here

      test.runTest(iterations, numOfClients, jndiURL, printLookupTime);
   }

   private void runTest(final int iterations, int numOfClients, final String jndiURL, final boolean printTime)
   {
      final CopyOnWriteArrayList timesList = new CopyOnWriteArrayList();
      final Counter counter = new Counter();
      long start = System.currentTimeMillis();

      System.out.println("Starting run now with " + numOfClients + " clients and " + iterations + " iterations.");

      for (int x = 0; x < numOfClients; x++)
      {
         new Thread()
         {
            public void run()
            {
               try
               {
                  for (int i = 0; i < iterations; i++)
                  {
                     long startTime = System.currentTimeMillis();
                     EJBTestClient client = new EJBTestClient();
                     client.execute(jndiURL);
                     long endTime = System.currentTimeMillis();
                     timesList.add(new Long(endTime - startTime));
                     if (printTime)
                        System.out.println(endTime - startTime);
                     counter.increment();
                     long value = counter.getValue();
                     if (value % 10000 == 0)
                     {
                        System.out.println("Executed " + value + " times so far.");
                     }

                  }
               }
               catch (Exception e)
               {
                  System.out.println("Error calling test client to do jndi lookup");
                  e.printStackTrace();
               }
            }
         }.start();
      }


      while (timesList.size() < (iterations * numOfClients))
      {
         try
         {
            Thread.sleep(1000);
         }
         catch (InterruptedException e)
         {
            e.printStackTrace()//TODO: -TME Implement
         }
      }

      long end = System.currentTimeMillis();

      System.out.println("Ran test with total of " + timesList.size() + " (iterations: " + iterations +
                         ", number of clients: " + numOfClients + ") in " + (end - start) / 1000 + " seconds.");

      long total = 0;
      for (int i = 0; i < timesList.size(); i++)
      {
         total += ((Long) timesList.get(i)).longValue();
      }

      System.out.println("Average time to make lookup is " + (total / (iterations * numOfClients)) + " milliseconds.");

      //System.out.println("Counter says was executed " + counter.getValue() + " times.");
View Full Code Here

      test.runTest(iterations, numOfClients, printLookupTime);
   }

   private void runTest(final int iterations, int numOfClients, final boolean printTime)
   {
      final CopyOnWriteArrayList timesList = new CopyOnWriteArrayList();
      final Counter counter = new Counter();
      long start = System.currentTimeMillis();

      System.out.println("Starting run now with " + numOfClients + " clients and " + iterations + " iterations.");

      for (int x = 0; x < numOfClients; x++)
      {
         new Thread()
         {
            public void run()
            {
               try
               {
                  for (int i = 0; i < iterations; i++)
                  {
                     long startTime = System.currentTimeMillis();
                     TestClient client = new TestClient();
                     client.lookup("SimpleSession", SimpleSessionHome.class);
                     long endTime = System.currentTimeMillis();
                     timesList.add(new Long(endTime - startTime));
                     if (printTime)
                        System.out.println(endTime - startTime);
                     counter.increment();
                     long value = counter.getValue();
                     if (value % 10000 == 0)
                     {
                        System.out.println("Executed " + value + " times so far.");
                     }

                  }
               }
               catch (Exception e)
               {
                  System.out.println("Error calling test client to do jndi lookup");
                  e.printStackTrace();
               }
            }
         }.start();
      }


      while (timesList.size() < (iterations * numOfClients))
      {
         try
         {
            Thread.sleep(1000);
         }
         catch (InterruptedException e)
         {
            e.printStackTrace()//TODO: -TME Implement
         }
      }

      long end = System.currentTimeMillis();

      System.out.println("Ran test with total of " + timesList.size() + " (iterations: " + iterations +
                         ", number of clients: " + numOfClients + ") in " + (end - start) / 1000 + " seconds.");

      long total = 0;
      for (int i = 0; i < timesList.size(); i++)
      {
         total += ((Long) timesList.get(i)).longValue();
      }

      System.out.println("Average time to make lookup is " + (total / (iterations * numOfClients)) + " milliseconds.");

      //System.out.println("Counter says was executed " + counter.getValue() + " times.");
View Full Code Here

        ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost");
        Connection connection = cf.createConnection();
        connection.start();

        CopyOnWriteArrayList resourceAdapters = null; //new CopyOnWriteArrayList();
        TransactionManagerImpl tm = new TransactionManagerImpl(600, new UnrecoverableLog(), resourceAdapters);

        final ExtendedTransactionManager etm = tm;
        XidImporter xidImporter = tm;
        TransactionContextManager manager = new TransactionContextManager(etm, xidImporter);
View Full Code Here

            MemoryBoundedQueue queue) {
        this.manager = manager;
        this.client = client;
        this.queue = queue;
        this.started = new SynchronizedBoolean(false);
        this.subscriptions = new CopyOnWriteArrayList();
        this.log = LogFactory.getLog("TransientTopicBoundedMessageContainer:- " + client);
    }
View Full Code Here

    this.clientIdGenerator = new IdGenerator();
    this.packetIdGenerator = new IdGenerator();
    this.handleIdGenerator = new IdGenerator();
    this.sessionIdGenerator = new IdGenerator();
    this.consumerNumberGenerator = new SynchronizedInt(0);
    this.sessions = new CopyOnWriteArrayList();
    this.messageDispatchers = new CopyOnWriteArrayList();
    this.connectionConsumers = new CopyOnWriteArrayList();
    this.connectionMetaData = new ActiveMQConnectionMetaData();
    this.started = new SynchronizedBoolean(false);
    this.startTime = System.currentTimeMillis();
    this.prefetchPolicy = new ActiveMQPrefetchPolicy();
    this.memoryManager = new MemoryBoundedObjectManager(clientID,
        DEFAULT_CONNECTION_MEMORY_LIMIT);
    this.boundedQueueManager = new MemoryBoundedQueueManager(memoryManager);
    this.memoryManager.addCapacityEventListener(this);
    boolean transactional = this instanceof XAConnection;
    factoryStats = factory.getFactoryStats();
    factoryStats.addConnection(this);
    stats = new JMSConnectionStatsImpl(sessions, transactional);
    this.transientConsumedRedeliverCache = new CopyOnWriteArrayList();
    this.tempDestinationMap = new ConcurrentHashMap();
    this.validDestinationsMap = new ConcurrentHashMap();
    factory.onConnectionCreate(this);
  }
View Full Code Here

        this.clientIdGenerator = new IdGenerator();
        this.packetIdGenerator = new IdGenerator();
        this.consumerIdGenerator = new IdGenerator();
        this.sessionIdGenerator = new IdGenerator();
        this.consumerNumberGenerator = new SynchronizedInt(0);
        this.sessions = new CopyOnWriteArrayList();
        this.messageDispatchers = new CopyOnWriteArrayList();
        this.connectionConsumers = new CopyOnWriteArrayList();
        this.connectionMetaData = new ActiveMQConnectionMetaData();
        this.closed = new SynchronizedBoolean(false);
        this.started = new SynchronizedBoolean(false);
        this.startTime = System.currentTimeMillis();
        this.prefetchPolicy = new ActiveMQPrefetchPolicy();
View Full Code Here

     * @throws JMSException on internal error
     */
    protected ActiveMQSession(ActiveMQConnection theConnection, int theAcknowledgeMode) throws JMSException {
        this.connection = theConnection;
        this.acknowledgeMode = theAcknowledgeMode;
        this.consumers = new CopyOnWriteArrayList();
        this.producers = new CopyOnWriteArrayList();
        this.consumerIdGenerator = new IdGenerator();
        this.transactionIdGenerator = new IdGenerator();
        this.temporaryDestinationGenerator = new IdGenerator();
        this.packetIdGenerator = new IdGenerator();
        this.closed = new SynchronizedBoolean(false);
View Full Code Here

TOP

Related Classes of EDU.oswego.cs.dl.util.concurrent.CopyOnWriteArrayList

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.