@Activate
  public void activate() {
    discreteConsumers =
        service
            .<DiscreteResource, ResourceConsumer>consistentMapBuilder()
            .withName(DISCRETE_CONSUMER_MAP)
            .withSerializer(SERIALIZER)
            .build();
    continuousConsumers =
        service
            .<ResourceId, ContinuousResourceAllocation>consistentMapBuilder()
            .withName(CONTINUOUS_CONSUMER_MAP)
            .withSerializer(SERIALIZER)
            .build();
    childMap =
        service
            .<DiscreteResource, Set<Resource>>consistentMapBuilder()
            .withName(CHILD_MAP)
            .withSerializer(SERIALIZER)
            .build();

    Tools.retryable(
        () -> childMap.put(Resource.ROOT, new LinkedHashSet<>()),
        ConsistentMapException.class,
        MAX_RETRIES,
        RETRY_DELAY);
    log.info("Started");
  }
Beispiel #2
0
 @Override
 public IdBlock getIdBlock(String topic) {
   AtomicCounter counter =
       topicCounters.computeIfAbsent(
           topic, name -> storageService.atomicCounterBuilder().withName(name).build());
   Long blockBase =
       Tools.retryable(counter::getAndAdd, StorageException.class, MAX_TRIES, RETRY_DELAY_MS)
           .apply(DEFAULT_BLOCK_SIZE);
   return new IdBlock(blockBase, DEFAULT_BLOCK_SIZE);
 }