How to store data in CloudSim 2.1

2,134 views
Skip to first unread message

sonam agrawal

unread,
Oct 4, 2010, 11:17:58 AM10/4/10
to cloudsim
hi
I have to store data in CloudSim 2.1
i have created an instance of File class and then use HarddriveStorage
class to store it
my problem is
1) how to write in the object of File class
2) how to show the data of the file stored at HarddriveStorage
3) if u have any other way of storing data in CloudSim then also tell
me
plz reply soon
bye

Rodrigo Calheiros

unread,
Oct 5, 2010, 6:15:56 PM10/5/10
to clou...@googlegroups.com
Dear Sonam,

class File does not store actual data, in the same way that Cloudlets
do not execute actual code. File is provided to allow estimation of
data transfer costs in the Cloudlet processing (e.g, if a file is
required by a Cloudlet, the execution will be delayed by the time
required to transfer the file).

So, if you need actual data written to a place and accessed by
Cloudlets, you will have to extend class File.

Regards,
Rodrigo

Anshu

unread,
Apr 19, 2013, 2:02:38 PM4/19/13
to clou...@googlegroups.com
Need the same functionality.
Please share the extended file class if available. I want to store some data on cloud as well.

Anshu

unread,
Apr 19, 2013, 3:10:09 PM4/19/13
to clou...@googlegroups.com
resolved

On Monday, 4 October 2010 20:47:58 UTC+5:30, sonam agrawal wrote:

Fariha

unread,
Apr 19, 2013, 4:26:33 PM4/19/13
to clou...@googlegroups.com
i'm newer in using cloudsim. I want to send a file after encrypting it to the cloud (datacenter) testing the rate of energy of upload and download. How can I do that with cloudsim?

Thanks for helping me.

Anshu Bansal

unread,
Apr 20, 2013, 11:11:59 AM4/20/13
to clou...@googlegroups.com
We need to extend File and HardDriveStorage classes and then we can store data in them.
Extended clases by me are attached for your reference.
 
PFB commands that you can use in your main source code for storing and retrieving data files in cloudSIM.
 

hdst = new CloudHarddriveStorage(50);

double hdstCap = hdst.getCapacity();

double hdstAvailSpace = hdst.getAvailableSpace();

Log.printLine(

"Capacity="+hdstCap+" Available="+hdstAvailSpace);

// First step: Initialize the CloudSim package. It should be called

// before creating any entities.

int num_user = 1; // number of cloud users

Calendar calendar = Calendar.getInstance();

boolean trace_flag = false; // mean trace events

// Initialize the CloudSim library

CloudSim.init(num_user, calendar, trace_flag);

Config config =

new Config("./data/encrypt/data.cfg","read");

ciphertext = config.getProperty("CipherText");

cipherKey = config.getProperty("CipherKey");

config.closeFile(

"read");

CloudFile file2 =

new CloudFile ("data.cfg",2);

file2.addCipherData(

ciphertext, cipherKey);

Log.printLine(file2.getName());

//FileOutputStream fop = new FileOutputStream(file2);

CloudSim.startSimulation();

//Date date = CloudSim.getSimulationCalendar().getTime();

//Log.printLine(date);

// org.cloudbus.cloudsim.File file1 = new org.cloudbus.cloudsim.File ("data.cfg",50);

// Log.printLine(file1.getName());

//file1.getFileAttribute();

//int size1 = file1.getSize();

//Log.printLine("size="+size1);

double timetaken = hdst.addCloudFile(file2);

hdstCap =

hdst.getCapacity();

hdstAvailSpace =

hdst.getAvailableSpace();

Log.printLine(

"Capacity="+hdstCap+" Available="+hdstAvailSpace);

 
 
-----------------------------
Data rerieval
-------------------------------
 

CloudFile fd1 =

hdst.getCloudFile("data.cfg");

ciphertext=fd1.getCipherData("cText");

cipherKey=fd1.getCipherData("cKey");

 

Hope it helps.

 

Regards,

Anshu

 


--
 
---
You received this message because you are subscribed to the Google Groups "cloudsim" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloudsim+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Regards,
Anshu
CloudFile.java
CloudHarddriveStorage.java

Yosra Zguira

unread,
Apr 21, 2013, 1:15:32 PM4/21/13
to clou...@googlegroups.com
Hi I am trying to test your code but I get an error in the main source code. In fact, the constructor of the Config class is not defined as you have done.

Here below a print screen of the error picture.

Thanks very much for helping me.


2013/4/20 Anshu Bansal <ansh...@gmail.com>
img.jpg

bhuvanesh waran

unread,
Apr 21, 2013, 1:24:43 PM4/21/13
to clou...@googlegroups.com
i am doing my ME project in cloud computing privacy anybody know the code for cloud sim

S.Bhuvanesh

Anshu

unread,
Apr 22, 2013, 12:07:07 AM4/22/13
to clou...@googlegroups.com
Config class is just a wrapper over java properties class to write data to .cfg file, you can remove that code and write your own simple java file handling routine using FileOutputStream class.

On Monday, 4 October 2010 20:47:58 UTC+5:30, sonam agrawal wrote:

Yosra Zguira

unread,
Apr 22, 2013, 5:38:32 AM4/22/13
to clou...@googlegroups.com
Ok thank you.


2013/4/22 Anshu <ansh...@gmail.com>
--

Anand

unread,
Sep 9, 2013, 11:50:21 AM9/9/13
to clou...@googlegroups.com, ansh...@gmail.com
i have tried your coding...but am getting nullpointerexception like shown below...
Exception in thread "main" java.lang.NullPointerException
at org.cloudbus.cloudsim.FileAttribute.<init>(FileAttribute.java:73)
at org.cloudbus.cloudsim.File.<init>(File.java:64)
at org.cloudbus.cloudsim.examples.CloudFile.<init>(CloudFile.java:15)
at org.cloudbus.cloudsim.examples.NewClass1.main(NewClass1.java:20)
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)

Kobra Bagheri

unread,
Nov 2, 2013, 3:42:32 AM11/2/13
to clou...@googlegroups.com
hi every body 
i need help fpr define my file in cloudsim and add them to my hosts.
pleaze help me.

Anand

unread,
Nov 22, 2013, 7:05:36 AM11/22/13
to clou...@googlegroups.com, ansh...@gmail.com
hi Anshu
        what is the Config class....could u please send me the Config Class coding...


On Saturday, April 20, 2013 8:41:59 PM UTC+5:30, Anshu Bansal wrote:

HuaHero

unread,
Apr 1, 2014, 4:52:40 AM4/1/14
to clou...@googlegroups.com, ansh...@gmail.com
I can't understand why the TransferTime is calculated by fileSize* getMaxTransferRate() / getCapacity(), rather than  calculated by fileSize / getMaxTransferRate()

在 2013年4月20日星期六UTC+8下午11时11分59秒,Anshu Bansal写道:
Message has been deleted

Saikrishna Mukkamala

unread,
Apr 2, 2014, 7:31:36 AM4/2/14
to clou...@googlegroups.com, ansh...@gmail.com

*************************************************

Please paste the code for config file and give clarity about procedure 
 

anju.anj...@gmail.com

unread,
Jun 3, 2014, 2:08:32 AM6/3/14
to clou...@googlegroups.com, ansh...@gmail.com


Config appears to be user defined class.Is it?

Please provide the coding.


I am trying to implement ABE(Attribute based encryption) on the cloud. I need to encrypt a file and sore the encrypted file on the cloud. The above code seems to fit the purpose. Can you provide some guidance?

Janjir Patel

unread,
Feb 25, 2016, 3:56:17 AM2/25/16
to cloudsim, ansh...@gmail.com
Hi !
I have to store data in CloudSim 3.0.3 
my problem is 
1) How to create code for creating file and store that file on HarddriveStorage ? 
2) if u have code for that storing data in CloudSim 3.0.3 then please send me

please reply as soon as possible

Reply all
Reply to author
Forward
0 new messages