APISonar


org.glassfish.virtualization.util.RuntimeContext.logger.log

> org > glassfish > virtualization > util > RuntimeContext > logger > log
org APIs glassfish APIs virtualization APIs util APIs RuntimeContext APIs logger APIs log APIs

Example 1
public String description() {
        StringBuilder sb = new StringBuilder();
        sb.append("Machine ").append(getName());
        try {
        // TODO: create proper description
        } catch (Exception e) {
            RuntimeContext.logger.log(Level.SEVERE, "Exception caught :" + e,e);
            throw new RuntimeException(e);
        }
        return sb.toString();
    }
Example 2
public InetAddress getAddress() {
        try {
            String name = owner.getConfig().getNetworkName();
            if (name != null) {
                return InetAddress.getByName(name);
            } else {
                return InetAddress.getByName(owner.getIpAddress());
            }
        } catch (UnknownHostException e1) {
            RuntimeContext.logger.log(Level.SEVERE, "Cannot create ip address");
            return null;
        }
    }
Example 3
public boolean download(File remoteFile, File localTargetDirectory) {
        try {
            FileUtils.copy(remoteFile, new File(localTargetDirectory, remoteFile.getName()));
            logger.log(Level.INFO, "Successfully copied file {0} to directory {2}",
                    new Object[]{remoteFile.getAbsolutePath(), localTargetDirectory.getAbsolutePath()});
            return true;
        } catch (Exception e) {
            RuntimeContext.logger.log(Level.WARNING, e.getMessage(), e);
            return false;
        }
    }
Example 4
public boolean upload(File localFile, File remoteTargetDirectory) {
        try {
            File toFile = new File(remoteTargetDirectory, localFile.getName());
            if(!toFile.equals(localFile)) {
                FileUtils.copy(localFile, toFile);
                logger.log(Level.INFO, "Successfully copied file {0} to directory {1}",
                        new Object[]{localFile.getAbsolutePath(), remoteTargetDirectory.getAbsolutePath()});
            }
            return true;
        } catch (Exception e) {
            RuntimeContext.logger.log(Level.WARNING, e.getMessage(), e);
            return false;
        }
    }
Example 5
public <T> T execute(MachineOperations<T> operations) throws IOException {

        SSHFileOperations sshFileOperations;
        try {
             sshFileOperations = connect();
        } catch (IOException e) {
            RuntimeContext.logger.log(Level.SEVERE, "Cannot open connection to machine " + this, e);
            throw e;
        }
        try {
            return operations.run(sshFileOperations);
        } finally {
            disconnect();
        }
    }
Example 6
public VirtualMachine byName(String name) throws VirtException {
        if (!domains.containsKey(name)) {
            try {
                getVMs();
            } catch (VirtException e) {
                RuntimeContext.logger.log(Level.SEVERE, "Exception while populating list of domains ", e);
            }
        }
        return domains.get(name);
    }
Example 7
public void install(TemplateInstance template) throws IOException {
        IOException lastException = null;
        for (Machine machine : machines.values()) {
            try {
                machine.install(template);
            } catch (IOException e) {
                lastException = e;
                RuntimeContext.logger.log(Level.SEVERE, "Error while installing template " +
                        template.getConfig().getName() +
                    " on " + machine.getName(), e);
            }
        }
        if (lastException!=null) throw lastException;
    }
Example 8
public void start(TemplateCustomizer customizer, VirtualMachine vm ) throws VirtException {
        try {
            RuntimeContext.logger.log(Level.INFO, "Entering Customizer.start called for " + vm.getName());
            customizeLock.readLock().lock();
            RuntimeContext.logger.log(Level.INFO, "Customizer.start start for " + vm.getName());
            customizer.start(vm, true);
            RuntimeContext.logger.log(Level.INFO, "Customizer.start done for " + vm.getName());
        } finally {
            customizeLock.readLock().unlock();
        }
    }
Example 9
public void postConstruct() {

        // by default all our templates are local to this machine until the Template installation task ran
        for (Template template : serverPool.getConfig().getVirtualization().getTemplates() ) {
            try {
                TemplateInstance ti = templateRepository.byName(template.getName());
                install(ti);
            } catch (IOException e) {
                RuntimeContext.logger.log(Level.SEVERE, "Cannot install template on machine " + getName(),e);
            }
        }
    }