Examples of JobQueue


Examples of com.google.code.lightssh.project.scheduler.entity.JobQueue

   
    if( page == null )
      page = new ListPage<JobQueue>();
   
    page.addAscending("createdTime");
    JobQueue t = new JobQueue();
    SchedulerType type = new SchedulerType();
    type.setId(jobTypeId);
    t.setType( type );
   
    return list(page, t);
  }
View Full Code Here

Examples of com.google.code.lightssh.project.scheduler.entity.JobQueue

    if( type == null )
      throw new ApplicationException("工作任务类型["+jobType+"]不存在!");
   
    List<JobQueue> queues = new ArrayList<JobQueue>();
    for(String refId:refIds ){
      JobQueue exists = getDao().get(jobType,refId);
      if( exists != null ){
        log.warn("任务[类型={}][关联ID={}]已存在队列!",jobType,refId);
        continue;
      }
     
      JobQueue queue = new JobQueue();
      queue.setType(type);
      queue.setRefId(refId);
      queue.setCreatedTime( Calendar.getInstance() );
      queue.setMaxSendCount(maxSendCount);
      queue.setFailureCount(0);
      queue.setStatus(JobQueue.Status.NEW);
      queue.setInvokeTime(invokeTime);
     
      queues.add(queue);
    }
   
    if( !queues.isEmpty() )
View Full Code Here

Examples of com.google.code.lightssh.project.scheduler.entity.JobQueue

        ec.setFinishedTime(Calendar.getInstance());
        ec.setStatus( Status.SUCCESS );
      }else{
        ec.setStatus( Status.FAILURE );
        if( result.getObject() != null && result.getObject() instanceof JobQueue ){
          JobQueue jq = (JobQueue)result.getObject();
          ec.incFailureCount( jq.getFailureCount());
          ec.setErrMsg(jq.getErrMsg());
        }
      }
    }
   
    dao.update(list);
View Full Code Here

Examples of com.google.code.lightssh.project.scheduler.entity.JobQueue

      if( results == null )
        throw new ApplicationException("返回结果为空!");
      //Map<String,JobQueue> map = new HashMap<String,JobQueue>();
     
      for(Result result:results ){
        JobQueue item = (JobQueue)result.getObject();
        if( item == null ){//TODO
          throw new ApplicationException("返回结果Result[key="
              +result.getKey()+"]关联Object为空!");
        }
       
        if( !result.isSuccess() && item != null ){
          item.incFailureCount();
          item.setStatus(JobQueue.Status.FAILURE );
          item.setErrMsg(result.getMessage());
        }
      }
    }catch( Exception e ){
      results = new ArrayList<Result>();
      for(JobQueue item:items){
        results.add(new Result(false,item.getRefId(),item,e.getMessage()));
       
        item.incFailureCount();
        item.setStatus( JobQueue.Status.FAILURE );
       
        String errMsg = e.getMessage()+(e.getCause()==null?"":e.getCause().getMessage());
        item.setErrMsg( errMsg.length()>199?errMsg.substring(0,199):errMsg );
       
        log.error("任务队列[id="+item.getIdentity()+",type="
            +item.getType().getName()+",ref_id="
            +item.getRefId()+"]执行异常:",e);
      }
     
    }
   
    List<JobQueue> outQueues = new ArrayList<JobQueue>();//成功队列
    List<JobQueue> updateQueues = new ArrayList<JobQueue>();//更新队列
    for(Result item:results ){
      JobQueue jobQueue = (JobQueue)item.getObject();
      if( item.isSuccess() || jobQueue.isDeletable() )
        outQueues.add(jobQueue);
      else
        updateQueues.add(jobQueue);
    }
   
View Full Code Here

Examples of com.projity.job.JobQueue

    return container;
  }

  public JobQueue getJobQueue(){
    if (jobQueue==null){
      jobQueue=new JobQueue("GraphicManager",false); //$NON-NLS-1$
    }
    return jobQueue;
  }
View Full Code Here

Examples of com.projity.job.JobQueue

//      printerJob.setPageable(printable);
      if (printerJob.printDialog()) {
        //update();


        final JobQueue jobQueue=SessionFactory.getInstance().getJobQueue();
        Job j=new Job(jobQueue,"Printing","Printing...",true,getPrintPreviewFrame());
        j.addRunnable(new JobRunnable("Printing",1.0f){
          public Object run() throws Exception{
            try {
              ViewPrintable vp=getSafePrintable();
              vp.setJr(this);
              vp.setPrinterJob(printerJob);
              vp.setPageFormat(printerJob.validatePage(getSafePageFormat()));
              vp.update();
//              printerJob.setPageable(printable);
              printerJob.setPrintable(vp, vp.getPageFormat());
              vp.setJr(this);
              vp.setPrinterJob(printerJob);
              printerJob.print();
            }catch (PrinterException e) {
              Alert.error(e.getMessage());
            }catch (Exception e) {
              e.printStackTrace();
            }
            return null;
          }
        });
        jobQueue.schedule(j);
      }
    } catch (PrinterException e) {
      Alert.error(e.getMessage());
    }
  }
View Full Code Here

Examples of com.projity.job.JobQueue

import com.projity.session.SessionFactory;

public class PDFExport {
  public static void export(final GraphPageable pageable,Component parentComponent) throws IOException{
    final File file=chooseFile(pageable.getRenderer().getProject().getName(),parentComponent);
    final JobQueue jobQueue=SessionFactory.getInstance().getJobQueue();
    Job job=new Job(jobQueue,"PDF Export","Exporting PDF...",true,parentComponent);
    job.addRunnable(new JobRunnable("PDF Export",1.0f){
      public Object run() throws Exception{
        Document document = new Document();
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file));
        pageable.update();
        int pageCount = pageable.getNumberOfPages();
        if (pageCount>0){
          ViewPrintable printable=pageable.getSafePrintable();
          ExtendedPageFormat pageFormat=pageable.getSafePageFormat();
          double width=pageFormat.getWidth();
          double height=pageFormat.getHeight();
          float startIncrement=0.1f;
          float endIncrement=0.0f;           
          float progressIncrement = (1.0f-startIncrement-endIncrement)/pageCount;
          for (int p=0;p< pageCount;p++) {
            setProgress(startIncrement+p*progressIncrement);
            document.setPageSize(new Rectangle((float)width,(float)height));
            if (p==0) document.open();
            else document.newPage();
           
            Graphics2D g = writer.getDirectContent().createGraphics((float)width, (float)height);
            printable.print(g, p);
            g.dispose();
          }
          document.close();
        }
        setProgress(1.0f);
        return null;
      }
    });
    jobQueue.schedule(job);
  }
View Full Code Here

Examples of com.projity.job.JobQueue

    return project.getResourceModel();
  }

  public JobQueue getJobQueue(){
    if (jobQueue==null){
      jobQueue=new JobQueue("GraphicManager",true);
    }
    return jobQueue;
  }
View Full Code Here

Examples of com.projity.job.JobQueue

    return container;
  }

  public JobQueue getJobQueue(){
    if (jobQueue==null){
      jobQueue=new JobQueue("GraphicManager",false); //$NON-NLS-1$
    }
    return jobQueue;
  }
View Full Code Here

Examples of com.publicobject.misc.util.concurrent.JobQueue

    /**
     * Make sure that our locks don't throw interrupted exceptions.
     */
    private void testLockInterrupt(final ReadWriteLock lock) {
        JobQueue jobQueue = new JobQueue();
        Thread jobQueueThread = new Thread(jobQueue);
        jobQueueThread.start();

        lock.writeLock().lock();

        // interrupt that thread
        jobQueueThread.interrupt();

        // create a thread that will block waiting on Lock.lock()
        JobQueue.Job result = jobQueue.invokeLater(new LockALockRunnable(lock.writeLock()));

        // make sure there's contention on the lock
        sleep(1000);

        // release the lock, this will cause our other job to finish
        lock.writeLock().unlock();

        // flush the queue
        jobQueue.flush();

        // validate that our thread didn't throw interrupted exception
        assertNull(result.getThrown());

        // validate that the thread is still interrupted
        jobQueue.invokeAndWait(new FailIfNotInterruptedRunnable());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.