fenzo-core/src/main/java/com/netflix/fenzo/InternalVMCloner.java
VirtualMachineLease getClonedMaxResourcesLease(Collection<AssignableVirtualMachine> avms) {
        double cpus = 0.0;
        double mem = 0.0;
        double disk = 0.0;
        double network = 0.0;
        double ports = 0.0;
        final Map<String, Double> scalars = new HashMap<>();
        final Map<String, Protos.Attribute> attributeMap = new HashMap<>();
        if (avms != null) {
            for (AssignableVirtualMachine avm : avms) {
                Map<VMResource, Double> maxResources = avm.getMaxResources();
                Double value = maxResources.get(VMResource.CPU);
                if (value != null) {
                    cpus = Math.max(cpus, value);
                }
                value = maxResources.get(VMResource.Memory);
                if (value != null) {
                    mem = Math.max(mem, value);
                }
                value = maxResources.get(VMResource.Disk);
                if (value != null) {
                    disk = Math.max(disk, value);
                }
                value = maxResources.get(VMResource.Network);
                if (value != null) {
                    network = Math.max(network, value);
                }
                value = maxResources.get(VMResource.Ports);
                if (value != null) {
                    ports = Math.max(ports, value);
                }
                final Map<String, Double> maxScalars = avm.getMaxScalars();
                if (maxScalars != null && !maxScalars.isEmpty()) {
                    for (String k : maxScalars.keySet())
                        scalars.compute(k, (s, oldVal) -> {
                            if (oldVal == null) {
                                oldVal = 0.0;
                            }
                            Double aDouble = maxScalars.get(k);
                            if (aDouble == null) {
                                aDouble = 0.0;
                            }
                            return oldVal + aDouble;
                        });
                }
                final Map<String, Protos.Attribute> attrs = avm.getCurrTotalLease().getAttributeMap();
                if (attrs != null && !attrs.isEmpty()) {
                    for (Map.Entry<String, Protos.Attribute> e : attrs.entrySet())
                        attributeMap.putIfAbsent(e.getKey(), e.getValue());
                }
            }
        }
        final double fcpus = cpus;
        final double fmem = mem;
        final double fdisk = disk;
        final double fnetwork = network;
        final List<VirtualMachineLease.Range> fports = Collections.singletonList(
                new VirtualMachineLease.Range(100, 100 + (int) ports));
        return new VirtualMachineLease() {
            @Override
            public String getId() {
                return "NoID";
            }

            @Override
            public long getOfferedTime() {
                return 0;
            }

            @Override
            public String hostname() {
                return "NoHostname";
            }

            @Override
            public String getVMID() {
                return "NoID";
            }

            @Override
            public double cpuCores() {
                return fcpus;
            }

            @Override
            public double memoryMB() {
                return fmem;
            }

            @Override
            public double networkMbps() {
                return fnetwork;
            }

            @Override
            public double diskMB() {
                return fdisk;
            }

            @Override
            public List<Range> portRanges() {
                return fports;
            }

            @Override
            public Protos.Offer getOffer() {
                return null;
            }

            @Override
            public Map<String, Protos.Attribute> getAttributeMap() {
                return attributeMap;
            }

            @Override
            public Double getScalarValue(String name) {
                return scalars.get(name);
            }

            @Override
            public Map<String, Double> getScalarValues() {
                return scalars;
            }
        };
    }
VirtualMachineLease getClonedMaxResourcesLease(Collection<AssignableVirtualMachine> avms) {
        double cpus = 0.0;
        double mem = 0.0;
        double disk = 0.0;
        double network = 0.0;
        double ports = 0.0;
        final Map<String, Double> scalars = new HashMap<>();
        final Map<String, Protos.Attribute> attributeMap = new HashMap<>();
        if (avms != null) {
            for (AssignableVirtualMachine avm : avms) {
                Map<VMResource, Double> maxResources = avm.getMaxResources();
                Double value = maxResources.get(VMResource.CPU);
                if (value != null) {
                    cpus = Math.max(cpus, value);
                }
                value = maxResources.get(VMResource.Memory);
                if (value != null) {
                    mem = Math.max(mem, value);
                }
                value = maxResources.get(VMResource.Disk);
                if (value != null) {
                    disk = Math.max(disk, value);
                }
                value = maxResources.get(VMResource.Network);
                if (value != null) {
                    network = Math.max(network, value);
                }
                value = maxResources.get(VMResource.Ports);
                if (value != null) {
                    ports = Math.max(ports, value);
                }
                final Map<String, Double> maxScalars = avm.getMaxScalars();
                if (maxScalars != null && !maxScalars.isEmpty()) {
                    for (String k : maxScalars.keySet())
                        scalars.compute(k, (s, oldVal) -> {
                            if (oldVal == null) {
                                oldVal = 0.0;
                            }
                            Double aDouble = maxScalars.get(k);
                            if (aDouble == null) {
                                aDouble = 0.0;
                            }
                            return oldVal + aDouble;
                        });
                }
                final Map<String, Protos.Attribute> attrs = avm.getCurrTotalLease().getAttributeMap();
                if (attrs != null && !attrs.isEmpty()) {
                    for (Map.Entry<String, Protos.Attribute> e : attrs.entrySet())
                        attributeMap.putIfAbsent(e.getKey(), e.getValue());
                }
            }
        }
        final double fcpus = cpus;
        final double fmem = mem;
        final double fdisk = disk;
        final double fnetwork = network;
        final List<VirtualMachineLease.Range> fports = Collections.singletonList(
                new VirtualMachineLease.Range(100, 100 + (int) ports));
        return new VirtualMachineLease() {
            @Override
            public String getId() {
                return "NoID";
            }

            @Override
            public long getOfferedTime() {
                return 0;
            }

            @Override
            public String hostname() {
                return "NoHostname";
            }

            @Override
            public String getVMID() {
                return "NoID";
            }

            @Override
            public double cpuCores() {
                return fcpus;
            }

            @Override
            public double memoryMB() {
                return fmem;
            }

            @Override
            public double networkMbps() {
                return fnetwork;
            }

            @Override
            public double diskMB() {
                return fdisk;
            }

            @Override
            public List<Range> portRanges() {
                return fports;
            }

            @Override
            public Protos.Offer getOffer() {
                return null;
            }

            @Override
            public Map<String, Protos.Attribute> getAttributeMap() {
                return attributeMap;
            }

            @Override
            public Double getScalarValue(String name) {
                return scalars.get(name);
            }

            @Override
            public Map<String, Double> getScalarValues() {
                return scalars;
            }
        };
    }
VirtualMachineLease getClonedMaxResourcesLease ( Collection < AssignableVirtualMachine > avms ) { double cpus = 0.0 ; double mem = 0.0 ; double disk = 0.0 ; double network = 0.0 ; double ports = 0.0 ; final Map < String , Double > scalars = new HashMap <> ( ) ; final Map < String , Protos . Attribute > attributeMap = new HashMap <> ( ) ; if ( avms != null ) { for ( AssignableVirtualMachine avm : avms ) { Map < VMResource , Double > maxResources = avm . getMaxResources ( ) ; Double value = maxResources . get ( VMResource . CPU ) ; if ( value != null ) { cpus = Math . max ( cpus , value ) ; } value = maxResources . get ( VMResource . Memory ) ; if ( value != null ) { mem = Math . max ( mem , value ) ; } value = maxResources . get ( VMResource . Disk ) ; if ( value != null ) { disk = Math . max ( disk , value ) ; } value = maxResources . get ( VMResource . Network ) ; if ( value != null ) { network = Math . max ( network , value ) ; } value = maxResources . get ( VMResource . Ports ) ; if ( value != null ) { ports = Math . max ( ports , value ) ; } final Map < String , Double > maxScalars = avm . getMaxScalars ( ) ; if ( maxScalars != null && ! maxScalars . isEmpty ( ) ) { for ( String k : maxScalars . keySet ( ) ) scalars . compute ( k , ( s , oldVal ) -> { if ( oldVal == null ) { oldVal = 0.0 ; } Double aDouble = maxScalars . get ( k ) ; if ( aDouble == null ) { aDouble = 0.0 ; } return oldVal + aDouble ; } ) ; } final Map < String , Protos . Attribute > attrs = avm . getCurrTotalLease ( ) . getAttributeMap ( ) ; if ( attrs != null && ! attrs . isEmpty ( ) ) { for ( Map . Entry < String , Protos . Attribute > e : attrs . entrySet ( ) ) attributeMap . putIfAbsent ( e . getKey ( ) , e . getValue ( ) ) ; } } } final double fcpus = cpus ; final double fmem = mem ; final double fdisk = disk ; final double fnetwork = network ; final List < VirtualMachineLease . Range > fports = Collections . singletonList ( new VirtualMachineLease . Range ( 100 , 100 + ( int ) ports ) ) ; return new VirtualMachineLease ( ) { @ Override public String getId ( ) { return "NoID" ; } @ Override public long getOfferedTime ( ) { return 0 ; } @ Override public String hostname ( ) { return "NoHostname" ; } @ Override public String getVMID ( ) { return "NoID" ; } @ Override public double cpuCores ( ) { return fcpus ; } @ Override public double memoryMB ( ) { return fmem ; } @ Override public double networkMbps ( ) { return fnetwork ; } @ Override public double diskMB ( ) { return fdisk ; } @ Override public List < Range > portRanges ( ) { return fports ; } @ Override public Protos . Offer getOffer ( ) { return null ; } @ Override public Map < String , Protos . Attribute > getAttributeMap ( ) { return attributeMap ; } @ Override public Double getScalarValue ( String name ) { return scalars . get ( name ) ; } @ Override public Map < String , Double > getScalarValues ( ) { return scalars ; } } ; }
/* package
/ * package