package org.gcube.contentmanagement.blobstorage.service.operation; import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import org.apache.commons.io.IOUtils; import org.gcube.contentmanagement.blobstorage.resource.MyFile; import org.gcube.contentmanagement.blobstorage.transport.backend.util.Costants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Produces the chunks for large files. This class is used only for terrastore * @author Roberto Cirillo (ISTI - CNR) * */ public class ChunkProducer implements Runnable{ MyFile resource; long dimensionChunk; int totChunks; int nThreads; ChunkConsumer task; Monitor monitor; String bucketName; final Logger logger=LoggerFactory.getLogger(ChunkProducer.class); public ChunkProducer(Monitor monitor, MyFile resource, long dimensionChunk, int totChunks, int nThreads, String bucket, ChunkConsumer consumer ) throws FileNotFoundException{ this.resource=resource; this.dimensionChunk=dimensionChunk; this.totChunks=totChunks; this.nThreads=nThreads; this.monitor=monitor; this.task=consumer; this.bucketName=bucket; } @Override public synchronized void run() { long start=System.currentTimeMillis(); ExecutorService executor = Executors.newFixedThreadPool (nThreads); // MyThreadConsumer task=new MyThreadConsumer(monitor, 1, server, bucket); // executor.submit (task); InputStream in=null; try { in = new BufferedInputStream(new FileInputStream(resource.getLocalPath())); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } for (int i=0; i