@Override public String toString() { return getServer() + ": " + getPlugins(); } }
public synchronized List<PluginSet> getPlugins() { List<PluginSet> pluginSets = new LinkedList<PluginSet>(); pluginSets.add(dashPlugins); for (ServerResource server : getServers()) { List<PluginDescriptor> plugins = getPluginsFor(server); PluginSet pSet = new PluginSet(); pSet.setServer(server); pSet.setPlugins(new HashSet<PluginDescriptor>(plugins)); pluginSets.add(pSet); } return pluginSets; } }
public synchronized List<String> getPluginNames() { Set<String> names = new HashSet<String>(); for (PluginSet pSet : getPlugins()) { for (PluginDescriptor p : pSet.getPlugins()) { names.add(p.getName()); } } List<String> pluginNames = new ArrayList<String>(names); sort(pluginNames); return pluginNames; }
@Autowired public PluginRepo(PluginSet dashboardPluginSet, AgentRepo agentRepo) { this.agentRepo = agentRepo; this.dashPlugins = dashboardPluginSet; me = dashboardPluginSet.getServer(); }
public static AgentIdentityCommand getAgentIdentity() { ServerResource server = new ServerResource(ServerName.valueOf("myserver")); ResourceProperties props = new ResourceProperties(server.getKey()); props.setProperty("one", "two", false); props.setProperty("two", "one", false); PluginSet plugins = new PluginSet(); plugins.setServer(server); HashSet<PluginDescriptor> pluginDescriptors = new HashSet<PluginDescriptor>(); pluginDescriptors.add(new PluginDescriptor("pluginname", "pluginversion", "pluginpublisher", "http://blah")); plugins.setPlugins(pluginDescriptors); return new AgentIdentityCommand(server, props, plugins); }
public synchronized List<PluginDescriptor> getPluginsFor(ServerResource server) { if (server.equals(me)) { return new ArrayList<PluginDescriptor>(dashPlugins.getPlugins()); } ActiveAgent agent = agentRepo.getActiveAgentMap().get(server); if (agent == null) { return Collections.emptyList(); } InsightAgentRuntimeState state = agent.getConfig(); if (state == null) { return Collections.emptyList(); } return new ArrayList<PluginDescriptor>(state.getPlugins()); }
@Override public boolean equals(Object obj) { if (obj == null) return false; if (this == obj) return true; if (getClass() != obj.getClass()) return false; PluginSet other = (PluginSet) obj; return ObjectUtil.typedEquals(getServer(), other.getServer()) && ListUtil.compareCollections(getPlugins(), other.getPlugins()) ; }
@Override public int hashCode() { // do not use plugins hash code since it may vary according to order of plugins rather than content return ObjectUtil.hashCode(getServer()) + ListUtil.size(getPlugins()) ; }
/** * @deprecated for backwards compatibility */ @Deprecated public synchronized void addPluginSet(PluginSet pluginSet) { ActiveAgent agent = agentRepo.getActiveAgentMap().get(pluginSet.getServer()); if (agent == null) { return; } InsightAgentRuntimeState pluginState = new InsightAgentRuntimeState(); for (PluginDescriptor p : pluginSet.getPlugins()) pluginState = pluginState.withPlugin(p); agent.updateConfig(pluginState); }