Package smilehouse.opensyncro.pipes

Examples of smilehouse.opensyncro.pipes.PipeWrapper


            //Iterate through all the pipes found in the database
            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,
View Full Code Here


      }
        }
       
    int queueLength = 0;
    try {
      PipeWrapper pipe = null;

      Map pipesAndThreads = null;

      // Get pipesAndThreads object from webapp context.
      // This is where running pipes and threads are listed
      pipesAndThreads = (Map) this.getServletContext().getAttribute(PIPES_AND_THREADS);
      boolean newThread = false;

      if (pipesAndThreads == null) {
        // No pipesAndThreads object exists -> no pipes have been started via HttpStart
        // nor has SyncroStartup started any.
        // Create synchronized map, as it may be modified simultaneously by several threads
        pipesAndThreads = Collections.synchronizedMap(new HashMap());
        this.getServletContext().setAttribute(PIPES_AND_THREADS,
            pipesAndThreads);
      }
     
      Iterator pipesIt=pipesAndThreads.keySet().iterator();
      boolean newPipe=true;
      // Iterate through active pipes to see if the pipe the incoming request refers to
      // is already executing

      while(pipesIt.hasNext()){
        PipeWrapper p = (PipeWrapper)pipesIt.next();
        String db=((PipeExecutionThread)pipesAndThreads.get(p)).getDatabaseName();
        //Since two databases could have pipes with the same name it is necessary to
        //check that in addition to pipe name database name also matches.
        if(p.getPipe().getName().equals(pipeName) && db.equals(database)){
          //Pipe was found. No need to create a new pipe
          newPipe=false;
          pipe=p;
        }
      }
      if(newPipe)
        pipe = new PipeWrapper(pers.findPipeByName(pipeName), database, database + pipeName);
     
      if(pipe == null || pipe.getPipe().getStartPassword() == null
          || !pipe.getPipe().getStartPassword().equals(startPassword)) {
        return "ERROR: Incorrect pipe name or start password";
      }
      if(!pipe.getPipe().isHttpStartEnabled()) {
        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();
View Full Code Here

            // Remove pipe and thread from webapp context (because queue is empty now)
            LinkedList<PipeWrapper> pipesThreadsToRemove = new LinkedList<PipeWrapper>();
      Iterator pipeWrapperIt = pipesThreads.keySet().iterator();
      while (pipeWrapperIt.hasNext()){
        PipeWrapper pw = (PipeWrapper)pipeWrapperIt.next();
        Pipe p = pw.getPipe();
        if(p.equals(pipe) && pw.getDatabase().equals(pers.getDatabaseName())){
          pipesThreadsToRemove.add(pw);
        }
      }
            Iterator ptRemoveIt = pipesThreadsToRemove.iterator();           
            while (ptRemoveIt.hasNext()){
View Full Code Here

TOP

Related Classes of smilehouse.opensyncro.pipes.PipeWrapper

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.