Examples of PluginContainer


Examples of org.rhq.core.pc.PluginContainer

     * @return true if the plugin container needed to be started (i.e. was not running before), false otherwise.
     */
    boolean startPc() {
        LOG.debug("Starting PluginContainer on demand...");
       
        PluginContainer pc = PluginContainer.getInstance();
        if (pc.isStarted()) {
            return false;
        }

        //always refresh the plugin finder so that it reports all the plugins
        //each time (and doesn't remember the plugins from previous PC runs)
        configuration.setPluginFinder(new FileSystemPluginFinder(configuration.getPluginDirectory()));

        if (LOG.isDebugEnabled() && (configuration.getAdditionalPackagesForRootPluginClassLoaderToExclude() != null)) {
            LOG.debug("Using root plugin classloader regex [" + configuration.getRootPluginClassLoaderRegex() + "]...");
        }

        pc.setConfiguration(configuration);
        pc.initialize();
        return true;
    }
View Full Code Here

Examples of org.rhq.core.pc.PluginContainer

     *
     * @return true if PC was running before this call, false otherwise
     */
    boolean stopPc() {
        LOG.debug("Stopping PluginContainer on demand...");
        PluginContainer pc = PluginContainer.getInstance();
        boolean wasStarted = pc.isStarted();
        if (wasStarted) {
            boolean shutdownGracefully = pc.shutdown();
            if (shutdownGracefully) {
                LOG.debug("Stopped PluginContainer gracefully.");
            } else {
                LOG.debug("Stopped PluginContainer.");
            }
View Full Code Here

Examples of org.rhq.core.pc.PluginContainer

     *                               with the server; if 0 or less, this method blocks <b>indefinitely</b>
     *
     * @return <code>true</code> if the plugin container is started, <code>false</code> if it did not start
     */
    public boolean startPluginContainer(final long wait_for_registration) {
        PluginContainer plugin_container = PluginContainer.getInstance();

        if (plugin_container.isStarted()) {
            return true;
        }

        plugin_container.setRebootRequestListener(new RebootRequestListener() {
            public void reboot() {
                try {
                    shutdown();
                } catch (Throwable t) {
                    LOG.error(t, "The plugin container has requested the agent be restarted but the shutdown "
                        + "operation failed.");
                }
                if (isStarted()) {
                    // Pause for a few seconds and try to shut down one more time.
                    try {
                        Thread.sleep(3000);
                        shutdown();
                    } catch (Throwable t) {
                        LOG.error(t, "The plugin container has requested the agent be restarted but the shutdown "
                            + "operation failed again.");
                    }
                }
                if (isStarted()) {
                    // At this point agent shut down failed twice. We can get by with rebooting the plugin container
                    // so we will try that as last ditch effort.

                    LOG.warn("The agent shut down operation has failed twice. Attempting to reboot the plugin "
                        + "container so that stale resource types and deleted plugins are removed.");
                    try {
                        rebootPluginContainer();
                    } catch (Throwable t) {
                        // If rebooting the plugin container fails as well, there is not much else we can do besides
                        // reporting the failures. Manual intervention is needed.
                        LOG.error("The agent could not be shut down and rebooting the plugin container failed. "
                            + "Please check the logs for errors and manually restart the agent as soon as "
                            + "possible.");
                        return;
                    }
                } else {
                    try {
                        cleanDataDirectory();
                    } catch (Throwable t) {
                        LOG.warn(t, "The plugin container has requested the agent be restarted but purging the "
                            + "data directory failed.");
                    }
                    try {
                        start();
                    } catch (Throwable t) {
                        LOG.warn(t, "An error occurred while trying to restart the agent. Attempting restart "
                            + "one more time");
                        try {
                            shutdown();
                            start();
                        } catch (Throwable t1) {
                            LOG.error(t1, "Restarting the agent has failed. Please check the logs for errors and "
                                + "manually restart the agent as soon as possible.");
                            return;
                        }
                    }
                    getAgentRestartCounter().restartedAgent(AgentRestartReason.STALE_INVENTORY);
                }
            }

            private void rebootPluginContainer() throws Throwable {
                PluginContainer pc = PluginContainer.getInstance();

                if (pc.isStarted()) {
                    try {
                        shutdownPluginContainer();
                    } catch (Throwable t) {
                        LOG.error(t, "The plugin container shut down operation failed.");
                        throw t;
View Full Code Here

Examples of org.rhq.core.pc.PluginContainer

                // If the server thinks we are down, we need to do some things to get this agent in sync with the server.
                // Anything we do in here should be very fast.
                boolean serverThinksWeAreDown = results.isDown();
                if (serverThinksWeAreDown) {
                    LOG.warn(AgentI18NResourceKeys.SERVER_THINKS_AGENT_IS_DOWN);
                    PluginContainer plugin_container = PluginContainer.getInstance();
                    if (plugin_container.isStarted()) {
                        // tell the plugin container to send a full avail report up so the server knows we are UP
                        plugin_container.getInventoryManager().requestFullAvailabilityReport();
                    }
                }
            } catch (AgentNotSupportedException anse) {
                throw anse; // bubble this up to the outer try-catch so we can update this agent now
            } catch (Throwable t) {
View Full Code Here

Examples of org.rhq.core.pc.PluginContainer

        if (container == null) {
            throw new IllegalArgumentException("Could not find a PluginContainer called '" + target.getName() + "'");           
        }
       
        try {
            PluginContainer pc = RhqAgentPluginContainer.switchPluginContainer(container.getName());
            pluginContainer.set(pc);
                       
            if (container.getDeployableContainer() instanceof RhqAgentPluginContainer) {
                rhqAgentPluginContainer.set((RhqAgentPluginContainer)container.getDeployableContainer());
            }
View Full Code Here

Examples of org.rhq.core.pc.PluginContainer

    protected void beforeClass() {
        PluginContainerConfiguration config = new PluginContainerConfiguration();
        File dataDir = new File("target/PluginContainerTest");
        dataDir.mkdirs();
        config.setDataDirectory(dataDir);
        PluginContainer pc = PluginContainer.getInstance();
        pc.setConfiguration(config);
        pc.initialize();
    }
View Full Code Here

Examples of org.rhq.core.pc.PluginContainer

        outputInventory(exportWriter, recurseChildren, xml, (ResourceContainer) null);
    }

    public static void outputInventory(PrintWriter exportWriter, boolean recurseChildren, boolean xml,
        ResourceContainer resourceContainer) {
        PluginContainer pc = PluginContainer.getInstance();
        outputInventory(exportWriter, recurseChildren, xml, resourceContainer, 0, pc.getPluginManager(), pc
            .getInventoryManager(), null, null);
        exportWriter.flush();
    }
View Full Code Here

Examples of org.rhq.core.pc.PluginContainer

        exportWriter.flush();
    }

    public static void outputInventory(PrintWriter exportWriter, boolean recurseChildren, boolean xml,
        InventoryFile file) {
        PluginContainer pc = PluginContainer.getInstance();
        outputInventory(exportWriter, recurseChildren, xml, null, 0, pc.getPluginManager(), pc.getInventoryManager(),
            file, null);
        exportWriter.flush();
    }
View Full Code Here

Examples of org.rhq.core.pc.PluginContainer

            PluginContainerTest.startConfiguredPluginContainer();

            configureApacheServerToUseAugeas();

            PluginContainer pc = PluginContainer.getInstance();
            Resource apacheServer = findApacheServerResource().getResource();

            for (int i = 0; i < configurationReadingInvocationCount; ++i) {
                checkApacheServerConfigurationRecursively(apacheServer, pc.getConfigurationManager());
                Thread.sleep(10000);
            }

            //wait a couple of seconds for the loadConfig calls to finish
            Thread.sleep(60000);
View Full Code Here

Examples of org.rhq.core.pc.PluginContainer

        // Speed up propagation of events by adjusting delay/period to 1 second
        PluginContainerConfiguration pcc = new PluginContainerConfiguration();
        pcc.setEventSenderInitialDelay(1);
        pcc.setEventSenderPeriod(1);

        PluginContainer pluginContainer = PluginContainer.getInstance();
        pluginContainer.setConfiguration(pcc);
        pluginContainer.initialize();
        eventManager = pluginContainer.getEventManager();

        Resource resource = new Resource();
        resource.setResourceType(resourceType);
        resource.setUuid(UUID.randomUUID().toString());

        resource.setPluginConfiguration(configuration);
        ResourceComponent parentResourceComponent = null;
        ResourceContext<?> parentResourceContext = null;
        ResourceDiscoveryComponent resourceDiscoveryComponent = new NothingDiscoveringDiscoveryComponent();
        SystemInfo systemInfo = SystemInfoFactory.createSystemInfo();
        File temporaryDirectory = temp;
        File dataDirectory = temp;
        String pluginContainerName = "rhq";
        EventContext eventContext = new EventContextImpl(resource, eventManager);
        OperationContext operationContext = new OperationContextImpl(0);
        ContentContext contentContext = new ContentContextImpl(0);
        PluginContainerDeployment pluginContainerDeployment = null;
        AvailabilityContext availContext = new AvailabilityContextImpl(resource, pluginContainer.getInventoryManager());
        InventoryContext inventoryContext = new InventoryContextImpl(resource, pluginContainer.getInventoryManager());
        ResourceContext context = new ResourceContext(resource, parentResourceComponent, parentResourceContext,
            resourceDiscoveryComponent, systemInfo, temporaryDirectory, dataDirectory, pluginContainerName,
            eventContext, operationContext, contentContext, availContext, inventoryContext, pluginContainerDeployment);
        Assert.assertNotNull(context.getEventContext());
        component.start(context);
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.