Package org.serviceconnector.api

Examples of org.serviceconnector.api.SCServiceException


   *             encoding of request URL failed<br />
   */
  public Map<String, String> getWorkload(int operationTimeoutSeconds, String serviceName) throws SCServiceException,
      UnsupportedEncodingException {
    if (this.attached == false) {
      throw new SCServiceException("Client not attached - isServiceEnabled not possible.");
    }
    String urlString = URLString.toURLRequestString(Constants.CC_CMD_SESSIONS, Constants.SERVICE_NAME, serviceName);
    String body = this.inspectCall(operationTimeoutSeconds, urlString);
    try {
      URLString urlResponse = new URLString();
      urlResponse.parseResponseURLString(body);
      return urlResponse.getParameterMap();
    } catch (UnsupportedEncodingException e) {
      throw new SCServiceException(e.toString());
    }
  }
View Full Code Here


   *             encoding of request URL failed<br />
   */
  public Map<String, String> inspectCache(int operationTimeoutSeconds, String serviceName, String cacheId)
      throws SCServiceException, UnsupportedEncodingException {
    if (this.attached == false) {
      throw new SCServiceException("Client not attached - inspectCache not possible.");
    }
    String urlString = URLString.toURLRequestString(Constants.CC_CMD_INSPECT_CACHE, Constants.SERVICE_NAME, serviceName,
        Constants.CACHE_ID, cacheId);
    String body = this.inspectCall(operationTimeoutSeconds, urlString);
    try {
      URLString urlResponse = new URLString();
      urlResponse.parseResponseURLString(body);
      return urlResponse.getParameterMap();
    } catch (UnsupportedEncodingException e) {
      throw new SCServiceException(e.toString());
    }
  }
View Full Code Here

    try {
      inspectCall.setRequestBody(instruction);
      inspectCall.invoke(callback, operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
    } catch (Exception e) {
      this.requester.destroy();
      throw new SCServiceException("Inspect request failed. ", e);
    }
    if (instruction.equalsIgnoreCase(Constants.CC_CMD_KILL)) {
      // on KILL SC cannot reply a message
      return null;
    }
    SCMPMessage reply = callback.getMessageSync(operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
    if (reply.isFault()) {
      SCServiceException ex = new SCServiceException("Inspect failed.");
      ex.setSCErrorCode(reply.getHeaderInt(SCMPHeaderAttributeKey.SC_ERROR_CODE));
      ex.setSCErrorText(reply.getHeader(SCMPHeaderAttributeKey.SC_ERROR_TEXT));
      throw ex;
    }
    return (String) reply.getBody();
  }
View Full Code Here

  public void setKeepAliveIntervalSeconds(int keepAliveIntervalSeconds) throws SCServiceException, SCMPValidatorException {
    // validate in this case its a local needed information
    ValidatorUtility.validateInt(Constants.MIN_KPI_VALUE, keepAliveIntervalSeconds, Constants.MAX_KPI_VALUE,
        SCMPError.HV_WRONG_KEEPALIVE_INTERVAL);
    if (this.attached == true) {
      throw new SCServiceException("Can not set property, client is already attached.");
    }
    this.keepAliveIntervalSeconds = keepAliveIntervalSeconds;
  }
View Full Code Here

  public void setKeepAliveTimeoutSeconds(int keepAliveTimeoutSeconds) throws SCMPValidatorException, SCServiceException {
    // validate in this case its a local needed information
    ValidatorUtility.validateInt(1, keepAliveTimeoutSeconds, Constants.MAX_KP_TIMEOUT_VALUE,
        SCMPError.HV_WRONG_KEEPALIVE_TIMEOUT);
    if (this.attached) {
      throw new SCServiceException("Can not set property, client is already attached.");
    }
    this.keepAliveTimeoutSeconds = keepAliveTimeoutSeconds;
  }
View Full Code Here

   * @throws SCServiceException
   *             called method after attach
   */
  public void setTCPKeepAlive(boolean tcpKeepAlive) throws SCServiceException {
    if (this.attached) {
      throw new SCServiceException("Can not set property, client is already attached.");
    }
    // sets the TCP keep alive in basic configuration
    AppContext.getBasicConfiguration().setTCPKeepAlive(tcpKeepAlive);
  }
View Full Code Here

   * @throws SCServiceException
   *             called method after attach
   */
  public void setMaxConnections(int maxConnections) throws SCServiceException, SCMPValidatorException {
    if (this.attached == true) {
      throw new SCServiceException("Can not set property, client is already attached.");
    }
    // maxConnections must be at least 2 - echo call and execute/send might be parallel
    ValidatorUtility.validateInt(2, maxConnections, SCMPError.HV_WRONG_MAX_CONNECTIONS);
    this.maxConnections = maxConnections;
  }
View Full Code Here

      registerServerCall.setUrlPath(this.urlPath);
      SCServerCallback callback = new SCServerCallback(true);
      try {
        registerServerCall.invoke(callback, Constants.DEFAULT_OPERATION_TIMEOUT_SECONDS * Constants.SEC_TO_MILLISEC_FACTOR);
      } catch (Exception e) {
        throw new SCServiceException("Register server failed. ", e);
      }
      SCMPMessage reply = callback.getMessageSync(Constants.DEFAULT_OPERATION_TIMEOUT_SECONDS
          * Constants.SEC_TO_MILLISEC_FACTOR);
      if (reply.isFault()) {
        SCServiceException ex = new SCServiceException("Register server failed.");
        ex.setSCErrorCode(reply.getHeaderInt(SCMPHeaderAttributeKey.SC_ERROR_CODE));
        ex.setSCErrorText(reply.getHeader(SCMPHeaderAttributeKey.SC_ERROR_TEXT));
        throw ex;
      }
      AppContext.attachedCommunicators.incrementAndGet();
    }
    // set up server timeout thread
View Full Code Here

        SCServerCallback callback = new SCServerCallback(true);
        try {
          deRegisterServerCall.invoke(callback, Constants.DEFAULT_OPERATION_TIMEOUT_SECONDS
              * Constants.SEC_TO_MILLISEC_FACTOR);
        } catch (Exception e) {
          throw new SCServiceException("Deregister server failed. ", e);
        }
        SCMPMessage reply = callback.getMessageSync(Constants.DEFAULT_OPERATION_TIMEOUT_SECONDS
            * Constants.SEC_TO_MILLISEC_FACTOR);
        if (reply.isFault()) {
          SCServiceException ex = new SCServiceException("Deregister server failed.");
          ex.setSCErrorCode(reply.getHeaderInt(SCMPHeaderAttributeKey.SC_ERROR_CODE));
          ex.setSCErrorText(reply.getHeader(SCMPHeaderAttributeKey.SC_ERROR_TEXT));
          throw ex;
        }
      } finally {
        this.registered = false;
        AppContext.attachedCommunicators.decrementAndGet();
View Full Code Here

   *             check registration failed<br />
   *             error message received from SC <br />
   */
  public synchronized void checkRegistration(int operationTimeoutSeconds) throws SCServiceException {
    if (this.registered == false) {
      throw new SCServiceException("Server is not registered for a service.");
    }
    // cancel server timeout not if its running already, you might interrupt current thread
    this.cancelServerTimeout(false);
    SCMPCheckRegistrationCall checkRegistrationCall = new SCMPCheckRegistrationCall(this.requester, this.serviceName);
    SCServerCallback callback = new SCServerCallback(true);
    try {
      checkRegistrationCall.invoke(callback, operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
    } catch (Exception e) {
      throw new SCServiceException("Check registration failed. ", e);
    }
    SCMPMessage reply = callback.getMessageSync(operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
    if (reply.isFault()) {
      SCServiceException ex = new SCServiceException("Check registration failed.");
      ex.setSCErrorCode(reply.getHeaderInt(SCMPHeaderAttributeKey.SC_ERROR_CODE));
      ex.setSCErrorText(reply.getHeader(SCMPHeaderAttributeKey.SC_ERROR_TEXT));
      throw ex;
    }
    // set up server timeout thread
    this.triggerServerTimeout();
  }
View Full Code Here

TOP

Related Classes of org.serviceconnector.api.SCServiceException

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.