Search in sources :

Example 1 with ContainerInfo

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

the class MaciSupervisorTest method setUp.

@Override
public void setUp() throws Exception {
    System.out.println("\n--- " + getName() + " ----------------");
    // make the manager
    // -----------------------------------------------------------------
    orb = Mockito.mock(ORB.class);
    manager = Mockito.mock(Manager.class);
    administrator = Mockito.mock(Administrator.class);
    final int hhhhh = 0;
    final int[] empty = new int[] {};
    ComponentInfo comp100 = new ComponentInfo("type", "code", null, "comp100", empty, 10, "cont10", 100, 0, new String[] {});
    ComponentInfo comp200 = new ComponentInfo("type", "code", null, "comp200", empty, 20, "cont20", 200, 0, new String[] {});
    ComponentInfo comp300 = new ComponentInfo("type", "code", null, "comp300", empty, 30, "cont30", 300, 0, new String[] {});
    ComponentInfo[] one_comp = { comp100 };
    ComponentInfo[] two_comps = { comp100, comp200 };
    ComponentInfo[] three_comps = { comp100, comp200, comp300 };
    ContainerInfo cont10 = new ContainerInfo("cont10", 10, null, empty);
    ContainerInfo cont20 = new ContainerInfo("cont20", 20, null, empty);
    ContainerInfo cont30 = new ContainerInfo("cont30", 30, null, empty);
    ContainerInfo[] one_cont = { cont10 };
    ContainerInfo[] two_conts = { cont10, cont20 };
    ContainerInfo[] three_conts = { cont10, cont20, cont30 };
    ClientInfo clientA = new ClientInfo(0, null, empty, "clientA", 0);
    ClientInfo client1 = new ClientInfo(1, null, empty, "client1", 0);
    ClientInfo client2 = new ClientInfo(2, null, empty, "client2", 0);
    ClientInfo client3 = new ClientInfo(3, null, empty, "client3", 0);
    ClientInfo[] one_client = { client1 };
    ClientInfo[] two_clients = { client1, client2 };
    ClientInfo[] three_clients = { client1, client2, client3 };
    Mockito.when(orb.string_to_object("dummy")).thenReturn(manager);
    Mockito.when(manager.login(administrator)).thenReturn(clientA);
    Mockito.when(manager.get_component_info(hhhhh, empty, "*", "*", false)).thenReturn(one_comp, two_comps, three_comps);
    Mockito.when(manager.get_container_info(hhhhh, empty, "*")).thenReturn(one_cont, one_cont, two_conts, three_conts);
    Mockito.when(manager.get_client_info(hhhhh, empty, "*")).thenReturn(one_client, two_clients, three_clients, two_clients, three_clients);
    // make the supervisor
    // -----------------------------------------------------------------
    log = new Logger("Test", null) {

        final long start = System.nanoTime();

        @Override
        public void log(LogRecord r) {
            long sinceStart = (System.nanoTime() - start) / 1000 / 1000 / 1000;
            System.out.println(String.format("%2d", sinceStart) + "  " + r.getLevel() + "  " + r.getMessage());
        }
    };
    log.setLevel(Level.FINE);
    testee = new MaciSupervisor("Test", "dummy", orb, log);
    testee.acImpl = testee.new AdministratorImplementation() {

        @Override
        protected Administrator asCorbaObject(ORB orb) {
            return administrator;
        }
    };
    testee.start();
    // assertions
    // ----------------------------------------------------------------
    maciListener = new MaciInfoListener();
    MaciInfo maciInformation = testee.getMaciInformation();
    maciInformation.addTreeModelListener(maciListener);
}
Also used : Manager(si.ijs.maci.Manager) Logger(java.util.logging.Logger) Administrator(si.ijs.maci.Administrator) LogRecord(java.util.logging.LogRecord) ContainerInfo(si.ijs.maci.ContainerInfo) ComponentInfo(si.ijs.maci.ComponentInfo) ClientInfo(si.ijs.maci.ClientInfo) ORB(org.omg.CORBA.ORB)

Example 2 with ContainerInfo

use of si.ijs.maci.ContainerInfo 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());
}
Also used : ManagerImpl(com.cosylab.acs.maci.manager.ManagerImpl) ContainerInfo(si.ijs.maci.ContainerInfo) HandleDataStore(com.cosylab.acs.maci.manager.HandleDataStore) ComponentInfo(si.ijs.maci.ComponentInfo) ClientInfo(si.ijs.maci.ClientInfo) File(java.io.File) FileInputStream(java.io.FileInputStream) ObjectInputStream(java.io.ObjectInputStream)

Example 3 with ContainerInfo

use of si.ijs.maci.ContainerInfo 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);
        }
    }
}
Also used : TRANSIENT(org.omg.CORBA.TRANSIENT) ContainerInfo(si.ijs.maci.ContainerInfo) NoPermissionEx(alma.maciErrType.NoPermissionEx) OBJECT_NOT_EXIST(org.omg.CORBA.OBJECT_NOT_EXIST) ComponentInfo(si.ijs.maci.ComponentInfo) ClientInfo(si.ijs.maci.ClientInfo)

Example 4 with ContainerInfo

use of si.ijs.maci.ContainerInfo 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;
}
Also used : ContainerInfo(si.ijs.maci.ContainerInfo) ClientInfo(si.ijs.maci.ClientInfo) ComponentInfo(si.ijs.maci.ComponentInfo)

Example 5 with ContainerInfo

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

the class ManagerProxyImpl method get_container_info.

/**
	 * Get all the information that the Manager has about its known Containers.
	 * 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 containers whose information is requested. If this is an empty sequence, the name_wc parameter is used.
	 * @param name_wc Wildcard that the container's name must match in order for its information to be returned.
	 * @return A sequence of ContainerInfo 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 ContainerInfo[] get_container_info(int id, int[] h, String name_wc) throws NoPermissionEx {
    pendingRequests.incrementAndGet();
    try {
        // invalid info (replacement for null)
        final ContainerInfo invalidInfo = new ContainerInfo("<invalid>", 0, null, new int[0]);
        // returned value
        ContainerInfo[] retVal = null;
        // transform to CORBA specific
        com.cosylab.acs.maci.ContainerInfo[] infos = manager.getContainerInfo(id, h, name_wc);
        if (infos != null) {
            retVal = new ContainerInfo[infos.length];
            for (int i = 0; i < infos.length; i++) if (infos[i] == null)
                retVal[i] = invalidInfo;
            else
                retVal[i] = new ContainerInfo(infos[i].getName(), infos[i].getHandle(), (Container) ((ContainerProxy) infos[i].getContainer()).getClient(), infos[i].getComponents().toArray());
        } else
            retVal = new ContainerInfo[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) Container(si.ijs.maci.Container) AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) CoreException(com.cosylab.acs.maci.CoreException) ContainerInfo(si.ijs.maci.ContainerInfo) UNKNOWN(org.omg.CORBA.UNKNOWN) NO_RESOURCES(org.omg.CORBA.NO_RESOURCES)

Aggregations

ContainerInfo (si.ijs.maci.ContainerInfo)11 ClientInfo (si.ijs.maci.ClientInfo)8 ComponentInfo (si.ijs.maci.ComponentInfo)8 Manager (si.ijs.maci.Manager)3 LoggingConfigurableOperations (alma.Logging.LoggingConfigurableOperations)1 GuiMaciSupervisor (alma.acs.commandcenter.meta.GuiMaciSupervisor)1 IMaciSupervisor (alma.acs.commandcenter.meta.IMaciSupervisor)1 FolderInfo (alma.acs.commandcenter.meta.MaciInfo.FolderInfo)1 InfoDetail (alma.acs.commandcenter.meta.MaciInfo.InfoDetail)1 SortingTreeNode (alma.acs.commandcenter.meta.MaciInfo.SortingTreeNode)1 MaciSupervisor (alma.acs.commandcenter.meta.MaciSupervisor)1 LogPaneNotFoundException (alma.acs.gui.loglevel.LogPaneNotFoundException)1 LogLevelSelectorPanel (alma.acs.gui.loglevel.leveldlg.LogLevelSelectorPanel)1 TreeContainerInfo (alma.acs.gui.loglevel.tree.node.TreeContainerInfo)1 ClientLogManager (alma.acs.logging.ClientLogManager)1 NoPermissionEx (alma.maciErrType.NoPermissionEx)1 AcsJNoPermissionEx (alma.maciErrType.wrappers.AcsJNoPermissionEx)1 BadParametersException (com.cosylab.acs.maci.BadParametersException)1 CoreException (com.cosylab.acs.maci.CoreException)1 NoResourcesException (com.cosylab.acs.maci.NoResourcesException)1