Examples of InventoryReport


Examples of org.rhq.core.clientapi.server.discovery.InventoryReport

            // TODO (ips, 05/16/12): Shouldn't we throw an exception here??
            if (log.isDebugEnabled()) {
                log.debug("No resource container for Resource with id [" + resourceId
                    + "] found - not performing a child service scan.");
            }
            return new InventoryReport(agent);
        }
        Resource resource = resourceContainer.getResource();
        RuntimeDiscoveryExecutor oneTimeExecutor = new RuntimeDiscoveryExecutor(this, configuration, resource);

        if (log.isDebugEnabled()) {
View Full Code Here

Examples of org.rhq.core.clientapi.server.discovery.InventoryReport

            long start = System.currentTimeMillis();

            log.info("Executing the initial inventory synchronization before upgrade.");

            boolean syncResult = handleReport(new InventoryReport(getAgent()));
            if (!syncResult) {
                log.warn("Failed to sync up the inventory with the server. The resource upgrade will be disabled.");
            }

            log.info("Starting to activate (and upgrade) resources.");
View Full Code Here

Examples of org.rhq.core.clientapi.server.discovery.InventoryReport

    @NotNull
    public InventoryReport call() {
        String target = (rootResource != null) ? this.rootResource.toString() : "platform";
        log.info("Executing runtime discovery scan rooted at [" + target + "]...");
        InventoryReport report = new InventoryReport(inventoryManager.getAgent());

        try {
            report.setRuntimeReport(true);
            report.setStartTime(System.currentTimeMillis());
            runtimeDiscover(report);
            report.setEndTime(System.currentTimeMillis());
            if (log.isDebugEnabled()) {
                log.debug(String.format("Runtime discovery scan took %d ms.",
                    (report.getEndTime() - report.getStartTime())));
            }
            // TODO: This is always zero for embedded because we don't populate the report.
            int numAddedRoots = report.getAddedRoots().size();
            int numNewDescendants = (report.getResourceCount() - numAddedRoots);
            log.info("Scanned " + target + " and " + numAddedRoots + " server(s) and discovered " + numNewDescendants
                + " new descendant Resource(s).");
            // TODO GH: This is principally valuable only until we work out the last of the data transfer situations.
            if (log.isTraceEnabled()) {
                ByteArrayOutputStream baos = new ByteArrayOutputStream(10000);
                ObjectOutputStream oos = new ObjectOutputStream(baos);
                oos.writeObject(report);
                log.trace("Runtime report contains " + report.getResourceCount() + " Resources with a size of "
                    + baos.size() + " bytes");
            }

            // If no child resources were discovered then don't send the empty report. This avoids some
            // major overhead in that each each report sent triggers a full inventory sync.
            if (numNewDescendants > 0) {
                this.inventoryManager.handleReport(report);
            } else {
                log.info("Not sending inventory report because no new descendent resources were discovered.");
            }
        } catch (Exception e) {
            log.warn("Exception caught while executing runtime discovery scan rooted at [" + target + "].", e);
            report.addError(new ExceptionPackage(Severity.Warning, e));
        }

        return report;
    }
View Full Code Here

Examples of org.rhq.core.clientapi.server.discovery.InventoryReport

        }
    }
   
    private void runDiscovery(RunDiscovery annotation, PluginContainer pluginContainer) {       
        if (annotation.discoverServers()) {
            InventoryReport serverScanReport = pluginContainer.getInventoryManager().executeServerScanImmediately();
            if (!serverScanReport.getErrors().isEmpty()) {
                throw new RuntimeException("Errors occurred during server scan: " + serverScanReport.getErrors());
            }
        }
        if (annotation.discoverServices()) {
            InventoryReport serviceScanReport = pluginContainer.getInventoryManager().executeServiceScanImmediately();
            if (!serviceScanReport.getErrors().isEmpty()) {
                throw new RuntimeException("Errors occurred during service scan: " + serviceScanReport.getErrors());
            }
        }
    }
View Full Code Here

Examples of org.rhq.core.clientapi.server.discovery.InventoryReport

        pluginMgr = context.mock(PluginManagerLocal.class);
    }

    @Test
    public void acceptReportWithNoDeletedTypes() {
        InventoryReport report = createReport();
        report.addAddedRoot(new ResourceBuilder()
            .createRandomServer()
            .with(2).randomChildServices()
            .build());
        report.addAddedRoot(new ResourceBuilder()
            .createRandomService()
            .with(2).randomChildServices()
            .build());

        final List<Plugin> plugins = new ArrayList<Plugin>(getPluginsInReport(report.getAddedRoots()));

        context.checking(new Expectations() {{
            allowing(subjectMgr).getOverlord();
            will(returnValue(new Subject("overlord", true, true)));
View Full Code Here

Examples of org.rhq.core.clientapi.server.discovery.InventoryReport

            .build();

        final PageList<ResourceType> deletedTypes = new PageList<ResourceType>();
        deletedTypes.add(deletedServiceType);

        InventoryReport report = createReport();
        report.addAddedRoot(new ResourceBuilder()
            .createRandomServer()
            .withChildService()
                .withName("ChildService")
                .withUuid("c1")
                .withResourceType(new ResourceTypeBuilder()
                    .createServiceResourceType()
                    .withName("TestService")
                    .withPlugin("TestPlugin")
                    .build())
                .included()
            .build());

        final List<Plugin> plugins = new ArrayList<Plugin>(getPluginsInReport(report.getAddedRoots()));

        context.checking(new Expectations() {{
            allowing(subjectMgr).getOverlord();
            will(returnValue(new Subject("overlord", true, true)));
View Full Code Here

Examples of org.rhq.core.clientapi.server.discovery.InventoryReport

            "deleted resource types");
    }

    @Test
    public void rejectReportWithPluginThatIsNotInstalled() {
        InventoryReport report = createReport();
        report.addAddedRoot(new ResourceBuilder()
            .createRandomServer()
            .with(2).randomChildServices()
            .build());
        report.addAddedRoot(new ResourceBuilder()
            .createRandomService()
            .withResourceType(new ResourceTypeBuilder()
                .createServerResourceType()
                .withName("StaleServer")
                .withPlugin("DeletedPlugin")
                .build())
            .with(2).randomChildServices()
            .build());

        List<Plugin> plugins = new ArrayList<Plugin>(getPluginsInReport(report.getAddedRoots()));
        final List<Plugin> installedPlugins = removePlugins(plugins, "DeletedPlugin");

        context.checking(new Expectations() {{
            allowing(subjectMgr).getOverlord();
            will(returnValue(new Subject("overlord", true, true)));
View Full Code Here

Examples of org.rhq.core.clientapi.server.discovery.InventoryReport

            "plugin but empty set was returned");
    }

    InventoryReport createReport() {
        Agent agent = new Agent("localhost", "localhost", 1234, "1234", "test-token");
        return new InventoryReport(agent);
    }
View Full Code Here

Examples of org.rhq.core.clientapi.server.discovery.InventoryReport

    }

    @NotNull
    public InventoryReport call() {
        log.info("Executing server discovery scan...");
        InventoryReport report = new InventoryReport(inventoryManager.getAgent());

        try {
            report.setStartTime(System.currentTimeMillis());
            if ((autoDiscoveryRequest == null)
                || autoDiscoveryRequest.getScanTypes().contains(AutoDiscoveryScanType.Plugin)) {
                List<ProcessInfo> processInfos = getProcessInfos();
                pluginDiscovery(report, processInfos);
            }
            report.setEndTime(System.currentTimeMillis());

            if (report.getAddedRoots().size() == 1 &&
                report.getAddedRoots().iterator().next().getResourceType().getCategory() == ResourceCategory.PLATFORM) {
                Resource platform = report.getAddedRoots().iterator().next();
                log.info("Discovered new platform with " + platform.getChildResources().size() + " child server(s).");
            } else {
                log.info("Discovered " + report.getAddedRoots().size() + " new server(s).");
            }

            if (log.isDebugEnabled()) {
                log.debug("Server discovery scan took [" + (report.getEndTime() - report.getStartTime()) + "] ms.");
            }

            // TODO GH: This is principally valuable only until we work out the last of the data transfer situations
            if (log.isTraceEnabled()) {
                ByteArrayOutputStream baos = new ByteArrayOutputStream(10000);
                ObjectOutputStream oos = new ObjectOutputStream(baos);
                oos.writeObject(report);
                log.trace("Server Discovery report for [" + report.getResourceCount() + "] resources with a size of ["
                    + baos.size() + "] bytes");
            }

            inventoryManager.handleReport(report);
        } catch (Exception e) {
            log.warn("Exception caught while executing server discovery scan.", e);
            report.addError(new ExceptionPackage(Severity.Warning, e));
        }

        return report;
    }
View Full Code Here

Examples of org.rhq.core.clientapi.server.discovery.InventoryReport

        final InventoryStatus requiredInventoryStatus) {
        return new Answer<MergeInventoryReportResults>() {
            @Override
            public MergeInventoryReportResults answer(InvocationOnMock invocation) throws Throwable {
                synchronized (FakeServerInventory.this) {
                    InventoryReport inventoryReport = (InventoryReport) invocation.getArguments()[0];

                    try {
                        throwIfFailing();

                        for (Resource res : inventoryReport.getAddedRoots()) {
                            Resource persisted = fakePersist(res, requiredInventoryStatus, new HashSet<String>());

                            if (res.getParentResource() == Resource.ROOT) {
                                platform = persisted;
                            }
                        }

                        return new MergeInventoryReportResults(getPlatformSyncInfo(), null);
                    } finally {
                        if (discoveryChecker != null && !inventoryReport.getAddedRoots().isEmpty()) {
                            discoveryChecker.setDepth(getResourceTreeDepth());
                        }
                    }
                }
            }
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.