Example usage for java.util.concurrent CopyOnWriteArrayList CopyOnWriteArrayList

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

Introduction

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

Prototype

public CopyOnWriteArrayList() 

Source Link

Document

Creates an empty list.

Usage

From source file:com.sm.store.cluster.Utils.java

public static List<TCPClient> buildEmptyList(int size) {
    List<TCPClient> list = new CopyOnWriteArrayList<TCPClient>();
    for (int i = 1; i < size; i++)
        list.add(null);//from   w w w .j ava2s . c o m
    return list;
}

From source file:ijfx.ui.explorer.view.GroupExplorable.java

public GroupExplorable() {
    list3D = new CopyOnWriteArrayList<>();
    list2D = new CopyOnWriteArrayList<>();
    listItems = new CopyOnWriteArrayList<>();
    metaDataList = new ArrayList<>();
    //TODO/* ww w. j a  v  a2  s . c o m*/
    metaDataList.add("1");
    metaDataList.add("2");
    metaDataList.add("3");
    sortListExplorable = new SortListExplorable<>();

}

From source file:rc.championship.platform.decoder.lap.publisher.JaxRSLapPublisher.java

@Override
protected void start() {
    super.start();
    targets = new CopyOnWriteArrayList<>();
    reloadTargetsFromProperties();/*from www  .  j a v a  2  s .com*/
    executor = Executors.newSingleThreadScheduledExecutor();
    executor.submit(this);
}

From source file:pzalejko.iot.hardware.home.core.service.DefaultEventBus.java

@Inject
public DefaultEventBus(TaskExecutor executor) {
    this.executor = executor;
    listeners = new CopyOnWriteArrayList<>();
}

From source file:net.ion.framework.db.manager.script.FileAlterationMonitor.java

public FileAlterationMonitor(long interval, ScheduledExecutorService ses, FileAlterationObserver first,
        FileAlterationObserver... observers) {
    this.ses = ses;
    this.observers = new CopyOnWriteArrayList<FileAlterationObserver>();
    this.interval = interval;
    addObserver(first);/*w ww  .  j  av a2 s  . c  o m*/
    for (FileAlterationObserver observer : observers) {
        addObserver(observer);
    }
}

From source file:org.apache.activemq.artemis.spi.core.protocol.AbstractProtocolManagerFactory.java

/**
 * This method exists because java templates won't store the type of P at runtime.
 * So it's not possible to write a generic method with having the Class Type.
 * This will serve as a tool for sub classes to filter properly* * *
 *
 * @param type/*from   ww w.j  a v a 2s  . co  m*/
 * @param listIn
 * @return
 */
protected List<P> internalFilterInterceptors(Class<P> type, List<? extends BaseInterceptor> listIn) {
    if (listIn == null) {
        return Collections.emptyList();
    } else {
        CopyOnWriteArrayList<P> listOut = new CopyOnWriteArrayList<>();
        for (BaseInterceptor<?> in : listIn) {
            if (type.isInstance(in)) {
                listOut.add((P) in);
            }
        }
        return listOut;
    }
}

From source file:io.atrac613.AbstractNfcTagFragment.java

/**
 * NfcAdapter??TechList??? (?????)/*from w  w w. java  2s .c om*/
 * @param techList ????????
 * @return String[][] ????????
 */
private static synchronized String[][] registerTechList(String[]... techList) {
    if (sTechList == null) {
        sTechList = new CopyOnWriteArrayList<String[]>();
    }

    for (String[] filterTech : techList) {
        boolean containTechList = false;
        if (sTechList.size() > 0) {
            for (String[] source : sTechList) {
                if (ArrayUtil.containArray(source, filterTech)) {
                    containTechList = true;
                    break;
                }
            }
        }
        if (!containTechList) {
            sTechList.add(filterTech);
        }
    }

    return sTechList.toArray(new String[sTechList.size()][]);
}

From source file:com.sm.store.cluster.BuildClusterNodes.java

public List<ClusterNodes> build() {
    List<HierarchicalConfiguration> list = (List<HierarchicalConfiguration>) config.configurationsAt(CLUSTERS);
    if (list == null || list.size() == 0)
        throw new RuntimeException("list is null or freq ==0 for node " + CLUSTERS);
    List<ClusterNodes> toReturn = new CopyOnWriteArrayList<ClusterNodes>();
    StringBuilder stringBuilder = new StringBuilder();
    HashSet<Short> sets = new HashSet<Short>();
    int error = 0;
    for (HierarchicalConfiguration each : list) {
        ClusterNodes clusterNode = buildClusterNodes(each);
        if (sets.contains(clusterNode.getId())) {
            error++;// w  w w  . j a v  a 2 s. c o  m
            stringBuilder.append(" cluster no " + clusterNode.getId());
        } else
            sets.add(clusterNode.getId());
        toReturn.add(clusterNode);
    }
    if (error > 0) {
        throw new RuntimeException(
                error + " duplicate clusters , " + stringBuilder.toString() + " in clusters.xml");
    } else
        return toReturn;
}

From source file:com.sm.store.cluster.BuildStoreConfig.java

public List<StoreConfig> build() {
    List<HierarchicalConfiguration> list = (List<HierarchicalConfiguration>) config.configurationsAt(STORE);
    if (list == null || list.size() == 0)
        throw new RuntimeException("list is null or freq ==0 for node " + STORE);
    List<StoreConfig> toReturn = new CopyOnWriteArrayList<StoreConfig>();
    for (HierarchicalConfiguration each : list) {
        toReturn.add(buildStoreConfig(each));
    }//from  w  w  w.  j av a2  s.  c o  m
    return toReturn;
}

From source file:org.wallride.job.UpdatePostViewsItemReader.java

@Override
protected void doReadPage() {
    if (results == null) {
        results = new CopyOnWriteArrayList<>();
    } else {/*w  w  w. j a v a  2  s  .c o m*/
        results.clear();
    }

    Blog blog = blogService.getBlogById(Blog.DEFAULT_ID);
    GoogleAnalytics googleAnalytics = blog.getGoogleAnalytics();
    if (googleAnalytics == null) {
        logger.warn("Configuration of Google Analytics can not be found");
        return;
    }

    Analytics analytics = GoogleAnalyticsUtils.buildClient(googleAnalytics);

    try {
        LocalDate now = LocalDate.now();
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        Analytics.Data.Ga.Get request = analytics.data().ga()
                .get(googleAnalytics.getProfileId(), now.minusYears(1).format(dateTimeFormatter),
                        now.format(dateTimeFormatter), "ga:pageViews")
                //                  .setDimensions(String.format("ga:dimension%d", googleAnalytics.getCustomDimensionIndex()))
                //                  .setSort(String.format("-ga:dimension%d", googleAnalytics.getCustomDimensionIndex()))
                .setDimensions(String.format("ga:pagePath", googleAnalytics.getCustomDimensionIndex()))
                .setSort(String.format("-ga:pageViews", googleAnalytics.getCustomDimensionIndex()))
                .setStartIndex(getPage() * getPageSize() + 1).setMaxResults(getPageSize());

        logger.info(request.toString());
        final GaData gaData = request.execute();
        if (CollectionUtils.isEmpty(gaData.getRows())) {
            return;
        }

        results.addAll(gaData.getRows());
    } catch (IOException e) {
        logger.warn("Failed to synchronize with Google Analytics", e);
        throw new GoogleAnalyticsException(e);
    }

    //      logger.info("Synchronization to google analytics is now COMPLETE. {} posts updated.", count);
}