use of com.sequenceiq.flow.core.ResourceIdProvider in project cloudbreak by hortonworks.
the class ComponentTestConfig method resourceIdProvider.
@Bean
public ResourceIdProvider resourceIdProvider() {
AtomicLong idSeq = new AtomicLong(0);
ConcurrentMap<String, Long> crnIdMap = new ConcurrentHashMap<>();
ConcurrentMap<String, Long> nameIdMap = new ConcurrentHashMap<>();
return new ResourceIdProvider() {
@Override
public Long getResourceIdByResourceCrn(String resourceCrn) {
return crnIdMap.computeIfAbsent(resourceCrn, r -> idSeq.incrementAndGet());
}
@Override
public Long getResourceIdByResourceName(String resourceName) {
return nameIdMap.computeIfAbsent(resourceName, r -> idSeq.incrementAndGet());
}
};
}
Aggregations