Search in sources :

Example 16 with ClientInfo

use of si.ijs.maci.ClientInfo in project ACS by ACS-Community.

the class ClientProxyImpl method login.

/*********************** Helper methods ***********************/
/**
	 * Login to the manager and obtain handle.
	 * 
	 * @param	manager	CORBA <code>maci::Manager</code> reference, non-<code>null</code>
	 * @return boolean
	 */
public boolean login(ORB orb, Manager manager) {
    assert (orb != null);
    assert (manager != null);
    this.manager = manager;
    try {
        ClientInfo clientInfo = manager.login(this._this(orb));
        if (clientInfo != null && clientInfo.h != 0) {
            client.setHandle(clientInfo.h);
            logger.info("Successfully logged in to the Manager.");
            return true;
        }
    } catch (Exception ex) {
        return false;
    }
    return false;
}
Also used : ClientInfo(si.ijs.maci.ClientInfo) RemoteException(com.cosylab.acs.maci.RemoteException)

Example 17 with ClientInfo

use of si.ijs.maci.ClientInfo in project ACS by ACS-Community.

the class ManagerProxyImpl method get_client_info.

/**
	 * Get all the information that the Manager has about its known clients.
	 * To invoke this method, the caller must have INTROSPECT_MANAGER access rights, or it must be the object whose info it is requesting.
	 * Calling this function does not affect the internal state of the Manager.
	 *
	 * @param id Identification of the caller.
	 * @param h Handles of the clients whose information is requested. If this is an empty sequence, the name_wc parameter is used.
	 * @param name_wc Wildcard that the clients's name must match in order for its information to be returned.
	 * @return A sequence of ClientInfo structures containing the entire Manager's knowledge about the containers.
	 *		  If access is denied to a subset of objects, the handles to those objects are set to 0.
	 */
public ClientInfo[] get_client_info(int id, int[] h, String name_wc) throws NoPermissionEx {
    pendingRequests.incrementAndGet();
    try {
        // invalid info (replacement for null)
        final ClientInfo invalidInfo = new ClientInfo(0, null, new int[0], "<invalid>", 0);
        // returned value
        ClientInfo[] retVal = null;
        // transform to CORBA specific
        com.cosylab.acs.maci.ClientInfo[] infos = manager.getClientInfo(id, h, name_wc);
        if (infos != null) {
            retVal = new ClientInfo[infos.length];
            for (int i = 0; i < infos.length; i++) if (infos[i] == null)
                retVal[i] = invalidInfo;
            else
                retVal[i] = new ClientInfo(infos[i].getHandle(), ((ClientProxy) infos[i].getClient()).getClient(), infos[i].getComponents().toArray(), infos[i].getName(), mapAccessRights(infos[i].getAccessRights()));
        } else
            retVal = new ClientInfo[0];
        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();
    }
}
Also used : BAD_PARAM(org.omg.CORBA.BAD_PARAM) BadParametersException(com.cosylab.acs.maci.BadParametersException) NoResourcesException(com.cosylab.acs.maci.NoResourcesException) AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) CoreException(com.cosylab.acs.maci.CoreException) ClientInfo(si.ijs.maci.ClientInfo) UNKNOWN(org.omg.CORBA.UNKNOWN) NO_RESOURCES(org.omg.CORBA.NO_RESOURCES)

Example 18 with ClientInfo

use of si.ijs.maci.ClientInfo in project ACS by ACS-Community.

the class BlockingPingClient method execute.

/**
	 * Main  routine.
	 */
public void execute(long sleepTimeMs) {
    initializeCORBA();
    Manager manager = resolveManager();
    if (manager != null) {
        ClientInfo clientInfo = login(manager, sleepTimeMs);
        if (clientInfo != null) {
            System.out.println("All initialization done.");
            run();
            logout(manager, clientInfo);
        }
    }
    finalizeCORBA();
}
Also used : ClientInfo(si.ijs.maci.ClientInfo) POAManager(org.omg.PortableServer.POAManager) Manager(si.ijs.maci.Manager)

Example 19 with ClientInfo

use of si.ijs.maci.ClientInfo in project ACS by ACS-Community.

the class ManagerDynComponentTest method test.

/**
	 * Main test routine.
	 */
public void test() {
    initializeCORBA();
    Manager manager = resolveManager();
    if (manager != null) {
        ClientInfo clientInfo = login(manager);
        if (clientInfo != null) {
            System.out.println("All initialization done.");
            try {
                /* ------------------------------------------------- */
                manager.restart_component(clientInfo.h, "invalid");
                manager.get_component(clientInfo.h, "MOUNT1", true);
                manager.restart_component(clientInfo.h, "MOUNT1");
                try {
                    manager.get_default_component(clientInfo.h, "invalid");
                    System.err.println("NoDefaultComponent exception expected.");
                } catch (NoDefaultComponentEx nde) {
                // this is OK
                }
                try {
                    manager.get_dynamic_component(clientInfo.h, new ComponentSpec("*", "invalidType", "*", "*"), true);
                    System.err.println("InvalidComponentSpec exception expected.");
                } catch (InvalidComponentSpecEx ics) {
                // this is OK
                }
                /* ------------------------------------------------- */
                ComponentInfo componentInfo = manager.get_dynamic_component(clientInfo.h, new ComponentSpec("FULL_DYNAMIC", "IDL:alma/PS/PowerSupply:1.0", "acsexmplPS", "Container"), true);
                System.out.println(componentInfo.h);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
            logout(manager, clientInfo);
        }
    }
    finalizeCORBA();
}
Also used : InvalidComponentSpecEx(alma.maciErrType.InvalidComponentSpecEx) ClientInfo(si.ijs.maci.ClientInfo) ComponentInfo(si.ijs.maci.ComponentInfo) POAManager(org.omg.PortableServer.POAManager) Manager(si.ijs.maci.Manager) ComponentSpec(si.ijs.maci.ComponentSpec) NoDefaultComponentEx(alma.maciErrType.NoDefaultComponentEx)

Example 20 with ClientInfo

use of si.ijs.maci.ClientInfo in project ACS by ACS-Community.

the class DeploymentTree method showContextMenu.

/**
	 * @param evt
	 */
protected void showContextMenu(MouseEvent evt) {
    TreePath targetPath = this.getClosestPathForLocation(evt.getX(), evt.getY());
    if (targetPath == null) {
        // clicked into a totally empty tree (no manager shown): ignore click.
        return;
    }
    setSelectionPath(targetPath);
    if (targetPath.getPathCount() == 1) {
        // that has no function besides looking good
        return;
    }
    // the supervisor (which is in the rootnode) for this subtree
    selectedSupervisor = maciSupervisor(((SortingTreeNode) targetPath.getPathComponent(1)));
    // the node the mouse was clicked on
    target = (SortingTreeNode) targetPath.getLastPathComponent();
    Object userObject = target.getUserObject();
    ContextMenu menu;
    if (userObject instanceof IMaciSupervisor) {
        menu = managerContextMenu;
    } else if (userObject instanceof ContainerInfo) {
        menu = containerContextMenu;
    } else if (userObject instanceof ClientInfo) {
        menu = clientContextMenu;
    } else if (userObject instanceof ComponentInfo) {
        menu = componentContextMenu;
    } else if (userObject instanceof FolderInfo) {
        menu = folderContextMenu;
    } else if (userObject instanceof InfoDetail) {
        // msc 2012-06: help user navigate in large datasets (cf. COMP-3684)
        // this menu is built dynamically from rather expensive information.
        menu = new ContextMenu(false);
        int[] selectedHandles = ((SortingTreeNode) target).representedHandles;
        if (selectedHandles.length > 0) {
            menu.add(new JLabel(" Scroll to ..."));
            menu.add(new JSeparator(JSeparator.HORIZONTAL));
            SortingTreeNode mgrNode = (SortingTreeNode) target.getPath()[1];
            List<Object> list = new ArrayList<Object>();
            list.add(mgrNode);
            for (SortingTreeNode top : mgrNode.childrens()) list.addAll(Collections.list(top.children()));
            for (Object obj : list) {
                final SortingTreeNode elem = (SortingTreeNode) obj;
                for (int i = 0; i < selectedHandles.length; i++) {
                    if (elem.represents(selectedHandles[i])) {
                        Object elemUserObject = elem.getUserObject();
                        String elemName = null;
                        if (elemUserObject instanceof ComponentInfo)
                            elemName = ((ComponentInfo) elemUserObject).name;
                        else if (elemUserObject instanceof ContainerInfo)
                            elemName = ((ContainerInfo) elemUserObject).name;
                        else if (elemUserObject instanceof ClientInfo)
                            elemName = ((ClientInfo) elemUserObject).name;
                        else if (elemUserObject instanceof MaciSupervisor)
                            elemName = "Manager";
                        if (elemName != null) {
                            menu.add(new AbstractAction(selectedHandles[i] + " = " + elemName) {

                                @Override
                                public void actionPerformed(ActionEvent evt) {
                                    DeploymentTree.this.scrollPathToVisible(new TreePath(elem.getPath()));
                                }
                            });
                        }
                    }
                }
            }
        }
    } else {
        return;
    }
    menu.show(this, evt.getX(), evt.getY());
}
Also used : GuiMaciSupervisor(alma.acs.commandcenter.meta.GuiMaciSupervisor) MaciSupervisor(alma.acs.commandcenter.meta.MaciSupervisor) IMaciSupervisor(alma.acs.commandcenter.meta.IMaciSupervisor) SortingTreeNode(alma.acs.commandcenter.meta.MaciInfo.SortingTreeNode) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) InfoDetail(alma.acs.commandcenter.meta.MaciInfo.InfoDetail) FolderInfo(alma.acs.commandcenter.meta.MaciInfo.FolderInfo) JSeparator(javax.swing.JSeparator) TreePath(javax.swing.tree.TreePath) ContainerInfo(si.ijs.maci.ContainerInfo) List(java.util.List) ArrayList(java.util.ArrayList) ClientInfo(si.ijs.maci.ClientInfo) ComponentInfo(si.ijs.maci.ComponentInfo) AbstractAction(javax.swing.AbstractAction) IMaciSupervisor(alma.acs.commandcenter.meta.IMaciSupervisor)

Aggregations

ClientInfo (si.ijs.maci.ClientInfo)24 ComponentInfo (si.ijs.maci.ComponentInfo)9 ContainerInfo (si.ijs.maci.ContainerInfo)8 Client (si.ijs.maci.Client)6 Manager (si.ijs.maci.Manager)6 POAManager (org.omg.PortableServer.POAManager)5 CBDescIn (alma.ACS.CBDescIn)2 CompletionHolder (alma.ACSErr.CompletionHolder)2 IMaciSupervisor (alma.acs.commandcenter.meta.IMaciSupervisor)2 NoPermissionEx (alma.maciErrType.NoPermissionEx)2 AcsJNoPermissionEx (alma.maciErrType.wrappers.AcsJNoPermissionEx)2 BadParametersException (com.cosylab.acs.maci.BadParametersException)2 CoreException (com.cosylab.acs.maci.CoreException)2 NoResourcesException (com.cosylab.acs.maci.NoResourcesException)2 Monitor (alma.ACS.Monitor)1 MonitorstringSeq (alma.ACS.MonitorstringSeq)1 ROstring (alma.ACS.ROstring)1 ROstringSeq (alma.ACS.ROstringSeq)1 AcsJContainerEx (alma.JavaContainerError.wrappers.AcsJContainerEx)1 OrbInitException (alma.acs.commandcenter.meta.Firestarter.OrbInitException)1