All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yahoo.bullet.rest.common.PublisherRandomPool Maven / Gradle / Ivy

Go to download

This is the Web Service for Bullet - a real-time query engine - in Spring Boot.

There is a newer version: 1.4.3
Show newest version
/*
 *  Copyright 2020, Yahoo Inc.
 *  Licensed under the terms of the Apache License, Version 2.0.
 *  See the LICENSE file associated with the project for terms.
 */
package com.yahoo.bullet.rest.common;

import com.yahoo.bullet.common.RandomPool;
import com.yahoo.bullet.pubsub.Publisher;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

@Slf4j
public class PublisherRandomPool extends RandomPool implements AutoCloseable {
    private List publishers;

    /**
     * Constructor for the RandomPool that takes a list of items.
     *
     * @param items A list of items to form the pool with.
     */
    public PublisherRandomPool(List items) {
        super(items);
        this.publishers = items;
    }

    @Override
    public void clear() {
        for (Publisher publisher : publishers) {
            try {
                publisher.close();
            } catch (Exception e) {
                log.error("Error closing publisher", e);
            }
        }
        publishers = null;
    }

    @Override
    public void close() {
        clear();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy