Package io.fabric8.utils

Examples of io.fabric8.utils.TablePrinter


            watcher.start();
        }

        if (list) {
            // list the watched bundles.
            TablePrinter printer = new TablePrinter();
            printer.columns("url", "profile", "version", "bundle");
            for (String url : watcher.getWatchURLs()) {
                Map<ProfileVersionKey, Map<String, Parser>> profileArtifacts = watcher.getProfileArtifacts();
                if (profileArtifacts.size() > 0) {
                    Set<Map.Entry<ProfileVersionKey, Map<String, Parser>>> entries = profileArtifacts.entrySet();
                    for (Map.Entry<ProfileVersionKey, Map<String, Parser>> entry : entries) {
                        ProfileVersionKey key = entry.getKey();
                        Map<String, Parser> artifactMap = entry.getValue();
                        Set<Map.Entry<String, Parser>> artifactMapEntries = artifactMap.entrySet();
                        for (Map.Entry<String, Parser> artifactMapEntry : artifactMapEntries) {
                            String location = artifactMapEntry.getKey();
                            Parser parser = artifactMapEntry.getValue();
                            if (isSnapshot(parser) || watcher.wildCardMatch(location, url)) {
                                printer.row(url, key.getProfileId(), key.getVersion(), location);
                            }
                        }
                    }
                } else {
                    printer.row(url, "", "", "");
                }
            }
            printer.print();
        } else {
            List<String> urls = watcher.getWatchURLs();
            if (urls != null && urls.size() > 0) {
                System.out.println("Watched URLs: ");
                for (String url : watcher.getWatchURLs()) {
View Full Code Here


        super(fabricService);
    }

    @Override
    protected void printRequirements(PrintStream out, FabricRequirements requirements) {
        TablePrinter table = new TablePrinter();
        table.columns("profile", "# minimum", "# maximum", "depends on");
        List<ProfileRequirements> profileRequirements = requirements.getProfileRequirements();
        for (ProfileRequirements profile : profileRequirements) {
            table.row(profile.getProfile(),
                    getStringOrBlank(profile.getMinimumInstances()),
                    getStringOrBlank(profile.getMaximumInstances()),
                    getStringOrBlank(profile.getDependentProfiles()));
        }
        table.print();
    }
View Full Code Here

        printProfiles(profileService, profiles, System.out);
        return null;
    }

    protected void printProfiles(ProfileService profileService, List<Profile> profiles, PrintStream out) {
        TablePrinter table = new TablePrinter();
        table.columns("id", "# containers", "parents");
        for (Profile profile : profiles) {
          String versionId = profile.getVersion();
          String profileId = profile.getId();
            // skip profiles that do not exists (they may have been deleted)
            if (profileService.hasProfile(versionId, profileId) && (hidden || !profile.isHidden())) {
                int active = fabricService.getAssociatedContainers(versionId, profileId).length;
                String parents = Strings.join(profile.getParentIds(), " ");
                table.row(profileId, activeContainerCountText(active), parents);
            }
        }
        table.print();
    }
View Full Code Here

        this.clusterService = clusterService;
    }

    @Override
    protected Object doExecute() throws Exception {
        TablePrinter printer = new TablePrinter();
        printer.column("id");

        List<String> containers = clusterService.getEnsembleContainers();
        if (containers != null) {
            for (String container : containers) {
                printer.row(container);
            }
        }
        printer.print();

        return null;
    }
View Full Code Here

        printInstallations(installations, System.out);
        return null;
    }

    protected void printInstallations(List<Installation> installations, PrintStream out) {
        TablePrinter printer = new TablePrinter();
        if (verbose) {
            printer.columns("id", "pid", "connected", "type", "directory");
        } else {
            printer.columns("id", "pid", "connected", "type");
        }

        for (Installation installation : installations) {

            String id = installation.getId();
            String pid = "";
            String connected = "no";
            String path = installation.getInstallDir() != null ? installation.getInstallDir().getPath() : "";

            String type = installation.getName();
            if (!verbose) {
                if (type.startsWith("java ")) {
                    // skip middle package name as that is too verbose
                    int idx = type.lastIndexOf('.');
                    if (idx > 0) {
                        type = "java " + type.substring(idx + 1);
                    }
                }
            }
            try {
                Long aid = installation.getActivePid();
                if (aid != null) {
                    pid = "" + aid;
                    connected = "yes";
                }
            } catch (IOException e) {
                // ignore
            }
            if (verbose) {
                printer.row(id, pid, connected, type, path);
            } else {
                printer.row(id, pid, connected, type);
            }
        }

        printer.print(out);
    }
View Full Code Here

    protected void doControlCommand(Installation installation) throws Exception {
        printEnvironment(installation, System.out);
    }

    protected void printEnvironment(Installation installation, PrintStream out) {
        TablePrinter printer = new TablePrinter();
        printer.columns("variable", "value");

        for (String variable : installation.getEnvironment().keySet()) {
            String value = installation.getEnvironment().get(variable);
            printer.row(variable, value);
        }

        printer.print(out);
    }
View Full Code Here

        List<Installation> installations = getContainerProcessManager().listInstallations(options);
        printInstallations(installations, System.out);
    }

    protected void printInstallations(List<Installation> installations, PrintStream out) {
        TablePrinter printer = new TablePrinter();
        printer.columns("id", "pid", "name");

        for (Installation installation : installations) {
            String id = installation.getId();
            String pid = "";
            try {
                pid = "" + installation.getActivePid();
            } catch (IOException e) {
                pid = "<unknown>";
            }
            printer.row(id, pid, installation.getName());
        }

        printer.print(out);
    }
View Full Code Here

       
        return null;
    }

    private void printContainers(PodListSchema pods, PrintStream out) {
        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 = KubernetesHelpers.createPodFilter(filterText);
        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 = KubernetesHelpers.toLabelsString(labelMap);
                DesiredState desiredState = item.getDesiredState();
                if (desiredState != null) {
                    ManifestSchema 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 = "";
                        }
                    }
                }
            }
        }
        table.print();
    }
View Full Code Here

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

    private void printContainers(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 = KubernetesHelpers.createServiceFilter(filterText);
        for (ServiceSchema item : items) {
            if (filter.matches(item)) {
                String labels = KubernetesHelpers.toLabelsString(item.getLabels());
                String selector = KubernetesHelpers.toLabelsString(item.getSelector());
                table.row(item.getId(), labels, selector, KubernetesHelpers.toPositiveNonZeroText(item.getPort()));
            }
        }
        table.print();
    }
View Full Code Here

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

    private void printContainers(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 = KubernetesHelpers.createReplicationControllerFilter(filterText);
        for (ReplicationControllerSchema item : items) {
            if (filter.matches(item)) {
                String id = item.getId();
                String labels = KubernetesHelpers.toLabelsString(item.getLabels());
                Integer replicas = null;
                ControllerDesiredState desiredState = item.getDesiredState();
                ControllerCurrentState currentState = item.getCurrentState();
                String selector = null;
                if (desiredState != null) {
                    selector = KubernetesHelpers.toLabelsString(desiredState.getReplicaSelector());
                }
                if (currentState != null) {
                    replicas = currentState.getReplicas();
                }
                table.row(id, labels, toPositiveNonZeroText(replicas), selector);
            }
        }
        table.print();
    }
View Full Code Here

TOP

Related Classes of io.fabric8.utils.TablePrinter

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.