Package org.rhq.core.domain.plugin

Examples of org.rhq.core.domain.plugin.ServerPlugin


            ids.add(pluginId);
            List<ServerPlugin> result = serverPluginManager.getServerPluginsById(ids); // use this API to get config, too
            if (result == null || result.isEmpty()) {
                return null;
            }
            ServerPlugin plugin = result.get(0);
            if (includeRelationships) {
                plugin = serverPluginManager.getServerPluginRelationships(plugin);
            }
            return SerialUtility.prepare(plugin, "PluginGWTService.getServerPlugin");
        } catch (Throwable t) {
View Full Code Here


        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

        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

                if (configDef != null) {
                    scheduledJobsConfig = configDef.getDefaultTemplate().createConfiguration();
                }

                File pluginFile = new File(env.getPluginUrl().toURI());
                ServerPlugin plugin = new ServerPlugin(0, env.getPluginKey().getPluginName(), pluginFile.getName(),
                    pluginDescriptor.getDisplayName(), true, PluginStatusType.INSTALLED, pluginDescriptor
                        .getDescription(), "", MessageDigestGenerator.getDigestString(pluginFile), pluginDescriptor
                        .getVersion(), pluginDescriptor.getVersion(), pluginConfig, scheduledJobsConfig,
                    new ServerPluginType(pluginDescriptor).stringify(), System.currentTimeMillis(), System
                        .currentTimeMillis());
View Full Code Here

            }
        }
    }

    public void testGetPlugins() throws Exception {
        ServerPlugin p1 = registerPlugin(1);
        ServerPlugin p2 = registerPlugin(2);
        PluginKey p1key = new PluginKey(p1);
        PluginKey p2key = new PluginKey(p2);
        List<PluginKey> pluginKeys = this.serverPluginsBean.getServerPluginKeysByEnabled(true);
        assert pluginKeys.contains(p1key) : pluginKeys;
        assert pluginKeys.contains(p2key) : pluginKeys;
        pluginKeys = this.serverPluginsBean.getServerPluginKeysByEnabled(false);
        assert !pluginKeys.contains(p1key) : pluginKeys;
        assert !pluginKeys.contains(p2key) : pluginKeys;

        ServerPlugin plugin = this.serverPluginsBean.getServerPlugin(p1key);
        assert plugin.getId() == p1.getId() : plugin;
        assert plugin.getName().equals(p1.getName()) : plugin;
        assetLazyInitializationException(plugin);

        plugin = this.serverPluginsBean.getServerPluginRelationships(plugin);
        assert plugin.getPluginConfiguration() != null;
        assert plugin.getScheduledJobsConfiguration() != null;
        assert plugin.getPluginConfiguration().equals(p1.getPluginConfiguration());
        assert plugin.getScheduledJobsConfiguration().equals(p1.getScheduledJobsConfiguration());

        List<ServerPlugin> plugins = this.serverPluginsBean.getServerPlugins();
        assert plugins.contains(p1) : plugins;
        assert plugins.contains(p2) : plugins;
        assetLazyInitializationException(plugins.get(plugins.indexOf(p1)));
View Full Code Here

        lastTimestamp = this.serverPluginsBean.getLastConfigurationChangeTimestamp(p2.getId());
        assert lastTimestamp == getConfigurationLastModifiedTimestamp(p2);
    }

    public void testUpdatePlugins() throws Exception {
        ServerPlugin p1 = registerPlugin(1);
        PluginKey p1key = new PluginKey(p1);

        p1 = this.serverPluginsBean.getServerPlugin(p1key);
        p1 = this.serverPluginsBean.getServerPluginRelationships(p1);

        ServerPlugin p1update = this.serverPluginsBean.updateServerPluginExceptContent(getOverlord(), p1);
        p1update = this.serverPluginsBean.getServerPluginRelationships(p1update);

        assert p1update.getId() == p1.getId() : p1update;
        assert p1update.getId() == p1.getId() : p1update;
        assert p1update.getName().equals(p1.getName()) : p1update;
        assert p1update.getName().equals(p1.getName()) : p1update;
        assert p1update.getPluginConfiguration().equals(p1.getPluginConfiguration()) : p1update;
        assert p1update.getScheduledJobsConfiguration().equals(p1.getScheduledJobsConfiguration()) : p1update;
        p1update.getPluginConfiguration().equals(p1.getPluginConfiguration());
        p1update.getScheduledJobsConfiguration().equals(p1.getScheduledJobsConfiguration());
    }
View Full Code Here

        p1update.getPluginConfiguration().equals(p1.getPluginConfiguration());
        p1update.getScheduledJobsConfiguration().equals(p1.getScheduledJobsConfiguration());
    }

    public void testTryEnableServerPluginsWithMissingRequiredConfiguration() throws Exception {
        ServerPlugin p1 = registerPlugin(1, Configuration.builder().addSimple("foo", "bar").build());
        ServerPlugin p2 = registerPlugin(2);
        PluginKey p1key = new PluginKey(p1);
        PluginKey p2key = new PluginKey(p2);

        List<Integer> ids = new ArrayList<Integer>(2);
        ids.add(p1.getId());
        ids.add(p2.getId());

        // first disable both plugins
        List<PluginKey> disabled = this.serverPluginsBean.disableServerPlugins(getOverlord(), ids);
        assert disabled.size() == 2 : disabled;
        assert disabled.contains(p1key) : disabled;
View Full Code Here

        }
        assert caught == true : "Exception must be thrown when attempting to enable plugin without required configuration set";
    }

    public void testDisableEnablePlugins() throws Exception {
        ServerPlugin p1 = registerPlugin(1);
        ServerPlugin p2 = registerPlugin(2);
        PluginKey p1key = new PluginKey(p1);
        PluginKey p2key = new PluginKey(p2);

        List<Integer> ids = new ArrayList<Integer>(2);
        ids.add(p1.getId());
        ids.add(p2.getId());
        List<PluginKey> disabled = this.serverPluginsBean.disableServerPlugins(getOverlord(), ids);
        assert disabled.size() == 2 : disabled;
        assert disabled.contains(p1key) : disabled;
        assert disabled.contains(p2key) : disabled;
        ;
        assert this.serverPluginsBean.getServerPlugin(p1key).getStatus() == PluginStatusType.INSTALLED; // still installed
        assert this.serverPluginsBean.getServerPlugin(p2key).getStatus() == PluginStatusType.INSTALLED; // still installed
        List<PluginKey> pluginKeys = this.serverPluginsBean.getServerPluginKeysByEnabled(false);
        assert pluginKeys.contains(p1key) : pluginKeys;
        assert pluginKeys.contains(p2key) : pluginKeys;
        pluginKeys = this.serverPluginsBean.getServerPluginKeysByEnabled(true);
        assert !pluginKeys.contains(p1key) : pluginKeys;
        assert !pluginKeys.contains(p2key) : pluginKeys;

        // re-enable them
        this.serverPluginsBean.enableServerPlugins(getOverlord(), ids);
        pluginKeys = this.serverPluginsBean.getServerPluginKeysByEnabled(true);
        assert pluginKeys.contains(p1key) : pluginKeys;
        assert pluginKeys.contains(p2key) : pluginKeys;
        pluginKeys = this.serverPluginsBean.getServerPluginKeysByEnabled(false);
        assert !pluginKeys.contains(p1key) : pluginKeys;
        assert !pluginKeys.contains(p2key) : pluginKeys;

        // make sure none of these enable/disable settings lost our config
        ServerPlugin plugin = this.serverPluginsBean.getServerPlugin(p1key);
        plugin = this.serverPluginsBean.getServerPluginRelationships(plugin);
        assert plugin.getPluginConfiguration() != null; // no LazyInitException should be thrown!
        assert plugin.getPluginConfiguration().equals(p1.getPluginConfiguration());
        plugin = this.serverPluginsBean.getServerPlugin(p2key);
        plugin = this.serverPluginsBean.getServerPluginRelationships(plugin);
        assert plugin.getPluginConfiguration() != null; // no LazyInitException should be thrown!
        assert plugin.getPluginConfiguration().equals(p1.getPluginConfiguration());
    }
View Full Code Here

        missingKey = new PluginKey(PluginDeploymentType.SERVER,
            new ServerPluginType(GenericPluginDescriptorType.class).stringify(), TEST_PLUGIN_NAME_PREFIX + "2");
        status = this.serverPluginsBean.getServerPluginStatus(missingKey);
        assert status == null;

        ServerPlugin p1 = registerPlugin(1);
        ServerPlugin p2 = registerPlugin(2);
        PluginKey p1key = new PluginKey(p1);
        PluginKey p2key = new PluginKey(p2);

        status = this.serverPluginsBean.getServerPluginStatus(p1key);
        assert status == PluginStatusType.INSTALLED;
        status = this.serverPluginsBean.getServerPluginStatus(p2key);
        assert status == PluginStatusType.INSTALLED;

        assert this.serverPluginsBean.getServerPlugins().size() == originalSize + 2;
        assert this.serverPluginsBean.getAllServerPlugins().size() == originalSize + 2;

        List<Integer> ids = new ArrayList<Integer>(2);
        ids.add(p1.getId());
        ids.add(p2.getId());
        List<PluginKey> undeployed = this.serverPluginsBean.deleteServerPlugins(getOverlord(), ids);
        assert undeployed.size() == 2 : undeployed;
        assert undeployed.contains(p1key) : undeployed;
        assert undeployed.contains(p2key) : undeployed;
        ServerPlugin p1deleted = getDeletedPluginInTx(p1.getName());
        ServerPlugin p2deleted = getDeletedPluginInTx(p2.getName());
        assert p1deleted.getStatus() == PluginStatusType.DELETED;
        assert p2deleted.getStatus() == PluginStatusType.DELETED;

        List<PluginKey> pluginKeys = this.serverPluginsBean.getServerPluginKeysByEnabled(false);
        assert !pluginKeys.contains(p1key) : "deleted plugins should not be returned even here" + pluginKeys;
        assert !pluginKeys.contains(p2key) : "deleted plugins should not be returned even here" + pluginKeys;
        pluginKeys = this.serverPluginsBean.getServerPluginKeysByEnabled(true);
View Full Code Here

        missingKey = new PluginKey(PluginDeploymentType.SERVER,
            new ServerPluginType(GenericPluginDescriptorType.class).stringify(), TEST_PLUGIN_NAME_PREFIX + "2");
        status = this.serverPluginsBean.getServerPluginStatus(missingKey);
        assert status == null;

        ServerPlugin p1 = registerPlugin(1);
        ServerPlugin p2 = registerPlugin(2);
        PluginKey p1key = new PluginKey(p1);
        PluginKey p2key = new PluginKey(p2);

        status = this.serverPluginsBean.getServerPluginStatus(p1key);
        assert status == PluginStatusType.INSTALLED;
        status = this.serverPluginsBean.getServerPluginStatus(p2key);
        assert status == PluginStatusType.INSTALLED;

        List<Integer> ids = new ArrayList<Integer>(2);
        ids.add(p1.getId());
        ids.add(p2.getId());
        List<PluginKey> undeployed = this.serverPluginsBean.deleteServerPlugins(getOverlord(), ids);
        assert undeployed.size() == 2 : undeployed;
        assert undeployed.contains(p1key) : undeployed;
        assert undeployed.contains(p2key) : undeployed;
        ServerPlugin p1deleted = getDeletedPluginInTx(p1.getName());
        assert p1deleted.getStatus() == PluginStatusType.DELETED;
        assert p1deleted.getPluginConfiguration() == null; // undeploy should have removed this
        assert p1deleted.getScheduledJobsConfiguration() == null; // undeploy should have removed this
        ServerPlugin p2deleted = getDeletedPluginInTx(p1.getName());
        assert p2deleted.getStatus() == PluginStatusType.DELETED;
        assert p2deleted.getPluginConfiguration() == null; // undeploy should have removed this
        assert p2deleted.getScheduledJobsConfiguration() == null; // undeploy should have removed this

        List<PluginKey> pluginKeys = this.serverPluginsBean.getServerPluginKeysByEnabled(false);
        assert !pluginKeys.contains(p1key) : "deleted plugins should not be returned even here" + pluginKeys;
        assert !pluginKeys.contains(p2key) : "deleted plugins should not be returned even here" + pluginKeys;
        pluginKeys = this.serverPluginsBean.getServerPluginKeysByEnabled(true);
        assert !pluginKeys.contains(p1key) : pluginKeys;
        assert !pluginKeys.contains(p2key) : pluginKeys;

        // purge them completely from the DB to prepare to re-register them
        this.serverPluginsBean.purgeServerPlugin(p1.getId());
        this.serverPluginsBean.purgeServerPlugin(p2.getId());

        // we just purged the database, make sure our entity ID's are all zero, since the original IDs are gone
        p1.setId(0);
        p2.setId(0);
        p1.setPluginConfiguration(p1.getPluginConfiguration().deepCopy(false));
        p2.setPluginConfiguration(p2.getPluginConfiguration().deepCopy(false));
        p1.setScheduledJobsConfiguration(p1.getScheduledJobsConfiguration().deepCopy(false));
        p2.setScheduledJobsConfiguration(p2.getScheduledJobsConfiguration().deepCopy(false));

        // re-register them now
        ServerPlugin p1again = this.serverPluginsBean.registerServerPlugin(getOverlord(), p1, null);
        ServerPlugin p2again = this.serverPluginsBean.registerServerPlugin(getOverlord(), p2, null);

        pluginKeys = this.serverPluginsBean.getServerPluginKeysByEnabled(true);
        assert pluginKeys.contains(p1key) : pluginKeys;
        assert pluginKeys.contains(p2key) : pluginKeys;
        assert p1again.getStatus() == PluginStatusType.INSTALLED;
        assert p2again.getStatus() == PluginStatusType.INSTALLED;
        pluginKeys = this.serverPluginsBean.getServerPluginKeysByEnabled(false);
        assert !pluginKeys.contains(p1key) : pluginKeys;
        assert !pluginKeys.contains(p2key) : pluginKeys;
    }
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.plugin.ServerPlugin

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.