Commit 9f025d13 authored by Björn Richerzhagen's avatar Björn Richerzhagen
Browse files

Removed Document-Interface (app-level code belongs into the simRunner)

parent 667f2308
/*
* Copyright (c) 2005-2011 KOM - Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
* PeerfactSim.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package de.tud.kom.p2psim.api.storage;
import java.util.Collection;
import de.tud.kom.p2psim.api.common.SimHostComponent;
import de.tudarmstadt.maki.simonstrator.api.common.UniqueID;
/**
*
* Represents a storage of documents inside of a host, which can be used by
* applications and overlays to store documents locally and fetch them again
* later.
*
* @author Sebastian Kaune <kaune@kom.tu-darmstadt.de>
* @author Konstantin Pussep <pussep@kom.tu-darmstadt.de>
* @version 1.0, 11/25/2007
*
* @deprecated Apps and App-related code is now part of the sim-runner project
*
*/
@Deprecated
public interface ContentStorage extends SimHostComponent {
/**
* Fetch doc from the local storage.
*
* @param key
* - document's key
* @return the requested document if present, null otherwise
*/
public Document loadDocument(UniqueID key);
/**
* Store the document in the local storage.
*
* @param doc
* - document to stores
*/
public void storeDocument(Document doc);
/**
* List the keys of all locally stored documents
*
* @return documents stored locally.
*/
public Collection<UniqueID> listDocumentKeys();
/**
* The way to find out whether a document with the given key is inside of
* this storage.
*
* @param key
* - document key
* @return whether the document with the <code>key</code> is inside
*/
public boolean containsDocument(UniqueID key);
/**
*
* @return all documents stored inside of this storage
*/
public Collection<Document> listDocuments();
}
/*
* Copyright (c) 2005-2011 KOM - Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
* PeerfactSim.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package de.tud.kom.p2psim.api.storage;
import de.tudarmstadt.maki.simonstrator.api.common.UniqueID;
/**
* All specific documents in the application layer and overlay layer should be a
* subtype of this interface.
*
* @author Sebastian Kaune <kaune@kom.tu-darmstadt.de>
* @author Konstantin Pussep <pussep@kom.tu-darmstadt.de>
* @version 1.0, 11/25/2007
*
* @deprecated Apps and app-related code is now part of the runner-project.
* Documents should be defined by the overlay/Service type
*/
@Deprecated
public interface Document {
/**
* Documents can have three different stats: empty, partial and complete
*
* @author Sebastian Kaune
*
*/
public enum State {
/**
* The document is empty if only its OverlayKey is known.
*/
EMPTY,
/**
* The document state becomes partial if some chunks have been
* downloaded
*/
PARTIAL,
/**
* The document is complete if all chunks are available
*/
COMPLETE
}
/**
* Assigns the OverlayKey <code>key</code> to a given document
*
* @param key
*/
public void setKey(UniqueID key);
/**
* Returns the OverlayKey of a given document
*
* @return the appropriate OverlayKey
*/
public UniqueID getKey();
/**
* Sets the size of a given document
*
* @param newSize
* the size in bytes
*/
public void setSize(long newSize);
/**
* Returns the size in bytes of a given document
*
* @return the document size in bytes
*/
public long getSize();
/**
* Returns the popularity of a given document
*
* @return the popularity of the document
*/
public int getPopularity();
/**
* Assigns a popularity to a given document
*
* @param popularity
* the popularity of the document
*/
public void setPopularity(int popularity);
/**
* Changes the state of a given document
*
* @param state
* the new state
*/
public void setState(State state);
/**
* Returns the state of a given document
*
* @return the state of the document
*/
public State getState();
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
-->
</head>
<body bgcolor="white">
Documents and local storage for documents
</body>
</html>
/*
* Copyright (c) 2005-2011 KOM - Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
* PeerfactSim.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package de.tud.kom.p2psim.impl.storage;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import de.tud.kom.p2psim.api.common.SimHost;
import de.tud.kom.p2psim.api.storage.ContentStorage;
import de.tud.kom.p2psim.api.storage.Document;
import de.tudarmstadt.maki.simonstrator.api.common.UniqueID;
/**
* Default implementation of a content storage.
*
* @author pussep
* @version 0.1, 28.11.2007
* @see ContentStorage
*/
public class DefaultContentStorage implements ContentStorage {
Map<UniqueID, Document> documents = new LinkedHashMap<UniqueID, Document>();
private SimHost host;
public DefaultContentStorage() {
// nothing to do
}
@Override
public void initialize() {
// not used
}
@Override
public void shutdown() {
// not used
}
public Collection<Document> listDocuments() {
return new LinkedHashSet<Document>(documents.values());
}
public void storeDocument(Document doc) {
UniqueID key = doc.getKey();
documents.put(key, doc);
}
public Document loadDocument(UniqueID key) {
return documents.get(key);
}
public Collection<UniqueID> listDocumentKeys() {
// return new ArrayList<UniqueID>(documents.keySet());
return Collections.unmodifiableSet(documents.keySet());
}
public boolean containsDocument(UniqueID key) {
return documents.containsKey(key);
}
public SimHost getHost() {
return host;
}
public void setHost(SimHost host) {
this.host = host;
}
}
/*
* Copyright (c) 2005-2011 KOM - Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
* PeerfactSim.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package de.tud.kom.p2psim.impl.storage;
import de.tudarmstadt.maki.simonstrator.api.Host;
import de.tudarmstadt.maki.simonstrator.api.component.HostComponentFactory;
public class StorageFactory implements HostComponentFactory {
public DefaultContentStorage createComponent(Host host) {
return new DefaultContentStorage();
}
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
@(#)package.html 1.60 98/01/27
Copyright 1998
-->
</head>
<body bgcolor="white">
Provides implementations of local storages, which are used by hosts to store documents locally.
</body>
</html>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment