use of com.cosylab.CDB.DAO in project ACS by ACS-Community.
the class HibernateWDALImpl method objectChangedForMap.
private void objectChangedForMap(String curl, Map map, Map objMap) {
synchronized (map) {
if (map.containsKey(curl)) {
DAO dao = (DAO) map.get(curl);
Object objDAO = objMap.get(curl);
//New Implementation!
dao.destroy();
byte[] id = curl.getBytes();
try {
poa.deactivate_object(id);
} catch (Throwable th) {
th.printStackTrace();
}
objMap.remove(curl);
map.remove(curl);
Object node = curl.length() == 0 ? rootNode : DOMJavaClassIntrospector.getNode(curl, rootNode);
if (node == null || DOMJavaClassIntrospector.isPrimitive(node.getClass())) {
return;
}
try {
get_DAO_Servant(curl);
} catch (Throwable th) {
th.printStackTrace();
}
//End new implementation.
//Object node = curl.length() == 0 ? rootNode : DOMJavaClassIntrospector.getNode(curl, rootNode);
//if (node == null || DOMJavaClassIntrospector.isPrimitive(node.getClass()))
//{
// // no longer exists
// dao.destroy();
// objMap.remove(curl);
// map.remove(curl);
//}
//
//if (objDAO instanceof DAOImpl)
//{
// if (node instanceof XMLTreeNode)
// ((DAOImpl)objDAO).setRootNode((XMLTreeNode)node);
// else
// {
// // type changed, destroy this one and reactivate new
// dao.destroy();
// objMap.remove(curl);
// map.remove(curl);
// try {
// get_DAO_Servant(curl);
// } catch (Throwable th) { th.printStackTrace(); }
// }
//}
//else if (objDAO instanceof HibernateWDAOImpl)
//{
// if (node instanceof XMLTreeNode)
// {
// // type changed, destroy this one and reactivate new
// dao.destroy();
// map.remove(curl);
// try {
// get_DAO_Servant(curl);
// } catch (Throwable th) { th.printStackTrace(); }
// }
// else
// ((HibernateWDAOImpl)objDAO).setRootNode(node);
//}
}
}
}
use of com.cosylab.CDB.DAO in project ACS by ACS-Community.
the class TestHighLevelNodes method testMACI_Managers.
public void testMACI_Managers() throws Exception {
HashSet<String> xmlNodes = new HashSet<String>(Arrays.asList(xmlDAL.list_nodes("MACI/Managers").split(" ")));
HashSet<String> rdbNodes = new HashSet<String>(Arrays.asList(rdbDAL.list_nodes("MACI/Managers").split(" ")));
logger.info("XML: " + xmlNodes.toString() + "; TMCDB: " + rdbNodes.toString());
assertEquals(xmlNodes, rdbNodes);
for (Iterator<String> iterator = xmlNodes.iterator(); iterator.hasNext(); ) {
String xmlstring = "MACI/Managers/" + (String) iterator.next();
DAO xmlDao = xmlDAL.get_DAO_Servant(xmlstring);
DAO rdbDao = rdbDAL.get_DAO_Servant(xmlstring);
examineLoggingConfig(xmlDao, rdbDao);
assertEquals(xmlDao.get_string("Startup"), rdbDao.get_string("Startup"));
assertEquals(xmlDao.get_string("ServiceComponents"), rdbDao.get_string("ServiceComponents"));
String sx = null;
boolean xbool = true;
try {
sx = xmlDao.get_string("ServiceDaemons");
} catch (CDBFieldDoesNotExistEx e) {
xbool = false;
}
String sr = null;
try {
sr = rdbDao.get_string("ServiceDaemons");
} catch (CDBFieldDoesNotExistEx e) {
if (xbool)
fail("Service Daemons: XML CDB has value: " + sx + " but TMCDB can't find the field.");
// Neither CDB can find it; move to next property
continue;
}
if (!xbool)
fail("Service Daemons: TMCDB has value: " + sr + " but XML CDB can't find the field.");
// TODO: Redo this once Matej's implementation is complete
assertEquals(sx, sr);
}
}
use of com.cosylab.CDB.DAO in project ACS by ACS-Community.
the class Helper method getEventHandlerTimeoutMap.
/**
* The following returns a map where each key is the name of an event and the
* value is the maximum amount of time (in floating point seconds) an event receiver has
* to process the event before a warning message is logged.
*
* @param channelName name of the channel
* @return HashMap described above
*/
public HashMap<String, Double> getEventHandlerTimeoutMap() {
// initialize the return value
HashMap<String, Double> retVal = new HashMap<String, Double>();
// data access object to traverse the ACS CDB
DAO dao = null;
// keys into the DAO
String[] keys = null;
// ...if this fails, just return.
try {
dao = m_services.getCDB().get_DAO_Servant("MACI/Channels/" + channelName);
} catch (Exception e) {
m_logger.finer("No CDB entry found for '" + channelName + "' channel");
return retVal;
}
// names of all the events
try {
keys = dao.get_string_seq("Events");
} catch (Exception e) {
m_logger.finer("CDB entry found for '" + channelName + "' but no Events element.");
return retVal;
}
// sanity check on the number of events
if (keys.length == 0) {
m_logger.finer("No event definitions found for the '" + channelName + "' within the CDB.");
return retVal;
}
// populate the hashmap
for (int i = 0; i < keys.length; i++) {
// determine the value location
String timeoutLocation = "Events/" + keys[i] + "/MaxProcessTime";
// get the value (floating point seconds)
try {
double value = dao.get_double(timeoutLocation);
retVal.put(keys[i], new Double(value));
} catch (Exception e) {
e.printStackTrace();
m_logger.severe("Could not convert 'MaxProcessTime' to floating " + "point seconds for the '" + channelName + "' channel and '" + keys[i] + "' event type.");
}
}
return retVal;
}
use of com.cosylab.CDB.DAO 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 com.cosylab.CDB.DAO in project ACS by ACS-Community.
the class DALImpl method object_changed.
/**
* @param curl
*/
protected void object_changed(String curl) {
synchronized (daoMap) {
if (daoMap.containsKey(curl)) {
DAO dao = daoMap.get(curl);
dao.destroy();
daoMap.remove(curl);
}
}
}
Aggregations