@Test public void testLessThanOrEqual() throws Exception { ResourceSpec rs1 = ResourceSpec.newBuilder().setCpuCores(1.0).setHeapMemoryInMB(100).build(); ResourceSpec rs2 = ResourceSpec.newBuilder().setCpuCores(1.0).setHeapMemoryInMB(100).build(); assertTrue(rs1.lessThanOrEqual(rs2)); assertTrue(rs2.lessThanOrEqual(rs1)); ResourceSpec rs3 = ResourceSpec.newBuilder(). setCpuCores(1.0). setHeapMemoryInMB(100). setGPUResource(1.1). build(); assertTrue(rs1.lessThanOrEqual(rs3)); assertFalse(rs3.lessThanOrEqual(rs1)); ResourceSpec rs4 = ResourceSpec.newBuilder(). setCpuCores(1.0). setHeapMemoryInMB(100). setGPUResource(2.2). build(); assertFalse(rs4.lessThanOrEqual(rs3)); assertTrue(rs3.lessThanOrEqual(rs4)); }
public boolean lessThanOrEqual(@Nonnull ResourceSpec other) { int cmp1 = Double.compare(this.cpuCores, other.cpuCores); int cmp2 = Integer.compare(this.heapMemoryInMB, other.heapMemoryInMB); int cmp3 = Integer.compare(this.directMemoryInMB, other.directMemoryInMB); int cmp4 = Integer.compare(this.nativeMemoryInMB, other.nativeMemoryInMB); int cmp5 = Integer.compare(this.stateSizeInMB, other.stateSizeInMB); int cmp6 = Integer.compare(this.managedMemoryInMB, other.managedMemoryInMB); if (cmp1 <= 0 && cmp2 <= 0 && cmp3 <= 0 && cmp4 <= 0 && cmp5 <= 0 && cmp6 <= 0) { for (Resource resource : extendedResources.values()) { if (!other.extendedResources.containsKey(resource.getName()) || other.extendedResources.get(resource.getName()).getResourceAggregateType() != resource.getResourceAggregateType() || other.extendedResources.get(resource.getName()).getValue() < resource.getValue()) { return false; } } return true; } return false; }
ResourceSpec implements Serializable { public boolean lessThanOrEqual(@Nonnull ResourceSpec other) { int cmp1 = Double.compare(this.cpuCores, other.cpuCores); int cmp2 = Integer.compare(this.heapMemoryInMB, other.heapMemoryInMB); int cmp3 = Integer.compare(this.directMemoryInMB, other.directMemoryInMB); int cmp4 = Integer.compare(this.nativeMemoryInMB, other.nativeMemoryInMB); int cmp5 = Integer.compare(this.stateSizeInMB, other.stateSizeInMB); int cmp6 = Integer.compare(this.managedMemoryInMB, other.managedMemoryInMB); if (cmp1 <= 0 && cmp2 <= 0 && cmp3 <= 0 && cmp4 <= 0 && cmp5 <= 0 && cmp6 <= 0) { for (Resource resource : extendedResources.values()) { if (!other.extendedResources.containsKey(resource.getName()) || other.extendedResources.get(resource.getName()).getResourceAggregateType() != resource.getResourceAggregateType() || other.extendedResources.get(resource.getName()).getValue() < resource.getValue()) { return false; } } return true; } return false; } }
ResourceSpec implements Serializable { public boolean lessThanOrEqual(@Nonnull ResourceSpec other) { int cmp1 = Double.compare(this.cpuCores, other.cpuCores); int cmp2 = Integer.compare(this.heapMemoryInMB, other.heapMemoryInMB); int cmp3 = Integer.compare(this.directMemoryInMB, other.directMemoryInMB); int cmp4 = Integer.compare(this.nativeMemoryInMB, other.nativeMemoryInMB); int cmp5 = Integer.compare(this.stateSizeInMB, other.stateSizeInMB); int cmp6 = Integer.compare(this.managedMemoryInMB, other.managedMemoryInMB); if (cmp1 <= 0 && cmp2 <= 0 && cmp3 <= 0 && cmp4 <= 0 && cmp5 <= 0 && cmp6 <= 0) { for (Resource resource : extendedResources.values()) { if (!other.extendedResources.containsKey(resource.getName()) || other.extendedResources.get(resource.getName()).getResourceAggregateType() != resource.getResourceAggregateType() || other.extendedResources.get(resource.getName()).getValue() < resource.getValue()) { return false; } } return true; } return false; } private  ResourceSpec(
			double cpuCores,
			int heapMemoryInMB,
			int directMemoryInMB,
			int nativeMemoryInMB,
			int stateSizeInMB,
			int managedMemoryInMB,
			Resource... extendedResources); private  ResourceSpec(); }
ResourceSpec implements Serializable { public boolean lessThanOrEqual(@Nonnull ResourceSpec other) { int cmp1 = Double.compare(this.cpuCores, other.cpuCores); int cmp2 = Integer.compare(this.heapMemoryInMB, other.heapMemoryInMB); int cmp3 = Integer.compare(this.directMemoryInMB, other.directMemoryInMB); int cmp4 = Integer.compare(this.nativeMemoryInMB, other.nativeMemoryInMB); int cmp5 = Integer.compare(this.stateSizeInMB, other.stateSizeInMB); int cmp6 = Integer.compare(this.managedMemoryInMB, other.managedMemoryInMB); if (cmp1 <= 0 && cmp2 <= 0 && cmp3 <= 0 && cmp4 <= 0 && cmp5 <= 0 && cmp6 <= 0) { for (Resource resource : extendedResources.values()) { if (!other.extendedResources.containsKey(resource.getName()) || other.extendedResources.get(resource.getName()).getResourceAggregateType() != resource.getResourceAggregateType() || other.extendedResources.get(resource.getName()).getValue() < resource.getValue()) { return false; } } return true; } return false; } private  ResourceSpec(
			double cpuCores,
			int heapMemoryInMB,
			int directMemoryInMB,
			int nativeMemoryInMB,
			int stateSizeInMB,
			int managedMemoryInMB,
			Resource... extendedResources); private  ResourceSpec(); ResourceSpec merge(ResourceSpec other); double getCpuCores(); int getHeapMemory(); int getDirectMemory(); int getNativeMemory(); int getStateSize(); int getManagedMemory(); double getGPUResource(); Map<String, Resource> getExtendedResources(); boolean isValid(); boolean lessThanOrEqual(@Nonnull ResourceSpec other); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); static Builder newBuilder(); }
ResourceSpec implements Serializable { public boolean lessThanOrEqual(@Nonnull ResourceSpec other) { int cmp1 = Double.compare(this.cpuCores, other.cpuCores); int cmp2 = Integer.compare(this.heapMemoryInMB, other.heapMemoryInMB); int cmp3 = Integer.compare(this.directMemoryInMB, other.directMemoryInMB); int cmp4 = Integer.compare(this.nativeMemoryInMB, other.nativeMemoryInMB); int cmp5 = Integer.compare(this.stateSizeInMB, other.stateSizeInMB); int cmp6 = Integer.compare(this.managedMemoryInMB, other.managedMemoryInMB); if (cmp1 <= 0 && cmp2 <= 0 && cmp3 <= 0 && cmp4 <= 0 && cmp5 <= 0 && cmp6 <= 0) { for (Resource resource : extendedResources.values()) { if (!other.extendedResources.containsKey(resource.getName()) || other.extendedResources.get(resource.getName()).getResourceAggregateType() != resource.getResourceAggregateType() || other.extendedResources.get(resource.getName()).getValue() < resource.getValue()) { return false; } } return true; } return false; } private  ResourceSpec(
			double cpuCores,
			int heapMemoryInMB,
			int directMemoryInMB,
			int nativeMemoryInMB,
			int stateSizeInMB,
			int managedMemoryInMB,
			Resource... extendedResources); private  ResourceSpec(); ResourceSpec merge(ResourceSpec other); double getCpuCores(); int getHeapMemory(); int getDirectMemory(); int getNativeMemory(); int getStateSize(); int getManagedMemory(); double getGPUResource(); Map<String, Resource> getExtendedResources(); boolean isValid(); boolean lessThanOrEqual(@Nonnull ResourceSpec other); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); static Builder newBuilder(); static final ResourceSpec UNKNOWN; static final ResourceSpec DEFAULT; static final String GPU_NAME; }