Package io.fathom.cloud.compute.scheduler

Examples of io.fathom.cloud.compute.scheduler.SchedulerHost


            }
        }
    }

    private void purgeInstance(InstanceData instance) throws IOException, CloudException {
        SchedulerHost host = scheduler.findHost(instance.getHostId());
        if (host == null) {
            throw new IllegalStateException("No host for instance");
        }

        String hostCookie = instance.getHostCookie();
        if (Strings.isNullOrEmpty(hostCookie)) {
            throw new IllegalStateException("No container for instance");
        }

        UUID containerId = UUID.fromString(hostCookie);
        host.purgeInstance(containerId);

        // TODO: Should we delete entirely? Maybe after a certain amount of
        // time? Maybe as part of an accounting sweep?
    }
View Full Code Here


        InstanceData instance = findInstance(projectId, instanceId);
        if (instance == null) {
            return null;
        }

        SchedulerHost host = scheduler.findHost(instance.getHostId());
        if (host == null) {
            return null;
        }

        String hostCookie = instance.getHostCookie();
        UUID containerId = UUID.fromString(hostCookie);

        byte[] secretData;
        try {
            secretData = host.getSecret(containerId, key);
        } catch (IOException e) {
            throw new CloudException("Error reading secret", e);
        }
        return secretData;
    }
View Full Code Here

    public ImageService.Image createImage(Project project, InstanceData instance, CreateImageRequest request)
            throws IOException, CloudException {
        // TODO: The spec (?) says this call is async.
        // We would probably do better to spend the effort to make it really
        // fast instead (BtrFS?)
        SchedulerHost host = scheduler.findHost(instance.getHostId());
        if (host == null) {
            throw new IllegalStateException();
        }

        String hostCookie = instance.getHostCookie();

        log.warn("createImage is inefficient - we should support side-load");

        Map<String, String> metadata = Maps.newHashMap();
        if (request.metadata != null) {
            metadata.putAll(request.metadata);
        }
        if (request.name != null) {
            metadata.put(ImageService.METADATA_KEY_NAME, request.name);
        }

        metadata.put(ImageService.METADATA_KEY_CONTAINER_FORMAT, "tar");
        metadata.put(ImageService.METADATA_KEY_DISK_FORMAT, "raw");

        UUID containerId = UUID.fromString(hostCookie);
        try (TempFile snapshot = host.createImage(containerId)) {
            ImageService.Image image = imageService.createImage(instance.getProjectId(), metadata);
            BlobData blobData = BlobData.build(snapshot.getFile());
            image = imageService.uploadData(image, blobData);
            return image;
        }
View Full Code Here

        result.instances = Lists.newArrayList();

        List<StartInstanceData> startInstances = Lists.newArrayList();
        for (int i = 0; i < hosts.size(); i++) {
            SchedulerHost host = hosts.get(i);
            InstanceData instanceInfo;
            {
                InstanceData.Builder b = InstanceData.newBuilder(instanceTemplate);
                b.setProjectId(project.getId());
                b.setHostId(host.getId());
                b.setReservationId(reservationInfo.getId());

                b.setInstanceState(InstanceState.PENDING);
                b.setLaunchIndex(i);
View Full Code Here

TOP

Related Classes of io.fathom.cloud.compute.scheduler.SchedulerHost

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.