use of bio.terra.buffer.common.ResourceState in project terra-resource-buffer by DataBiosphere.
the class FlightSchedulerTest method newPoolWithResourceCount.
/**
* Creates a pool with resources with given {@code resourceStates}.
*/
private Pool newPoolWithResourceCount(int poolSize, Multiset<ResourceState> resourceStates) {
PoolId poolId = PoolId.create(UUID.randomUUID().toString());
Pool pool = Pool.builder().creation(Instant.now()).id(poolId).resourceType(ResourceType.GOOGLE_PROJECT).size(poolSize).resourceConfig(new ResourceConfig().configName("resourceName")).status(PoolStatus.ACTIVE).build();
bufferDao.createPools(ImmutableList.of(pool));
for (ResourceState state : resourceStates) {
bufferDao.createResource(Resource.builder().id(ResourceId.create(UUID.randomUUID())).poolId(poolId).creation(Instant.now()).state(state).build());
}
return pool;
}
use of bio.terra.buffer.common.ResourceState in project terra-resource-buffer by DataBiosphere.
the class PoolService method getPoolInfo.
/**
* Gets pool information by given {@link PoolId}.
*/
public PoolInfo getPoolInfo(PoolId poolId) {
Optional<PoolAndResourceStates> poolAndResourceStates = bufferDao.retrievePoolAndResourceStatesById(poolId);
if (poolAndResourceStates.isEmpty()) {
throw new NotFoundException(String.format("Pool %s not found", poolId));
}
Pool pool = poolAndResourceStates.get().pool();
Multiset<ResourceState> resourceStates = poolAndResourceStates.get().resourceStates();
return new PoolInfo().poolConfig(new PoolConfig().poolId(poolId.toString()).size(pool.size()).resourceConfigName(pool.resourceConfig().getConfigName())).status(bio.terra.buffer.generated.model.PoolStatus.valueOf(pool.status().toString())).putResourceStateCountItem(ResourceState.CREATING.name(), resourceStates.count(ResourceState.CREATING)).putResourceStateCountItem(ResourceState.READY.name(), resourceStates.count(ResourceState.READY)).putResourceStateCountItem(ResourceState.DELETED.name(), resourceStates.count(ResourceState.DELETED)).putResourceStateCountItem(ResourceState.HANDED_OUT.name(), resourceStates.count(ResourceState.HANDED_OUT));
}
Aggregations