Package jade.imtp.leap

Examples of jade.imtp.leap.ICPException


        while (responseToLastOutgoingCommand == null) {
          responseToLastOutgoingCommandLock.wait(timeout);
          if (responseToLastOutgoingCommand == null) {
            if (frontEndStatus == TERMINATED) {
              // We terminated in the meanwhile
              throw new ICPException("Terminated");
            }
            else {
              // Timeout expired
              setFrontEndDisconnected();
              throw new ICPException("Response timeout");
            }
          }
        }
        JICPPacket response = responseToLastOutgoingCommand;
        responseToLastOutgoingCommand = null;
        return response;
      }
    }
    catch (InterruptedException ie) {
      throw new ICPException("Interrupted while waiting for response to outgoing command");
    }
  }
View Full Code Here


      String nodeName = myID.replace(':', '_');
      props.setProperty(Profile.CONTAINER_NAME, nodeName);
     
      myContainer = new BackEndContainer(props, this);
      if (!myContainer.connect()) {
        throw new ICPException("BackEnd container failed to join the platform");
      }
      // Possibly the node name was re-assigned by the main
      myID = myContainer.here().getName();
      if(myLogger.isLoggable(Logger.CONFIG)) {
        myLogger.log(Logger.CONFIG,"BackEndContainer "+myID+" successfully joined the platform");
      }
      return new BackEndSkel(myContainer);
    }
    catch (ProfileException pe) {
      // should never happen
      pe.printStackTrace();
      throw new ICPException("Error creating profile");
    }
  }
View Full Code Here

     Passes to this mediator a JICPPacket received by the
     JICPMediatorManager this mediator is attached to.
     In a NIOMediator this should never be called.
   */
  public JICPPacket handleJICPPacket(JICPPacket p, InetAddress addr, int port) throws ICPException {
    throw new ICPException("Unexpected call");
  }
View Full Code Here

    case JICPProtocol.ERROR_TYPE:
      System.out.println("RESPONSE/ERROR received: "+pkt.getSessionID());
      inpManager.notifyIncomingResponseReceived(pkt);
      break;
    default:
      throw new ICPException("Unexpected packet type "+type);
    }
   
    if (reply != null) {
      try {
        writePacket(myConnection, reply);
View Full Code Here

  public synchronized byte[] dispatch(byte[] payload, boolean flush) throws ICPException {
    if (connectionDropped) {
      // Move from DROPPED state to DISCONNECTED state and wait
      // for the FE to reconnect
      droppedToDisconnected();
      throw new ICPException("Connection dropped");
    }
    else {
      // Normal dispatch
      JICPPacket pkt = new JICPPacket(JICPProtocol.COMMAND_TYPE, JICPProtocol.DEFAULT_INFO, payload);
      pkt = inpManager.dispatch(pkt, flush);
View Full Code Here

    final JICPPacket dispatch(JICPPacket pkt, boolean flush) throws ICPException {
      dispatching = true;
      try {
        if (active && myConnection != null) {
          if (waitingForFlush && !flush) {
            throw new ICPException("Upsetting dispatching order");
          }
          waitingForFlush = false;
       
          if (myLogger.isLoggable(Logger.FINE)) {
            myLogger.log(Logger.FINE, myID+": Sending command "+inpCnt+" to FE");
          }
          pkt.setSessionID((byte) inpCnt);
          try {
            lastIncomingResponse = null;
            System.out.println("Sending command to FE "+pkt.getSessionID());
            writePacket(myConnection, pkt);
            System.out.println("Waiting for response from FE "+pkt.getSessionID());
            pkt = waitForResponse(inpCnt, RESPONSE_TIMEOUT);
            if (pkt != null) {
              System.out.println("Response received from FE "+pkt.getSessionID());
              if (myLogger.isLoggable(Logger.FINER)) {
                myLogger.log(Logger.FINER, myID+": Response received from FE "+pkt.getSessionID());
              }             
              if (pkt.getType() == JICPProtocol.ERROR_TYPE) {
                // Communication OK, but there was a JICP error on the peer
                throw new ICPException(new String(pkt.getData()));
              }
             
              checkTerminatedInfo(pkt);
              if (!peerActive) {
                // This is the response to an exit command --> Suicide, without
                // killing the above container since it is already dying.
                BackEndDispatcher.this.shutdown();
              }
              inpCnt = (inpCnt+1) & 0x0f;
              return pkt;
            }
            else {
              myLogger.log(Logger.WARNING, myID+": Response timeout expired");
              handleConnectionError(myConnection, null);
              throw new ICPException("Response timeout expired");
            }
          }
          catch (IOException ioe) {
            // There was an IO exception writing data to the connection
            // --> reset the connection.
            myLogger.log(Logger.WARNING, myID+": "+ioe);
            handleConnectionError(myConnection, ioe);
            throw new ICPException("Dispatching error.", ioe);
          }
        }
        else {
          throw new ICPException("Unreachable");
        }
      }
      finally {
        dispatching = false;
      }
View Full Code Here

            String nodeName = myID.replace(':', '_');
            props.setProperty(Profile.CONTAINER_NAME, nodeName);

            myContainer = new BackEndContainer(props, this);
            if (!myContainer.connect()) {
                throw new ICPException("BackEnd container failed to join the platform");
            }
            // Possibly the node name was re-assigned by the main
            myID = myContainer.here().getName();
            if (myLogger.isLoggable(Logger.CONFIG)) {
                myLogger.log(Logger.CONFIG, "BackEndContainer " + myID + " successfully joined the platform");
            }
            return new BackEndSkel(myContainer);
        } catch (ProfileException pe) {
            // should never happen
            pe.printStackTrace();
            throw new ICPException("Error creating profile");
        }
    }
View Full Code Here

    Passes to this mediator a JICPPacket received by the
    JICPMediatorManager this mediator is attached to.
    In a NIOMediator this should never be called.
     */
    public JICPPacket handleJICPPacket(JICPPacket p, InetAddress addr, int port) throws ICPException {
        throw new ICPException("Unexpected call");
    }
View Full Code Here

        } /* Asynch-reply
        else if (type == JICPProtocol.RESPONSE_TYPE || type == JICPProtocol.ERROR_TYPE) {
        inpManager.handleResponse(c, pkt);
        return null;
        }*/ else {
            throw new ICPException("Unexpected packet type " + type);
        }
    }
View Full Code Here

        if (connectionDropped) {
            // Move from DROPPED state to DISCONNECTED state and wait
            // for the FE to reconnect
            droppedToDisconnected();
            requestRefresh();
            throw new ICPException("Connection dropped");
        } else {
            // Normal dispatch
            JICPPacket pkt = new JICPPacket(JICPProtocol.COMMAND_TYPE, JICPProtocol.DEFAULT_INFO, payload);
            pkt = inpManager.dispatch(pkt, flush);
            return pkt.getData();
View Full Code Here

TOP

Related Classes of jade.imtp.leap.ICPException

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.