Package smilehouse.opensyncro.system

Examples of smilehouse.opensyncro.system.PipeExecutionThread


            while (pipeIt.hasNext()) {
              Persister perPipePersister = new Persister(database);
          Pipe p = perPipePersister.findPipeByName(((Pipe) pipeIt.next()).getName());
          String dbase = perPipePersister.getDatabaseName();
          PipeWrapper pw = new PipeWrapper(p, dbase, dbase + p.getName());
          PipeExecutionThread pet = new PipeExecutionThread(pipesAndThreads,
              p.getId(),perPipePersister);
          //PipeExecutionQueue peq = new PipeExecutionQueue(perPipePersister,
            //  p.getId());
          //If the there are PipeExecutionRequests in the database for this pipe,
          //execute them.
          if (!pet.getPipeExecutionQueue().isQueueEmpty()) {
            pipesAndThreads.put(pw, pet);
            pet.start();
              }
              else{
                pet.close();
              }
         
        }
          }
          else{
View Full Code Here


        return "ERROR: HTTP start is not enabled for this pipe";
      }

      //If pipesAndThreads already contains the pipe, get the PipeExecutionThread from it
      pipesIt=pipesAndThreads.keySet().iterator();
      PipeExecutionThread pet = null;
      while(pipesIt.hasNext()){
        PipeWrapper p = (PipeWrapper)pipesIt.next();
        String db=((PipeExecutionThread)pipesAndThreads.get(p)).getDatabaseName();
        if(p.getPipe().getName().equals(pipe.getPipe().getName()) && db.equals(pipe.getDatabase())){
          pet = (PipeExecutionThread) pipesAndThreads.get(p);
        }
      }

      Long pipeId=pipe.getPipe().getId();
     
      if (pet == null || !pet.getDatabaseName().equals(database)) {
        // Create new thread if no execution thread exists.
        pet = new PipeExecutionThread(pipesAndThreads,pipeId,pers);
        // Add the created thread to webapp context
        pipesAndThreads.put(pipe, pet);
        //Remember that new thread was created and this has to be started
        newThread = true;
      }

      // Add the new request to the threads execution queue
      pet.getPipeExecutionQueue().addToQueue(
          new PipeExecutionRequest(pipe.getPipe(), new Date()));
      if (newThread)
        pet.start();
      if (isSynced) {
        // If synced mode was specified, wait for the thread to finish
        pet.join();
      } else
        // Otherwise get the queue length to return in the response
        queueLength = pet.getPipeExecutionQueue().getQueueLength();
     
    } catch (Exception e) {
      Environment en=Environment.getInstance();
      en.log("Exception while processing requests in pipe execution queue for pipe: " + pipeName);
      en.log(e.getMessage(),e);
View Full Code Here

TOP

Related Classes of smilehouse.opensyncro.system.PipeExecutionThread

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.