use of alma.acs.exceptions.AcsJException in project ACS by ACS-Community.
the class CommonPropertyImpl method mnemonicValue.
/**
* Mnemonic value retrival.
* If <code>keyTime == mnemonicTime</code> cached mnemonic value is returned.
* @param keyTime time (java) of mnemonic request.
* @param completionHolder completion holder that will be given completion.
* NOTE: completion is passsed by reference, so do not change its value,
* copy its value before and do it on a local copy
* @return current property value.
* @see getSync
*/
// TODO implement test with many threads calling this method...
public Object mnemonicValue(long keyTime, CompletionHolder completionHolder) {
for (; ; ) {
// read mnemonic data lock
try {
mnemonicDataLock.readLock().lock();
} catch (Throwable th) {
completionHolder.value = mnemonicCompletion;
return mnemonicValue;
/* return old */
}
try {
// if same time or newer exist return cached value
if (keyTime <= mnemonicTime) {
completionHolder.value = mnemonicCompletion;
return mnemonicValue;
}
} finally {
mnemonicDataLock.readLock().unlock();
}
// read value wait, if reading is already pending
synchronized (mnemonicValueRetrival) {
// lock if not newer read
if (keyTime <= mnemonicReadPending) {
try {
mnemonicValueRetrival.wait();
} catch (InterruptedException ie) {
}
// re-read again
continue;
} else {
mnemonicReadPending = keyTime;
break;
}
}
}
//
// value retrival
//
Object retValue = null;
try {
retValue = getSync(completionHolder);
} catch (AcsJException acsex) {
retValue = defaultValue;
completionHolder.value = CompletionUtil.generateCompletion(acsex);
} catch (Throwable th) {
retValue = defaultValue;
completionHolder.value = CompletionUtil.generateCompletion(new AcsJUnknownEx("Failed to retrieve value.", th));
}
// write mnemonic data lock
try {
mnemonicDataLock.writeLock().lock();
} catch (Throwable th) {
return mnemonicValue;
/* return old */
}
try {
if (keyTime > mnemonicTime) {
mnemonicTime = keyTime;
mnemonicValue = retValue;
mnemonicCompletion = completionHolder.value;
}
return mnemonicValue;
} finally {
mnemonicDataLock.writeLock().unlock();
// read value wait release
synchronized (mnemonicValueRetrival) {
mnemonicValueRetrival.notifyAll();
}
}
}
use of alma.acs.exceptions.AcsJException in project ACS by ACS-Community.
the class CommonPropertyImpl method setSync.
/*********************** [ RW<type> helpers ] ***********************/
/**
* @see alma.ACSErr.Completion alma.ACS.RW<type>Operations#set_sync(<type>)
*/
protected Completion setSync(Object value) throws AcsJException {
try {
CompletionHolder completionHolder = CompletionUtil.createCompletionHolder();
dataAccess.set(value, completionHolder);
// generate no-error completion, if not generated
if (completionHolder.value == null)
completionHolder.value = CompletionUtil.generateNoErrorCompletion();
return completionHolder.value;
} catch (AcsJException acsex) {
throw new AcsJCouldntPerformActionEx("Failed to set value.", acsex);
}
}
use of alma.acs.exceptions.AcsJException in project ACS by ACS-Community.
the class ManagerImpl method internalNoSyncDeactivateComponent.
/**
* Deactivate component, issue deactivate reeust to container (or other manager).
* @param componentInfo info about component to be deactivated.
*/
private void internalNoSyncDeactivateComponent(ComponentInfo componentInfo) throws Throwable {
// unbind from remote directory
//unbind(convertToHiearachical(componentInfo.getName()), "O");
int handle = componentInfo.getHandle() & HANDLE_MASK;
int owners = componentInfo.getClients().size();
try {
//
// get container/remote manager
//
String name = componentInfo.getName();
boolean isOtherDomainComponent = name.startsWith(CURL_URI_SCHEMA);
if (isOtherDomainComponent) {
Manager remoteManager = null;
// @todo MF do the login?
try {
String domainName = CURLHelper.createURI(name).getAuthority();
remoteManager = getManagerForDomain(domainName);
if (remoteManager == null)
throw new CoreException("Failed to obtain manager for domain '" + domainName + "'.");
} catch (Throwable th) {
logger.log(Level.WARNING, "Failed to obtain non-local manager required by component '" + name + "'.", th);
throw th;
}
// release component
try {
URI curlName = CURLHelper.createURI(name);
// @todo MF tmp (handle)
remoteManager.releaseComponent(INTERDOMAIN_MANAGER_HANDLE, curlName);
} catch (Throwable th) {
logger.log(Level.WARNING, "Failed to release component '" + componentInfo.getName() + "' on remote manager.'", th);
throw th;
}
} else {
//
// search for container by its name
//
Container container = null;
ContainerInfo containerInfo = null;
int containerHandle = componentInfo.getContainer();
// if containerHandle equals 0, we have unavailable or registered component
if (containerHandle != 0) {
containerInfo = getContainerInfo(containerHandle);
if (containerInfo != null) {
// remove component from container component list
synchronized (containerInfo.getComponents()) {
// !!! ACID
if (containerInfo.getComponents().contains(componentInfo.getHandle()))
executeCommand(new ContainerInfoCommandComponentRemove(containerInfo.getHandle() & HANDLE_MASK, componentInfo.getHandle()));
//containerInfo.getComponents().remove(componentInfo.getHandle());
}
// we allow this (since releasing components is part of container shutdown procedure)
//checkContainerState(containerInfo);
container = containerInfo.getContainer();
}
// required container is not logged in
if (container == null) {
// then simply do not do the deactivation
String containerName;
if (containerInfo != null)
containerName = containerInfo.getName();
else
containerName = HandleHelper.toString(componentInfo.getContainer());
logger.log(Level.WARNING, "Container '" + containerName + "' required by component '" + componentInfo.getName() + "' is not logged in.");
}
}
if (container != null) {
// log info
logger.log(Level.INFO, "Deactivating component '" + componentInfo.getName() + "' (" + HandleHelper.toString(componentInfo.getHandle()) + ") on container '" + containerInfo.getName() + "'.");
// destruct
try {
componentInfo.getComponent().destruct();
} catch (Throwable ex) {
RemoteException re = new RemoteException("Failed to destruct component '" + componentInfo.getName() + "', exception caught when invoking 'destruct()' method.", ex);
logger.log(Level.SEVERE, re.getMessage(), re);
throw ex;
}
long deactivationTime = 0;
// deactivate component in anycase
try {
container.deactivate_component(componentInfo.getHandle());
deactivationTime = System.currentTimeMillis();
} catch (AcsJException aex) {
logger.log(Level.SEVERE, aex.getMessage(), aex);
throw aex;
} catch (Throwable ex) {
RemoteException re = new RemoteException("Failed to deactivate component '" + componentInfo.getName() + "' (" + HandleHelper.toString(componentInfo.getHandle()) + ") on container '" + containerInfo.getName() + "'.", ex);
logger.log(Level.SEVERE, re.getMessage(), re);
throw ex;
}
// notify administrators about deactivation, but not if failed
if (deactivationTime != 0)
notifyComponentDeactivated(componentInfo.getHandle(), deactivationTime);
// shutdown container if required (and necessary)
conditionalShutdownContainer(containerInfo);
}
}
} finally {
if (owners == 0) {
// deallocate Component
componentsLock.lock();
try {
executeCommand(new ComponentCommandDeallocate(handle, componentInfo.getHandle(), WhyUnloadedReason.REMOVED));
//components.deallocate(handle);
} finally {
componentsLock.unlock();
}
}
}
// log info
logger.log(Level.INFO, "Component '" + componentInfo.getName() + "' (" + HandleHelper.toString(componentInfo.getHandle()) + ") deactivated.");
// release all subcomponents (just like client logoff)
// component should have already done this by itself, but take care of clean cleanup
// what about that: if subcomponent becomes unavailable, does component also becomes?!
// no, it is notified and it handles situation by its own way (e.g. changes component state).
// Just like it already handles activation (manager does not care for dependecy trees).
int[] subcomponents = null;
// no not hold the lock
synchronized (componentInfo.getComponents()) {
if (componentInfo.getComponents().size() > 0) {
IntArray toCleanupList = new IntArray();
IntArray comps = componentInfo.getComponents();
for (int i = 0; i < comps.size(); i++) if (components.isAllocated(comps.get(i) & HANDLE_MASK))
toCleanupList.add(comps.get(i));
if (toCleanupList.size() > 0)
subcomponents = toCleanupList.toArray();
}
//subcomponents = componentInfo.getComponents().toArray();
}
if (subcomponents != null && subcomponents.length > 0)
new ReleaseComponentTask(componentInfo.getHandle(), subcomponents).run();
// make unavailable (deactivation was forced)
if (owners > 0)
makeUnavailable(componentInfo);
}
use of alma.acs.exceptions.AcsJException in project ACS by ACS-Community.
the class EventSupplierSpr2005067Impl method sendEvents.
/** Sends some events to an event channel.
* @param param number of events to send
*/
public void sendEvents(short param) {
/*
* This is OK
*/
m_logger.info("Now sending ControlSystemChangeOfStateEvent2 events. This should always be OK");
try {
ControlSystemChangeOfStateEvent2 t_block = new ControlSystemChangeOfStateEvent2(alma.SPR2005067.SystemState.INACCESSIBLE, alma.SPR2005067.SystemSubstate.STARTING_UP_PASS1, false, 0);
for (short i = 0; i < param; i++) {
m_supplier.publishEvent(t_block);
}
} catch (AcsJException e) {
/*
* Here I just log the error trace.
* It would be nicer to throw it to the caller,
* but the interface of sendEvents does not allow it.
* We should change that interface.
*/
AcsJGenericErrorEx ex = new AcsJGenericErrorEx("This exception publishing events should have never occurred", e);
ex.log(m_logger);
} catch (Throwable thr) {
AcsJUnexpectedExceptionEx ex = new AcsJUnexpectedExceptionEx("Got unexpected exception", thr);
/*
* Here I just log the error trace.
* It would be nicer to throw it to the caller,
* but the interface of sendEvents does not allow it.
* We should change that interface.
*/
ex.log(m_logger);
}
/*
* This fails with JacORB (tested up to version 2.2.4)
* See SPR 2005067
*/
m_logger.info("Now sending ControlSystemChangeOfStateEvent events. This FAILS now but should be OK as well. See SPR2005067");
try {
ControlSystemChangeOfStateEvent t_block = new ControlSystemChangeOfStateEvent(alma.SPR2005067.SystemState.INACCESSIBLE, alma.SPR2005067.SystemSubstate.STARTING_UP_PASS1, alma.SPR2005067.SystemState.INACCESSIBLE, alma.SPR2005067.SystemSubstate.STARTING_UP_PASS1, false, 0);
for (short i = 0; i < param; i++) {
m_supplier.publishEvent(t_block);
}
} catch (AcsJException e) {
/*
* Here I just log the error trace.
* It would be nicer to throw it to the caller,
* but the interface of sendEvents does not allow it.
* We should change that interface.
*/
AcsJGenericErrorEx ex = new AcsJGenericErrorEx("This exception is due to SPR2005067", e);
ex.log(m_logger);
} catch (Throwable thr) {
/*
* The message int the exception logged is incomplete.
* Look at the println and compare to see the difference
*/
System.err.println(thr);
AcsJUnexpectedExceptionEx ex = new AcsJUnexpectedExceptionEx("Got unexpected exception", thr);
/*
* Here I just log the error trace.
* It would be nicer to throw it to the caller,
* but the interface of sendEvents does not allow it.
* We should change that interface.
*/
ex.log(m_logger);
}
}
use of alma.acs.exceptions.AcsJException 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;
}
Aggregations