use of net.java.slee.resource.diameter.rf.events.RfAccountingRequest in project jain-slee.diameter by RestComm.
the class DiameterRfResourceAdaptor method fireEvent.
// Event and Activities management -------------------------------------
public boolean fireEvent(Object event, ActivityHandle handle, FireableEventType eventID, Address address, boolean useFiltering, boolean transacted) {
if (useFiltering && eventIDFilter.filterEvent(eventID)) {
if (tracer.isFineEnabled()) {
tracer.fine("Event " + eventID + " filtered");
}
} else if (eventID == null) {
tracer.severe("Event ID for " + eventID + " is unknown, unable to fire.");
} else {
if (tracer.isFineEnabled()) {
tracer.fine("Firing event " + event + " on handle " + handle);
}
try {
/* TODO: Support transacted fire of events when in cluster
if (transacted){
this.raContext.getSleeEndpoint().fireEventTransacted(handle, eventID, event, address, null, EVENT_FLAGS);
}
else */
{
// fetch state for Server Activities
Object o = getActivity(handle);
if (o == null) {
Transaction t = raContext.getSleeTransactionManager().getTransaction();
throw new IllegalStateException("TX[ " + t + " ] No activity for handle: " + handle);
}
if (o instanceof RfServerSessionActivityImpl && event instanceof RfAccountingRequest) {
((RfServerSessionActivityImpl) o).fetchSessionData((RfAccountingRequest) event, true);
}
this.raContext.getSleeEndpoint().fireEvent(handle, eventID, event, address, null, EVENT_FLAGS);
}
return true;
} catch (Exception e) {
tracer.severe("Error firing event.", e);
}
}
return false;
}
use of net.java.slee.resource.diameter.rf.events.RfAccountingRequest in project jain-slee.diameter by RestComm.
the class RfClientSessionActivityImpl method createRfAccountingRequest.
public RfAccountingRequest createRfAccountingRequest(AccountingRecordType accountingRecordType) {
RfAccountingRequest acr = rfMessageFactory.createRfAccountingRequest(accountingRecordType);
// Set Acct-Application-Id to 3 as specified
acr.setAcctApplicationId(3L);
acr.setAccountingRecordType(accountingRecordType);
return acr;
}
use of net.java.slee.resource.diameter.rf.events.RfAccountingRequest in project jain-slee.diameter by RestComm.
the class RfFactoriesTest method isProxiableCopiedACA.
@Test
public void isProxiableCopiedACA() throws Exception {
RfAccountingRequest acr = rfMessageFactory.createRfAccountingRequest(AccountingRecordType.EVENT_RECORD);
// needed ...
acr.setAccountingRecordNumber(5L);
RfAccountingAnswer aca = rfServerSession.createRfAccountingAnswer(acr);
assertEquals("The 'P' bit is not copied from request in Accounting-Answer, it should. [RFC3588/6.2]", acr.getHeader().isProxiable(), aca.getHeader().isProxiable());
// Reverse 'P' bit ...
((DiameterMessageImpl) acr).getGenericData().setProxiable(!acr.getHeader().isProxiable());
assertTrue("The 'P' bit was not modified in Accounting-Request, it should.", acr.getHeader().isProxiable() != aca.getHeader().isProxiable());
aca = rfServerSession.createRfAccountingAnswer(acr);
assertEquals("The 'P' bit is not copied from request in Accounting-Answer, it should. [RFC3588/6.2]", acr.getHeader().isProxiable(), aca.getHeader().isProxiable());
}
use of net.java.slee.resource.diameter.rf.events.RfAccountingRequest in project jain-slee.diameter by RestComm.
the class RfFactoriesTest method testMessageFactoryApplicationIdChangeACR.
@Test
public void testMessageFactoryApplicationIdChangeACR() throws Exception {
long vendor = 10415L;
ApplicationId originalAppId = ((RfMessageFactoryImpl) rfMessageFactory).getApplicationId();
boolean isAuth = originalAppId.getAuthAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE;
boolean isAcct = originalAppId.getAcctAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE;
boolean isVendor = originalAppId.getVendorId() != 0L;
assertTrue("Invalid Application-Id (" + originalAppId + "). Should only, and at least, contain either Auth or Acct value.", (isAuth && !isAcct) || (!isAuth && isAcct));
System.out.println("Default VENDOR-ID for Rf is " + originalAppId.getVendorId());
// let's create a message and see how it comes...
RfAccountingRequest originalACR = rfMessageFactory.createRfAccountingRequest(AccountingRecordType.EVENT_RECORD);
BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalACR);
// now we switch..
originalACR = null;
isVendor = !isVendor;
((RfMessageFactoryImpl) rfMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
// create a new message and see how it comes...
RfAccountingRequest changedACR = rfMessageFactory.createRfAccountingRequest(AccountingRecordType.EVENT_RECORD);
BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedACR);
// revert back to default
((RfMessageFactoryImpl) rfMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
use of net.java.slee.resource.diameter.rf.events.RfAccountingRequest in project jain-slee.diameter by RestComm.
the class RfFactoriesTest method hasTFlagSetACA.
@Test
public void hasTFlagSetACA() throws Exception {
RfAccountingRequest acr = rfMessageFactory.createRfAccountingRequest(AccountingRecordType.EVENT_RECORD);
// needed ...
acr.setAccountingRecordNumber(5L);
((DiameterMessageImpl) acr).getGenericData().setReTransmitted(true);
assertTrue("The 'T' flag should be set in Accounting-Request", acr.getHeader().isPotentiallyRetransmitted());
RfAccountingAnswer aca = rfServerSession.createRfAccountingAnswer(acr);
assertFalse("The 'T' flag should not be set in Accounting-Answer", aca.getHeader().isPotentiallyRetransmitted());
}
Aggregations