Storage & Retrival of file in Datacenter in cloudsim

892 views
Skip to first unread message

priyank sharma

unread,
Feb 15, 2014, 12:31:25 PM2/15/14
to clou...@googlegroups.com
hello all !!!
I am fairly new user of Cloudsim. Can anyone help me to store and retrieve a file in datacenter of
cloudsim3.0??

Priyank

Mario Henrique Souza Pardo

unread,
Mar 1, 2014, 10:22:45 AM3/1/14
to clou...@googlegroups.com
Hi Dear Priyank,

   try this code, maybe can help you. It's based on CloudsimExample6.java I guess:

            int num_user = 1;
            Calendar calendar = Calendar.getInstance();
            boolean trace_flag = false;
            CloudSim.init(num_user, calendar, trace_flag);

            //******************************************************
            //Creating 3 Storages
            HarddriveStorage hd1 = new HarddriveStorage(1024);
            HarddriveStorage hd2 = new HarddriveStorage(1024);
            HarddriveStorage hd3 = new HarddriveStorage(1024);

            System.out.println("* * *");
            System.out.println("Used disk space on hd1=" + hd1.getCurrentSize());
            System.out.println("Used disk space on hd2=" + hd2.getCurrentSize());
            System.out.println("Used disk space on hd3=" + hd3.getCurrentSize());
            System.out.println("* * *");


            //Creating 3 Files
            //Attention: This is the "org.cloudbus.cloudsim.File" class!!
            File file1 = new File("file1.dat", 300);
            File file2 = new File("file2.dat", 300);
            File file3 = new File("file3.dat", 300);

            hd1.addFile(file1);
            hd2.addFile(file2);
            hd3.addFile(file3);
            //************************************************************
            LinkedList<Storage> hdList = new LinkedList<Storage>();
            hdList.add(hd1);
            hdList.add(hd2);
            hdList.add(hd3);
            //You can add files into datacenter by Datacenter.addFile method too.


            //Look inside createDatacenter() method!! 
            Datacenter mydc = createDatacenter("MyDC", hdList);

            DatacenterBroker broker = createBroker();
            int brokerId = broker.getId();


            CloudSim.startSimulation();


            System.out.println("* * *");
            System.out.println("Used disk space on hd1=" + hd1.getCurrentSize());
            System.out.println("Used disk space on hd2=" + hd2.getCurrentSize());
            System.out.println("Used disk space on hd3=" + hd3.getCurrentSize());
            System.out.println("* * *");

--------------------------------------------

Hope that can be useful for you. I'm available to help if you need.

Regards!
Mário Pardo
ICMC-USP / São Carlos / Brazil



--
 
---
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.

.

unread,
Apr 6, 2014, 2:01:30 PM4/6/14
to clou...@googlegroups.com
Hello Mario
Thank you so much for your reply.It worked.
Now I want to know
1. how to create more than one user in cloudsim. along with that,
2. I want to provide attribute based encryption(ABE) to the files
which i have added according to your code. just like the permissions
provided to the file in Unix/Linux.
> You received this message because you are subscribed to a topic in the
> Google Groups "cloudsim" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/cloudsim/m5e2pXF21yQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to

Mario Henrique Souza Pardo

unread,
Apr 8, 2014, 7:29:54 PM4/8/14
to clou...@googlegroups.com
Hello Dear Priyank,

1. By default, CloudSim considers DatacenterBroker like a client from datacenter. So, if you want to really have a client entity you need to program it for your own. You can start extending SimEntity class, programming the required abstract methods and after you can create your own client events codes, launch and handle these events. This will create your client effect desired for your simulated environment.

   If you want to use CloudSim ready structures, so, I suggest you to create a lot of Datacenterbrokers and manage them like clients for your environment.

2. To the second question I suggest you to create a new attribute in CloudSim File class or in FileAttribute class (I don't work with files in my jobs, so, I don't know much about this subject). I'm basing my explanation looking in the CloudSim API. 

   So, create the refered attribute, its setter and getter methods and then, to create the desired permission system effect in your simulation program, will be necessary to make modifications in the class that handles directly the calls for file access. I think (but I'm not sure about that) that can be HardriveStorage or Datacenter, but is better you take a careful look in that.

   As you see, I'm not so good with this part of simulator, so, consider my ideas like suggestions or opinions, ok?

  I desire success in your implementation.

        Regards!
Mário Pardo
ICMC-USP / São Carlos / Brazil
Research Gate Profile [LINK]


For more options, visit https://groups.google.com/d/optout.

.

unread,
Apr 10, 2014, 5:22:02 AM4/10/14
to clou...@googlegroups.com
thanks a lot mario.
can u please help me in executing this file which i have attached.
actually when i am trying to execute it i am getting error.


For more options, visit https://groups.google.com/d/optout.

CloudHarddriveStorage.java

Mario Henrique Souza Pardo

unread,
Apr 22, 2014, 11:39:26 AM4/22/14
to clou...@googlegroups.com
Hello Priyank,

first... I have a question for you: What is CloudFile class? This is not a default class from CloudSim API specification (I checked it). I guess it's a custom implementation of your project, isn't it?

second... I identified that you are trying to use a next() method with java.util.Iterator, so, what about to use a for-each and handle the list in a different mode?

Look at this code adaptation I have done for you...

-----------------------------------------

public CloudFile getCloudFile(String fileName) {
// check first whether file name is valid or not
CloudFile obj = null;
if (fileName == null || fileName.length() == 0) {
Log.printLine(super.getName() + ".getFile(): Warning - invalid " + "file name.");
return obj;
}

Iterator <CloudFile> it =  fileList.listIterator();
int size = 0;
int index = 0;
boolean found = false;
//CloudFile tempFile = null;

                
// find the file in the disk
//while (it.hasNext()) {
//tempFile = it.next();
                        
                for (CloudFile tempFile : fileList){
size += tempFile.getSize();
if (tempFile.getName().equals(fileName)) {
found = true;
obj = tempFile;
break;
}

index++;
}

// if the file is found, then determine the time taken to get it
if (found) {
                    //If you wants to use get and set method, fileList needs to be an ArrayList instance
obj = fileList.get(index);
double seekTime = getSeekTime(size);
double transferTime = getTransferTime(obj.getSize());

// total time for this operation
obj.setTransactionTime(seekTime + transferTime);
}

return obj;
}

----------------------------------------- 

   I hope these tips help you to find the way.

   Regards!

Mário Pardo
ICMC-USP / São Carlos / Brazil

.

unread,
May 1, 2014, 4:46:36 AM5/1/14
to clou...@googlegroups.com
thanks Mario !!!  I will try this and let you know.

Shredha Kishore

unread,
Mar 20, 2015, 1:24:02 AM3/20/15
to clou...@googlegroups.com
Hey
Can anyone please tell me how to retrieve the file stored in the harddiskdrive via cloudsim3.0.
To store, I used the above code.

Shredha Kishore

unread,
Mar 20, 2015, 1:24:04 AM3/20/15
to clou...@googlegroups.com

elh elhem

unread,
Dec 14, 2016, 3:53:04 PM12/14/16
to cloudsim
Hi mario, 
Please this code

// if the file is found, then determine the time taken to get it
if (found) {
                    //If you wants to use get and set method, fileList needs to be an ArrayList instance
obj = fileList.get(index);
double seekTime = getSeekTime(size);
double transferTime = getTransferTime(obj.getSize());

// total time for this operation
obj.setTransactionTime(seekTime + transferTime);
}

return obj;

is responsable for retreiving the file by the VM??
Thanks for your help.

beenish jadoon

unread,
Aug 17, 2017, 9:02:53 AM8/17/17
to cloudsim
hello mario 

i am having difficulties in implementing project on cloudsim

>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
> --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "cloudsim" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/cloudsim/m5e2pXF21yQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to

> For more options, visit https://groups.google.com/groups/opt_out.
>

--

---
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--

---
You received this message because you are subscribed to a topic in the Google Groups "cloudsim" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cloudsim/m5e2pXF21yQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cloudsim+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--

---
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+unsubscribe@googlegroups.com.

Swas

unread,
Jan 15, 2018, 8:32:28 AM1/15/18
to cloudsim
Hi all,

Can anyone tell me where exactly a file is stored when we call harddrivestorage.addfile() method

Reply all
Reply to author
Forward
0 new messages