/** * Check if a configuration is allowed. * * @param group the cluster group. * @param category the configuration category constant. * @param pid the configuration PID. * @param type the cluster event type. * @return true if the cluster event type is allowed, false else. */ public boolean isAllowed(Group group, String category, String pid, EventType type) { CellarSupport support = new CellarSupport(); support.setClusterManager(this.clusterManager); support.setGroupManager(this.groupManager); support.setConfigurationAdmin(this.configurationAdmin); return support.isAllowed(group, category, pid, type); }
/** * Check if a configuration is allowed. * * @param group the cluster group. * @param category the configuration category constant. * @param pid the configuration PID. * @param type the cluster event type. * @return true if the cluster event type is allowed, false else. */ public boolean isClusterConfigPIDAllowed(Group group, String category, String pid, EventType type) { CellarSupport support = new CellarSupport(); support.setClusterManager(this.karafCellarClusterManager); support.setGroupManager(this.karafCellarGroupManager); support.setConfigurationAdmin(this.osgiConfigurationAdmin); return support.isAllowed(group, category, pid, type); }
/** * Check if a configuration is allowed. * * @param group the cluster group. * @param category the configuration category constant. * @param pid the configuration PID. * @param type the cluster event type. * @return true if the cluster event type is allowed, false else. */ public boolean isAllowed(Group group, String category, String pid, EventType type) { CellarSupport support = new CellarSupport(); support.setClusterManager(this.clusterManager); support.setGroupManager(this.groupManager); support.setConfigurationAdmin(this.configurationAdmin); return support.isAllowed(group, category, pid, type); }
/** * Check if a configuration is allowed. * * @param group the cluster group. * @param category the configuration category constant. * @param pid the configuration PID. * @param type the cluster event type. * @return true if the cluster event type is allowed, false else. */ public boolean isClusterConfigPIDAllowed(Group group, String category, String pid, EventType type) { CellarSupport support = new CellarSupport(); support.setClusterManager(this.karafCellarClusterManager); support.setGroupManager(this.karafCellarGroupManager); support.setConfigurationAdmin(this.osgiConfigurationAdmin); return support.isAllowed(group, category, pid, type); }
/** * Check if an OBR cluster event is allowed. * * @param group the cluster group. * @param category the OBR category name. * @param id the event ID. * @param type the event type (inbound, outbound). * @return in case of check failure. */ public boolean isAllowed(Group group, String category, String id, EventType type) { CellarSupport support = new CellarSupport(); support.setClusterManager(this.clusterManager); support.setGroupManager(this.groupManager); support.setConfigurationAdmin(this.configurationAdmin); return support.isAllowed(group, category, id, type); }
@Override public void block(String groupName, String bundlePattern, boolean whitelist, boolean blacklist, boolean in, boolean out) throws Exception { List<String> patterns = new ArrayList<String>(); Map<String, ExtendedBundleState> bundles = gatherBundles(groupName); List<String> selectedBundles = selector(bundlePattern, bundles); for (String selectedBundle : selectedBundles) { patterns.add(bundles.get(selectedBundle).getLocation()); } if (patterns.isEmpty()) { patterns.add(bundlePattern); } CellarSupport support = new CellarSupport(); support.setClusterManager(clusterManager); support.setGroupManager(groupManager); support.setConfigurationAdmin(configurationAdmin); for (String pattern : patterns) { if (in) { if (whitelist) support.switchListEntry(Configurations.WHITELIST, groupName, Constants.CATEGORY, EventType.INBOUND, pattern); if (blacklist) support.switchListEntry(Configurations.BLACKLIST, groupName, Constants.CATEGORY, EventType.INBOUND, pattern); } if (out) { if (whitelist) support.switchListEntry(Configurations.WHITELIST, groupName, Constants.CATEGORY, EventType.OUTBOUND, pattern); if (blacklist) support.switchListEntry(Configurations.BLACKLIST, groupName, Constants.CATEGORY, EventType.OUTBOUND, pattern); } } }
@Override public void block(String groupName, String bundlePattern, boolean whitelist, boolean blacklist, boolean in, boolean out) throws Exception { List<String> patterns = new ArrayList<String>(); Map<String, ExtendedBundleState> bundles = gatherBundles(groupName); List<String> selectedBundles = selector(bundlePattern, bundles); for (String selectedBundle : selectedBundles) { patterns.add(bundles.get(selectedBundle).getLocation()); } if (patterns.isEmpty()) { patterns.add(bundlePattern); } CellarSupport support = new CellarSupport(); support.setClusterManager(clusterManager); support.setGroupManager(groupManager); support.setConfigurationAdmin(configurationAdmin); for (String pattern : patterns) { if (in) { if (whitelist) support.switchListEntry(Configurations.WHITELIST, groupName, Constants.CATEGORY, EventType.INBOUND, pattern); if (blacklist) support.switchListEntry(Configurations.BLACKLIST, groupName, Constants.CATEGORY, EventType.INBOUND, pattern); } if (out) { if (whitelist) support.switchListEntry(Configurations.WHITELIST, groupName, Constants.CATEGORY, EventType.OUTBOUND, pattern); if (blacklist) support.switchListEntry(Configurations.BLACKLIST, groupName, Constants.CATEGORY, EventType.OUTBOUND, pattern); } } }
support.setClusterManager(this.clusterManager); support.setGroupManager(this.groupManager); support.setConfigurationAdmin(this.configurationAdmin); if (!support.isAllowed(group, Constants.CATEGORY, pid, EventType.OUTBOUND)) { throw new IllegalStateException("Configuration PID " + pid + " is blocked outbound for cluster group " + groupName);
support.setClusterManager(this.clusterManager); support.setGroupManager(this.groupManager); support.setConfigurationAdmin(this.configurationAdmin); if (!support.isAllowed(group, Constants.CATEGORY, pid, EventType.OUTBOUND)) { throw new IllegalArgumentException("Configuration PID " + pid + " is blocked outbound for cluster group " + groupName);
support.setClusterManager(this.clusterManager); support.setGroupManager(this.groupManager); support.setConfigurationAdmin(this.configurationAdmin); if (!support.isAllowed(group, Constants.CATEGORY, pid, EventType.OUTBOUND)) { throw new IllegalArgumentException("Configuration PID " + pid + " is blocked outbound for cluster group " + groupName);
@Override public void block(String groupName, String featurePattern, boolean whitelist, boolean blacklist, boolean in, boolean out) throws Exception { Group group = groupManager.findGroupByName(groupName); if (group == null) { throw new IllegalArgumentException("Cluster group " + groupName + " doesn't exist"); } CellarSupport support = new CellarSupport(); support.setClusterManager(clusterManager); support.setGroupManager(groupManager); support.setConfigurationAdmin(configurationAdmin); if (in) { if (whitelist) support.switchListEntry(Configurations.WHITELIST, groupName, Constants.CATEGORY, EventType.INBOUND, featurePattern); if (blacklist) support.switchListEntry(Configurations.BLACKLIST, groupName, Constants.CATEGORY, EventType.INBOUND, featurePattern); } if (out) { if (whitelist) support.switchListEntry(Configurations.WHITELIST, groupName, Constants.CATEGORY, EventType.OUTBOUND, featurePattern); if (blacklist) support.switchListEntry(Configurations.BLACKLIST, groupName, Constants.CATEGORY, EventType.OUTBOUND, featurePattern); } }
support.setClusterManager(this.clusterManager); support.setGroupManager(this.groupManager); support.setConfigurationAdmin(this.configurationAdmin); if (!support.isAllowed(group, Constants.CATEGORY, pid, EventType.OUTBOUND)) { throw new IllegalStateException("Configuration PID " + pid + " is blocked outbound for cluster group " + groupName);
@Override public void block(String groupName, String featurePattern, boolean whitelist, boolean blacklist, boolean in, boolean out) throws Exception { Group group = groupManager.findGroupByName(groupName); if (group == null) { throw new IllegalArgumentException("Cluster group " + groupName + " doesn't exist"); } CellarSupport support = new CellarSupport(); support.setClusterManager(clusterManager); support.setGroupManager(groupManager); support.setConfigurationAdmin(configurationAdmin); if (in) { if (whitelist) support.switchListEntry(Configurations.WHITELIST, groupName, Constants.CATEGORY, EventType.INBOUND, featurePattern); if (blacklist) support.switchListEntry(Configurations.BLACKLIST, groupName, Constants.CATEGORY, EventType.INBOUND, featurePattern); } if (out) { if (whitelist) support.switchListEntry(Configurations.WHITELIST, groupName, Constants.CATEGORY, EventType.OUTBOUND, featurePattern); if (blacklist) support.switchListEntry(Configurations.BLACKLIST, groupName, Constants.CATEGORY, EventType.OUTBOUND, featurePattern); } }
@Override protected Object doExecute() throws Exception { // check if the group exists Group group = groupManager.findGroupByName(groupName); if (group == null) { System.err.println("Cluster group " + groupName + " doesn't exist"); return null; } // check if the producer is ON if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) { System.err.println("Cluster event producer is OFF"); return null; } CellarSupport support = new CellarSupport(); support.setConfigurationAdmin(configurationAdmin); support.setGroupManager(groupManager); support.setClusterManager(clusterManager); // check if the kar is allowed if (support.isAllowed(group, Constants.CATEGORY, url, EventType.OUTBOUND)) { // broadcast cluster event ClusterKarEvent clusterEvent = new ClusterKarEvent(url, true); clusterEvent.setSourceGroup(group); clusterEvent.setInstall(true); eventProducer.produce(clusterEvent); } else { System.err.println("KAR " + url + " is blocked outbound for cluster group " + groupName); } return null; }
support.setClusterManager(this.clusterManager); support.setGroupManager(this.groupManager); support.setConfigurationAdmin(this.configurationAdmin); if (!support.isAllowed(group, Constants.CATEGORY, pid, EventType.OUTBOUND)) { throw new IllegalStateException("Configuration PID " + pid + " is blocked outbound for cluster group " + groupName);
@Override protected Object doExecute() throws Exception { // check if the group exists Group group = groupManager.findGroupByName(groupName); if (group == null) { System.err.println("Cluster group " + groupName + " doesn't exist"); return null; } // check if the producer is ON if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) { System.err.println("Cluster event producer is OFF"); return null; } CellarSupport support = new CellarSupport(); support.setConfigurationAdmin(configurationAdmin); support.setGroupManager(groupManager); support.setClusterManager(clusterManager); // check if the kar is allowed if (support.isAllowed(group, Constants.CATEGORY, name, EventType.OUTBOUND)) { // broadcast cluster event ClusterKarEvent clusterEvent = new ClusterKarEvent(name, true); clusterEvent.setSourceGroup(group); clusterEvent.setInstall(false); eventProducer.produce(clusterEvent); } else { System.err.println("KAR " + name + " is blocked outbound for cluster group " + groupName); } return null; }
@Override public void deployBundle(String groupName, String bundleId, boolean start, boolean deployOptional) throws Exception { // check if the group exists Group group = groupManager.findGroupByName(groupName); if (group == null) { throw new IllegalArgumentException("Cluster group " + groupName + " doesn't exist"); } // check if the producer is ON if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) { throw new IllegalStateException("Cluster event producer is OFF"); } // check if the bundle ID is allowed outbound CellarSupport support = new CellarSupport(); support.setClusterManager(this.clusterManager); support.setGroupManager(this.groupManager); support.setConfigurationAdmin(this.configurationAdmin); if (!support.isAllowed(group, Constants.BUNDLES_CONFIG_CATEGORY, bundleId, EventType.OUTBOUND)) { throw new IllegalArgumentException("OBR bundle " + bundleId + " is blocked outbound for cluster group " + groupName); } // broadcast a cluster event ClusterObrBundleEvent event = new ClusterObrBundleEvent(bundleId, start, deployOptional); event.setSourceGroup(group); event.setSourceNode(clusterManager.getNode()); eventProducer.produce(event); }
@Override public void block(String groupName, String pid, boolean whitelist, boolean blacklist, boolean in, boolean out) throws Exception { CellarSupport support = new CellarSupport(); support.setClusterManager(clusterManager); support.setGroupManager(groupManager); support.setConfigurationAdmin(configurationAdmin); if (in) { if (whitelist) support.switchListEntry(Configurations.WHITELIST, groupName, Constants.CATEGORY, EventType.INBOUND, pid); if (blacklist) support.switchListEntry(Configurations.BLACKLIST, groupName, Constants.CATEGORY, EventType.INBOUND, pid); } if (out) { if (whitelist) support.switchListEntry(Configurations.WHITELIST, groupName, Constants.CATEGORY, EventType.OUTBOUND, pid); if (blacklist) support.switchListEntry(Configurations.BLACKLIST, groupName, Constants.CATEGORY, EventType.OUTBOUND, pid); } }
@Override public void block(String groupName, String pid, boolean whitelist, boolean blacklist, boolean in, boolean out) throws Exception { CellarSupport support = new CellarSupport(); support.setClusterManager(clusterManager); support.setGroupManager(groupManager); support.setConfigurationAdmin(configurationAdmin); if (in) { if (whitelist) support.switchListEntry(Configurations.WHITELIST, groupName, Constants.CATEGORY, EventType.INBOUND, pid); if (blacklist) support.switchListEntry(Configurations.BLACKLIST, groupName, Constants.CATEGORY, EventType.INBOUND, pid); } if (out) { if (whitelist) support.switchListEntry(Configurations.WHITELIST, groupName, Constants.CATEGORY, EventType.OUTBOUND, pid); if (blacklist) support.switchListEntry(Configurations.BLACKLIST, groupName, Constants.CATEGORY, EventType.OUTBOUND, pid); } }
support.setClusterManager(this.clusterManager); support.setGroupManager(this.groupManager); support.setConfigurationAdmin(this.configurationAdmin); if (!support.isAllowed(group, Constants.URLS_CONFIG_CATEGORY, url, EventType.OUTBOUND)) { throw new IllegalArgumentException("OBR URL " + url + " is blocked outbound for cluster group " + groupName);