Package org.apache.droids.api

Examples of org.apache.droids.api.Task


 
 
  @SuppressWarnings("unchecked")
  @Override
  public IModel<WorkBean<T>> model( WorkBean<T> object) {
    final Task t = object.getTask();
    return new AbstractReadOnlyModel<WorkBean<T>>() {
      @Override
      public WorkBean<T> getObject() {
        return map.get( t );
      }
View Full Code Here


    }));
   
    info.add( new Label( "lastTask", new AbstractReadOnlyModel<String>() {
      @Override
      public String getObject() {
        Task task = droid.getTaskMaster().getLastCompletedTask();
        return (task==null)?"" : task.getId();
      }
    }));

    info.add( new Label( "memory", new AbstractReadOnlyModel<CharSequence>() {
      @Override
      public CharSequence getObject() {
        Runtime runtime = Runtime.getRuntime();
        Bytes total = Bytes.bytes( runtime.totalMemory() );
        Bytes free = Bytes.bytes( runtime.freeMemory() );
        Bytes max = Bytes.bytes( runtime.maxMemory() );
        Bytes used = Bytes.bytes( total.bytes()-free.bytes() );
        int per = (int)((used.bytes()/(float)max.bytes())*100.0f);
       
        return used + "("+total+")/" +max + " (%"+per+")";
      }
    }));
    add( info );
   
    WebMarkupContainer classinfo = new WebMarkupContainer( "classinfo" );
    classinfo.add( new Label( "droid", droid.toString() ) );
    classinfo.add( new Label( "queue", taskQueue.toString() ) );
    classinfo.add( new Label( "taskMaster", taskMaster.toString() ) );
    add( classinfo );
   
    // TASK MASTER
    WebMarkupContainer tmDIV = new WebMarkupContainer( "taskMaster" );
    final WebMarkupContainer workers = new WebMarkupContainer( "workers" );
    workers.setOutputMarkupId( true );
    workers.add(new DataView<WorkBean>("task", new WorkBeanDataProvider(
        new AbstractReadOnlyModel<SimpleWorkMonitor>() {
          @Override
          public SimpleWorkMonitor getObject() {
            return monitor;
          }
    } ) )
    {
      @Override
      protected void populateItem(final Item<WorkBean> item)
      {
        WorkBean bean = item.getModelObject();
        long elapsed = System.currentTimeMillis() - bean.getStartTime().getTime();
        item.add( new Label("time", elapsed+"" )); //DurationFormatUtil.formatDurationHMS(elapsed) ) );
        item.add( new Label("text", bean.getTask().toString() ) );
      }
    });
    tmDIV.add( workers );
    WebMarkupContainer threads = new WebMarkupContainer( "threads" );
    threads.add( new AjaxEditableChoiceLabel<Integer>("count",
        new PropertyModel<Integer>( taskMaster, "maxThreads" )
    , Arrays.asList( 1,2,3,4,5,6,7,8 ) ) )
    tmDIV.add( threads );
    add( tmDIV );
   
   
   
    // QUEUE
    final WebMarkupContainer queueDIV = new WebMarkupContainer( "queue" );
    queueDIV.add( new RefreshingView<Task>("task")
    {
      /**
       * Return an iterator over models for items in the view
       */
      @Override
      protected Iterator<IModel<Task>> getItemModels()
      {
        return taskQueue.iterator();
      }

      @Override
      protected void populateItem(final Item<Task> item) {
        Task task = item.getModelObject();
        long elapsed = System.currentTimeMillis() - task.getTaskDate().getTime();
        item.add( new Label("time", elapsed+"" )); //DurationFormatUtil.formatDurationHMS(elapsed) ) );
        item.add( new Label("text", task.toString() ) );
      }
    });
    queueDIV.add( new Label( "more", new AbstractReadOnlyModel<String>() {
      @Override
      public String getObject() {
View Full Code Here

TOP

Related Classes of org.apache.droids.api.Task

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.