use of org.omg.CORBA.NO_RESOURCES in project ACS by ACS-Community.
the class ManagerProxyImpl method restart_component.
/**
* Restarts an component.
* @param id identification of the caller. Called has to be an owner of the component.
* @param component_url CURL of the component to be restarted.
* @return CORBA reference of the restarted component, <code>null</code> if it fails.
*/
public Object restart_component(int id, String component_url) throws NoPermissionEx {
pendingRequests.incrementAndGet();
try {
// returned value
Object retVal = null;
// transform to CORBA specific
URI uri = null;
if (component_url != null)
uri = CURLHelper.createURI(component_url);
Component component = manager.restartComponent(id, uri);
// extract component CORBA reference
if (component != null)
retVal = (Object) component.getObject();
return retVal;
} catch (URISyntaxException usi) {
BadParametersException hbpe = new BadParametersException(usi.getMessage(), usi);
reportException(hbpe);
// rethrow CORBA specific
throw new BAD_PARAM(usi.getMessage());
} catch (BadParametersException bpe) {
BadParametersException hbpe = new BadParametersException(bpe.getMessage(), bpe);
reportException(hbpe);
// rethrow CORBA specific
throw new BAD_PARAM(bpe.getMessage());
} catch (NoResourcesException nre) {
NoResourcesException hnre = new NoResourcesException(nre.getMessage(), nre);
reportException(hnre);
// rethrow CORBA specific
throw new NO_RESOURCES(nre.getMessage());
} catch (AcsJBadParameterEx bpe) {
reportException(bpe);
//throw bpe.toBadParameterEx();
throw new BAD_PARAM(bpe.getMessage());
} catch (AcsJNoPermissionEx npe) {
// rethrow CORBA specific
throw npe.toNoPermissionEx();
} catch (Throwable ex) {
CoreException hce = new CoreException(ex.getMessage(), ex);
reportException(hce);
// rethrow CORBA specific
throw new UNKNOWN(ex.getMessage());
} finally {
pendingRequests.decrementAndGet();
}
}
use of org.omg.CORBA.NO_RESOURCES in project ACS by ACS-Community.
the class HibernateWDAOImpl method set_double.
/* (non-Javadoc)
* @see com.cosylab.CDB.WDAOOperations#set_double(java.lang.String, double)
*/
@SuppressWarnings("unchecked")
public void set_double(String propertyName, double value) throws CDBFieldIsReadOnlyEx, CDBFieldDoesNotExistEx {
NodeAndMutator nodeAndMutator = DOMJavaClassIntrospector.getRecursiveMutatorMethod(propertyName, m_rootNode);
if (nodeAndMutator == null) {
AcsJCDBFieldDoesNotExistEx ex = new AcsJCDBFieldDoesNotExistEx();
ex.setFieldName(propertyName);
throw ex.toCDBFieldDoesNotExistEx();
}
Transaction tr = null;
try {
if (nodeAndMutator.mutator.getParameterTypes().length != 1) {
AcsJCDBFieldIsReadOnlyEx acsex = new AcsJCDBFieldIsReadOnlyEx();
acsex.setFieldName(propertyName);
throw acsex.toCDBFieldIsReadOnlyEx();
}
Object toSet;
Class parameterClass = nodeAndMutator.mutator.getParameterTypes()[0];
if (parameterClass.isAssignableFrom(String.class))
toSet = String.valueOf(value);
else if (parameterClass.isAssignableFrom(Integer.class) || parameterClass.isAssignableFrom(int.class))
toSet = Integer.valueOf((int) value);
else if (parameterClass.isAssignableFrom(Long.class) || parameterClass.isAssignableFrom(long.class))
toSet = Long.valueOf((long) value);
else if (parameterClass.isAssignableFrom(Byte.class) || parameterClass.isAssignableFrom(byte.class))
toSet = Byte.valueOf((byte) value);
else if (parameterClass.isAssignableFrom(Short.class) || parameterClass.isAssignableFrom(short.class))
toSet = Short.valueOf((short) value);
else if (parameterClass.isAssignableFrom(Double.class) || parameterClass.isAssignableFrom(double.class))
toSet = Double.valueOf(value);
else if (parameterClass.isAssignableFrom(Float.class) || parameterClass.isAssignableFrom(float.class))
toSet = Float.valueOf((float) value);
else if (parameterClass.isAssignableFrom(Boolean.class) || parameterClass.isAssignableFrom(boolean.class))
toSet = (value != 0);
else
throw new NO_RESOURCES("cannot convert value");
if (m_autoCommit)
tr = m_session.beginTransaction();
nodeAndMutator.mutator.invoke(nodeAndMutator.node, new Object[] { toSet });
if (tr != null)
tr.commit();
} catch (Throwable th) {
if (tr != null)
tr.rollback();
if (!m_silent)
m_logger.log(AcsLogLevel.NOTICE, "Failed to set '" + value + "' to : " + (this.m_name + "/" + propertyName), th);
throw new NO_RESOURCES(th.getMessage());
}
}
use of org.omg.CORBA.NO_RESOURCES in project ACS by ACS-Community.
the class HibernateWDALImpl method clear_cache.
public void clear_cache(String curl) {
System.out.println("clear_cache(curl)");
if (loadInProgress.get()) {
m_logger.warning("Incoming Corba call denied (NO_RESOURCES) because data is being loaded.");
throw new NO_RESOURCES("load in progress");
}
curl = curl.replaceAll("/+", "/");
//Reload curl data from DB
if (curl.matches("/")) {
System.out.println("clear_cache_all()");
clear_cache_all();
return;
} else {
loadInProgress.set(true);
m_logger.info("clear_cache(curl): Main1");
try {
hibernateUtil.getSession().clear();
} catch (Throwable th) {
th.printStackTrace();
}
m_logger.info("clear_cache(curl): Main2");
String c = curl.replaceFirst("^/", "");
c = curl.replaceFirst("/$", "");
if (plugin != null) {
try {
Map<String, Object> rootMap = (Map<String, Object>) rootNode;
Session session = hibernateUtil.getSession();
plugin.updatePrologue(session, config, rootMap, c);
} catch (Throwable th) {
this.m_logger.log(Level.SEVERE, "Failure in plugin " + plugin.getClass().getName(), th);
th.printStackTrace();
}
}
m_logger.info("clear_cache(curl): Main3");
if (c.startsWith("MACI")) {
loadMACI(c, true);
//} else if (c.startsWith("Alarms"){
// loadAlarms(c);
} else if (c.startsWith(COMPONENT_TREE_NAME)) {
loadComponentsTree(c, true);
} else {
System.out.println("Unsupported curl: " + curl);
}
m_logger.info("clear_cache(curl): Main4");
if (plugin != null) {
try {
Map<String, Object> rootMap = (Map<String, Object>) rootNode;
Session session = hibernateUtil.getSession();
plugin.updateEpilogue(session, config, rootMap, c);
} catch (Throwable th) {
this.m_logger.log(Level.SEVERE, "Failure in plugin " + plugin.getClass().getName(), th);
th.printStackTrace();
}
}
m_logger.info("clear_cache(curl): Main5");
loadInProgress.set(false);
}
//Set<String> curls = new HashSet<String>();
//curls.add(curl);
//synchronized (daoMap) {
// Iterator iter = daoMap.keySet().iterator();
// while (iter.hasNext()) {
// String c = (String) iter.next();
// if(c.startsWith(curl))
// curls.add(c);
// }
//}
//synchronized (wdaoMap) {
// Iterator iter = wdaoMap.keySet().iterator();
// while (iter.hasNext()) {
// String c = (String) iter.next();
// if(c.startsWith(curl))
// curls.add(c);
// }
//}
//
//synchronized (listenedCurls) {
// Iterator iter = listenedCurls.keySet().iterator();
// while (iter.hasNext()) {
// String c = (String) iter.next();
// if(c.startsWith(curl))
// curls.add(c);
// }
//}
Set<String> curls = new HashSet<String>();
synchronized (daoMap) {
curls.addAll(daoMap.keySet());
}
m_logger.info("clear_cache(curl): Main6");
synchronized (wdaoMap) {
curls.addAll(wdaoMap.keySet());
}
m_logger.info("clear_cache(curl): Main7");
synchronized (listenedCurls) {
Iterator iter = listenedCurls.keySet().iterator();
while (iter.hasNext()) {
String c = (String) iter.next();
curls.add(c);
}
}
m_logger.info("clear_cache(curl): Main8");
for (String c : curls) clearCache(c);
m_logger.info("clear_cache(curl): Main9");
}
use of org.omg.CORBA.NO_RESOURCES in project ACS by ACS-Community.
the class HibernateWDAOImpl method set_string.
/*
* (non-Javadoc)
*
* @see com.cosylab.CDB.WDAOOperations#set_string(java.lang.String,
* java.lang.String)
*/
@SuppressWarnings("unchecked")
public void set_string(String propertyName, String value) throws CDBFieldIsReadOnlyEx, CDBFieldDoesNotExistEx {
NodeAndMutator nodeAndMutator = DOMJavaClassIntrospector.getRecursiveMutatorMethod(propertyName, m_rootNode);
if (nodeAndMutator == null) {
AcsJCDBFieldDoesNotExistEx ex = new AcsJCDBFieldDoesNotExistEx();
ex.setFieldName(propertyName);
throw ex.toCDBFieldDoesNotExistEx();
}
Transaction tr = null;
try {
if (nodeAndMutator.mutator.getParameterTypes().length != 1) {
AcsJCDBFieldIsReadOnlyEx acsex = new AcsJCDBFieldIsReadOnlyEx();
acsex.setFieldName(propertyName);
throw acsex.toCDBFieldIsReadOnlyEx();
}
Object toSet;
Class parameterClass = nodeAndMutator.mutator.getParameterTypes()[0];
if (parameterClass.isAssignableFrom(String.class))
toSet = String.valueOf(value);
else if (parameterClass.isAssignableFrom(Integer.class) || parameterClass.isAssignableFrom(int.class))
toSet = Integer.valueOf(value);
else if (parameterClass.isAssignableFrom(Long.class) || parameterClass.isAssignableFrom(long.class))
toSet = Long.valueOf(value);
else if (parameterClass.isAssignableFrom(Byte.class) || parameterClass.isAssignableFrom(byte.class))
toSet = Byte.valueOf(value);
else if (parameterClass.isAssignableFrom(Short.class) || parameterClass.isAssignableFrom(short.class))
toSet = Short.valueOf(value);
else if (parameterClass.isAssignableFrom(Double.class) || parameterClass.isAssignableFrom(double.class))
toSet = Double.valueOf(value);
else if (parameterClass.isAssignableFrom(Float.class) || parameterClass.isAssignableFrom(float.class))
toSet = Float.valueOf(value);
else if (parameterClass.isAssignableFrom(Boolean.class) || parameterClass.isAssignableFrom(boolean.class))
toSet = Boolean.valueOf(value);
else
throw new NO_RESOURCES("cannot convert value");
if (m_autoCommit)
tr = m_session.beginTransaction();
nodeAndMutator.mutator.invoke(nodeAndMutator.node, new Object[] { toSet });
if (tr != null)
tr.commit();
} catch (Throwable th) {
if (tr != null)
tr.rollback();
if (!m_silent)
m_logger.log(AcsLogLevel.NOTICE, "Failed to set '" + value + "' to : " + (this.m_name + "/" + propertyName), th);
throw new NO_RESOURCES(th.getMessage());
}
}
use of org.omg.CORBA.NO_RESOURCES in project ACS by ACS-Community.
the class CommonPropertyImpl method addValueToHistory.
/**
* Add value to the history.
* @param value value to be added to the history.
* @param timestamp value timestamp (OMG) to be added to the history.
*/
protected void addValueToHistory(Object value, long timestamp) {
// if history is disabled
if (historySize == 0)
return;
synchronized (historyValue) {
// add
historyTime[historyPosition] = timestamp;
if (propertyType.isPrimitive()) {
if (propertyType.isAssignableFrom(double.class))
Array.setDouble(historyValue, historyPosition, ((Double) value).doubleValue());
else if (propertyType.isAssignableFrom(int.class))
Array.setInt(historyValue, historyPosition, ((Integer) value).intValue());
else if (propertyType.isAssignableFrom(long.class))
Array.setLong(historyValue, historyPosition, ((Long) value).longValue());
else if (propertyType.isAssignableFrom(short.class))
Array.setShort(historyValue, historyPosition, ((Short) value).shortValue());
else if (propertyType.isAssignableFrom(boolean.class))
Array.setBoolean(historyValue, historyPosition, ((Boolean) value).booleanValue());
else if (propertyType.isAssignableFrom(byte.class))
Array.setByte(historyValue, historyPosition, ((Byte) value).byteValue());
else if (propertyType.isAssignableFrom(float.class))
Array.setFloat(historyValue, historyPosition, ((Float) value).floatValue());
else if (propertyType.isAssignableFrom(char.class))
Array.setChar(historyValue, historyPosition, ((Character) value).charValue());
else {
m_logger.log(Level.WARNING, "jBaci::CommonPropertyImpl::addValueToHistory - Unhandled primitive.");
throw new NO_RESOURCES("Unhandled primitive");
}
} else
Array.set(historyValue, historyPosition, value);
// manage control variables
historyPosition = ++historyPosition % historySize;
if (!historyTurnaround && historyPosition == 0)
historyTurnaround = true;
}
}
Aggregations