use of com.cosylab.acs.maci.RemoteException 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 com.cosylab.acs.maci.RemoteException in project ACS by ACS-Community.
the class AdministratorProxy method component_activated.
/**
* @see com.cosylab.acs.maci.Administrator#component_activated(com.cosylab.acs.maci.ComponentInfo, long, long)
*/
public void component_activated(ComponentInfo info, long timeStamp, long executionId) throws RemoteException {
try {
// invalid info (replacement for null)
final si.ijs.maci.ComponentInfo invalidInfo = new si.ijs.maci.ComponentInfo("<invalid>", "<invalid>", null, "<invalid>", new int[0], 0, "<invalid>", 0, 0, new String[0]);
si.ijs.maci.ComponentInfo componentInfo = invalidInfo;
if (info != null) {
Object obj = null;
if (info.getComponent() != null)
obj = (Object) info.getComponent().getObject();
String[] interfaces;
if (info.getInterfaces() != null)
interfaces = info.getInterfaces();
else
interfaces = new String[0];
componentInfo = new si.ijs.maci.ComponentInfo(info.getType(), info.getCode(), obj, info.getName(), info.getClients().toArray(), info.getContainer(), info.getContainerName(), info.getHandle(), ManagerProxyImpl.mapAccessRights(info.getAccessRights()), interfaces);
}
administrator.component_activated(componentInfo, UTCUtility.utcJavaToOmg(timeStamp), executionId);
} catch (TIMEOUT te) {
throw new RemoteTimeoutException("Failed to invoke 'component_activated()' method due to timeout.", te);
} catch (TRANSIENT tre) {
throw new RemoteTransientException("Failed to invoke 'component_activated()' method due to transient exception.", tre);
} catch (Throwable ex) {
throw new RemoteException("Failed to invoke 'component_activated()' method.", ex);
}
}
use of com.cosylab.acs.maci.RemoteException in project ACS by ACS-Community.
the class ClientProxy method components_available.
/**
* @see com.cosylab.acs.maci.Client#components_available(ComponentInfo[])
*/
public void components_available(ComponentInfo[] cobs) throws RemoteException {
try {
// invalid info (replacement for null)
final si.ijs.maci.ComponentInfo invalidInfo = new si.ijs.maci.ComponentInfo("<invalid>", "<invalid>", null, "<invalid>", new int[0], 0, "<invalid>", 0, 0, new String[0]);
// transform to CORBA specific
si.ijs.maci.ComponentInfo[] infos = null;
if (cobs != null) {
infos = new si.ijs.maci.ComponentInfo[cobs.length];
for (int i = 0; i < cobs.length; i++) if (cobs[i] == null)
infos[i] = invalidInfo;
else {
Object obj = null;
if (cobs[i].getComponent() != null)
obj = (Object) cobs[i].getComponent().getObject();
String[] interfaces;
if (cobs[i].getInterfaces() != null)
interfaces = cobs[i].getInterfaces();
else
interfaces = new String[0];
infos[i] = new si.ijs.maci.ComponentInfo(cobs[i].getType(), cobs[i].getCode(), obj, cobs[i].getName(), cobs[i].getClients().toArray(), cobs[i].getContainer(), cobs[i].getContainerName(), cobs[i].getHandle(), ManagerProxyImpl.mapAccessRights(cobs[i].getAccessRights()), interfaces);
}
} else
infos = new si.ijs.maci.ComponentInfo[0];
client.components_available(infos);
} catch (TIMEOUT te) {
throw new RemoteTimeoutException("Failed to invoke 'components_available()' method due to timeout.", te);
} catch (TRANSIENT tre) {
throw new RemoteTransientException("Failed to invoke 'components_available()' method due to transient exception.", tre);
} catch (Throwable ex) {
throw new RemoteException("Failed to invoke 'component_available()' method.", ex);
}
}
use of com.cosylab.acs.maci.RemoteException in project ACS by ACS-Community.
the class ClientProxy method taggedmessage.
/**
* @see com.cosylab.acs.maci.Client#message(MessageType, String)
*/
public void taggedmessage(MessageType type, short id, String message) throws RemoteException {
try {
short msgType;
if (type == MessageType.MSG_ERROR)
msgType = si.ijs.maci.Client.MSG_ERROR;
else
msgType = si.ijs.maci.Client.MSG_INFORMATION;
client.taggedmessage(msgType, id, message);
} catch (TIMEOUT te) {
throw new RemoteTimeoutException("Failed to invoke 'tagged_message()' method due to timeout.", te);
} catch (TRANSIENT tre) {
throw new RemoteTransientException("Failed to invoke 'tagged_message()' method due to transient exception.", tre);
} catch (Throwable ex) {
throw new RemoteException("Failed to invoke 'tagged_message()' method.", ex);
}
}
use of com.cosylab.acs.maci.RemoteException in project ACS by ACS-Community.
the class ClientProxyImpl method taggedmessage.
/**
* @see si.ijs.maci.ClientOperations#taggedmessage(short, String)
*/
public void taggedmessage(short type, short id, String message) {
try {
MessageType msgType;
if (type == Client.MSG_ERROR)
msgType = MessageType.MSG_ERROR;
else
msgType = MessageType.MSG_INFORMATION;
client.taggedmessage(msgType, id, message);
} catch (RemoteException re) {
// noop.
}
}
Aggregations