@Override public List<String> getUrls(String groupName) throws Exception { // check if the group exists Group group = groupManager.findGroupByName(groupName); if (group == null) { throw new IllegalArgumentException("Cluster group " + groupName + " doesn't exist"); } List<String> result = new ArrayList<String>(); Set<String> clusterUrls = clusterManager.getSet(Constants.URLS_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName); for (String url : clusterUrls) { result.add(url); } return result; }
@Override public 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; } // get the OBR URLs in a cluster group Set<String> clusterUrls = clusterManager.getSet(Constants.URLS_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName); if (clusterUrls != null) { for (String url : clusterUrls) { System.out.println(url); } } return null; }
/** * Pull the OBR URLs from a cluster group to update the local state. * * @param group the cluster group. */ @Override public void pull(Group group) { if (group != null) { String groupName = group.getName(); Set<String> clusterUrls = clusterManager.getSet(Constants.URLS_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName); ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); if (clusterUrls != null && !clusterUrls.isEmpty()) { for (String url : clusterUrls) { try { LOGGER.debug("CELLAR OBR: adding repository URL {}", url); obrService.addRepository(url); } catch (Exception e) { LOGGER.error("CELLAR OBR: failed to add repository URL {}", url, e); } } } } finally { Thread.currentThread().setContextClassLoader(originalClassLoader); } } }
@Override public TabularData getBundles(String groupName) throws Exception { // check if the group exists Group group = groupManager.findGroupByName(groupName); if (group == null) { throw new IllegalArgumentException("Cluster group " + groupName + " doesn't exist"); } CompositeType compositeType = new CompositeType("OBR Bundle", "Bundles available in the OBR service", new String[]{ "name", "symbolic", "version"}, new String[]{ "Name of the bundle", "Symbolic name of the bundle", "Version of the bundle" }, new OpenType[]{ SimpleType.STRING, SimpleType.STRING, SimpleType.STRING }); TabularType tableType = new TabularType("OBR Bundles", "Table of all bundles available in the OBR service", compositeType, new String[]{"name", "version"}); TabularData table = new TabularDataSupport(tableType); ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); Set<ObrBundleInfo> clusterBundles = clusterManager.getSet(Constants.BUNDLES_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName); for (ObrBundleInfo info : clusterBundles) { CompositeData data = new CompositeDataSupport(compositeType, new String[]{ "name", "symbolic", "version" }, new Object[]{ info.getPresentationName(), info.getSymbolicName(), info.getVersion() }); table.put(data); } } finally { Thread.currentThread().setContextClassLoader(originalClassLoader); } return table; }
if (group != null) { String groupName = group.getName(); Set<String> clusterUrls = clusterManager.getSet(Constants.URLS_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName); eventProducer.produce(urlEvent); Set<ObrBundleInfo> clusterBundles = clusterManager.getSet(Constants.BUNDLES_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName); Resource[] resources = repository.getResources(); for (Resource resource : resources) {
@Override public Object doExecute() { // check if the group exists Group group = groupManager.findGroupByName(groupName); if (group == null) { System.err.println("Cluster group " + groupName + " doesn't exist"); return null; } ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); Set<ObrBundleInfo> clusterBundles = clusterManager.getSet(Constants.BUNDLES_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName); ShellTable table = new ShellTable(); table.column("Name"); table.column("Symbolic Name"); table.column("Version"); for (ObrBundleInfo bundle : clusterBundles) { table.addRow().addContent(emptyIfNull(bundle.getPresentationName()), emptyIfNull(bundle.getSymbolicName()), emptyIfNull(bundle.getVersion())); } table.print(System.out, !noFormat); } finally { Thread.currentThread().setContextClassLoader(originalClassLoader); } return null; }
Set<String> urls = clusterManager.getSet(Constants.URLS_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName); urls.remove(url); Set<ObrBundleInfo> bundles = clusterManager.getSet(Constants.BUNDLES_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName); synchronized(obrService) { Repository repository = obrService.addRepository(url);
Set<String> clusterUrls = clusterManager.getSet(Constants.URLS_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName); clusterUrls.add(url); Set<ObrBundleInfo> clusterBundles = clusterManager.getSet(Constants.BUNDLES_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName); synchronized(obrService) { Repository repository = obrService.addRepository(url);
Set<String> clusterUrls = clusterManager.getSet(Constants.URLS_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName); clusterUrls.remove(url); Set<ObrBundleInfo> clusterBundles = clusterManager.getSet(Constants.BUNDLES_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName); synchronized (obrService) { Repository repository = obrService.addRepository(url);
Set<String> clusterUrls = clusterManager.getSet(Constants.URLS_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName); clusterUrls.add(url); Set<ObrBundleInfo> clusterBundles = clusterManager.getSet(Constants.BUNDLES_DISTRIBUTED_SET_NAME + Configurations.SEPARATOR + groupName); synchronized (obrService) { Repository repository = obrService.addRepository(url);