private void handleAspInactive(AspImpl aspImpl, ASPInactive aspInactive) { AsImpl appServer = (AsImpl) aspImpl.getAs(); FSM aspPeerFSM = aspImpl.getPeerFSM(); if (aspPeerFSM == null) { logger.error( String.format( "Received ASPINACTIVE=%s for ASP=%s. But peer FSM for ASP is null.", aspInactive, this.aspFactoryImpl.getName())); return; } FSM asLocalFSM = appServer.getLocalFSM(); if (asLocalFSM == null) { logger.error( String.format( "Received ASPINACTIVE=%s for ASP=%s. But local FSM for AS is null.", aspInactive, this.aspFactoryImpl.getName())); return; } ASPInactiveAck aspInactAck = (ASPInactiveAck) this.aspFactoryImpl.messageFactory.createMessage( MessageClass.ASP_TRAFFIC_MAINTENANCE, MessageType.ASP_INACTIVE_ACK); aspInactAck.setRoutingContext(appServer.getRoutingContext()); this.aspFactoryImpl.write(aspInactAck); try { aspPeerFSM.setAttribute(FSM.ATTRIBUTE_MESSAGE, aspInactive); aspPeerFSM.signal(TransitionState.ASP_INACTIVE); // Signal AS to transition asLocalFSM.setAttribute(AsImpl.ATTRIBUTE_ASP, aspImpl); asLocalFSM.signal(TransitionState.ASP_INACTIVE); } catch (UnknownTransitionException e) { logger.error(e.getMessage(), e); } }
protected void handleAspInactiveAck(ASPInactiveAck aspInactiveAck) { if (!this.aspFactoryImpl.started) { // If management stopped this ASP, ignore ASPInactiveAck return; } RoutingContext rc = aspInactiveAck.getRoutingContext(); if (aspFactoryImpl.getFunctionality() == Functionality.AS || (aspFactoryImpl.getFunctionality() == Functionality.SGW && aspFactoryImpl.getExchangeType() == ExchangeType.DE) || (aspFactoryImpl.getFunctionality() == Functionality.IPSP && aspFactoryImpl.getExchangeType() == ExchangeType.DE) || (aspFactoryImpl.getFunctionality() == Functionality.IPSP && aspFactoryImpl.getExchangeType() == ExchangeType.SE && aspFactoryImpl.getIpspType() == IPSPType.CLIENT)) { if (rc == null) { AspImpl aspImpl = this.getAspForNullRc(); if (aspImpl == null) { // Error condition logger.error( String.format( "Rx : ASPINACTIVE_ACK=%s with null RC for Aspfactory=%s. But no ASP configured for null RC. Sent back Error", aspInactiveAck, this.aspFactoryImpl.getName())); return; } handleAspInactiveAck(aspImpl, aspInactiveAck); } else { long[] rcs = aspInactiveAck.getRoutingContext().getRoutingContexts(); for (int count = 0; count < rcs.length; count++) { AspImpl aspImpl = this.aspFactoryImpl.getAsp(rcs[count]); if (aspImpl == null) { // this is error. Send back error RoutingContext rcObj = this.aspFactoryImpl.parameterFactory.createRoutingContext(new long[] {rcs[count]}); ErrorCode errorCodeObj = this.aspFactoryImpl.parameterFactory.createErrorCode( ErrorCode.Invalid_Routing_Context); sendError(rcObj, errorCodeObj); logger.error( String.format( "Rx : ASPINACTIVE_ACK=%s with RC=%d for Aspfactory=%s. But no ASP configured for this RC. Sending back Error", aspInactiveAck, rcs[count], this.aspFactoryImpl.getName())); continue; } handleAspInactiveAck(aspImpl, aspInactiveAck); } // for } } else { // TODO : Should we silently drop ASPINACTIVE_ACK? // ASPINACTIVE_ACK is unexpected in this state ErrorCode errorCodeObj = this.aspFactoryImpl.parameterFactory.createErrorCode(ErrorCode.Unexpected_Message); sendError(rc, errorCodeObj); } }