doc/ServiceDescription/DistributedStorageDocumentation

Distributed Storage

Provides persistent access to shared resources. Creates replicas of resources on different peers using the social structure of the network and the access to resources. When a peer access a shared resource, a replica of this resource is created locally and advertised on the overlay network.

Overview

The data are replicated using "social" replication. As an example, imagine that a file F is located on peer P1. A peer P2 looks for that file: P2 sends a search query in the P-Grid network and gets back the location (IP address and TCP port of P1) of the file F. P2 downloads F and updates the index entry of F with its own location. A third peer P3 is now able to download F from either P1 or P2. That is, popular files are more replicated that unpopular ones.

There is no advanced replication mechanism in P-Grid. If a file F on P1 is never downloaded by an other peer and P1 goes offline, then F is not available until P1 goes online again.

Features

Provides a simple API to store a file or get a file:

/**
 * Adds the specified fileInstance to the DistributeStorage and returns the fileID 
 * describing the File.
 * @param fileInstance file to be stored
 * @return the fileID
 */
public String addFile(File fileInstance);

/**
 * Gets the file that matches the fileID. destinationFile specifies the place to store the file being fetched.
 * This destinationFile will be put back into the p2pIndex with the same fileID; 
 * 
 * @param fileID fileID of the file to be retrieved
 * @param destinationFile path where to store the downloaded file
 */
public void getFile(String fileID, File destinationFile);

Authors/Developers

[Vasillis Darlagiannis VasillisDarlagiannis?], EPFL, architecture, technologies, API, documentation .

[Nicolas Bonvin NicolasBonvin?], EPFL, implementation, documentation.

[Surender Reddy Yerva SurenderReddyYerva?], EPFL, implementation, documentation.

Examples

First get the storage object:

ServiceReference sr = context.getServiceReference(IDistributedStorage.class.getName());
if (sr == null) {
   throw new Exception("Distributed Storage service not found, aborting.");
} else {
   ds = (IDistributedStorage) context.getService(sr);
}

Then, to add a file:

File file = new File("/tmp/report.pdf");

// fileID contains the fileID of the file inserted in the distributed storage. 
// This ID is needed to download the file
String fileID = ds.addFile(file);

To get a file:

String fileID = "....";
File destinationFile = new File("/home/downloads/report.pdf");
ds.getFile(fileID, destinationFile);

SVN browsing

http://dev.nepomuk.semanticdesktop.org/browser/trunk/java/org.semanticdesktop.nepomuk.comp.distributedStorage