Package io.fabric8.utils

Examples of io.fabric8.utils.FileChangeInfo


    /**
     * Deploy a file; if its changed then lets force an update of the deployment checksums for this container
     */
    public void onDeploymentFileWrite(String location, File target, FileChangeInfo oldChangeInfo, boolean isSharedLibrary) throws IOException {
        FileChangeInfo changeInfo = FileChangeInfo.newInstance(target);
        boolean updateChecksums = true;
        if (updateMode) {
            if (oldChangeInfo != null) {
                if (oldChangeInfo.equals(changeInfo)) {
                    updateChecksums = false;
                } else {
                    if (isSharedLibrary) {
                        addRestartReason(target);
                    }
                }
            } else if (target.isFile() && target.exists()) {
                if (isSharedLibrary) {
                    addRestartReason(target);
                }
            } else {
                updateChecksums = false;
            }
        }
        if (updateChecksums && container != null) {
            if (containerChecksums == null) {
                containerChecksums = container.getProvisionChecksums();
            }
            if (containerChecksums != null) {
                long checksum = changeInfo.getChecksum();
                containerChecksums.put(location, Long.toString(checksum));
            }
        }
    }
View Full Code Here


        }
    }

    public FileChangeInfo createChangeInfo(File destFile, Long cachedChecksum) throws IOException {
        if (cachedChecksum != null) {
            return new FileChangeInfo(destFile.length(), cachedChecksum);
        } else {
            return createChangeInfo(destFile);
        }
    }
View Full Code Here

        }
    }

    private void copyToContent(InstallContext installContext, File baseDir, String name, String content) throws IOException {
        File target = new File(baseDir, name);
        FileChangeInfo changeInfo = installContext.createChangeInfo(target);
        if (!target.exists() && !target.getParentFile().exists() && !target.getParentFile().mkdirs()) {
            throw new IOException("Directory: " + target.getParentFile().getAbsolutePath() + " can't be created");
        } else if (target.isDirectory()) {
            throw new IOException("Can't write to : " + target.getAbsolutePath() + ". It's a directory");
        } else if (!target.exists() && !target.createNewFile()) {
View Full Code Here

                        checksum = ChecksumUtils.checksumFile(file);
                        checksums.put(destFile, checksum);
                    }
                } else {
                    // we can't use the 'checksum' value as its using the source file not the destFile
                    FileChangeInfo changeInfo = installContext.createChangeInfo(destFile);
                    LOG.debug("Copying file " + fileName + " to :  " + destFile.getCanonicalPath());
                    org.codehaus.plexus.util.FileUtils.copyFile(file, destFile);
                    installContext.onDeploymentFileWrite(location, destFile, changeInfo, isSharedLibrary);
                }
            }
View Full Code Here

                } catch (MalformedURLException e) {
                    LOG.warn("Ignoring invalid URL '" + urlText + "' for overlay resource " + localPath + ". " + e, e);
                }
                if (url != null) {
                    File newFile = new File(baseDir, localPath);
                    FileChangeInfo changeInfo = installContext.createChangeInfo(newFile);
                    newFile.getParentFile().mkdirs();
                    InputStream stream = url.openStream();
                    if (stream != null) {
                        Files.copy(stream, new BufferedOutputStream(new FileOutputStream(newFile)));
                        installContext.onFileWrite(newFile, changeInfo);
View Full Code Here

        for (Map.Entry<String, Pair<File, File>> entry : entries) {
            String location = entry.getKey();
            Pair<File, File> pair = entry.getValue();
            File sourceFile = pair.getFirst();
            File destFile = pair.getSecond();
            FileChangeInfo oldChangeInfo = installContext.createChangeInfo(destFile);
            Files.copy(sourceFile, destFile);
            installContext.onDeploymentFileWrite(location, destFile, oldChangeInfo, true);
        }
    }
View Full Code Here

    @Override
    public Result execute(UIExecutionContext uiExecutionContext) throws Exception {
        Kubernetes kubernetes = getKubernetes();
        PodListSchema pods = kubernetes.getPods();
        KubernetesHelper.removeEmptyPods(pods);
        TablePrinter table = podsAsTable(pods);
        return tableResults(table);
    }
View Full Code Here

        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

TOP

Related Classes of io.fabric8.utils.FileChangeInfo

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.