Class Request

java.lang.Object
com.bea.wcp.diameter.Message
com.bea.wcp.diameter.Request
Direct Known Subclasses:
ACR, CCR, Peer.CER, RAR, SySLR, SySNR, SySTR

public class Request extends Message
Diameter request message. Request extends Message with the ability to directly get and set the destination host, destination realm, and ApplicationId for the request.
Author:
Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
  • Constructor Details

    • Request

      public Request(Node node, Command cmd, int appId, String sessionId)
      Creates a new Request for a given command, application, and optional session identifier.
      Parameters:
      node - the Diameter Node originating the request
      cmd - the request command
      appId - the message header application identifier
      sessionId - the session identifier AVP value, or null if none
    • Request

      public Request(Command cmd, Application app)
      Creates a new Request for the specified application and command.
      Parameters:
      cmd - the Command for the request
      app - the Application for the request
    • Request

      public Request(Command cmd, Session session)
      Creates a new Request for the specified session and command.
      Parameters:
      session - the Diameter session for this request
      cmd - the Request command name
    • Request

      public Request(ByteBuffer bb, com.bea.wcp.diameter.transport.Connection c)
      Creates a new Request decoded from the specified message bytes.
      Parameters:
      bb - the message bytes
      c - the connection used to receive the message
  • Method Details

    • getNode

      public Node getNode()
    • preValidate

      public void preValidate() throws MessageException
      Description copied from class: Message
      Performs initial validation of a message to include validation of AVPs required to determine if the request/answer should be forwarded. If we determine the message should be handled locally, then the remaining AVPs will be validated by 'validate()'.
      Overrides:
      preValidate in class Message
      Throws:
      MessageException - if validation failed
    • preValidateAvp

      protected void preValidateAvp(Avp avp) throws AvpException
      Description copied from class: Message
      Fully decodes and validates the specified AVP. Message implementations can override this to provide additional validation or to cache AVP results.
      Overrides:
      preValidateAvp in class Message
      Parameters:
      avp - the AVP to be validated
      Throws:
      AvpException - if the AVP was invalid
    • createAnswer

      public Answer createAnswer(ResultCode rc)
      Creates an Answer message for this request. The relevant header fields and AVPs will be copied from the original request (see RFC 3588).
    • createAnswer

      public Answer createAnswer(ResultCode rc, String error)
      Creates a new Answer message for this request. An Error-Message AVP will be included if the specified error message is not null.
      Parameters:
      rc - the ResultCode for the answer
      error - the error message or null if none
      Returns:
      the Answer message for the request
    • sendError

      public void sendError(Throwable ex) throws IOException
      Sends an error answer for this request and the specified exception.
      Parameters:
      ex - the exception that caused the error
      Throws:
      IOException - if the answer could not be sent
    • getDestinationHost

      public String getDestinationHost()
      Returns the destination host for this request, or null if none. This corresponds to the value of the Destination-Host AVP.
    • getDestinationRealm

      public String getDestinationRealm()
      Returns the destination realm for this request. This corresponds to the value of the Destination-Realm AVP.
    • getApplicationId

      public ApplicationId getApplicationId()
      Returns the ApplicationId for this request, or null if none. This corresponds to one of the Auth-Application-Id, Acct-Application-Id, or Vendor-Specific-Application-Id AVPs. A different application id can be specified in the message header itself.
    • setDestinationHost

      public void setDestinationHost(String host)
      Sets the destination host for this request. This will result in the Destination-Host AVP being added to the request.
      Parameters:
      host - the destination host
      Throws:
      IllegalStateException - if the destination host has already been set
    • unsetDestinationHost

      public void unsetDestinationHost()
      Unsets the destination host for this request and removes the Destination-Host AVP.
    • setDestinationRealm

      public void setDestinationRealm(String realm)
      Sets the destination realm for the request. This will result in the Destination-Realm AVP being added to the request. The destination realm can only be set once, and must be set if the request is proxiable.
      Parameters:
      realm - the destination realm
      Throws:
      IllegalStateException - if the destination realm has already been set
    • setApplicationId

      public void setApplicationId(ApplicationId id)
      Sets the ApplicationId for the request. This will result in one of the Auth-Application-Id, Acct-Application-Id, or Vendor-Specific-Application-Id AVPs being added to the request. The ApplicationId can be different from the application id specified in the message header. The ApplicationId can only be set once, and must be set if the request is proxiable.
      Parameters:
      id - the ApplicationId for the request
      Throws:
      IllegalStateException - if the application id has already been set
    • setSession

      public void setSession(Session session)
    • getSession

      public Session getSession()
      Returns the session associated with this request.
      Specified by:
      getSession in class Message
      Returns:
      the Session for this Request, or null if none
    • commit

      public void commit() throws IOException
      Commits the request and sends it to the destination peer or realm.
      Specified by:
      commit in class Message
      Throws:
      IOException - if an I/O error occurred while sending
    • isCommitted

      public boolean isCommitted()
      Returns true if the request has been committed.
      Specified by:
      isCommitted in class Message
      Returns:
      true if committed, false otherwise
    • send

      public void send(long timeout) throws IOException
      Sends the request. If the destination host has been set, then the request will be sent directly to the peer associated with the host. Otherwise, the message will be routed based on destination realm and application identifier.
      Throws:
      IOException - if an I/O error has occurred
    • send

      public void send() throws IOException
      Description copied from class: Message
      Sends this Diameter message.
      Specified by:
      send in class Message
      Throws:
      IOException - if an I/O error occurred while sending
    • sendAndWait

      public Answer sendAndWait(long timeout) throws IOException
      Parameters:
      timeout -
      Returns:
      Throws:
      IOException
    • sendAndWait

      public Answer sendAndWait() throws IOException
      Throws:
      IOException
    • attemptFailover

      public boolean attemptFailover()
    • getRetrySupported

      public boolean getRetrySupported()
    • setRetrySupported

      public void setRetrySupported(boolean canRetry)
    • isThreadWaiting

      public boolean isThreadWaiting()
    • setAnswer

      public void setAnswer(Answer ans)
    • getAnswer

      public Answer getAnswer()
    • isAnswered

      public boolean isAnswered()
      Returns true if this request has already been answered.
    • cancel

      public void cancel()
    • getDestinationPeers

      public Peer[] getDestinationPeers() throws IOException
      Returns the destination peers for this request. If Destination-Host AVP is present and is a configured peer, then returns a list with just that peer. Otherwise, returns list of available peers according to Destination-Route AVP (realm-based routing).
      Returns:
      list of destination peers
      Throws:
      IOException - if no destination peers are available
    • getRouteDLBEnabled

      public boolean getRouteDLBEnabled() throws IOException
      returns if load balance enabled for this route or not.
      Throws:
      IOException
    • pushProxyInfo

      public void pushProxyInfo()
      Adds proxy info AVP to the list representing the current node. Additionally, allocates a new hop-by-hop identifier for this request.
    • setIsPotentiallyRetransmitted

      public static void setIsPotentiallyRetransmitted(ByteBuffer bb)