use of io.fabric8.watcher.Processor in project camel by apache.
the class KubernetesConfigMapsProducerTest method getConfigMapTest.
@Test
public void getConfigMapTest() throws Exception {
if (ObjectHelper.isEmpty(authToken)) {
return;
}
Exchange ex = template.request("direct:getConfigMap", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_CONFIGMAP_NAME, "elasticsearch-7015o");
}
});
ConfigMap result = ex.getOut().getBody(ConfigMap.class);
assertNull(result);
}
use of io.fabric8.watcher.Processor in project camel by apache.
the class KubernetesNamespacesProducerTest method getNamespace.
@Test
public void getNamespace() throws Exception {
if (ObjectHelper.isEmpty(authToken)) {
return;
}
Exchange ex = template.request("direct:getNs", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
}
});
Namespace ns = ex.getOut().getBody(Namespace.class);
assertEquals(ns.getMetadata().getName(), "default");
}
use of io.fabric8.watcher.Processor in project fabric8 by jboss-fuse.
the class FileWatcher method unscan.
private void unscan(final Path file) throws IOException {
if (isMatchesFile(file)) {
Processor processor = getProcessor();
if (processor != null) {
processor.onRemove(file);
}
lastModified = System.currentTimeMillis();
} else {
// lets find all the files that now no longer exist
List<Path> files = new ArrayList<Path>(processedMap.keySet());
for (Path path : files) {
if (!Files.exists(path)) {
LOGGER.debug("File has been deleted: " + path);
processedMap.remove(path);
if (isMatchesFile(path)) {
Processor processor = getProcessor();
if (processor != null) {
processor.onRemove(path);
}
fireListeners(path, ENTRY_DELETE);
lastModified = System.currentTimeMillis();
}
}
}
}
}
use of io.fabric8.watcher.Processor in project fabric8 by jboss-fuse.
the class FileWatcherMapping method init.
public void init() throws IOException {
if (camelContext == null) {
throw new IllegalArgumentException("CamelContext must be configured on " + this);
}
mapper = new DozerBeanMapper();
setFileMatchPattern("glob:META-INF/services/dozer/*.xml");
setProcessor(new Processor() {
public void process(Path path) {
addOrUpdateMapping(path);
}
public void onRemove(Path path) {
removeMapping(path);
}
});
super.init();
LOG.info("Watching directory " + getRoot() + " for Dozer XML Mapping file changes");
}
use of io.fabric8.watcher.Processor in project camel by apache.
the class KubernetesNodesConsumerTest method createAndDeletePod.
@Test
public void createAndDeletePod() throws Exception {
if (ObjectHelper.isEmpty(authToken)) {
return;
}
mockResultEndpoint.expectedMessageCount(1);
mockResultEndpoint.expectedHeaderValuesReceivedInAnyOrder(KubernetesConstants.KUBERNETES_EVENT_ACTION, "MODIFIED");
Exchange ex = template.request("direct:createPod", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_POD_NAME, "test");
Map<String, String> labels = new HashMap<String, String>();
labels.put("this", "rocks");
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_PODS_LABELS, labels);
PodSpec podSpec = new PodSpec();
podSpec.setHostname("localhost");
Container cont = new Container();
cont.setImage("docker.io/jboss/wildfly:latest");
cont.setName("pippo");
List<ContainerPort> containerPort = new ArrayList<ContainerPort>();
ContainerPort port = new ContainerPort();
port.setHostIP("0.0.0.0");
port.setHostPort(8080);
port.setContainerPort(8080);
containerPort.add(port);
cont.setPorts(containerPort);
List<Container> list = new ArrayList<Container>();
list.add(cont);
podSpec.setContainers(list);
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_POD_SPEC, podSpec);
}
});
ex = template.request("direct:deletePod", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_POD_NAME, "test");
}
});
boolean podDeleted = ex.getOut().getBody(Boolean.class);
assertTrue(podDeleted);
Thread.sleep(3000);
mockResultEndpoint.assertIsSatisfied();
}
Aggregations