Package org.rhq.enterprise.server.plugin

Examples of org.rhq.enterprise.server.plugin.ServerPluginManagerLocal


    @Override
    public void updateServerPluginConfiguration(PluginKey serverPluginKey, Configuration config)
        throws RuntimeException {
        try {
            ServerPluginManagerLocal serverPlugins = LookupUtil.getServerPluginManager();

            // first load the full original plugin data
            ServerPlugin plugin = serverPlugins.getServerPlugin(serverPluginKey);
            if (plugin == null) {
                throw new IllegalArgumentException("Unknown plugin key: " + serverPluginKey);
            }

            plugin = serverPlugins.getServerPluginRelationships(plugin);

            // now overwrite the config that we want to set and tell the server about it
            plugin.setPluginConfiguration(config);
            serverPlugins.updateServerPluginExceptContent(getSessionSubject(), plugin);

            // Since the config has changed, we can tell the server to re-load the plugin now
            // in order for it to pick up the changes immediately. Any other servers in the HA Server Cloud
            // will pick up these changes later, when they scan for changes in the database.
            // Note that if the plugin is disabled, don't bother since the plugin isn't really running anyway.
            if (plugin.isEnabled()) {
                // enabling an already enabled plugin forces the plugin to reload
                ArrayList<Integer> id = new ArrayList<Integer>(1);
                id.add(plugin.getId());
                serverPlugins.enableServerPlugins(getSessionSubject(), id);
            }
        } catch (Throwable t) {
            throw getExceptionToThrowToClient(t);
        }
    }
View Full Code Here


    @Override
    public void updateServerPluginScheduledJobs(PluginKey serverPluginKey, Configuration jobsConfig)
        throws RuntimeException {
        try {
            ServerPluginManagerLocal serverPlugins = LookupUtil.getServerPluginManager();

            // first load the full original plugin data
            ServerPlugin plugin = serverPlugins.getServerPlugin(serverPluginKey);
            if (plugin == null) {
                throw new IllegalArgumentException("Unknown plugin key: " + serverPluginKey);
            }

            plugin = serverPlugins.getServerPluginRelationships(plugin);

            // now overwrite the config that we want to set and tell the server about it
            plugin.setScheduledJobsConfiguration(jobsConfig);
            serverPlugins.updateServerPluginExceptContent(getSessionSubject(), plugin);

            // Since the config has changed, we can tell the server to re-load the plugin now
            // in order for it to pick up the changes immediately. Any other servers in the HA Server Cloud
            // will pick up these changes later, when they scan for changes in the database.
            // Note that if the plugin is disabled, don't bother since the plugin isn't really running anyway.
            if (plugin.isEnabled()) {
                // enabling an already enabled plugin forces the plugin to reload
                ArrayList<Integer> id = new ArrayList<Integer>(1);
                id.add(plugin.getId());
                serverPlugins.enableServerPlugins(getSessionSubject(), id);
            }
        } catch (Throwable t) {
            throw getExceptionToThrowToClient(t);
        }
    }
View Full Code Here

            registerServerPlugin(file);
        }
        this.scanned.clear();

        // we now have to see if the state of existing plugins have changed in the DB
        ServerPluginManagerLocal serverPluginsManager = LookupUtil.getServerPluginManager();
        List<ServerPlugin> allPlugins = serverPluginsManager.getAllServerPlugins();
        List<ServerPlugin> installedPlugins = new ArrayList<ServerPlugin>();
        List<ServerPlugin> undeployedPlugins = new ArrayList<ServerPlugin>();
        for (ServerPlugin plugin : allPlugins) {
            if (plugin.getStatus() == PluginStatusType.INSTALLED) {
                installedPlugins.add(plugin);
            } else {
                undeployedPlugins.add(plugin);
            }
        }

        // first, have any plugins been undeployed since we last checked?
        for (ServerPlugin undeployedPlugin : undeployedPlugins) {
            File undeployedFile = new File(this.getServerPluginDir(), undeployedPlugin.getPath());
            PluginWithDescriptor pluginWithDescriptor = this.serverPluginsOnFilesystem.get(undeployedFile);
            if (pluginWithDescriptor != null) {
                try {
                    log.info("Plugin file [" + undeployedFile + "] has been undeployed. It will be deleted.");
                    List<Integer> id = Arrays.asList(undeployedPlugin.getId());
                    serverPluginsManager.deleteServerPlugins(LookupUtil.getSubjectManager().getOverlord(), id);
                } finally {
                    this.serverPluginsOnFilesystem.remove(undeployedFile);
                }
            }
        }

        // now see if any plugins changed state from enabled->disabled or vice versa
        // this also checks to see if the plugin configuration has changed since it was last loaded
        MasterServerPluginContainer master = LookupUtil.getServerPluginService().getMasterPluginContainer();
        if (master != null) {
            for (ServerPlugin installedPlugin : installedPlugins) {
                PluginKey key = PluginKey.createServerPluginKey(installedPlugin.getType(), installedPlugin.getName());
                AbstractTypeServerPluginContainer pc = master.getPluginContainerByPlugin(key);
                if (pc != null && pc.isPluginLoaded(key)) {
                    boolean needToReloadPlugin = false;
                    boolean currentlyEnabled = pc.isPluginEnabled(key);
                    if (installedPlugin.isEnabled() != currentlyEnabled) {
                        log.info("Detected a state change to plugin [" + key + "]. It will now be "
                            + ((installedPlugin.isEnabled()) ? "[enabled]" : "[disabled]"));
                        needToReloadPlugin = true;
                    } else {
                        Long pluginLoadTime = pc.getPluginLoadTime(key);
                        if (pluginLoadTime != null) {
                            long configChangeTimestamp = serverPluginsManager
                                .getLastConfigurationChangeTimestamp(installedPlugin.getId());
                            if (configChangeTimestamp > pluginLoadTime) {
                                // since the last time the plugin was loaded, its configuration has changed, reload it to pick up the new config
                                log.info("Detected a config change to plugin [" + key + "]. It will be reloaded and "
                                    + ((installedPlugin.isEnabled()) ? "[enabled]" : "[disabled]"));
View Full Code Here

        for (File updatedFile : allUpdatedFiles) {
            log.debug("Scan detected server plugin [" + updatedFile + "]...");
            this.scanned.add(updatedFile);
        }

        ServerPluginManagerLocal pluginMgr = LookupUtil.getServerPluginManager();
        ServerManagerLocal serverMgr = LookupUtil.getServerManager();
        Server thisServer = serverMgr.getServer();

        pluginMgr.acknowledgeDeletedPluginsBy(thisServer.getId());
    }
View Full Code Here

            if (descriptor.getHelp() != null && !descriptor.getHelp().getContent().isEmpty()) {
                plugin.setHelp(String.valueOf(descriptor.getHelp().getContent().get(0)));
            }

            ServerPluginManagerLocal serverPluginsManager = LookupUtil.getServerPluginManager();

            // see if this plugin has been deleted previously; if so, don't register and delete the file
            PluginKey newPluginKey = new PluginKey(plugin);
            PluginStatusType status = serverPluginsManager.getServerPluginStatus(newPluginKey);

            if (PluginStatusType.DELETED == status) {
                log.warn("Plugin file [" + pluginFile + "] has been detected but that plugin with name [" + pluginName
                    + "] was previously undeployed. Will not re-register that plugin and the file will be deleted.");
                boolean succeeded = pluginFile.delete();
                if (!succeeded) {
                    log.error("Failed to delete obsolete plugin file [" + pluginFile + "].");
                }
            } else {
                // now attempt to register the plugin. "dbPlugin" will be the new updated plugin; but if
                // the scanned plugin does not obsolete the current plugin, then dbPlugin will be the old, still valid, plugin.
                SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
                ServerPlugin dbPlugin = serverPluginsManager.registerServerPlugin(subjectManager.getOverlord(), plugin,
                    pluginFile);
                log.info("Registered server plugin [" + dbPlugin.getName() + "], version " + dbPlugin.getVersion());
            }
        } catch (Exception e) {
            log.error("Failed to register server plugin file [" + pluginFile + "]", e);
View Full Code Here

        // the same list as above, only they are the files that are written to the filesystem and no longer missing
        List<File> updatedFiles = new ArrayList<File>();

        // process all the installed plugins
        ServerPluginManagerLocal serverPluginsManager = LookupUtil.getServerPluginManager();
        List<ServerPlugin> installedPlugins = serverPluginsManager.getServerPlugins();
        for (ServerPlugin installedPlugin : installedPlugins) {
            String name = installedPlugin.getName();
            String path = installedPlugin.getPath();
            String md5 = installedPlugin.getMd5();
            long mtime = installedPlugin.getMtime();
View Full Code Here

            pluginMgr.purgePlugins(pluginsToPurge);
        }
    }

    private void purgeServerPlugins() {
        ServerPluginManagerLocal pluginMgr = LookupUtil.getServerPluginManager();

        for (ServerPlugin p : pluginMgr.getDeletedPlugins()) {
            if (pluginMgr.isReadyForPurge(p.getId())) {
                pluginMgr.purgeServerPlugin(p.getId());
            }
        }
    }
View Full Code Here

     * @param pluginEnv
     * @return the ServerPlugin object for the given plugin
     */
    protected ServerPlugin getPlugin(ServerPluginEnvironment pluginEnv) {
        // get the plugin data from the database
        ServerPluginManagerLocal serverPluginsManager = LookupUtil.getServerPluginManager();
        ServerPlugin plugin = serverPluginsManager.getServerPlugin(pluginEnv.getPluginKey());
        plugin = serverPluginsManager.getServerPluginRelationships(plugin);
        return plugin;
    }
View Full Code Here

        sender.extraParameters = getNewOrCleansed(notification.getExtraConfiguration());

        ServerPluginContext ctx = getServerPluginContext(env);
        PluginKey key = ctx.getPluginEnvironment().getPluginKey();

        ServerPluginManagerLocal pluginsMgr = LookupUtil.getServerPluginManager();
        ServerPlugin plugin = pluginsMgr.getServerPlugin(key);
        plugin = pluginsMgr.getServerPluginRelationships(plugin);

        sender.preferences = getNewOrCleansed(plugin.getPluginConfiguration());
        sender.pluginComponent = getServerPluginComponent(key.getPluginName());
        sender.serverPluginEnvironment = pluginEnvByName.get(senderName);
View Full Code Here

        return "success";
    }

    public String updatePlugin() {
        try {
            ServerPluginManagerLocal serverPlugins = LookupUtil.getServerPluginManager();
            Subject subject = EnterpriseFacesContextUtility.getSubject();

            ServerPlugin plugin = serverPlugins.updateServerPluginExceptContent(subject, getPlugin());
            setPlugin(plugin);

            // Since the config has changed, we can tell the server to re-load the plugin now
            // in order for it to pick up the changes immediately. Any other servers in the HA Server Cloud
            // will pick up these changes later, when they scan for changes in the database.
            // Note that if the plugin is disabled, don't bother since the plugin isn't really running anyway.
            if (plugin.isEnabled()) {
                // enabling an already enabled plugin forces the plugin to reload
                serverPlugins.enableServerPlugins(subject, getPluginIdList());
            }

            FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Configuration settings saved.");
        } catch (Exception e) {
            //            log.error("Error updating the plugin configurations.", e);
View Full Code Here

TOP

Related Classes of org.rhq.enterprise.server.plugin.ServerPluginManagerLocal

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.