use of si.ijs.maci.ComponentInfo in project ACS by ACS-Community.
the class ManagerProxyImpl method get_default_component.
/**
* Returns the default component of specific type.
* @param id identification of the caller.
* @param type component type, IDL ID.
* @return <code>ComponentInfo</code> of requested component.
*/
public ComponentInfo get_default_component(int id, String type) throws NoPermissionEx, NoDefaultComponentEx, CannotGetComponentEx {
pendingRequests.incrementAndGet();
try {
// returned value
ComponentInfo retVal = null;
// transform to CORBA specific
com.cosylab.acs.maci.ComponentInfo info = manager.getDefaultComponent(id, type);
if (info == null || info.getComponent() == null)
throw new AcsJCannotGetComponentEx();
Object obj = null;
obj = (Object) info.getComponent().getObject();
String[] interfaces;
if (info.getInterfaces() != null)
interfaces = info.getInterfaces();
else
interfaces = new String[0];
retVal = new ComponentInfo(info.getType(), info.getCode(), obj, info.getName(), info.getClients().toArray(), info.getContainer(), info.getContainerName(), info.getHandle(), mapAccessRights(info.getAccessRights()), interfaces);
return retVal;
} catch (NoDefaultComponentException ndce) {
NoDefaultComponentException hndce = new NoDefaultComponentException(ndce.getMessage(), ndce);
reportException(hndce);
// rethrow CORBA specific
throw new AcsJNoDefaultComponentEx().toNoDefaultComponentEx();
} 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 (AcsJNoPermissionEx npe) {
// rethrow CORBA specific
throw npe.toNoPermissionEx();
} catch (AcsJCannotGetComponentEx cgce) {
// rethrow CORBA specific
throw cgce.toCannotGetComponentEx();
} 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 si.ijs.maci.ComponentInfo in project ACS by ACS-Community.
the class DeserializeManagerFromFile method main.
/**
* @param args
*/
public static void main(String[] args) throws Throwable {
File f = new File(args[0]);
ObjectInputStream obj = new ObjectInputStream(new FileInputStream(f));
// we cast directly to the implementation
ManagerImpl manager = (ManagerImpl) obj.readObject();
{
//
// list all active components
//
HandleDataStore components = manager.getComponents();
System.out.println("Capacity of handle data store: " + components.capacity());
System.out.println(components.size() + " component(s) stored:");
int h = components.first();
while (h != 0) {
ComponentInfo componentInfo = (ComponentInfo) components.get(h);
System.out.println("\tName : " + componentInfo.name);
System.out.println("\tHandle : " + componentInfo.h + ", " + HandleHelper.toString(componentInfo.h));
System.out.println("\tType : " + componentInfo.type);
System.out.println("\tCode : " + componentInfo.code);
System.out.println("\tContainer name : " + componentInfo.container_name);
System.out.println("\tContainer handle: " + HandleHelper.toString(componentInfo.container));
System.out.println("\tClients : count = " + componentInfo.clients.length);
for (int j = 0; j < componentInfo.clients.length; j++) System.out.println("\t \t" + componentInfo.clients[j]);
System.out.println("\t-------------------------------");
h = components.next(h);
}
}
System.out.println();
System.out.println();
System.out.println();
{
//
// list all active containers
//
HandleDataStore containers = manager.getContainers();
System.out.println("Capacity of handle data store: " + containers.capacity());
System.out.println(containers.size() + " container(s) returned:");
int h = containers.first();
while (h != 0) {
ContainerInfo containersInfo = (ContainerInfo) containers.get(h);
System.out.println("\tName : " + containersInfo.name);
System.out.println("\tHandle : " + containersInfo.h + ", " + HandleHelper.toString(containersInfo.h));
System.out.println("\tComponents : count = " + containersInfo.components.length);
for (int j = 0; j < containersInfo.components.length; j++) System.out.println("\t \t" + containersInfo.components[j]);
System.out.println("\t-------------------------------");
}
}
System.out.println();
System.out.println();
System.out.println();
{
//
// list all active clients
//
HandleDataStore clients = manager.getClients();
System.out.println("Capacity of handle data store: " + clients.capacity());
System.out.println(clients.size() + " clients(s) returned:");
int h = clients.first();
while (h != 0) {
ClientInfo clientsInfo = (ClientInfo) clients.get(h);
System.out.println("\tName : " + clientsInfo.name);
System.out.println("\tHandle : " + clientsInfo.h + ", " + HandleHelper.toString(clientsInfo.h));
System.out.println("\tComponents : count = " + clientsInfo.components.length);
for (int j = 0; j < clientsInfo.components.length; j++) System.out.println("\t \t" + clientsInfo.components[j]);
System.out.println("\t-------------------------------");
}
}
System.out.println();
System.out.println();
System.out.println();
{
//
// list all active administrators
//
HandleDataStore clients = manager.getAdministrators();
System.out.println("Capacity of handle data store: " + clients.capacity());
System.out.println(clients.size() + " administrators(s) returned:");
int h = clients.first();
while (h != 0) {
ClientInfo clientsInfo = (ClientInfo) clients.get(h);
System.out.println("\tName : " + clientsInfo.name);
System.out.println("\tHandle : " + clientsInfo.h + ", " + HandleHelper.toString(clientsInfo.h));
System.out.println("\tComponents : count = " + clientsInfo.components.length);
for (int j = 0; j < clientsInfo.components.length; j++) System.out.println("\t \t" + clientsInfo.components[j]);
System.out.println("\t-------------------------------");
}
}
System.out.println();
System.out.println();
System.out.println();
System.out.println("# of unavailable components in a map: " + manager.getUnavailableComponents().size());
System.out.println("# of default components in a map: " + manager.getDefaultComponents().size());
System.out.println("# of active alarms in a map: " + manager.getActiveAlarms().size());
System.out.println("# of released handles in a map: " + manager.getReleasedHandles().size());
}
use of si.ijs.maci.ComponentInfo in project ACS by ACS-Community.
the class BACIRemoteAccess method internalManagerConnect.
/**
* Insert the method's description here.
* Creation date: (2.11.2000 0:34:52)
* @param node si.ijs.acs.objectexplorer.engine.BACI.BACIRemoteNode
*/
private void internalManagerConnect(BACIRemoteNode baciNode) throws AcsJObjectExplorerConnectEx {
/* we are connecting directly to the Manager to obtain the object reference */
//System.out.println("DEBUG: imc "+baciNode);
String curl = (String) baciNode.getUserObject();
notifier.reportDebug("BACIRemoteAccess::internalManagerConnect", "Requesting component: '" + curl + "', activate = true");
notifier.reportMessage("Connecting to '" + curl + "'.");
baciNode.setNonSticky(connectNonSticky);
org.omg.CORBA.Object obj = null;
if (connectNonSticky) {
try {
obj = manager.get_component_non_sticky(handle, curl);
} catch (Throwable e) {
String message = "Connection to component '" + curl + "' failed. \n" + "'Connect as non-sticky' mode is enabled: in this mode component will not be activated by ObjectExplorer,\n" + "only already activated components can be accessed.";
int ans = choiceForNonStickyComponentConnection(message);
switch(ans) {
case 0:
baciNode.setNonSticky(false);
System.out.println("BACIRemoteAccess.internalManagerConnect setNonSticky to " + baciNode.isNonSticky() + " @ " + baciNode.hashCode());
break;
case 1:
baciEngineMenu.setNonSticky(false);
baciNode.setNonSticky(false);
break;
case 2:
{
AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx(e);
acsjex.setCurl(curl);
throw acsjex;
}
default:
{
// should not happen.
notifier.reportError("Unexpected choice.");
AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx(e);
acsjex.setCurl(curl);
throw acsjex;
}
}
}
}
try {
if (obj == null) {
obj = manager.get_component(handle, curl, true);
}
notifier.reportDebug("BACIRemoteAccess::internalManagerConnect", "Manager returns OK");
}/*
* We wrap into a specific exception and report up
*/
catch (CannotGetComponentEx e) {
notifier.reportError("Connection to component '" + curl + "' failed.");
AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx(e);
acsjex.setCurl(curl);
throw acsjex;
} catch (org.omg.CORBA.TRANSIENT e) {
notifier.reportError("Connection to component '" + curl + "' failed.\nCouldn't connect to the manager.");
AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx(e);
acsjex.setCurl(curl);
throw acsjex;
} catch (Throwable e) {
notifier.reportError("Connection to component '" + curl + "' failed.\nUnknown Reason.");
AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx(e);
acsjex.setCurl(curl);
throw acsjex;
}
String irfid = null;
try {
notifier.reportDebug("BACIRemoteAccess::internalManagerConnect", "Querying component '" + curl + "' for CORBA type id.");
ComponentInfo[] cobInfos = manager.get_component_info(handle, new int[0], curl, "*", true);
if (cobInfos.length != 1) {
AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx();
acsjex.setReason("Manager did not return valid ComponentInfo for '" + curl + "'.");
throw acsjex;
}
irfid = cobInfos[0].type;
notifier.reportDebug("BACIRemoteAccess::internalManagerConnect", "component '" + curl + "' has id: " + irfid);
} catch (Exception e) {
notifier.reportError("Cannot retrieve Interface Repository ID for component '" + curl + "'", e);
AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx(e);
acsjex.setCurl(curl);
throw acsjex;
}
// baciNode.setNonSticky(connectNonSticky);
baciNode.setCORBARef(obj);
try {
baciNode.setIFDesc(getIFDesc(irfid));
if (baciNode.getIFDesc() != null)
notifier.reportDebug("BACIRemoteAccess::internalManagerConnect", "IR Query OK.");
else {
AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx();
acsjex.setCurl(curl);
acsjex.setReason("Cannot retrieve Interface Repository description for component for '" + curl + "'.");
throw acsjex;
}
} catch (Exception e) {
baciNode.setCORBARef(null);
notifier.reportError("Failed to retrieve interface description from IR, releasing component on Manager, if needed.", e);
AcsJException releaseCompEx = null;
try {
if (manager != null && obj != null && !baciNode.isNonSticky()) {
manager.release_component(handle, curl);
}
} catch (NoPermissionEx npe) {
releaseCompEx = AcsJNoPermissionEx.fromNoPermissionEx(npe);
} catch (CannotDeactivateComponentEx ex) {
// @TODO remove this catch once we remove this ex from maci.idl
releaseCompEx = AcsJCannotDeactivateComponentEx.fromCannotDeactivateComponentEx(ex);
} catch (ComponentDeactivationUncleanEx ex) {
releaseCompEx = AcsJComponentDeactivationUncleanEx.fromComponentDeactivationUncleanEx(ex);
} catch (ComponentDeactivationFailedEx ex) {
releaseCompEx = AcsJComponentDeactivationFailedEx.fromComponentDeactivationFailedEx(ex);
}
if (releaseCompEx != null) {
notifier.reportError("Failed to release component", releaseCompEx);
logACSException(releaseCompEx);
}
AcsJObjectExplorerInterfaceRepositoryAccessEx acsjex = new AcsJObjectExplorerInterfaceRepositoryAccessEx(e);
acsjex.setCurl(curl);
acsjex.setIRid(irfid);
AcsJObjectExplorerConnectEx acsjex2 = new AcsJObjectExplorerConnectEx(acsjex);
acsjex2.setCurl(curl);
throw acsjex2;
}
notifier.reportMessage("Connected to '" + curl + "'.");
}
use of si.ijs.maci.ComponentInfo in project ACS by ACS-Community.
the class MaciSupervisor method refreshNow.
/**
* Tries to refresh the component-section, container-section, and client-section
* of the info tree model. The treemodel will be updated when things go well
* and also when things fail.
*
* A call to this method will instantly perform a refresh, possibly
* throwing an exception or blocking the current thread for a long time. Calling
* {@link #getMaciInformation()} and {@link #refreshSoon()} will shield you from
* these effects.
*
* @throws NoPermissionEx error during refresh
* @throws NotConnectedToManagerException error during refresh
* @throws CorbaTransientException
* @throws CorbaNotExistException
* @throws UnknownErrorException
*/
public synchronized void refreshNow() throws NoPermissionEx, NotConnectedToManagerException, SystemException, CorbaTransientException, CorbaNotExistException, UnknownErrorException {
log.fine(read + "retrieving acs deployment info from acs manager");
List<ComponentInfo> newComponents = Collections.EMPTY_LIST;
List<ContainerInfo> newContainers = Collections.EMPTY_LIST;
List<ClientInfo> newClientApps = Collections.EMPTY_LIST;
Map<Object, String> newAuxiliary = Collections.EMPTY_MAP;
boolean nothingChanged = false;
try {
try {
// retrieve data from manager
// -------------------------------
newComponents = Arrays.asList(this.retrieveComponentInfo("*"));
newContainers = Arrays.asList(this.retrieveContainerInfo("*"));
newClientApps = Arrays.asList(this.retrieveClientInfo("*"));
/* If the retrieval bails out it is (as far as i've seen)
* always because the manager is not reachable at all.
* thus, there's no need to try and retrieve e.g. the
* clients if the components have already failed. thus,
* one exception handler for all retrievals is enough */
} catch (NotConnectedToManagerException exc) {
log.fine(read + "problem: " + exc);
mcehandler.handleExceptionTalkingToManager(exc);
throw exc;
} catch (NoPermissionEx exc) {
log.fine(read + "problem: " + exc);
mcehandler.handleExceptionTalkingToManager(exc);
throw exc;
} catch (org.omg.CORBA.TRANSIENT exc) {
log.fine(read + "problem: " + exc);
mcehandler.handleExceptionTalkingToManager(exc);
throw new CorbaTransientException(exc);
} catch (org.omg.CORBA.OBJECT_NOT_EXIST exc) {
log.fine(read + "problem: " + exc);
mcehandler.handleExceptionTalkingToManager(exc);
throw new CorbaNotExistException(exc);
} catch (RuntimeException exc) {
log.fine(read + "problem: " + exc);
mcehandler.handleExceptionTalkingToManager(exc);
throw new UnknownErrorException(exc);
}
// 2013-05 Marcus OSF Mission -----------------------------------------
if (log.isLoggable(Level.FINER)) {
StringBuilder sb = new StringBuilder();
sb.append("\nretrieved containers (").append(newContainers.size()).append(") = | ");
for (ContainerInfo ci : newContainers) sb.append("n=").append(ci.name).append(",h=").append(ci.h).append(" | ");
sb.append("\nknown containers (").append(maciInfo.containers.size()).append(") = | ");
for (ContainerInfo ci : maciInfo.containers) sb.append("n=").append(ci.name).append(",h=").append(ci.h).append(" | ");
log.finer(read + "diffing container info" + sb);
}
// ------------------------------------------------------------------
diffComponents.diff(maciInfo.components, newComponents);
diffContainers.diff(maciInfo.containers, newContainers);
diffClientApps.diff(maciInfo.clientApps, newClientApps);
// 2013-05 Marcus OSF Mission -----------------------------------------
if (log.isLoggable(Level.FINER))
log.finer(write + "diff results: containers=" + !diffContainers.areEqual() + ", components=" + !diffComponents.areEqual() + ", clients=" + !diffClientApps.areEqual());
if (diffComponents.areEqual() && diffContainers.areEqual() && diffClientApps.areEqual()) {
log.finer(write + "no change found");
nothingChanged = true;
} else {
// we provide some additional info over what is available in the manager's
// info structs. we must compute it upfront since you need an ORB to do it.
newAuxiliary = new HashMap<Object, String>();
for (ContainerInfo info : newContainers) {
int infokey = System.identityHashCode(info);
newAuxiliary.put(infokey + ".location", extractLocation(info.reference));
}
for (ClientInfo info : newClientApps) {
int infokey = System.identityHashCode(info);
newAuxiliary.put(infokey + ".location", extractLocation(info.reference));
}
}
} finally {
if (nothingChanged == false) {
log.fine(write + "writing changes to maci-info structure");
maciInfo.setContents(newComponents, newContainers, newClientApps, newAuxiliary);
}
}
}
use of si.ijs.maci.ComponentInfo in project ACS by ACS-Community.
the class MaciInfo method createNode.
/**
* Factory method
*/
protected SortingTreeNode createNode(Object info) {
SortingTreeNode ret = new SortingTreeNode();
if (info instanceof ContainerInfo) {
ret.setUserObject(info);
ContainerInfo casted = (ContainerInfo) info;
if (casted.h != 0)
ret.representedHandles = new int[] { casted.h };
} else if (info instanceof ClientInfo) {
ret.setUserObject(info);
ClientInfo casted = (ClientInfo) info;
if (casted.h != 0)
ret.representedHandles = new int[] { casted.h };
} else if (info instanceof ComponentInfo) {
ret.setUserObject(info);
ComponentInfo casted = (ComponentInfo) info;
if (casted.h != 0)
ret.representedHandles = new int[] { casted.h };
} else if (info instanceof InfoDetail) {
InfoDetail casted = (InfoDetail) info;
ret.setUserObject(info);
ret.representedHandles = casted.representedHandles;
} else if (info instanceof FolderInfo) {
ret.setUserObject(info);
} else {
ret.setUserObject(info);
/* when a component is configured as "autostart", it will have
* the manager as its first client.
* matej email 2009-04: there is no way to retrieve the handle
* of the manager... but it is always fixed. */
if (// = 83886080
"Manager".equals(info))
ret.representedHandles = new int[] { HandleConstants.MANAGER_MASK };
}
return ret;
}
Aggregations