<commit_before>/**
 * 
 */
package org.jscsi.target.storage;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import org.jclouds.ContextBuilder;
import org.jclouds.blobstore.BlobStore;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.domain.Blob;
import org.jclouds.filesystem.reference.FilesystemConstants;
import org.jscsi.target.storage.buffering.BufferedTaskWorker;
import org.jscsi.target.storage.buffering.BufferedWriteTask;
import org.jscsi.target.storage.buffering.BufferedWriteTask.PoisonTask;
import org.jscsi.target.storage.buffering.Collision;

import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;

/**
 * @author <NAME>, University of Konstanz
 * 
 */
public class JCloudsStorageModule implements IStorageModule {

    /** Number of Blocks in one Cluster. */
    public static final int BLOCK_IN_CLUSTER = 512;

    private final long mNumberOfCluster;

    private final String mContainerName;

    private final BlobStore mStore;

    private final BlobStoreContext mContext;

    // /**
    // * The service that holds the BufferedTaskWorker
    // */
    // private final ExecutorService mWriterService;

    /**
     * The worker to process write tasks
     */
    private final BufferedTaskWorker mWorker;

    /**
     * Creates a new {@link JCloudsStorageModules} backed by the specified
     * file. If no such file exists, a {@link FileNotFoundException} will be
     * thrown.
     * 
     * @param pSizeInBlocks
     *            blocksize for this module
     * 
     * @throws FileNotFoundException
     *             if the specified file does not exist
     */
    public JCloudsStorageModule(final long pSizeInBlocks, final File pFile) {
        try {
            mNumberOfCluster = pSizeInBlocks / BLOCK_IN_CLUSTER;
            mContainerName = "grave9283746";
            String[] credentials = getCredentials();
            if (credentials.length == 0) {
                Properties properties = new Properties();
                properties.setProperty(FilesystemConstants.PROPERTY_BASEDIR, pFile.getAbsolutePath());
                mContext =
                    ContextBuilder.newBuilder("filesystem").overrides(properties).credentials("testUser",
                        "testPass").buildView(BlobStoreContext.class);
            } else {
                mContext =
                    ContextBuilder.newBuilder("aws-s3").credentials(getCredentials()[0], getCredentials()[1])
                        .buildView(BlobStoreContext.class);
            }

            // Create Container
            mStore = mContext.getBlobStore();
            if (!mStore.containerExists(mContainerName)) {
                mStore.createContainerInLocation(null, mContainerName);
            }
            // mWriterService = Executors.newSingleThreadExecutor();
            mWorker = new BufferedTaskWorker(mStore, mContainerName);
            // mWriterService.submit(mWorker);
            // mWriterService.shutdown();
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e);<commit_msg>[MOD] fixing size in jcloudsStorageModule<commit_after>/**
 * 
 */
package org.jscsi.target.storage;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import org.jclouds.ContextBuilder;
import org.jclouds.blobstore.BlobStore;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.domain.Blob;
import org.jclouds.filesystem.reference.FilesystemConstants;
import org.jscsi.target.storage.buffering.BufferedTaskWorker;
import org.jscsi.target.storage.buffering.BufferedWriteTask;
import org.jscsi.target.storage.buffering.BufferedWriteTask.PoisonTask;
import org.jscsi.target.storage.buffering.Collision;

import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;

/**
 * @author <NAME>, University of Konstanz
 * 
 */
public class JCloudsStorageModule implements IStorageModule {

    /** Number of Blocks in one Cluster. */
    public static final int BLOCK_IN_CLUSTER = 512;

    private final long mNumberOfCluster;

    private final String mContainerName;

    private final BlobStore mStore;

    private final BlobStoreContext mContext;

    // /**
    // * The service that holds the BufferedTaskWorker
    // */
    // private final ExecutorService mWriterService;

    /**
     * The worker to process write tasks
     */
    private final BufferedTaskWorker mWorker;

    /**
     * Creates a new {@link JCloudsStorageModules} backed by the specified
     * file. If no such file exists, a {@link FileNotFoundException} will be
     * thrown.
     * 
     * @param pSizeInBlocks
     *            blocksize for this module
     * 
     * @throws FileNotFoundException
     *             if the specified file does not exist
     */
    public JCloudsStorageModule(final long pSizeInBlocks, final File pFile) {
        try {
            mNumberOfCluster = 2097152 / BLOCK_IN_CLUSTER;
            mContainerName = "grave9283746";
            String[] credentials = getCredentials();
            if (credentials.length == 0) {
                Properties properties = new Properties();
                properties.setProperty(FilesystemConstants.PROPERTY_BASEDIR, pFile.getAbsolutePath());
                mContext =
                    ContextBuilder.newBuilder("filesystem").overrides(properties).credentials("testUser",
                        "testPass").buildView(BlobStoreContext.class);
            } else {
                mContext =
                    ContextBuilder.newBuilder("aws-s3").credentials(getCredentials()[0], getCredentials()[1])
                        .buildView(BlobStoreContext.class);
            }

            // Create Container
            mStore = mContext.getBlobStore();
            if (!mStore.containerExists(mContainerName)) {
                mStore.createContainerInLocation(null, mContainerName);
            }
            // mWriterService = Executors.newSingleThreadExecutor();
            mWorker = new BufferedTaskWorker(mStore, mContainerName);
            // mWriterService.submit(mWorker);
            // mWriterService.shutdown();
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e);
{'fraction_non_alphanumeric': 0.09252669039145907, 'fraction_numerical': 0.005189798339264531, 'mean_word_length': 2.708081363386476, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4826762', 'n_tokens_mistral': 1841, 'n_tokens_neox': 1782, 'n_words': 389}