Example usage for java.util.concurrent CopyOnWriteArraySet CopyOnWriteArraySet

List of usage examples for java.util.concurrent CopyOnWriteArraySet CopyOnWriteArraySet

Introduction

In this page you can find the example usage for java.util.concurrent CopyOnWriteArraySet CopyOnWriteArraySet.

Prototype

public CopyOnWriteArraySet() 

Source Link

Document

Creates an empty set.

Usage

From source file:org.ut.biolab.medsavant.client.view.component.GeneSelectionPanel.java

public Set<Gene> getSelectedGenes() {
    Set<Gene> selectedGenes = new CopyOnWriteArraySet<Gene>();

    for (int row : getSelectedRows()) {
        Object[] rowData = getRowData(row);
        String geneName = (String) rowData[0];
        String chrom = (String) rowData[1];
        int start = (Integer) rowData[2];
        int end = (Integer) rowData[3];

        Gene g = new Gene(geneName, chrom, start, end);
        selectedGenes.add(g);/*from  www .j a  v a2  s  .c o m*/
    }

    return selectedGenes;
}

From source file:com.twitter.ambrose.hive.reporter.AmbroseHiveProgressReporter.java

private void init() {
    jobIdToProgress = new ConcurrentHashMap<String, Integer>();
    jobIdToNodeId = new ConcurrentHashMap<String, String>();
    jobs = new CopyOnWriteArrayList<Job>();
    completedJobIds = new CopyOnWriteArraySet<String>();
    totalMRJobs = 0;/*from  ww  w. ja v a  2s  .  co m*/
    workflowVersion = null;
}

From source file:org.dspace.rdf.RDFizer.java

public RDFizer() {
    this.stdout = false;
    this.verbose = false;
    this.dryrun = false;
    this.lang = "TURTLE";
    this.processed = new CopyOnWriteArraySet<UUID>();
    this.context = new Context(Context.Mode.READ_ONLY);

    this.configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
    this.contentServiceFactory = ContentServiceFactory.getInstance();
    this.communityService = contentServiceFactory.getCommunityService();
    this.itemService = contentServiceFactory.getItemService();
    this.handleService = HandleServiceFactory.getInstance().getHandleService();
    this.storage = RDFFactory.getInstance().getRDFStorage();
}

From source file:com.devicehive.eventbus.SubscriberRegistry.java

/**
 * Registers subscription and subscriber in registry maps.
 * Performs following steps://  ww  w.  j  a  va  2 s.  c  o  m
 *  - if subscriber doesn't have any subscriptions in {@link SubscriberRegistry#subscriberSubscriptions} - creates an empty list for him;
 *  - adds subscription into subscriber's list in {@link SubscriberRegistry#subscriberSubscriptions};
 *  - if nobody is subscribed to this subscription in {@link SubscriberRegistry#subscriptions} - initializes the list;
 *  - adds subscriber to this subscription's list in {@link SubscriberRegistry#subscriptions}
 *
 * @param subscriber - subscriber
 * @param subscription - subscription to subscribe to
 */
void register(Subscriber subscriber, Subscription subscription) {
    CopyOnWriteArraySet<Subscription> subscriptions = subscriberSubscriptions.get(subscriber.getId());
    if (subscriptions == null) {
        //initialize list in a thread safe manner
        CopyOnWriteArraySet<Subscription> newSet = new CopyOnWriteArraySet<>();
        subscriptions = firstNonNull(subscriberSubscriptions.putIfAbsent(subscriber.getId(), newSet), newSet);
    }
    subscriptions.add(subscription);

    CopyOnWriteArraySet<Subscriber> subscribers = this.subscriptions.get(subscription);
    if (subscribers == null) {
        //initialize list in a thread safe manner
        CopyOnWriteArraySet<Subscriber> newSet = new CopyOnWriteArraySet<>();
        subscribers = firstNonNull(this.subscriptions.putIfAbsent(subscription, newSet), newSet);
    }
    subscribers.add(subscriber);
}

From source file:com.espertech.esper.epl.metric.MetricReportingServiceImpl.java

/**
 * Ctor./*  ww w. j  a  v  a  2 s.c  o  m*/
 * @param specification configuration
 * @param engineUri engine URI
 */
public MetricReportingServiceImpl(ConfigurationMetricsReporting specification, String engineUri) {
    if (specification.isEnableMetricsReporting()) {
        MetricUtil.initialize();
    }
    this.specification = specification;
    this.engineUri = engineUri;
    schedule = new MetricScheduleService();

    stmtMetricRepository = new StatementMetricRepository(engineUri, specification);
    statementGroupExecutions = new LinkedHashMap<String, MetricExecStatement>();
    statementMetricHandles = new HashMap<String, StatementMetricHandle>();
    statementOutputHooks = new CopyOnWriteArraySet<StatementResultListener>();

    if (specification.isThreading()) {
        metricsExecutor = new MetricsExecutorThreaded(engineUri);
    } else {
        metricsExecutor = new MetricsExecutorUnthreaded();
    }
}

From source file:org.wrml.runtime.format.application.schema.json.JsonSchema.java

JsonSchema(final JsonSchemaLoader loader, final ObjectNode rootNode) {

    _JsonSchemaLoader = loader;//from  ww w.ja  v a2  s .co  m
    _RootNode = rootNode;

    final SyntaxLoader syntaxLoader = _JsonSchemaLoader.getContext().getSyntaxLoader();
    _SchemaUri = Definitions.PropertyType.$Schema.getValue(_RootNode, syntaxLoader);

    _ExtendsSet = new CopyOnWriteArraySet<>();

    _Properties = new ConcurrentHashMap<>();
    _Dependencies = new ConcurrentHashMap<>();
    _Required = new CopyOnWriteArrayList<>();
    _Links = new CopyOnWriteArrayList<>();

    // TODO not pass the args...
    parseExtensions(rootNode, syntaxLoader);
    parseProperties();
    parseLinks();
    parseRequireds();
    parseDependencies();
}

From source file:com.twitter.distributedlog.config.ConfigurationSubscription.java

public ConfigurationSubscription(ConcurrentBaseConfiguration viewConfig,
        List<FileConfigurationBuilder> fileConfigBuilders, ScheduledExecutorService executorService,
        int reloadPeriod, TimeUnit reloadUnit) throws ConfigurationException {
    Preconditions.checkNotNull(fileConfigBuilders);
    Preconditions.checkArgument(!fileConfigBuilders.isEmpty());
    Preconditions.checkNotNull(executorService);
    Preconditions.checkNotNull(viewConfig);
    this.viewConfig = viewConfig;
    this.executorService = executorService;
    this.reloadPeriod = reloadPeriod;
    this.reloadUnit = reloadUnit;
    this.fileConfigBuilders = fileConfigBuilders;
    this.fileConfigs = Lists.newArrayListWithExpectedSize(this.fileConfigBuilders.size());
    this.confListeners = new CopyOnWriteArraySet<ConfigurationListener>();
    reload();/*from ww  w . ja va  2 s. com*/
    scheduleReload();
}

From source file:org.apache.distributedlog.common.config.ConfigurationSubscription.java

public ConfigurationSubscription(ConcurrentBaseConfiguration viewConfig,
        List<FileConfigurationBuilder> fileConfigBuilders, ScheduledExecutorService executorService,
        int reloadPeriod, TimeUnit reloadUnit) throws ConfigurationException {
    checkNotNull(fileConfigBuilders);//from  w  ww.j a va 2 s.  c  o m
    checkArgument(!fileConfigBuilders.isEmpty());
    checkNotNull(executorService);
    checkNotNull(viewConfig);
    this.viewConfig = viewConfig;
    this.executorService = executorService;
    this.reloadPeriod = reloadPeriod;
    this.reloadUnit = reloadUnit;
    this.fileConfigBuilders = fileConfigBuilders;
    this.fileConfigs = Lists.newArrayListWithExpectedSize(this.fileConfigBuilders.size());
    this.confListeners = new CopyOnWriteArraySet<ConfigurationListener>();
    reload();
    scheduleReload();
}

From source file:jp.co.acroquest.endosnipe.data.db.ConnectionManager.java

/**
 * ????//from   w w  w .j a va  2  s.c o m
 */
private ConnectionManager() {
    this.dataSourceList_ = new ArrayList<DataSourceEntry>();
    this.connectionPoolMap_ = new ConcurrentHashMap<String, ObjectPool>();
    this.initializedDatabaseSet_ = new CopyOnWriteArraySet<String>();
}

From source file:de.taimos.dvalin.interconnect.core.spring.DaemonEvents.java

@Override
@SuppressWarnings("rawtypes")
public <I extends IVO> void listen(final Class<I> eventIVOClazz, IDaemonEventListener<I> listener) {
    this.listeners.putIfAbsent(eventIVOClazz, new CopyOnWriteArraySet<IDaemonEventListener>());
    this.listeners.get(eventIVOClazz).add(listener);
}