Skip to content

when I use multiple threads to call Geowave API to write data , and i found there are missing some data. #1485

@scially

Description

@scially

when I use multiple threads to call org.locationtech.geowave.core.store.api.Writer to write data at the same time, and add layer to geoserver, and i found there are missing some data. Is org.locationtech.geowave.core.store.api.Writer thread safe?

       BlockingQueue<SimpleFeature> queue = new LinkedBlockingQueue<>(INGEST_BATCH_SIZE);

        final SimpleFeatureType sft = collection.getSchema();

        final FeatureDataAdapter dataAdapter = new FeatureDataAdapter(sft);
        final Writer<SimpleFeature> writer = createWrite(dataAdapter, index);
        // init thread pool
        ExecutorService ingestExecutor = Executors.newFixedThreadPool(threads);
        final List<SimpleIngestTask> ingestTasks = new ArrayList<>();
        try {
            for (int i = 0; i < threads; i++) {
                final String id = String.valueOf(i);
                final SimpleIngestTask task = new SimpleIngestTask(
                        id,
                        queue,
                        writer);
                ingestTasks.add(task);
                ingestExecutor.submit(task);
            }

            while (iter.hasNext()) {
                 queue.offer(iter.next())...
                 ....
           }

SimplIngestTask.run()

        try {
            while (true) {
                SimpleFeature geowaveData = readQueue.poll(
                        100,
                        TimeUnit.MILLISECONDS);
                if (geowaveData == null) {
                    if (isTerminated && readQueue.size() == 0) {
  
                        break;
                    }
                    continue;
                }

                writer.write(geowaveData);
                i++;
            }
        }catch (Exception e){
            ...
        }finally {
            isFinished = true;
        }
    }

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions