// Path: src/main/java/fr/eurecom/hybris/Config.java
// public class Config {
// 
//     private static Config instance = null;
//     private static Properties hybrisProperties = null;
//     private static Properties accountsProperties = null;
// 
//     public static final String LOGGER_NAME = "hybrisLogger";
// 
//     public static final String HS_F = "hybris.f";
//     public static final String HS_CLIENTID = "hybris.clientid";
//     public static final String HS_TO_WRITE = "hybris.timeoutwrite";
//     public static final String HS_TO_READ = "hybris.timeoutread";
//     public static final String HS_GC = "hybris.gc";
// 
//     public static final String HS_CRYPTO = "hybris.crypto";
//     
//     public static final String ECODING = "hybris.erasurecoding";
//     public static final String ECODING_K = "hybris.erasurecoding.k";
// 
//     public static final String CACHE_ENABLED = "hybris.cache";
//     public static final String CACHE_ADDRESS = "hybris.cache.address";
//     public static final String CACHE_EXP = "hybris.cache.exp";
//     public static final String CACHE_POLICY = "hybris.cache.policy";
// 
//     public static final String MDS = "hybris.mds";
//     public static final String MDS_ADDR = "hybris.mds.address";
//     public static final String MDS_ROOT = "hybris.mds.root";
//     public static final String MDS_READ = "hybris.mds.quorumread";
// 
//     public static final String KVS_ROOT = "hybris.kvs.root";
//     public static final String KVS_ACCOUNTSFILE = "hybris.kvs.accountsfile";
//     public static final String KVS_TESTSONSTARTUP = "hybris.kvs.latencytestonstartup";
// 
//     private static final String C_ACCOUNTS = "hybris.kvs.drivers";
//     public static final String C_AKEY = "hybris.kvs.drivers.%s.akey";
//     public static final String C_SKEY = "hybris.kvs.drivers.%s.skey";
//     public static final String C_ENABLED = "hybris.kvs.drivers.%s.enabled";
//     public static final String C_COST = "hybris.kvs.drivers.%s.cost";
// 
//     public static synchronized Config getInstance () {
//         if (instance == null)
//             instance = new Config();
//         return instance;
//     }
// 
//     public synchronized void loadProperties(String propertiesFile) throws IOException {
//         if (hybrisProperties == null)
//             try {
//                 propertiesFile = propertiesFile.replaceFirst("^~",System.getProperty("user.home"));
//                 hybrisProperties = new Properties();
//                 hybrisProperties.load(new FileInputStream(propertiesFile));
//             } catch (Exception e) {
//                 throw new IOException(e);
//             }
//     }
// 
//     public String getProperty (String key) {
//         return hybrisProperties.getProperty(key);
//     }
// 
//     /* --------------- Accounts properties management --------------- */
// 
//     public synchronized void loadAccountsProperties(String propertiesFile) throws IOException {
//         if (accountsProperties == null)
//             try {
//                 propertiesFile = propertiesFile.replaceFirst("^~",System.getProperty("user.home"));
//                 accountsProperties = new Properties();
//                 accountsProperties.load(new FileInputStream(propertiesFile));
//             } catch (Exception e) {
//                 throw new IOException(e);
//             }
//     }
// 
//     public String[] getAccountsIds() {
//         return accountsProperties.getProperty(C_ACCOUNTS).trim().split(",");
//     }
// 
//     public String getAccountsProperty(String key) {
//         return accountsProperties.getProperty(key);
//     }
// }


import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URISyntaxException;
import java.security.InvalidKeyException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.microsoft.azure.storage.CloudStorageAccount;
import com.microsoft.azure.storage.StorageException;
import com.microsoft.azure.storage.blob.BlobRequestOptions;
import com.microsoft.azure.storage.blob.CloudBlob;
import com.microsoft.azure.storage.blob.CloudBlobClient;
import com.microsoft.azure.storage.blob.CloudBlobContainer;
import com.microsoft.azure.storage.blob.CloudBlockBlob;
import com.microsoft.azure.storage.blob.ListBlobItem;
import fr.eurecom.hybris.Config;
		}

		this.createContainer();
		this.blobRefs = new HashMap<String, CloudBlockBlob>();
	}

	public void put(String key, byte[] value) throws IOException {
		try {
			CloudBlockBlob blob = this.containerRef.getBlockBlobReference(key);
			blob.getProperties().setContentMD5(null);
			blob.upload(new ByteArrayInputStream(value), value.length);
			this.blobRefs.put(key, blob);
		} catch (URISyntaxException | StorageException | IOException e) {
			throw new IOException(e);
		}
	}

	public byte[] get(String key) throws IOException {
		try {
			CloudBlockBlob blob = this.blobRefs.get(key);
			if (blob == null)
				blob = this.containerRef.getBlockBlobReference(key);
			ByteArrayOutputStream baos = new ByteArrayOutputStream();
			blob.download(baos);
			return baos.toByteArray();
		} catch (URISyntaxException | StorageException e) {

			if (e instanceof StorageException) {
				StorageException se = (StorageException) e;
				if (ERROR_BLOB_NOT_FOUND.equals(se.getErrorCode()))
// Path: src/main/java/fr/eurecom/hybris/Config.java
// public class Config {
// 
//     private static Config instance = null;
//     private static Properties hybrisProperties = null;
//     private static Properties accountsProperties = null;
// 
//     public static final String LOGGER_NAME = "hybrisLogger";
// 
//     public static final String HS_F = "hybris.f";
//     public static final String HS_CLIENTID = "hybris.clientid";
//     public static final String HS_TO_WRITE = "hybris.timeoutwrite";
//     public static final String HS_TO_READ = "hybris.timeoutread";
//     public static final String HS_GC = "hybris.gc";
// 
//     public static final String HS_CRYPTO = "hybris.crypto";
//     
//     public static final String ECODING = "hybris.erasurecoding";
//     public static final String ECODING_K = "hybris.erasurecoding.k";
// 
//     public static final String CACHE_ENABLED = "hybris.cache";
//     public static final String CACHE_ADDRESS = "hybris.cache.address";
//     public static final String CACHE_EXP = "hybris.cache.exp";
//     public static final String CACHE_POLICY = "hybris.cache.policy";
// 
//     public static final String MDS = "hybris.mds";
//     public static final String MDS_ADDR = "hybris.mds.address";
//     public static final String MDS_ROOT = "hybris.mds.root";
//     public static final String MDS_READ = "hybris.mds.quorumread";
// 
//     public static final String KVS_ROOT = "hybris.kvs.root";
//     public static final String KVS_ACCOUNTSFILE = "hybris.kvs.accountsfile";
//     public static final String KVS_TESTSONSTARTUP = "hybris.kvs.latencytestonstartup";
// 
//     private static final String C_ACCOUNTS = "hybris.kvs.drivers";
//     public static final String C_AKEY = "hybris.kvs.drivers.%s.akey";
//     public static final String C_SKEY = "hybris.kvs.drivers.%s.skey";
//     public static final String C_ENABLED = "hybris.kvs.drivers.%s.enabled";
//     public static final String C_COST = "hybris.kvs.drivers.%s.cost";
// 
//     public static synchronized Config getInstance () {
//         if (instance == null)
//             instance = new Config();
//         return instance;
//     }
// 
//     public synchronized void loadProperties(String propertiesFile) throws IOException {
//         if (hybrisProperties == null)
//             try {
//                 propertiesFile = propertiesFile.replaceFirst("^~",System.getProperty("user.home"));
//                 hybrisProperties = new Properties();
//                 hybrisProperties.load(new FileInputStream(propertiesFile));
//             } catch (Exception e) {
//                 throw new IOException(e);
//             }
//     }
// 
//     public String getProperty (String key) {
//         return hybrisProperties.getProperty(key);
//     }
// 
//     /* --------------- Accounts properties management --------------- */
// 
//     public synchronized void loadAccountsProperties(String propertiesFile) throws IOException {
//         if (accountsProperties == null)
//             try {
//                 propertiesFile = propertiesFile.replaceFirst("^~",System.getProperty("user.home"));
//                 accountsProperties = new Properties();
//                 accountsProperties.load(new FileInputStream(propertiesFile));
//             } catch (Exception e) {
//                 throw new IOException(e);
//             }
//     }
// 
//     public String[] getAccountsIds() {
//         return accountsProperties.getProperty(C_ACCOUNTS).trim().split(",");
//     }
// 
//     public String getAccountsProperty(String key) {
//         return accountsProperties.getProperty(key);
//     }
// }


// Path: src/main/java/fr/eurecom/hybris/kvs/drivers/AzureKvs.java
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URISyntaxException;
import java.security.InvalidKeyException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.microsoft.azure.storage.CloudStorageAccount;
import com.microsoft.azure.storage.StorageException;
import com.microsoft.azure.storage.blob.BlobRequestOptions;
import com.microsoft.azure.storage.blob.CloudBlob;
import com.microsoft.azure.storage.blob.CloudBlobClient;
import com.microsoft.azure.storage.blob.CloudBlobContainer;
import com.microsoft.azure.storage.blob.CloudBlockBlob;
import com.microsoft.azure.storage.blob.ListBlobItem;
import fr.eurecom.hybris.Config;

		}

		this.createContainer();
		this.blobRefs = new HashMap<String, CloudBlockBlob>();
	}

	public void put(String key, byte[] value) throws IOException {
		try {
			CloudBlockBlob blob = this.containerRef.getBlockBlobReference(key);
			blob.getProperties().setContentMD5(null);
			blob.upload(new ByteArrayInputStream(value), value.length);
			this.blobRefs.put(key, blob);
		} catch (URISyntaxException | StorageException | IOException e) {
			throw new IOException(e);
		}
	}

	public byte[] get(String key) throws IOException {
		try {
			CloudBlockBlob blob = this.blobRefs.get(key);
			if (blob == null)
				blob = this.containerRef.getBlockBlobReference(key);
			ByteArrayOutputStream baos = new ByteArrayOutputStream();
			blob.download(baos);
			return baos.toByteArray();
		} catch (URISyntaxException | StorageException e) {

			if (e instanceof StorageException) {
				StorageException se = (StorageException) e;
				if (ERROR_BLOB_NOT_FOUND.equals(se.getErrorCode()))
					return null;