Examples of TablePrinter


Examples of io.fabric8.utils.TablePrinter

                    }
                }
            }
        }

        TablePrinter table = new TablePrinter();
        table.columns("cluster", "masters", "slaves", "services");

        for (String clusterName : clusters.keySet()) {
            Map<String, ClusterNode> nodes = clusters.get(clusterName);
            table.row(clusterName, "", "", "", "");
            for (String nodeName : nodes.keySet()) {
                ClusterNode node = nodes.get(nodeName);
                table.row("   " + nodeName,
                        printList(node.masters),
                        printList(node.slaves),
                        printList(node.services));
            }
        }
        table.print();
    }
View Full Code Here

Examples of io.fabric8.utils.TablePrinter

        }
        return null;
    }

    private void printContainers(Container[] containers, Version version, PrintStream out) {
        TablePrinter table = new TablePrinter();
        table.columns("id", "version", "type", "connected", "profiles", "provision status");
        for (Container container : containers) {
            if (CommandUtils.matchVersion(container, version)) {
                String indent = "";
                for (Container c = container; !c.isRoot(); c = c.getParent()) {
                    indent+="  ";
                }
                //Mark local container with a star symbol
                String marker = "";
                if (container.getId().equals(fabricService.getCurrentContainer().getId())) {
                    marker = "*";
                }

                List<String> assignedProfiles = dataStore.getContainerProfiles(container.getId());
                table.row(indent + container.getId() + marker, container.getVersion().getId(), container.getType(),
                        aliveText(container), assignedProfiles.get(0), CommandUtils.status(container));

                // we want multiple profiles to be displayed on next lines
                for (int i = 1; i < assignedProfiles.size(); i++) {
                    table.row("", "", "", "", assignedProfiles.get(i), "");
                }
            }
        }
        table.print();
    }
View Full Code Here

Examples of io.fabric8.utils.TablePrinter

    protected static String aliveText(Container container) {
        return container.isAlive() ? "yes" : "";
    }

    private void printContainersVerbose(Container[] containers, Version version, PrintStream out) {
        TablePrinter table = new TablePrinter();
        table.columns("id", "version", "type", "connected", "profiles", "blueprint", "spring", "provision status");
        for (Container container : containers) {
            if (CommandUtils.matchVersion(container, version)) {
                String indent = "";
                for (Container c = container; !c.isRoot(); c = c.getParent()) {
                    indent += "  ";
                }
                //Mark local container with a star symbol
                String marker = "";
                if (container.getId().equals(fabricService.getCurrentContainer().getId())) {
                    marker = "*";
                }

                String blueprintStatus = dataStore.getContainerAttribute(container.getId(), DataStore.ContainerAttribute.BlueprintStatus, "", false, false);
                String springStatus = dataStore.getContainerAttribute(container.getId(), DataStore.ContainerAttribute.SpringStatus, "", false, false);
                blueprintStatus = blueprintStatus.toLowerCase(Locale.ENGLISH);
                springStatus = springStatus.toLowerCase(Locale.ENGLISH);

                List<String> assignedProfiles = dataStore.getContainerProfiles(container.getId());
                table.row(indent + container.getId() + marker, container.getVersion().getId(), container.getType(),
                        aliveText(container), assignedProfiles.get(0), blueprintStatus, springStatus, CommandUtils.status(container));

                // we want multiple profiles to be displayed on next lines
                for (int i = 1; i < assignedProfiles.size(); i++) {
                    table.row("", "", "", "", assignedProfiles.get(i), "", "", "");
                }
            }
        }
        table.print();

    }
View Full Code Here

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

Examples of io.fabric8.utils.TablePrinter

        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

Examples of io.fabric8.utils.TablePrinter

        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

Examples of io.fabric8.utils.TablePrinter

        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

Examples of io.fabric8.utils.TablePrinter

        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

Examples of io.fabric8.utils.TablePrinter

    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

Examples of io.fabric8.utils.TablePrinter

        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
TOP
Copyright © 2018 www.massapi.com. 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.