Search in sources :

Example 16 with InternalException

use of org.jdiameter.api.InternalException in project jain-slee.diameter by RestComm.

the class DiameterBaseResourceAdaptor method raActive.

public void raActive() {
    if (tracer.isFineEnabled()) {
        tracer.fine("Diameter Base RA :: raActive.");
    }
    try {
        if (tracer.isInfoEnabled()) {
            tracer.info("Activating Diameter Base RA Entity");
        }
        this.diameterMultiplexerObjectName = new ObjectName("diameter.mobicents:service=DiameterStackMultiplexer");
        Object object = null;
        if (ManagementFactory.getPlatformMBeanServer().isRegistered(this.diameterMultiplexerObjectName)) {
            // trying to get via MBeanServer
            object = ManagementFactory.getPlatformMBeanServer().invoke(this.diameterMultiplexerObjectName, "getMultiplexerMBean", new Object[] {}, new String[] {});
            if (tracer.isInfoEnabled()) {
                tracer.info("Trying to get via Platform MBeanServer: " + this.diameterMultiplexerObjectName + ", object: " + object);
            }
        } else {
            // trying to get via locateJBoss
            object = MBeanServerLocator.locateJBoss().invoke(this.diameterMultiplexerObjectName, "getMultiplexerMBean", new Object[] {}, new String[] {});
            if (tracer.isInfoEnabled()) {
                tracer.info("Trying to get via JBoss MBeanServer: " + this.diameterMultiplexerObjectName + ", object: " + object);
            }
        }
        if (object != null && object instanceof DiameterStackMultiplexerMBean) {
            this.diameterMux = (DiameterStackMultiplexerMBean) object;
        }
        // this.activities = new ConcurrentHashMap<ActivityHandle, DiameterActivity>();
        // Initialize the protocol stack
        initStack();
        // Initialize activity storage
        initActivitiesMgmt();
        // Initialize factories
        this.messageFactory = new DiameterMessageFactoryImpl(stack);
        this.avpFactory = new DiameterAvpFactoryImpl();
        // Setup session factories
        this.sessionFactory = this.stack.getSessionFactory();
        this.accSessionFactory = AccountingSessionFactory.INSTANCE;
        this.accSessionFactory.registerListener(this, messageTimeout, sessionFactory);
        this.authSessionFactory = new AuthorizationSessionFactory(this, messageTimeout, sessionFactory);
        this.proxySessionFactory = new SessionFactory() {

            public <T extends AppSession> T getNewAppSession(ApplicationId applicationId, Class<? extends AppSession> userSession) throws InternalException {
                return (T) sessionFactory.getNewAppSession(applicationId, userSession);
            }

            public <T extends AppSession> T getNewAppSession(String sessionId, ApplicationId applicationId, Class<? extends AppSession> userSession) throws InternalException {
                return (T) sessionFactory.getNewAppSession(sessionId, applicationId, userSession);
            }

            public RawSession getNewRawSession() throws InternalException {
                try {
                    return stack.getSessionFactory().getNewRawSession();
                } catch (IllegalDiameterStateException e) {
                    tracer.severe("Failure while obtaining Session Factory for new Raw Session.", e);
                    return null;
                }
            }

            public Session getNewSession() throws InternalException {
                Session session = sessionFactory.getNewSession();
                sessionCreated(session);
                return session;
            }

            public Session getNewSession(String sessionId) throws InternalException {
                Session session = sessionFactory.getNewSession(sessionId);
                sessionCreated(session);
                return session;
            }

            public String getSessionId() {
                return sessionFactory.getSessionId();
            }

            public String getSessionId(String customPart) {
                return sessionFactory.getSessionId(customPart);
            }
        };
        // Register Accounting App Session Factories
        ((ISessionFactory) sessionFactory).registerAppFacory(ServerAccSession.class, accSessionFactory);
        ((ISessionFactory) sessionFactory).registerAppFacory(ClientAccSession.class, accSessionFactory);
        // Register Authorization App Session Factories
        ((ISessionFactory) sessionFactory).registerAppFacory(ServerAuthSession.class, authSessionFactory);
        ((ISessionFactory) sessionFactory).registerAppFacory(ClientAuthSession.class, authSessionFactory);
    } catch (Exception e) {
        tracer.severe("Error Activating Diameter Base RA Entity", e);
    }
}
Also used : AccountingSessionFactory(org.mobicents.slee.resource.diameter.base.handlers.AccountingSessionFactory) AuthorizationSessionFactory(org.mobicents.slee.resource.diameter.base.handlers.AuthorizationSessionFactory) SessionFactory(org.jdiameter.api.SessionFactory) ISessionFactory(org.jdiameter.client.api.ISessionFactory) DiameterStackMultiplexerMBean(org.mobicents.diameter.stack.DiameterStackMultiplexerMBean) AuthorizationSessionFactory(org.mobicents.slee.resource.diameter.base.handlers.AuthorizationSessionFactory) RawSession(org.jdiameter.api.RawSession) AvpDataException(org.jdiameter.api.AvpDataException) InternalException(org.jdiameter.api.InternalException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) IllegalDiameterStateException(org.jdiameter.api.IllegalDiameterStateException) IOException(java.io.IOException) CreateActivityException(net.java.slee.resource.diameter.base.CreateActivityException) InvalidConfigurationException(javax.slee.resource.InvalidConfigurationException) ObjectName(javax.management.ObjectName) InternalException(org.jdiameter.api.InternalException) IllegalDiameterStateException(org.jdiameter.api.IllegalDiameterStateException) ISessionFactory(org.jdiameter.client.api.ISessionFactory) ApplicationId(org.jdiameter.api.ApplicationId) ServerAuthSession(org.jdiameter.api.auth.ServerAuthSession) ClientAuthSession(org.jdiameter.api.auth.ClientAuthSession) AppSession(org.jdiameter.api.app.AppSession) RawSession(org.jdiameter.api.RawSession) ClientAccSession(org.jdiameter.api.acc.ClientAccSession) Session(org.jdiameter.api.Session) ServerAccSession(org.jdiameter.api.acc.ServerAccSession)

Example 17 with InternalException

use of org.jdiameter.api.InternalException in project jain-slee.diameter by RestComm.

the class CreditControlMessageFactoryImpl method createRawMessage.

protected Message createRawMessage(DiameterHeader header) {
    int commandCode = 0;
    long endToEndId = 0;
    long hopByHopId = 0;
    ApplicationId aid = ApplicationId.createByAuthAppId(_CCA_VENDOR, _CCA_AUTH_APP_ID);
    if (header != null) {
        // Answer
        commandCode = header.getCommandCode();
        endToEndId = header.getEndToEndId();
        hopByHopId = header.getHopByHopId();
    // aid = ApplicationId.createByAuthAppId(header.getApplicationId());
    } else {
        commandCode = CreditControlRequest.commandCode;
    // endToEndId = (long) (Math.random()*1000000);
    // hopByHopId = (long) (Math.random()*1000000)+1;
    }
    try {
        if (header != null) {
            return stack.getSessionFactory().getNewRawSession().createMessage(commandCode, aid, hopByHopId, endToEndId);
        } else {
            return stack.getSessionFactory().getNewRawSession().createMessage(commandCode, aid);
        }
    } catch (IllegalDiameterStateException e) {
        logger.error("Failed to get session factory for message creation.", e);
    } catch (InternalException e) {
        logger.error("Failed to create new raw session for message creation.", e);
    }
    return null;
}
Also used : IllegalDiameterStateException(org.jdiameter.api.IllegalDiameterStateException) ApplicationId(org.jdiameter.api.ApplicationId) InternalException(org.jdiameter.api.InternalException)

Example 18 with InternalException

use of org.jdiameter.api.InternalException in project jain-slee.diameter by RestComm.

the class CxDxClientSessionImpl method createRegistrationTerminationAnswer.

/* (non-Javadoc)
   * @see net.java.slee.resource.diameter.cxdx.CxDxClientSession#createRegistrationTerminationRequest()
   */
public RegistrationTerminationAnswer createRegistrationTerminationAnswer() {
    // Make sure we have the correct type of Request
    if (!(lastRequest instanceof RegistrationTerminationRequest)) {
        logger.warn("Invalid type of answer for this activity.");
        return null;
    }
    try {
        // Create the answer
        RegistrationTerminationAnswer rta = (RegistrationTerminationAnswer) this.cxdxMessageFactory.createCxDxMessage(lastRequest.getHeader(), new DiameterAvp[] {}, RegistrationTerminationAnswer.COMMAND_CODE, cxdxMessageFactory.getApplicationId());
        // Fill session related AVPs, if present
        fillSessionAVPs(rta);
        return rta;
    } catch (InternalException e) {
        logger.error("Failed to create Registration-Termination-Answer.", e);
    }
    return null;
}
Also used : RegistrationTerminationAnswer(net.java.slee.resource.diameter.cxdx.events.RegistrationTerminationAnswer) RegistrationTerminationRequest(net.java.slee.resource.diameter.cxdx.events.RegistrationTerminationRequest) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) InternalException(org.jdiameter.api.InternalException)

Example 19 with InternalException

use of org.jdiameter.api.InternalException in project jain-slee.diameter by RestComm.

the class CxDxServerSessionImpl method createLocationInfoAnswer.

/*
   * (non-Javadoc)
   * @see net.java.slee.resource.diameter.cxdx.CxDxServerSession#createLocationInfoAnswer()
   */
public LocationInfoAnswer createLocationInfoAnswer() {
    // Make sure we have the correct type of Request
    if (!(lastRequest instanceof LocationInfoRequest)) {
        logger.warn("Invalid type of answer for this activity.");
        return null;
    }
    try {
        // Create the answer
        LocationInfoAnswer lia = (LocationInfoAnswer) this.cxdxMessageFactory.createCxDxMessage(lastRequest.getHeader(), new DiameterAvp[] {}, LocationInfoAnswer.COMMAND_CODE, cxdxMessageFactory.getApplicationId());
        // Fill session related AVPs, if present
        fillSessionAVPs(lia);
        return lia;
    } catch (InternalException e) {
        logger.error("Failed to create Location-Info-Answer.", e);
    }
    return null;
}
Also used : LocationInfoRequest(net.java.slee.resource.diameter.cxdx.events.LocationInfoRequest) DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) LocationInfoAnswer(net.java.slee.resource.diameter.cxdx.events.LocationInfoAnswer) InternalException(org.jdiameter.api.InternalException)

Aggregations

InternalException (org.jdiameter.api.InternalException)19 DiameterAvp (net.java.slee.resource.diameter.base.events.avp.DiameterAvp)15 IllegalDiameterStateException (org.jdiameter.api.IllegalDiameterStateException)4 DiameterMessage (net.java.slee.resource.diameter.base.events.DiameterMessage)2 ApplicationId (org.jdiameter.api.ApplicationId)2 Message (org.jdiameter.api.Message)2 IOException (java.io.IOException)1 ObjectName (javax.management.ObjectName)1 InvalidConfigurationException (javax.slee.resource.InvalidConfigurationException)1 CreateActivityException (net.java.slee.resource.diameter.base.CreateActivityException)1 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)1 LocationInfoAnswer (net.java.slee.resource.diameter.cxdx.events.LocationInfoAnswer)1 LocationInfoRequest (net.java.slee.resource.diameter.cxdx.events.LocationInfoRequest)1 MultimediaAuthenticationAnswer (net.java.slee.resource.diameter.cxdx.events.MultimediaAuthenticationAnswer)1 MultimediaAuthenticationRequest (net.java.slee.resource.diameter.cxdx.events.MultimediaAuthenticationRequest)1 PushProfileAnswer (net.java.slee.resource.diameter.cxdx.events.PushProfileAnswer)1 PushProfileRequest (net.java.slee.resource.diameter.cxdx.events.PushProfileRequest)1 RegistrationTerminationAnswer (net.java.slee.resource.diameter.cxdx.events.RegistrationTerminationAnswer)1 RegistrationTerminationRequest (net.java.slee.resource.diameter.cxdx.events.RegistrationTerminationRequest)1 ServerAssignmentAnswer (net.java.slee.resource.diameter.cxdx.events.ServerAssignmentAnswer)1