Examples of MergeInventoryReportResults


Examples of org.rhq.core.domain.discovery.MergeInventoryReportResults

        service1.setUuid(String.valueOf(new Random().nextInt()));
        service2.setUuid(String.valueOf(new Random().nextInt()));

        inventoryReport.addAddedRoot(platform);

        MergeInventoryReportResults results = discoveryBoss.mergeInventoryReport(serialize(inventoryReport));
        assert results != null;
        assert checkIgnoredTypes(results) : "nothing should have been ignored in this test";
        assertNotNull(results.getPlatformSyncInfo());
    }
View Full Code Here

Examples of org.rhq.core.domain.discovery.MergeInventoryReportResults

        // First just submit the platform
        InventoryReport inventoryReport = new InventoryReport(agent);
        Resource platform = new Resource(prefix("alpha"), prefix("platform"), platformType);
        platform.setUuid(String.valueOf(new Random().nextInt()));
        inventoryReport.addAddedRoot(platform);
        MergeInventoryReportResults results = discoveryBoss.mergeInventoryReport(serialize(inventoryReport));
        assert results != null;
        assert checkIgnoredTypes(results) : "nothing should have been ignored in this test";
        assertNotNull(results.getPlatformSyncInfo());
        Collection<ResourceSyncInfo> syncInfos = discoveryBoss.getResourceSyncInfo(results.getPlatformSyncInfo()
            .getPlatform().getId());
        assert syncInfos != null;
        assert !syncInfos.isEmpty();

        platform.setId(results.getPlatformSyncInfo().getPlatform().getId());

        // Now submit the server and its children as an update report
        inventoryReport = new InventoryReport(agent);
        Resource server = new Resource(prefix("bravo"), prefix("server"), serverType);
        platform.addChildResource(server);
        Resource service1 = new Resource(prefix("charlie"), prefix("service 1"), serviceType1);
        Resource service2 = new Resource(prefix("delta"), prefix("service 2"), serviceType2);
        server.addChildResource(service1);
        server.addChildResource(service2);

        server.setUuid(String.valueOf(new Random().nextInt()));
        service1.setUuid(String.valueOf(new Random().nextInt()));
        service2.setUuid(String.valueOf(new Random().nextInt()));

        inventoryReport.addAddedRoot(server);

        results = discoveryBoss.mergeInventoryReport(serialize(inventoryReport));
        assert results != null;
        assert checkIgnoredTypes(results) : "nothing should have been ignored in this test";
        assertNotNull(results.getPlatformSyncInfo());
    }
View Full Code Here

Examples of org.rhq.core.domain.discovery.MergeInventoryReportResults

        server.setUuid(String.valueOf(new Random().nextInt()));
        service2.setUuid(String.valueOf(new Random().nextInt()));

        inventoryReport.addAddedRoot(platform);

        MergeInventoryReportResults results = discoveryBoss.mergeInventoryReport(serialize(inventoryReport));
        assert results != null;
        assert checkIgnoredTypes(results) : "nothing should have been ignored in this test";
        assertNotNull(results.getPlatformSyncInfo());
        assertNotNull(results.getPlatformSyncInfo().getTopLevelServerIds());
        assertTrue(!results.getPlatformSyncInfo().getTopLevelServerIds().isEmpty());
        Integer resourceId = results.getPlatformSyncInfo().getTopLevelServerIds().iterator().next();
        Collection<ResourceSyncInfo> syncInfos = discoveryBoss.getResourceSyncInfo(resourceId);
        assert syncInfos != null;
        assert !syncInfos.isEmpty();

        Resource resource1 = discoveryBoss.manuallyAddResource(subjectManager.getOverlord(), serviceType2.getId(),
View Full Code Here

Examples of org.rhq.core.domain.discovery.MergeInventoryReportResults

        }

        inventoryReport.addAddedRoot(platform);

        // Merge this inventory report
        MergeInventoryReportResults mergeResults = discoveryBoss.mergeInventoryReport(serialize(inventoryReport));
        assert mergeResults != null;
        assert checkIgnoredTypes(mergeResults) : "nothing should have been ignored: "
            + mergeResults.getIgnoredResourceTypes();
        PlatformSyncInfo platformSyncInfo = mergeResults.getPlatformSyncInfo();
        assert platformSyncInfo != null;

        // Check merge result
        assertEquals(InventoryStatus.NEW, platformSyncInfo.getPlatform().getInventoryStatus());
        assertEquals(platform.getChildResources().size(), platformSyncInfo.getTopLevelServerIds().size());
View Full Code Here

Examples of org.rhq.core.domain.discovery.MergeInventoryReportResults

        server.setUuid(String.valueOf(new Random().nextInt()));
        platform.addChildResource(server);
        inventoryReport.addAddedRoot(platform);

        // Merge this inventory report
        MergeInventoryReportResults mergeResults = discoveryBoss.mergeInventoryReport(serialize(inventoryReport));
        assert mergeResults != null;
        PlatformSyncInfo platformSyncInfo = mergeResults.getPlatformSyncInfo();
        assert platformSyncInfo != null;
        assertNotNull(mergeResults.getIgnoredResourceTypes());
        assert checkIgnoredTypes(mergeResults, 1) : "expected one ignored type";
        assert mergeResults.getIgnoredResourceTypes().contains(new ResourceTypeFlyweight(serverType));

        // Check merge result - make sure we should not see any children under the platform (it should have been ignored)
        assertEquals(InventoryStatus.NEW, platformSyncInfo.getPlatform().getInventoryStatus());
        assertEquals(platformSyncInfo.getTopLevelServerIds().size(), 0);
    }
View Full Code Here

Examples of org.rhq.core.domain.discovery.MergeInventoryReportResults

        server.setUuid(String.valueOf(new Random().nextInt()));
        platform.addChildResource(server);
        inventoryReport.addAddedRoot(platform);

        // Merge this inventory report
        MergeInventoryReportResults mergeResults = discoveryBoss.mergeInventoryReport(serialize(inventoryReport));
        assert mergeResults != null;
        PlatformSyncInfo platformSyncInfo = mergeResults.getPlatformSyncInfo();
        assert platformSyncInfo != null;

        // now see that we were told about the service types being ignored (even though we had no resources of that type in the report)
        Collection<ResourceTypeFlyweight> ignoredResourceTypes = mergeResults.getIgnoredResourceTypes();
        assertNotNull(ignoredResourceTypes);
        assert checkIgnoredTypes(mergeResults, 2) : "expected two ignored types";
        assert ignoredResourceTypes.contains(new ResourceTypeFlyweight(serviceType1));
        assert ignoredResourceTypes.contains(new ResourceTypeFlyweight(serviceType2));
    }
View Full Code Here

Examples of org.rhq.core.domain.discovery.MergeInventoryReportResults

            platform.addChildResource(server);
        }
        inventoryReport.addAddedRoot(platform);

        // Merge this inventory report to get platform and servers in NEW state
        MergeInventoryReportResults mergeResults = discoveryBoss.mergeInventoryReport(serialize(inventoryReport));
        assert mergeResults != null;
        assert checkIgnoredTypes(mergeResults) : "nothing should have been ignored: "
            + mergeResults.getIgnoredResourceTypes();
        PlatformSyncInfo platformSyncInfo = mergeResults.getPlatformSyncInfo();
        assert platformSyncInfo != null;

        // Collect the resource ids generated for the platform and the servers
        int platformId = platformSyncInfo.getPlatform().getId();
        List<Integer> serverIds = new LinkedList<Integer>();
        for (Integer serverId : platformSyncInfo.getTopLevelServerIds()) {
            serverIds.add(serverId);
        }
        int[] arrayOfServerIds = ArrayUtils.unwrapCollection(serverIds);

        // Now import platform and servers into inventory
        discoveryBoss.importResources(subjectManager.getOverlord(), new int[] { platformId });
        discoveryBoss.importResources(subjectManager.getOverlord(), arrayOfServerIds);

        // make sure servers are committed into inventory now
        List<Integer> serverTypeIdInList = new ArrayList<Integer>(1);
        serverTypeIdInList.add(serverType.getId());
        PageList<Resource> allServers = resourceManager.findResourceByIds(subjectManager.getOverlord(),
            arrayOfServerIds, false, PageControl.getUnlimitedInstance());
        for (Resource aServer : allServers) {
            assert aServer.getInventoryStatus() == InventoryStatus.COMMITTED : "should be committed: " + aServer;
        }
        assert allServers.getTotalSize() == arrayOfServerIds.length : "all servers were not committed into inventory";

        // now ignore the server type - this should uninventory all servers
        resourceTypeManager.setResourceTypeIgnoreFlagAndUninventoryResources(subjectManager.getOverlord(),
            serverType.getId(), true);

        // make sure all servers were uninventoried
        allServers = resourceManager.findResourceByIds(subjectManager.getOverlord(), arrayOfServerIds, false,
            PageControl.getUnlimitedInstance());
        for (Resource aServer : allServers) {
            assert aServer.getInventoryStatus() != InventoryStatus.COMMITTED : "should not be committed: " + aServer;
        }

        // Merge the inventory report again to simulate another discovery - the servers should be ignored now
        mergeResults = discoveryBoss.mergeInventoryReport(serialize(inventoryReport));
        assert mergeResults != null;
        platformSyncInfo = mergeResults.getPlatformSyncInfo();
        assert platformSyncInfo != null;
        assertNotNull(mergeResults.getIgnoredResourceTypes());
        assert checkIgnoredTypes(mergeResults, 1) : "expected one ignored type";
        assert mergeResults.getIgnoredResourceTypes().contains(new ResourceTypeFlyweight(serverType));

        assertEquals(InventoryStatus.COMMITTED, platformSyncInfo.getPlatform().getInventoryStatus()); // notice platform is committed now
        assertEquals(platformSyncInfo.getTopLevelServerIds().size(), 0); // notice there are no server children now
    }
View Full Code Here

Examples of org.rhq.core.domain.discovery.MergeInventoryReportResults

            .addSimple("storagePort", 7100).addSimple("host", "localhost").build());

        inventoryReport.addAddedRoot(storagePlatform);

        // Merge this inventory report
        MergeInventoryReportResults mergeResults = discoveryBoss.mergeInventoryReport(serialize(inventoryReport));
        assert mergeResults != null;
        assert checkIgnoredTypes(mergeResults) : "nothing should have been ignored: "
            + mergeResults.getIgnoredResourceTypes();
        PlatformSyncInfo platformSyncInfo = mergeResults.getPlatformSyncInfo();
        assert platformSyncInfo != null;

        // Check merge result
        assertEquals(InventoryStatus.COMMITTED, platformSyncInfo.getPlatform().getInventoryStatus());
        assertEquals(storagePlatform.getChildResources().size(), platformSyncInfo.getTopLevelServerIds().size());
View Full Code Here

Examples of org.rhq.core.domain.discovery.MergeInventoryReportResults

        server.setUuid(String.valueOf(new Random().nextInt()));
        platform.addChildResource(server);

        inventoryReport.addAddedRoot(platform);

        MergeInventoryReportResults results = discoveryBoss.mergeInventoryReport(serialize(inventoryReport));
        assertNotNull(results);
        assert checkIgnoredTypes(results) : "nothing should have been ignored in this test "
            + results.getIgnoredResourceTypes();
        final PlatformSyncInfo firstDiscoverySyncInfo = results.getPlatformSyncInfo();
        assertNotNull(firstDiscoverySyncInfo);

        // Then simulate a create resource request
        final String userSuppliedResourceName = prefix("User Supplied Resource Name");
        final String newResourceKey = prefix("Created Resource Key");
        final int serverResourceId = firstDiscoverySyncInfo.getTopLevelServerIds().iterator().next();

        executeInTransaction(false, new TransactionCallback() {
            @Override
            public void execute() throws Exception {
                Resource serverResource = getEntityManager().find(Resource.class, serverResourceId);
                CreateResourceHistory createResourceHistory = new CreateResourceHistory(serverResource, serviceType1,
                    subjectManager.getOverlord().getName(), new Configuration());
                createResourceHistory.setCreatedResourceName(userSuppliedResourceName);
                createResourceHistory.setNewResourceKey(newResourceKey);
                createResourceHistory.setStatus(SUCCESS);
                getEntityManager().persist(createResourceHistory);
                serverResource.addCreateChildResourceHistory(createResourceHistory);
                getEntityManager().flush();
            }
        });

        // Eventually inventory the newly discovered service

        inventoryReport = new InventoryReport(agent);
        Resource service1 = new Resource(newResourceKey, prefix("Plugin Computed Resource Name"), serviceType1);
        service1.setUuid(String.valueOf(new Random().nextInt()));
        server.setId(serverResourceId);
        server.addChildResource(service1);
        inventoryReport.addAddedRoot(server);

        results = discoveryBoss.mergeInventoryReport(serialize(inventoryReport));
        assertNotNull(results);
        assert checkIgnoredTypes(results) : "nothing should have been ignored in this test "
            + results.getIgnoredResourceTypes();
        PlatformSyncInfo secondDiscoverySyncInfo = results.getPlatformSyncInfo();
        assertNotNull(secondDiscoverySyncInfo);

        // Check that the resource ends with the user supplied name in inventory

        Integer toplevelServerId = secondDiscoverySyncInfo.getTopLevelServerIds().iterator().next();
View Full Code Here

Examples of org.rhq.core.domain.discovery.MergeInventoryReportResults

        InventoryReportSerializer.getSingleton().lock(report.getAgent().getName());
        try {
            long start = System.currentTimeMillis();
            DiscoveryBossLocal discoveryBoss = LookupUtil.getDiscoveryBoss();
            MergeInventoryReportResults results;
            try {
                results = discoveryBoss.mergeInventoryReport(report);
            } catch (StaleTypeException e) {
                // There is no need to log this exception as it is part of a normal work flow
                // that occurs as a result of a user deleting a plugin. DiscoveryBossBean
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.