use of io.fabric8.common.util.Filter in project fabric8 by jboss-fuse.
the class DependencyFilters method parse.
/**
* Creates a filter from the given String
*/
public static Filter<Dependency> parse(String dependencyFilterText) {
List<Filter<Dependency>> filters = new ArrayList<Filter<Dependency>>();
StringTokenizer iter = new StringTokenizer(dependencyFilterText);
while (iter.hasMoreElements()) {
String text = iter.nextToken();
Filter<Dependency> filter = parseSingleFilter(text);
if (filter != null) {
filters.add(filter);
}
}
return Filters.compositeFilter(filters);
}
use of io.fabric8.common.util.Filter in project fabric8 by jboss-fuse.
the class Manager method init.
public void init() throws Exception {
// Create client and server
this.client = new ClientInvokerImpl(queue, timeout, serializationStrategies);
this.server = new ServerInvokerImpl(uri, queue, serializationStrategies);
this.client.start();
this.server.start();
// ZooKeeper tracking
try {
create(curator, DOSGI_REGISTRY, CreateMode.PERSISTENT);
} catch (KeeperException.NodeExistsException e) {
// The node already exists, that's fine
}
this.tree = new TreeCacheExtended(curator, DOSGI_REGISTRY, true);
this.tree.getListenable().addListener(this);
this.tree.start();
// UUID
this.uuid = Utils.getUUID(this.bundleContext);
// Service listener filter
String filter = "(" + RemoteConstants.SERVICE_EXPORTED_INTERFACES + "=*)";
// Initialization
this.bundleContext.addServiceListener(this, filter);
// Service registration
this.registration = this.bundleContext.registerService(new String[] { ListenerHook.class.getName(), EventHook.class.getName(), FindHook.class.getName() }, this, null);
// Check existing services
ServiceReference[] references = this.bundleContext.getServiceReferences((String) null, filter);
if (references != null) {
for (ServiceReference reference : references) {
exportService(reference);
}
}
}
use of io.fabric8.common.util.Filter in project strimzi by strimzi.
the class AbstractAssemblyOperator method reconcileAll.
/**
* Reconcile assembly resources in the given namespace having the given selector.
* Reconciliation works by getting the assembly ConfigMaps in the given namespace with the given selector and
* comparing with the corresponding {@linkplain #getResources(String) resource}.
* <ul>
* <li>An assembly will be {@linkplain #createOrUpdate(Reconciliation, ConfigMap, Handler) created} for all ConfigMaps without same-named resources</li>
* <li>An assembly will be {@linkplain #delete(Reconciliation, Handler) deleted} for all resources without same-named ConfigMaps</li>
* </ul>
*
* @param trigger A description of the triggering event (timer or watch), used for logging
* @param namespace The namespace
* @param selector The selector
*/
public final CountDownLatch reconcileAll(String trigger, String namespace, Labels selector) {
Labels selectorWithCluster = selector.withType(assemblyType);
// get ConfigMaps with kind=cluster&type=kafka (or connect, or connect-s2i) for the corresponding cluster type
List<ConfigMap> cms = configMapOperations.list(namespace, selectorWithCluster);
Set<String> cmsNames = cms.stream().map(cm -> cm.getMetadata().getName()).collect(Collectors.toSet());
log.debug("reconcileAll({}, {}): ConfigMaps with labels {}: {}", assemblyType, trigger, selectorWithCluster, cmsNames);
// get resources with kind=cluster&type=kafka (or connect, or connect-s2i)
List<? extends HasMetadata> resources = getResources(namespace);
// now extract the cluster name from those
Set<String> resourceNames = resources.stream().filter(// exclude Cluster CM, which won't have a cluster label
r -> Labels.kind(r) == null).map(Labels::cluster).collect(Collectors.toSet());
log.debug("reconcileAll({}, {}): Other resources with labels {}: {}", assemblyType, trigger, selectorWithCluster, resourceNames);
cmsNames.addAll(resourceNames);
// We use a latch so that callers (specifically, test callers) know when the reconciliation is complete
// Using futures would be more complex for no benefit
CountDownLatch latch = new CountDownLatch(cmsNames.size());
for (String name : cmsNames) {
Reconciliation reconciliation = new Reconciliation(trigger, assemblyType, namespace, name);
reconcileAssembly(reconciliation, result -> {
if (result.succeeded()) {
log.info("{}: Assembly reconciled", reconciliation);
} else {
log.error("{}: Failed to reconcile", reconciliation);
}
latch.countDown();
});
}
return latch;
}
use of io.fabric8.common.util.Filter in project halyard by spinnaker.
the class BakeDebianServiceProvider method getInstallCommand.
@Override
public String getInstallCommand(DeploymentDetails deploymentDetails, GenerateService.ResolvedConfiguration resolvedConfiguration, Map<String, String> installCommands, String startupCommand) {
Map<String, Object> bindings = new HashMap<>();
List<SpinnakerService.Type> serviceTypes = new ArrayList<>(installCommands.keySet()).stream().map(SpinnakerService.Type::fromCanonicalName).collect(Collectors.toList());
List<String> upstartNames = getPrioritizedBakeableServices(serviceTypes).stream().filter(i -> resolvedConfiguration.getServiceSettings(i.getService()).getEnabled()).map(i -> ((BakeDebianService) i).getUpstartServiceName()).filter(Objects::nonNull).collect(Collectors.toList());
List<String> systemdServiceConfigs = upstartNames.stream().map(n -> n + ".service").collect(Collectors.toList());
List<String> serviceInstalls = serviceTypes.stream().map(t -> installCommands.get(t.getCanonicalName())).collect(Collectors.toList());
TemplatedResource resource = new StringReplaceJarResource("/debian/init.sh");
bindings.put("services", Strings.join(upstartNames, " "));
bindings.put("systemd-service-configs", Strings.join(systemdServiceConfigs, " "));
String upstartInit = resource.setBindings(bindings).toString();
BillOfMaterials.ArtifactSources artifactSources = artifactService.getArtifactSources(deploymentDetails.getDeploymentName());
resource = new StringReplaceJarResource("/debian/pre-bake.sh");
bindings = new HashMap<>();
bindings.put("debian-repository", artifactSourcesConfig.mergeWithBomSources(artifactSources).getDebianRepository());
bindings.put("install-commands", String.join("\n", serviceInstalls));
bindings.put("upstart-init", upstartInit);
bindings.put("startup-file", Paths.get(startupScriptPath, "startup.sh").toString());
bindings.put("startup-command", startupCommand);
return resource.setBindings(bindings).toString();
}
use of io.fabric8.common.util.Filter in project halyard by spinnaker.
the class LocalDebianServiceProvider method clean.
@Override
public RemoteAction clean(DeploymentDetails details, SpinnakerRuntimeSettings runtimeSettings) {
String uninstallArtifacts = String.join("\n", getServices().stream().filter(s -> s != null && runtimeSettings.getServiceSettings(s).getEnabled()).map(s -> ((LocalDebianService) s).uninstallArtifactCommand()).collect(Collectors.toList()));
Map<String, Object> bindings = new HashMap<>();
TemplatedResource resource = new StringReplaceJarResource("/debian/uninstall.sh");
bindings.put("uninstall-artifacts", uninstallArtifacts);
return new RemoteAction().setScript(resource.setBindings(bindings).toString()).setAutoRun(true).setScriptDescription("This script apt-get purges all spinnaker components & deletes their config");
}
Aggregations