use of org.jdiameter.api.IllegalDiameterStateException in project jain-slee.diameter by RestComm.
the class GqMessageFactoryImpl method createRawMessage.
protected Message createRawMessage(DiameterHeader header) {
if (header == null) {
return null;
}
int commandCode = 0;
long endToEndId = 0;
long hopByHopId = 0;
boolean isRequest = true;
boolean isProxiable = true;
boolean isError = false;
boolean isPotentiallyRetransmitted = false;
commandCode = header.getCommandCode();
endToEndId = header.getEndToEndId();
hopByHopId = header.getHopByHopId();
isRequest = header.isRequest();
isProxiable = header.isProxiable();
isError = header.isError();
isPotentiallyRetransmitted = header.isPotentiallyRetransmitted();
Message msg = null;
try {
msg = stack.getSessionFactory().getNewRawSession().createMessage(commandCode, gqAppId, hopByHopId, endToEndId);
// Set the message flags from header (or default)
msg.setRequest(isRequest);
msg.setProxiable(isProxiable);
msg.setError(isError);
msg.setReTransmitted(isRequest && isPotentiallyRetransmitted);
} 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 msg;
}
use of org.jdiameter.api.IllegalDiameterStateException in project jain-slee.diameter by RestComm.
the class RoMessageFactoryImpl method createRawMessage.
protected Message createRawMessage(DiameterHeader header) {
int commandCode = 0;
long endToEndId = 0;
long hopByHopId = 0;
boolean isRequest = true;
boolean isProxiable = true;
boolean isError = false;
boolean isPotentiallyRetransmitted = false;
if (header != null) {
// Answer
commandCode = header.getCommandCode();
endToEndId = header.getEndToEndId();
hopByHopId = header.getHopByHopId();
isRequest = header.isRequest();
isProxiable = header.isProxiable();
isError = header.isError();
isPotentiallyRetransmitted = header.isPotentiallyRetransmitted();
// aid = ApplicationId.createByAuthAppId(header.getApplicationId());
} else {
commandCode = RoCreditControlRequest.commandCode;
// endToEndId = (long) (Math.random()*1000000);
// hopByHopId = (long) (Math.random()*1000000)+1;
}
Message msg = null;
try {
if (header != null) {
msg = stack.getSessionFactory().getNewRawSession().createMessage(commandCode, roAppId, hopByHopId, endToEndId);
} else {
msg = stack.getSessionFactory().getNewRawSession().createMessage(commandCode, roAppId);
}
} 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);
}
// Set the message flags from header (or default)
msg.setRequest(isRequest);
msg.setProxiable(isProxiable);
msg.setError(isError);
msg.setReTransmitted(isRequest && isPotentiallyRetransmitted);
return msg;
}
use of org.jdiameter.api.IllegalDiameterStateException 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);
}
}
use of org.jdiameter.api.IllegalDiameterStateException 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;
}
Aggregations