Package org.rhq.enterprise.server.inventory

Examples of org.rhq.enterprise.server.inventory.InventoryManagerLocal


    }

    @Test(dependsOnMethods = { "deletePlugins" })
    public void isPluginReadyForPurge() throws Exception {
        ResourceTypeManagerLocal resourceTypeManager = LookupUtil.getResourceTypeManager();
        InventoryManagerLocal inventoryManager = LookupUtil.getInventoryManager();

        Plugin plugin = getDeletedPlugin(PLUGIN_1);
        if (plugin == null) {
            //ok so there's no delete plugin like that. Let's check that there's no installed plugin either
            plugin = pluginMgr.getPlugin(PLUGIN_1);
            if (plugin != null) {
                fail(PLUGIN_1 + "should have been deleted in PluginManagerBeanTest#deletePlugins()");
            }

            //So there's no such plugin at all. This means that some other test intertwined between this test and
            //deletePlugins.
            //
            //Because tests are configured to clean up after themselves (mainly in the afterClassWork() method)
            //it may happen that the plugin we marked for deletion in deletePlugins has actually been deleted
            //by the clean up methods.
            //
            //The point of this test is in that case fulfilled anyway because by the plugin disappearing,
            //we proved that at some point in time between deletePlugins and this test it was indeed purgeable.
            return;
        }

        List<ResourceType> resourceTypes = resourceTypeManager.getResourceTypesByPlugin(plugin.getName());
        List<ResourceType> deletedTypes = inventoryManager.getDeletedTypes();

        boolean resourceTypesPurged = resourceTypes.isEmpty() && deletedTypes.isEmpty();

        //ack the plugins as deleted so that the only remaining condition for their
        //purge-ability is the disappearance of their resource types.
View Full Code Here


    @Test(dependsOnMethods = { "registerPlugins", "isPluginReadyForPurge" })
    public void pluginPurgeCheckShouldUseExactMatchesInQuery() throws Exception {
        // See https://bugzilla.redhat.com/show_bug.cgi?id=845700 for details on this test

        InventoryManagerLocal inventoryManager = LookupUtil.getInventoryManager();
        ResourceTypeManagerLocal resourceTypeManager = LookupUtil.getResourceTypeManager();

        Plugin plugin3 = getPlugin(PLUGIN_3);
        ResourceType resourceType = resourceTypeManager
            .getResourceTypeByNameAndPlugin("TestServer3", plugin3.getName());
        ResourceType resourceTypeIgnored = resourceTypeManager.getResourceTypeByNameAndPlugin("TestServer3Ignored",
            plugin3.getName());

        assertNotNull("Failed to find resource type. Did the resource type name in the plugin descriptor change?",
            resourceType);
        assertNotNull("Failed to find ignored resource type. Did the type name in the plugin descriptor change?",
            resourceTypeIgnored);

        pluginMgr.deletePlugins(subjectMgr.getOverlord(), asList(plugin3.getId()));
        inventoryManager.purgeDeletedResourceType(resourceType);
        inventoryManager.purgeDeletedResourceType(resourceTypeIgnored);

        ackDeletedPlugins();

        assertTrue("Expected " + plugin3 + " to be ready for purge since all its resource types have been purged "
            + "and the servers acked its deletion", pluginMgr.isReadyForPurge(plugin3));
View Full Code Here

        }
    }

    @Override
    public void executeJobCode(JobExecutionContext context) throws JobExecutionException {
        InventoryManagerLocal inventoryMgr = LookupUtil.getInventoryManager();
        DeletionStats stats = new DeletionStats();

        long startTotalTime = System.currentTimeMillis();
        List<ResourceType> deletedTypes = inventoryMgr.getDeletedTypes();
        for (ResourceType deletedType : deletedTypes) {
            if (inventoryMgr.isReadyForPermanentRemoval(deletedType)) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Permanently removing " + deletedType);
                }
                long startTime = System.currentTimeMillis();
                inventoryMgr.purgeDeletedResourceType(deletedType);
                long endTime = System.currentTimeMillis();
                stats.numDeleted++;
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Deleted " + deletedType + " in " + (endTime - startTime) + " ms");
                }
View Full Code Here

TOP

Related Classes of org.rhq.enterprise.server.inventory.InventoryManagerLocal

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.