Package org.serviceconnector.scmp

Examples of org.serviceconnector.scmp.SCMPMessage


        ScheduledFuture<TimeoutWrapper> timeout = (ScheduledFuture<TimeoutWrapper>) AppContext.otiScheduler.schedule(
            timeoutWrapper, (long) timeoutMillis, TimeUnit.MILLISECONDS);
        reqCallback.setOperationTimeout(timeout);
        reqCallback.setTimeoutMillis(timeoutMillis);
        // extract first part message & send
        SCMPMessage part = largeResponse.getFirst();
        // handling msgSequenceNr
        if (SCMPMessageSequenceNr.necessaryToWrite(message.getMessageType())) {
          part.setHeader(SCMPHeaderAttributeKey.MESSAGE_SEQUENCE_NR, msgSequenceNr.getCurrentNr());
        }
        // send
        connection.send(part, requesterCallback);
      } else {
        requesterCallback = new SCRequesterSCMPCallback(message, scmpCallback, connectionContext, msgSequenceNr);
View Full Code Here


    }
    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

          this.scmpCallback.receive(this.largeResponse);
          // delete compositeReceiver - large response done!
          this.largeResponse = null;
          return;
        }
        SCMPMessage message = largeResponse.getPart();
        if (SCMPMessageSequenceNr.necessaryToWrite(message.getMessageType())) {
          // increment msgSequenceNr
          this.msgSequenceNr.incrementAndGetMsgSequenceNr();
          message.setHeader(SCMPHeaderAttributeKey.MESSAGE_SEQUENCE_NR, msgSequenceNr.getCurrentNr());
        }
        // updating cache part number for poll request
        Integer partNr = scmpReply.getHeaderInt(SCMPHeaderAttributeKey.CACHE_PARTN_NUMBER);
        if (partNr == null) {
          partNr = 1;
        }
        message.setHeader(SCMPHeaderAttributeKey.CACHE_PARTN_NUMBER, partNr);
        LOGGER.debug("handling large response using cache id = " + message.getCacheId());
        // poll & exit
        this.connectionCtx.getConnection().send(message, this);
        return;
      }
View Full Code Here

  public void receive(Exception ex) {
    String sid = this.reqMessage.getSessionId();
    LOGGER.warn("receive exception sid=" + sid + " " + ex.toString());
    // creation failed remove from server
    this.tempSubscription.getServer().removeSession(tempSubscription);
    SCMPMessage fault = null;
    String serviceName = this.reqMessage.getServiceName();
    if (ex instanceof IdleTimeoutException) {
      // operation timeout handling
      fault = new SCMPMessageFault(SCMPError.OPERATION_TIMEOUT, "Operation timeout expired on SC cln subscribe sid=" + sid);
    } else if (ex instanceof IOException) {
      fault = new SCMPMessageFault(SCMPError.CONNECTION_EXCEPTION, "broken connection on SC cln subscribe sid=" + sid);
    } else if (ex instanceof InterruptedException) {
      fault = new SCMPMessageFault(SCMPError.SC_ERROR, "executing cln subscribe failed, thread interrupted sid=" + sid);
    } else if (ex instanceof InvalidMaskLengthException) {
      fault = new SCMPMessageFault(SCMPError.HV_WRONG_MASK, ex.getMessage() + " sid=" + sid);
    } else {
      fault = new SCMPMessageFault(SCMPError.SC_ERROR, "executing cln subscribe failed sid=" + sid);
    }
    // forward reply to client
    fault.setIsReply(true);
    fault.setServiceName(serviceName);
    fault.setMessageType(msgType);
    response.setSCMP(fault);
    this.responderCallback.responseCallback(request, response);
  }
View Full Code Here

  @Override
  public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
    if (this.pendingRequest) {
      this.pendingRequest = false;
      SCMPMessage ret = null;
      try {
        byte[] buffer = (byte[]) e.getMessage();
        Statistics.getInstance().incrementTotalMessages(buffer.length);
        if (ConnectionLogger.isEnabledFull()) {
          InetSocketAddress remoteAddress = (InetSocketAddress) ctx.getChannel().getRemoteAddress();
View Full Code Here

  /** {@inheritDoc} */
  @Override
  public final void run(final IRequest request, final IResponse response, final IResponderCallback responderCallback)
      throws Exception {
    SCMPMessage reqMsg = request.getMessage();
    String bodyString = (String) reqMsg.getBody();

    URLString urlRequestString = new URLString();
    urlRequestString.parseRequestURLString(bodyString);
    String callKey = urlRequestString.getCallKey();
    String serviceName = urlRequestString.getParamValue(Constants.SERVICE_NAME);

    SCMPMessage scmpReply = new SCMPMessage();
    scmpReply.setIsReply(true);
    InetAddress localHost = InetAddress.getLocalHost();
    scmpReply.setHeader(SCMPHeaderAttributeKey.IP_ADDRESS_LIST, localHost.getHostAddress());
    scmpReply.setMessageType(getKey());

    if (Constants.CC_CMD_STATE.equalsIgnoreCase(callKey)) {
      // state for service requested
      LOGGER.debug("state request for service=" + serviceName);
      try {
        // get state of all services
        scmpReply.setBody(this.getStateOfServicesString(serviceName));
      } catch (Exception e) {
        LOGGER.debug("service=" + serviceName + " not found");
        scmpReply = new SCMPMessageFault(SCMPError.SERVICE_NOT_FOUND, serviceName);
      }
      response.setSCMP(scmpReply);
      // initiate responder to send reply
      responderCallback.responseCallback(request, response);
      return;
    }
    if (Constants.CC_CMD_SESSIONS.equalsIgnoreCase(callKey)) {
      // state for service requested
      LOGGER.debug("sessions request for service=" + serviceName);
      try {
        // get sessions of all services
        scmpReply.setBody(this.getSessionsOfServicesString(serviceName));
      } catch (Exception e) {
        LOGGER.debug("service=" + serviceName + " not found");
        scmpReply = new SCMPMessageFault(SCMPError.SERVICE_NOT_FOUND, serviceName);
      }
      response.setSCMP(scmpReply);
      // initiate responder to send reply
      responderCallback.responseCallback(request, response);
      return;
    }
    if (Constants.CC_CMD_SERVICE_CONF.equalsIgnoreCase(callKey)) {
      LOGGER.debug("service configuration request for serviceName=" + serviceName);
      try {
        scmpReply.setBody(this.getServiceConfigurationString(serviceName));
      } catch (Exception e) {
        LOGGER.debug("service=" + serviceName + " not found");
        scmpReply = new SCMPMessageFault(SCMPError.SERVICE_NOT_FOUND, serviceName);
      }
      response.setSCMP(scmpReply);
      // initiate responder to send reply
      responderCallback.responseCallback(request, response);
      return;
    }
    if (Constants.CC_CMD_INSPECT_CACHE.equalsIgnoreCase(callKey)) {
      String cacheId = urlRequestString.getParamValue("cacheId");
      LOGGER.debug("cache inspect for serviceName=" + serviceName + ", cacheId=" + cacheId);
      String cacheInspectString = this.getCacheInspectString(serviceName, serviceName + Constants.UNDERLINE + cacheId);
      scmpReply.setBody(cacheInspectString);
      response.setSCMP(scmpReply);
      // initiate responder to send reply
      responderCallback.responseCallback(request, response);
      return;
    }
    if (Constants.CC_CMD_SC_VERSION.equalsIgnoreCase(callKey)) {
      LOGGER.debug("sc version request");
      String scVersion = Constants.CC_CMD_SC_VERSION + Constants.EQUAL_SIGN + SCVersion.CURRENT;
      scmpReply.setBody(scVersion);
      response.setSCMP(scmpReply);
      // initiate responder to send reply
      responderCallback.responseCallback(request, response);
      return;
    }
View Full Code Here

  /** {@inheritDoc} */
  @Override
  public final void validate(final IRequest request) throws Exception {
    try {
      SCMPMessage message = request.getMessage();
      // ipAddressList mandatory
      String ipAddressList = message.getHeader(SCMPHeaderAttributeKey.IP_ADDRESS_LIST);
      ValidatorUtility.validateIpAddressList(ipAddressList);
    } catch (HasFaultResponseException ex) {
      // needs to set message type at this point
      ex.setMessageType(getKey());
      throw ex;
View Full Code Here

   * @param requester
   *            the requester
   */
  public SCMPCallAdapter(IRequester requester) {
    this.requester = requester;
    this.requestMessage = new SCMPMessage();
  }
View Full Code Here

    @Override
    public void invoke(ISCMPMessageCallback callback, int timeoutMillis) throws Exception {
      if (this.groupState == SCMPGroupState.CLOSE) {
        LOGGER.warn("tried to invoke groupCall but state of group is closed");
      }
      SCMPMessage callSCMP = this.parentCall.getRequest();
      SCMPCallAdapter.this.requestMessage.setInternalStatus(SCMPInternalStatus.GROUP);

      if (callSCMP.isLargeMessage()) {
        // parent call is large no need to change anything
        this.parentCall.invoke(callback, timeoutMillis);
        return;
      }
      if (callSCMP.isPart() == false) {
        // callSCMP is small and not part but inside a group only parts are allowed
        SCMPPart scmpPart = new SCMPPart();
        scmpPart.setHeader(callSCMP);
        scmpPart.setBody(callSCMP.getBody());
        scmpPart.setIsPollRequest(callSCMP.isPollRequest());
        SCMPCallAdapter.this.requestMessage = scmpPart; // SCMPCallAdapter.this points to this.parentCall
        callSCMP = null;
      }
      this.parentCall.invoke(callback, timeoutMillis);
      return;
View Full Code Here

    /** {@inheritDoc} */
    @Override
    public void closeGroup(ISCMPMessageCallback callback, int timeoutMillis) throws Exception {
      this.groupState = SCMPGroupState.CLOSE;
      // send empty closing REQ
      SCMPMessage message = new SCMPMessage();
      message.setHeader(SCMPCallAdapter.this.requestMessage);
      message.setBody(null);
      message.setInternalStatus(SCMPInternalStatus.GROUP);
      SCMPCallAdapter.this.requestMessage = message;
      this.parentCall.invoke(callback, timeoutMillis);
      return;
    }
View Full Code Here

TOP

Related Classes of org.serviceconnector.scmp.SCMPMessage

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.