Пример #1
0
 /**
  * Stops the given AUT.
  *
  * @param autId The ID of the Running AUT to stop.
  * @param timeout indicates whether the AUT should be forced to quit (timeout == 0) or whether the
  *     AUT should terminate by itself (timeout > 0)
  */
 public void stopAut(AutIdentifier autId, int timeout) {
   boolean force = timeout == 0;
   if (!force) {
     long startTime = System.currentTimeMillis();
     boolean timedOut = false;
     while (m_auts.containsKey(autId) && !timedOut) {
       timedOut = (startTime + timeout) < System.currentTimeMillis();
       TimeUtil.delay(250);
     }
     if (!timedOut) {
       // The AUT has just unregistered itself - which must not be exactly
       // the same as terminated - therefore we wait for another moment
       // of time
       TimeUtil.delayDefaultOrExternalTime(
           AUT_POST_DEREGISTRATION_DELAY_DEFAULT, AUT_POST_DEREGISTRATION_DELAY_VAR);
     } else {
       force = true;
     }
   }
   synchronized (m_auts) {
     Communicator autCommunicator = m_auts.get(autId);
     if (autCommunicator != null) {
       if (force) {
         removeAut(autId);
       }
     }
   }
 }
Пример #2
0
  /**
   * Requests the aut starter log file and handles occurring errors.
   *
   * @return The response for request of the aut starter log file. If the aut starter did not
   *     respond in time, then null is returned.
   */
  public ServerLogResponseMessage requestServerLog() {
    // Send request to aut starter and wait for response
    ServerLogResponseCommand request = new ServerLogResponseCommand(this);
    SendServerLogMessage message = new SendServerLogMessage();
    try {
      AutAgentConnection.getInstance().request(message, request, TIMEOUT);
    } catch (NotConnectedException nce) {
      ErrorHandlingUtil.createMessageDialog(MessageIDs.E_NO_SERVER_CONNECTION_INIT);
    } catch (CommunicationException ce) {
      ErrorHandlingUtil.createMessageDialog(MessageIDs.E_MESSAGE_REQUEST);
    }

    int waited = 0;
    while ((m_response == null) && (waited <= TIMEOUT)) {
      TimeUtil.delay(200);
      waited += 200;
    }

    // reset m_response for next request of aut starter log
    ServerLogResponseMessage responseToReturn = m_response;
    m_response = null;

    handleServerRequestErrors(responseToReturn);

    return responseToReturn;
  }
Пример #3
0
 /**
  * Delay for a certain amount of time. Uses if set the given keys property value as a delay
  *
  * @param defaultDelay the delay in ms, must not be negative
  * @param delayPropertyKey the property key; can be used to override / allow external setting of
  *     amount of delay
  */
 public static void delayDefaultOrExternalTime(
     final long defaultDelay, final String delayPropertyKey) {
   long timeToWait = defaultDelay;
   try {
     String value = EnvironmentUtils.getProcessOrSystemProperty(delayPropertyKey);
     timeToWait = Long.valueOf(value).longValue();
   } catch (NumberFormatException e) {
     // ignore invalid formatted values and use default instead
   }
   TimeUtil.delay(timeToWait);
 }