use of org.omg.CORBA.Any in project ACS by ACS-Community.
the class ChannelProperties method getCDBQoSProps.
// //////////////////////////////////////////////////////////////////////////
/**
* Given a channel name that exists in the ACS CDB
* ($ACS_CDB/CDB/MACI/Channels/channelName/channelName.xml), this function
* returns the channel's quality of service properties in their CORBA format.
* <p>
* The schema for this channel configuration is <code>urn:schemas-cosylab-com:EventChannel:1.0</code>.
*
* @param channelName
* name of the channel found in $ACS_CDB/CDB/MACI/Channels
* @return channel's quality of service properties
* @throws AcsJException
* if the channel's CDB entry is corrupted in any way
*/
public Property[] getCDBQoSProps(String channelName) throws alma.acs.exceptions.AcsJException {
// use this object to get at channel information from the CDB
DAO tempDAO = null;
try {
tempDAO = m_services.getCDB().get_DAO_Servant("MACI/Channels/" + channelName);
} catch (alma.cdbErrType.CDBXMLErrorEx e) {
m_logger.log(Level.WARNING, "Bad CDB entry found for '" + channelName + "' channel");
throw new alma.ACSErrTypeCommon.wrappers.AcsJUnknownEx(e);
} catch (alma.cdbErrType.CDBRecordDoesNotExistEx e) {
m_logger.log(Level.WARNING, "No CDB entry found for '" + channelName + "' channel");
throw new alma.ACSErrTypeCommon.wrappers.AcsJFileNotFoundEx(e);
} catch (AcsJContainerServicesEx e) {
m_logger.log(Level.WARNING, "CDB unavailable", e);
throw new alma.ACSErrTypeCommon.wrappers.AcsJNoResourcesEx(e);
}
// EventReliability - ///////////////////////////////////////////////
Any eventRelAny = m_services.getAdvancedContainerServices().getAny();
short eventRelVal = Persistent.value;
try {
if (tempDAO.get_string(EventReliability.value).equals("BestEffort")) {
eventRelVal = BestEffort.value;
}
} catch (Exception e) {
m_logger.log(Level.SEVERE, "Bad CDB entry datatype found for '" + channelName + "' channel", e);
throw new alma.ACSErrTypeCommon.wrappers.AcsJTypeNotSupportedEx(e);
}
eventRelAny.insert_short(eventRelVal);
Property eventRel = new Property(EventReliability.value, eventRelAny);
// ConnectionReliability - ///////////////////////////////////////////////
Any connectRelAny = m_services.getAdvancedContainerServices().getAny();
short connectRelVal = Persistent.value;
try {
if (tempDAO.get_string(ConnectionReliability.value).equals("BestEffort")) {
connectRelVal = BestEffort.value;
}
} catch (Exception e) {
m_logger.log(Level.SEVERE, "Bad CDB entry datatype found for '" + channelName + "' channel", e);
throw new alma.ACSErrTypeCommon.wrappers.AcsJTypeNotSupportedEx(e);
}
connectRelAny.insert_short(Persistent.value);
Property connectRel = new Property(ConnectionReliability.value, connectRelAny);
//@TODO do something with this connectRel, e.g. check why it's commented out at the end of this method!
// Also enforce that EventReliability=Persistent && ConnectionRelability=BestEffort is undefined (spec 2.5.5.1).
// ConnectionRelability=Persistent requires TAO topology persistence to be enabled.
// Priority - ///////////////////////////////////////////////
Any priorityAny = m_services.getAdvancedContainerServices().getAny();
try {
priorityAny.insert_short((short) tempDAO.get_long(Priority.value));
} catch (Exception e) {
m_logger.log(Level.SEVERE, "Bad CDB entry datatype found for '" + channelName + "' channel", e);
throw new alma.ACSErrTypeCommon.wrappers.AcsJTypeNotSupportedEx(e);
}
Property priority = new Property(Priority.value, priorityAny);
// Timeout - ///////////////////////////////////////////////
Any timeoutAny = m_services.getAdvancedContainerServices().getAny();
try {
org.omg.TimeBase.TimeTHelper.insert(timeoutAny, tempDAO.get_long(Timeout.value));
} catch (Exception e) {
m_logger.log(Level.SEVERE, "Bad CDB entry datatype found for '" + channelName + "' channel", e);
throw new alma.ACSErrTypeCommon.wrappers.AcsJTypeNotSupportedEx(e);
}
Property timeout = new Property(Timeout.value, timeoutAny);
// OrderPolicy - ///////////////////////////////////////////////
Any orderPolAny = m_services.getAdvancedContainerServices().getAny();
short orderPolicyVal;
try {
if (tempDAO.get_string(OrderPolicy.value).equals("AnyOrder")) {
orderPolicyVal = AnyOrder.value;
} else if (tempDAO.get_string(OrderPolicy.value).equals("FifoOrder")) {
orderPolicyVal = FifoOrder.value;
} else if (tempDAO.get_string(OrderPolicy.value).equals("PriorityOrder")) {
orderPolicyVal = PriorityOrder.value;
} else if (tempDAO.get_string(OrderPolicy.value).equals("DeadlineOrder")) {
orderPolicyVal = DeadlineOrder.value;
} else {
m_logger.log(Level.SEVERE, "Bad CDB entry datatype found for '" + channelName + "' channel");
throw new Exception("No value found for order policy.");
}
} catch (Exception e) {
m_logger.log(Level.SEVERE, "Bad CDB entry datatype found for '" + channelName + "' channel", e);
throw new alma.ACSErrTypeCommon.wrappers.AcsJTypeNotSupportedEx(e);
}
orderPolAny.insert_short(orderPolicyVal);
Property orderPol = new Property(OrderPolicy.value, orderPolAny);
// DiscardPolicy - ///////////////////////////////////////////////
Any discardPolAny = m_services.getAdvancedContainerServices().getAny();
short discardPolicyVal;
try {
if (tempDAO.get_string(DiscardPolicy.value).equals("AnyOrder")) {
discardPolicyVal = AnyOrder.value;
} else if (tempDAO.get_string(DiscardPolicy.value).equals("FifoOrder")) {
discardPolicyVal = FifoOrder.value;
} else if (tempDAO.get_string(DiscardPolicy.value).equals("PriorityOrder")) {
discardPolicyVal = PriorityOrder.value;
} else if (tempDAO.get_string(DiscardPolicy.value).equals("DeadlineOrder")) {
discardPolicyVal = DeadlineOrder.value;
} else if (tempDAO.get_string(DiscardPolicy.value).equals("LifoOrder")) {
discardPolicyVal = LifoOrder.value;
} else {
m_logger.log(Level.SEVERE, "Bad CDB entry datatype found for '" + channelName + "' channel");
throw new Exception("No value found for discard policy.");
}
} catch (Exception e) {
m_logger.log(Level.SEVERE, "Bad CDB entry datatype found for '" + channelName + "' channel", e);
throw new alma.ACSErrTypeCommon.wrappers.AcsJTypeNotSupportedEx(e);
}
discardPolAny.insert_short(discardPolicyVal);
Property discardPol = new Property(DiscardPolicy.value, discardPolAny);
// StartTimeSupported - ///////////////////////////////////////////////
Any startTSAny = m_services.getAdvancedContainerServices().getAny();
boolean startTSVal = true;
try {
if (tempDAO.get_string(StartTimeSupported.value).equals("false")) {
startTSVal = false;
}
} catch (Exception e) {
m_logger.log(Level.SEVERE, "Bad CDB entry datatype found for '" + channelName + "' channel", e);
throw new alma.ACSErrTypeCommon.wrappers.AcsJTypeNotSupportedEx(e);
}
startTSAny.insert_boolean(startTSVal);
Property startTS = new Property(StartTimeSupported.value, startTSAny);
// StopTimeSupported - ///////////////////////////////////////////////
Any stopTSAny = m_services.getAdvancedContainerServices().getAny();
boolean stopTSVal = true;
try {
if (tempDAO.get_string(StopTimeSupported.value).equals("false")) {
stopTSVal = false;
}
} catch (Exception e) {
m_logger.log(Level.SEVERE, "Bad CDB entry datatype found for '" + channelName + "' channel", e);
throw new alma.ACSErrTypeCommon.wrappers.AcsJTypeNotSupportedEx(e);
}
stopTSAny.insert_boolean(stopTSVal);
Property stopTS = new Property(StopTimeSupported.value, stopTSAny);
// MaxEventsPerConsumer - ///////////////////////////////////////////////
Any MEPCAny = m_services.getAdvancedContainerServices().getAny();
try {
MEPCAny.insert_long(tempDAO.get_long(MaxEventsPerConsumer.value));
} catch (Exception e) {
m_logger.log(Level.SEVERE, "Bad CDB entry datatype found for '" + channelName + "' channel", e);
throw new alma.ACSErrTypeCommon.wrappers.AcsJTypeNotSupportedEx(e);
}
Property MEPC = new Property(MaxEventsPerConsumer.value, MEPCAny);
Property[] qosProps = { // connectRel,
priority, timeout, orderPol, discardPol, // stopTS,
MEPC };
return qosProps;
}
use of org.omg.CORBA.Any in project ACS by ACS-Community.
the class AnyAideTest method testComplexAnyToObject.
public void testComplexAnyToObject() {
NestedEvent nestedStruct = new NestedEvent();
nestedStruct.sampVal = advancedCS.getAny();
nestedStruct.sampVal.insert_long(12);
Any any1 = advancedCS.getAny();
NestedEventHelper.insert(any1, nestedStruct);
NestedEvent ns2 = (NestedEvent) anyAide.complexAnyToObject(any1);
assertNotNull(ns2);
assertTrue(ns2.sampVal.toString().equals("12"));
}
use of org.omg.CORBA.Any in project ACS by ACS-Community.
the class AnyAideTest method testStringArrayToCorbaAny.
public void testStringArrayToCorbaAny() {
final String[] strs = new String[] { "3", "5", "7" };
Any any1 = anyAide.stringArrayToCorbaAny(strs);
String[] strs2;
strs2 = stringSeqHelper.extract(any1);
assertEquals(strs.length, strs2.length);
for (int i = 0; i < strs2.length; ++i) {
assertEquals(strs[i], strs2[i]);
}
}
use of org.omg.CORBA.Any in project ACS by ACS-Community.
the class AnyAideTest method testIntArrayToCorbaAny.
public void testIntArrayToCorbaAny() {
final int[] ints = new int[] { 3, 5, 7 };
Any any1 = anyAide.intArrayToCorbaAny(ints);
int[] ints2;
ints2 = longSeqHelper.extract(any1);
assertEquals(ints.length, ints2.length);
for (int i = 0; i < ints2.length; ++i) {
assertEquals(ints[i], ints2[i]);
}
}
use of org.omg.CORBA.Any in project ACS by ACS-Community.
the class EventDetailTestHarness method parsePttDataEvent.
public static ParsedAnyData[] parsePttDataEvent() {
pttDataEvent pde = new pttDataEvent(new actuatorSpace(new double[2952]), new actuatorSpace(new double[2952]), 25, 32L);
StructuredEvent se = null;
String eventName = null;
Any eventAny = null;
try {
se = seCreator.createEvent(pde);
eventName = se.header.fixed_header.event_type.type_name;
eventAny = se.filterable_data[0].value;
} catch (AcsJException e) {
e.printStackTrace();
System.err.println("Couldn't create structured event for pttDataEvent");
}
StopWatch sw = new StopWatch(logger);
DynAnyParser parser = new DynAnyParser(eventAny, eventName);
ParsedAnyData[] pResults = parser.getParsedResults(null);
sw.logLapTime("parse this eventAny");
return pResults;
}
Aggregations