Package io.fabric8.watcher

Examples of io.fabric8.watcher.Processor


        TablePrinter table = podsAsTable(pods);
        return tableResults(table);
    }

    protected TablePrinter podsAsTable(PodListSchema pods) {
        TablePrinter table = new TablePrinter();
        table.columns("id", "image(s)", "host", "labels", "status");
        List<PodSchema> items = pods.getItems();
        if (items == null) {
            items = Collections.EMPTY_LIST;
        }
        Filter<PodSchema> filter = KubernetesHelper.createPodFilter(filterText.getValue());
        for (PodSchema item : items) {
            if (filter.matches(item)) {
                String id = item.getId();
                CurrentState currentState = item.getCurrentState();
                String status = "";
                String host = "";
                if (currentState != null) {
                    status = currentState.getStatus();
                    host = currentState.getHost();
                }
                Map<String, String> labelMap = item.getLabels();
                String labels = KubernetesHelper.toLabelsString(labelMap);
                DesiredState desiredState = item.getDesiredState();
                if (desiredState != null) {
                    Manifest manifest = desiredState.getManifest();
                    if (manifest != null) {
                        List<ManifestContainer> containers = manifest.getContainers();
                        for (ManifestContainer container : containers) {
                            String image = container.getImage();
                            table.row(id, image, host, labels, status);

                            id = "";
                            host = "";
                            status = "";
                            labels = "";
View Full Code Here


        printReplicationControllers(replicationControllers, System.out);
        return null;
    }

    private void printReplicationControllers(ReplicationControllerListSchema replicationControllers, PrintStream out) {
        TablePrinter table = new TablePrinter();
        table.columns("id", "labels", "replicas", "replica selector");
        List<ReplicationControllerSchema> items = replicationControllers.getItems();
        if (items == null) {
            items = Collections.EMPTY_LIST;
        }
        Filter<ReplicationControllerSchema> filter = KubernetesHelper.createReplicationControllerFilter(filterText.getValue());
        for (ReplicationControllerSchema item : items) {
            if (filter.matches(item)) {
                String id = item.getId();
                String labels = KubernetesHelper.toLabelsString(item.getLabels());
                Integer replicas = null;
                ControllerDesiredState desiredState = item.getDesiredState();
                ControllerCurrentState currentState = item.getCurrentState();
                String selector = null;
                if (desiredState != null) {
                    selector = KubernetesHelper.toLabelsString(desiredState.getReplicaSelector());
                }
                if (currentState != null) {
                    replicas = currentState.getReplicas();
                }
                table.row(id, labels, toPositiveNonZeroText(replicas), selector);
            }
        }
        table.print();
    }
View Full Code Here

        printServices(services, System.out);
        return null;
    }

    private void printServices(ServiceListSchema services, PrintStream out) {
        TablePrinter table = new TablePrinter();
        table.columns("id", "labels", "selector", "port");
        List<ServiceSchema> items = services.getItems();
        if (items == null) {
            items = Collections.EMPTY_LIST;
        }
        Filter<ServiceSchema> filter = KubernetesHelper.createServiceFilter(filterText.getValue());
        for (ServiceSchema item : items) {
            if (filter.matches(item)) {
                String labels = KubernetesHelper.toLabelsString(item.getLabels());
                String selector = KubernetesHelper.toLabelsString(item.getSelector());
                table.row(item.getId(), labels, selector, KubernetesHelper.toPositiveNonZeroText(item.getPort()));
            }
        }
        table.print();
    }
View Full Code Here

    private BlueprintContainer parentContainer;

    public WatcherBlueprintContainer() {
        this.classLoader = getClass().getClassLoader();
        setFileMatchPattern("glob:**.xml");
        setProcessor(new Processor() {
            public void process(Path path) {
                if (!closing.get()) {
                    addPath(path);
                }
            }
View Full Code Here

        return matches;
    }

    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();
                    }
                }
View Full Code Here

            }
        }
    }

    private void process(final Path path) throws IOException {
        final Processor processor = getProcessor();
        if (processor != null) {
            processing.incrementAndGet();
            try {
                executor.execute(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            processor.process(path);
                            lastModified = System.currentTimeMillis();
                        } finally {
                            processing.decrementAndGet();
                            synchronized (processing) {
                                processing.notifyAll();
View Full Code Here

    private long compileDelayMillis = 1000;
    private ClassLoader classLoader;

    public FileWatcherDynamicCompiler() {
        setFileMatchPattern("glob:**.xsd");
        setProcessor(new Processor() {
            public void process(Path path) {
                addCompilePath(path);
            }

            public void onRemove(Path path) {
View Full Code Here

            watcher.setDirMatchPattern(dirMatcher);
        }
        if (fileMatcher != null && !fileMatcher.isEmpty()) {
            watcher.setFileMatchPattern(fileMatcher);
        }
        watcher.setProcessor(new Processor() {
            @Override
            public void process(Path path) {
                scan(path);
            }
            @Override
View Full Code Here

    private ApplicationContext parentApplicationContext;
    private AtomicBoolean closing = new AtomicBoolean(false);

    public WatcherSpringContext() {
        setFileMatchPattern("glob:**.xml");
        setProcessor(new Processor() {
            public void process(Path path) {
                if (!closing.get()) {
                    addPath(path);
                }
            }
View Full Code Here

        }

        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) {
View Full Code Here

TOP

Related Classes of io.fabric8.watcher.Processor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.