Package com.webobjects.foundation

Examples of com.webobjects.foundation.NSTimestamp


    NSTimestamp _currentTimestamp;

    public NSTimestamp currentTimestamp() {
      if (_currentTimestamp == null)
        _currentTimestamp = new NSTimestamp();
      return _currentTimestamp;
    }
View Full Code Here


    public Session theSession() {
      return (Session)session();
    }
 
    public NSTimestamp now() {
      return new NSTimestamp();
    }
View Full Code Here

  public NSTimestamp endTime = null;
  long endMillis = 0L;

  public WOComponent clickNow() {
    endTime = new NSTimestamp();
    endMillis = System.currentTimeMillis();
    return null;
  }
View Full Code Here

  public Main(WOContext context) {
    super(context);
  }

  public NSTimestamp time() { return new NSTimestamp(); }
View Full Code Here

  NSTimestamp _currentTS;

  public NSTimestamp currentTS() {
    if (_currentTS == null)
      _currentTS = new NSTimestamp();
    return _currentTS;
  }
View Full Code Here

    try {
      // Create the new TaskInfo
      TaskInfo taskInfo = ERXEOControlUtilities.createAndInsertObject(ec, TaskInfo.class);
     
      // Task start time
      taskInfo.setStartTime(new NSTimestamp(startTime));
     
      taskInfo.setStartNumber(_numberToCheck);
      taskInfo.setDuration(DURATION);
     
      // Loop for a period of time
      while (_elapsedTime < DURATION && !_isStopped) {
        ResultItem resultItem = ERXEOControlUtilities.createAndInsertObject(ec, ResultItem.class);
        resultItem.setTaskInfo(taskInfo);
       
        resultItem.setNumberToCheck(_numberToCheck);

        if (Utilities.isPrime(_numberToCheck)) {
          log.info("==>> " + _numberToCheck + " is a PRIME number.");
          resultItem.setIsPrime(Boolean.TRUE);
        } else {
          log.debug(_numberToCheck + " is not a prime number but is a COMPOSITE number.");
          resultItem.setIsPrime(Boolean.FALSE);
        }
       
        ec.saveChanges();
       
       
        _elapsedTime = System.currentTimeMillis() - startTime;
       
        // Update progress variables
        _count++;
        _percentComplete = (double)(_elapsedTime) / (double)DURATION;
        _status = wholeNumberFormatter.format(_count) + " numbers checked for prime qualification";

        _numberToCheck++;
      }
     
      // Complete the stats
      taskInfo.setEndNumber(_numberToCheck - 1);
      taskInfo.setEndTime(new NSTimestamp());
      taskInfo.setWorkflowState(TaskInfo.WORKFLOW_PRIME_CHECKED);
     
      ec.saveChanges();
     
      _resultGid = ec.globalIDForObject(taskInfo);
View Full Code Here

   
    return results.toString();
  }

  public static String timeFromNow(NSTimestamp time) {
    return timeFrom(time, new NSTimestamp());
  }
View Full Code Here

      NSMutableArray<Future<?>> childFutures = new NSMutableArray<Future<?>>();
      // Create the new TaskInfo
      TaskInfo taskInfo = ERXEOControlUtilities.createAndInsertObject(ec, TaskInfo.class);
     
      // Task start time
      taskInfo.setStartTime(new NSTimestamp(startTime));
     
      taskInfo.setStartNumber(_startNumber);
      taskInfo.setDuration(_taskDuration);
     
      ec.saveChanges();
      _resultGid = ec.globalIDForObject(taskInfo);
      _parentTaskPrimaryKey = (Integer) taskInfo.rawPrimaryKey();
     
      // Initialize loop variables
      long childTaskStartNumber = _startNumber;
      int incrementQuantity = _childBatchBaseQuantity + Utilities.sharedRandom().nextInt(_childBatchBaseQuantity);
      long childTaskEndNumber =  childTaskStartNumber + incrementQuantity;
     
     
      // Loop for a period of time
      while (_elapsedTime < _taskDuration && !_isStopped) {
        ChildPrimeTask childTask = new ChildPrimeTask(_nextChildIDValue, _resultGid, childTaskStartNumber, childTaskEndNumber);
        _nextChildIDValue++;
       
        boolean isRejected = true;
        while (isRejected && !ChildTaskPool.EXECUTOR_SERVICE.isShutdown() && !_isStopped) {
          try {
            Future<?> future = ChildTaskPool.EXECUTOR_SERVICE.submit(childTask);
           
            if (log.isInfoEnabled())
              log.info("Submitted task corresponding to " + future);
            isRejected = false;
            childFutures.add(future);
           
            // For the sake of demo, we assume all child tasks complete their work.
            _endNumber = childTaskEndNumber;
          } catch (RejectedExecutionException e) {
            try {
              Thread.sleep(2000);
              removeCompletedFutures(childFutures);
            } catch (InterruptedException e1) {
              stop();
            }
          }
        }
       
        childTaskStartNumber = childTaskEndNumber + 1;
        incrementQuantity = _childBatchBaseQuantity + Utilities.sharedRandom().nextInt(_childBatchBaseQuantity * 2);
        childTaskEndNumber =  childTaskStartNumber + incrementQuantity;

        _elapsedTime = System.currentTimeMillis() - startTime;
       
        // Update progress variables
        _percentComplete = (double)(_elapsedTime) / (double)_taskDuration;
        _status = wholeNumberFormatter.format(_count) + " numbers checked for prime qualification";

      }
     
      if (_isStopped) {
        _status = "Stopped";
      }
     
      // Wait for all child tasks to finish
      while (childFutures.count() > 0) {
        removeCompletedFutures(childFutures);
        Thread.sleep(1000);
      }
     
      // Complete the stats
      // Refresh it since the object has been already updated (its relationship) and saved on ChildThreads
      ERXEOControlUtilities.refreshObject(taskInfo);
      taskInfo.setEndNumber(_endNumber);
      taskInfo.setEndTime(new NSTimestamp());
      taskInfo.setWorkflowState(TaskInfo.WORKFLOW_PRIME_CHECKED);
      ec.saveChanges();
     
      _resultGid = ec.globalIDForObject(taskInfo);
     
View Full Code Here

        _numberToCheck++;
      }
     
      // Complete the stats
      taskInfo.setEndNumber(_numberToCheck - 1);
      taskInfo.setEndTime(new NSTimestamp());
      taskInfo.setWorkflowState(TaskInfo.WORKFLOW_PRIME_CHECKED);
     
      ec.saveChanges();
     
      _resultGid = ec.globalIDForObject(taskInfo);
View Full Code Here

        super(context);
        _updateTime();
  }
 
  private void _updateTime() {
    _now = new NSTimestamp();
  }
View Full Code Here

TOP

Related Classes of com.webobjects.foundation.NSTimestamp

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.