Package org.exoplatform.services.jcr.load.blob.thread

Examples of org.exoplatform.services.jcr.load.blob.thread.CreateThread


   }

   public void _testReadWriteSet() throws Exception
   {
      // creators
      CreateThread creator = new CreateThread(repository.login(this.credentials, "ws1"));
      creator.start();
      try
      {
         log.info("Wait 20 sec. for CreateThread");
         Thread.sleep(20000); // 30 sec.
      }
      catch (InterruptedException e)
      {
         log.error("Creator wait. Sleep error: " + e.getMessage(), e);
      }

      List<ReadThread> readers = new ArrayList<ReadThread>();

      log.info("Begin readers...");
      for (int i = 0; i < 5; i++)
      {
         ReadThread readed =
            new ReadThread(repository.login(
               this.credentials /*
                                                                                                                    * session.getCredentials(
                                                                                                                    * )
                                                                                                                    */,
               "ws1"));
         readed.start();
         readers.add(readed);
         try
         {
            Thread.sleep(5000);
         }
         catch (InterruptedException e)
         {
            log.error("Start reader. Sleep error: " + e.getMessage(), e);
         }
      }

      log.info("Begin cleaner...");
      DeleteThread cleaner = new DeleteThread(repository.login(this.credentials /*
                                                                                                    * session.getCredentials
                                                                                                    * ()
                                                                                                    */, "ws1"));
      cleaner.start();

      log.info("<<<<<<<<<<<<<<<<<<<< Wait cycle >>>>>>>>>>>>>>>>>>>>>");
      // 360 - 60 min
      // 4320 - 12 hours
      int cycles = 180; // 5min
      while (cycles >= 0)
      {
         Thread.yield();
         try
         {
            Thread.sleep(10000);
         }
         catch (InterruptedException e)
         {
            log.error("Test lifecycle. Sleep error: " + e.getMessage(), e);
         }
         log.info("<<<<<<<<<<<<<<<<<<<< Cycle " + cycles + " >>>>>>>>>>>>>>>>>>>>>");
         cycles--;
      }

      log.info("<<<<<<<<<<<<<<<<<<<< Stopping >>>>>>>>>>>>>>>>>>>>>");

      for (ReadThread reader : readers)
      {
         try
         {
            reader.testStop();
            reader.join(3000);
            Thread.yield();
         }
         catch (InterruptedException e)
         {
            log.error("Test lifecycle. Readed stop error: " + e.getMessage(), e);
         }
      }

      try
      {
         creator.testStop();
         creator.join();
         Thread.yield();
      }
      catch (InterruptedException e)
      {
         log.error("Test lifecycle. Creator stop error: " + e.getMessage(), e);
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jcr.load.blob.thread.CreateThread

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.