use of si.ijs.maci.ClientInfo in project ACS by ACS-Community.
the class BACIRemoteAccess method resolveManager.
/**
* Insert the method's description here.
* Creation date: (1.11.2000 14:29:17)
*/
private void resolveManager() {
if (managerLoc == null)
throw new IllegalStateException("Cannot resolve manager corbaloc when it is null.");
try {
org.omg.CORBA.Object object = orb.string_to_object(managerLoc);
notifier.reportDebug("BACIRemoteAccess::resolveManager", "Manager reference string_to_object OK with managerLoc = '" + managerLoc + "'.");
manager = ManagerHelper.narrow(object);
notifier.reportDebug("BACIRemoteAccess::resolveManager", "Manager reference narrowing OK.");
notifier.reportMessage("Obtained reference to 'Manager'.");
if (manager == null)
throw new NullPointerException("Manager is null after ManagerHelper.narrow()");
} catch (Exception e) {
throw new RemoteException("Could not resolve manager reference: " + e);
}
try {
client = new ClientImpl();
Client cIF = client._this(orb);
notifier.reportDebug("BACIRemoteAccess::resolveManager", "Instantiated Client servant.");
ClientInfo info = manager.login(cIF);
if (info == null)
throw new Exception("Failed to login to the manager when returned ClientInfo is null.");
handle = info.h;
notifier.reportDebug("BACIRemoteAccess::resolveManager", "Manager login OK.");
} catch (Exception e1) {
throw new RemoteException("Cannot login to the manager: " + e1);
}
new Thread(new Runnable() {
public void run() {
notifier.reportDebug("BACIRemoteAccess::resolveManager", "Initializing remote logging...");
ClientLogManager.getAcsLogManager().initRemoteLogging(orb, manager, handle, true);
notifier.reportDebug("BACIRemoteAccess::resolveManager", "Remote logging initialized.");
}
}, "InitRemoteLogging").start();
}
use of si.ijs.maci.ClientInfo 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.ClientInfo 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;
}
use of si.ijs.maci.ClientInfo in project ACS by ACS-Community.
the class ManagerDynComponentTest method login.
/**
* Login to the manager.
* @param manager manager reference.
* @return client info, <code>null</code> on failure.
*/
private ClientInfo login(Manager manager) {
if (orb == null || manager == null)
return null;
System.out.println("Logging to the manager...");
try {
ClientImpl clientImpl = new ClientImpl();
Client client = clientImpl._this(orb);
ClientInfo info = manager.login(client);
if (info == null)
throw new Exception("Failed to login to the manager since returned ClientInfo is 'null'.");
System.out.println("Logged in to the manager.");
return info;
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("Failed to login to the manager.");
return null;
}
}
use of si.ijs.maci.ClientInfo in project ACS by ACS-Community.
the class ManagerProxyImpl method login.
/**
* Login to MACI.
* Containers, Clients and Administrative clients call this function
* first to identify themselves with the Manager. The Manager authenticates them
* (through the authenticate function), and assigns them access rights and a handle,
* through which they will identify themselves at subsequent calls to the Manager.
*
* @param reference A reference to the Client.
* @return A ClientInfo structure with handle (h) and access fields filled-in.
* If the client with this name did not logout prior to calling login,
* the components sequence in ClientInfo contains the handles of all components that
* the client was using. (For Containers, the components sequence contains
* handles of all components previously hosted by the Container.)
*/
public ClientInfo login(Client reference) throws NoPermissionEx {
pendingRequests.incrementAndGet();
try {
// client proxy
com.cosylab.acs.maci.Client clientProxy = null;
// create approperiate proxies
if (reference != null) {
if (reference._is_a(ContainerHelper.id())) {
clientProxy = new ContainerProxy(ContainerHelper.narrow(reference));
} else if (reference._is_a(SynchronousAdministratorHelper.id())) {
clientProxy = new SynchronousAdministratorProxy(SynchronousAdministratorHelper.narrow(reference));
} else if (reference._is_a(AdministratorHelper.id())) {
clientProxy = new AdministratorProxy(AdministratorHelper.narrow(reference));
} else if (reference._is_a(ClientHelper.id())) {
clientProxy = new ClientProxy(reference);
} else {
// this should never happen, but we are carefuly anyway
BadParametersException af = new BadParametersException("Given reference does not implement 'maci::Client' interface.");
reportException(af);
throw new BAD_PARAM(af.getMessage());
}
}
ClientInfo retVal = null;
com.cosylab.acs.maci.ClientInfo info = manager.login(clientProxy);
if (info != null)
retVal = new ClientInfo(info.getHandle(), ((ClientProxy) info.getClient()).getClient(), info.getComponents().toArray(), info.getName(), mapAccessRights(info.getAccessRights()));
return retVal;
} 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 (Throwable ex) {
CoreException hce = new CoreException(ex.getMessage(), ex);
reportException(hce);
// rethrow CORBA specific
throw new UNKNOWN(ex.getMessage());
} finally {
pendingRequests.decrementAndGet();
}
}
Aggregations