Package i5.las2peer.persistency
Class SharedStorage
java.lang.Object
i5.las2peer.api.Configurable
i5.las2peer.persistency.SharedStorage
- All Implemented Interfaces:
L2pStorageInterface
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Storage mode for the pastry node – either use only memory or the file system for stored artifacts. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long
static final int
static final long
static final int
static final String
-
Constructor Summary
ConstructorsConstructorDescriptionSharedStorage
(rice.p2p.commonapi.Node node, SharedStorage.STORAGE_MODE storageMode, ExecutorService threadpool, String storageDir) -
Method Summary
Modifier and TypeMethodDescriptioncreateEnvelope
(EnvelopeVersion previousVersion, Serializable content) Creates an continuous version instance for the given Envelope.createEnvelope
(EnvelopeVersion previousVersion, Serializable content, AgentImpl... readers) Creates an continuous version instance for the given Envelope.createEnvelope
(EnvelopeVersion previousVersion, Serializable content, Collection<?> readers) Creates an continous version instance for the given Envelope.createEnvelope
(String identifier, PublicKey expectedAuthorPubKey, Serializable content, AgentImpl... readers) Creates a new version of an Envelope.createEnvelope
(String identifier, PublicKey expectedAuthorPubKey, Serializable content, Collection<?> readers) Creates a new version of an Envelope.createUnencryptedEnvelope
(EnvelopeVersion previousVersion, Serializable content) Creates an continous unencrypted version instance for the given Envelope.createUnencryptedEnvelope
(String identifier, PublicKey expectedAuthorPubKey, Serializable content) Creates a new version of an unencrypted Envelope.fetchEnvelope
(String identifier, long timeoutMs) Fetches the latest version for the given identifier from the network.fetchEnvelope
(String identifier, long version, long timeoutMs) void
fetchEnvelopeAsync
(String identifier, long version, StorageEnvelopeHandler envelopeHandler, StorageExceptionHandler exceptionHandler) void
fetchEnvelopeAsync
(String identifier, StorageEnvelopeHandler envelopeHandler, StorageExceptionHandler exceptionHandler) Fetches the latest version for the given identifier from the network.byte[]
fetchHashedContent
(byte[] hash, long timeoutMs) void
fetchHashedContentAsync
(byte[] hash, StorageArtifactHandler artifactHandler, StorageExceptionHandler exceptionHandler) long
long
void
removeEnvelope
(String identifier) Removes the envelope with the given identifier from the network.void
storeEnvelope
(EnvelopeVersion envelope, AgentImpl author, long timeoutMs) Stores the given Envelope in the network.void
storeEnvelopeAsync
(EnvelopeVersion envelope, AgentImpl author, StorageStoreResultHandler resultHandler, StorageCollisionHandler collisionHandler, StorageExceptionHandler exceptionHandler) Stores the given Envelope in the network.void
storeHashedContent
(byte[] content, long timeoutMs) void
storeHashedContentAsync
(byte[] content, StorageStoreResultHandler resultHandler, StorageExceptionHandler exceptionHandler) Methods inherited from class i5.las2peer.api.Configurable
getProperties, setFieldValues
-
Field Details
-
DEFAULT_NUM_OF_REPLICAS
public static final int DEFAULT_NUM_OF_REPLICAS- See Also:
-
DEFAULT_MAXIMUM_CACHE_SIZE
public static final int DEFAULT_MAXIMUM_CACHE_SIZE- See Also:
-
DEFAULT_STORAGE_ROOT_DIR
-
DEFAULT_MAXIMUM_STORAGE_SIZE
public static final long DEFAULT_MAXIMUM_STORAGE_SIZE- See Also:
-
DEFAULT_ASYNC_INSERT_OPERATION_TIMEOUT
public static final long DEFAULT_ASYNC_INSERT_OPERATION_TIMEOUT- See Also:
-
-
Constructor Details
-
Method Details
-
getLocalSize
public long getLocalSize() -
getLocalMaxSize
public long getLocalMaxSize() -
createEnvelope
public EnvelopeVersion createEnvelope(String identifier, PublicKey expectedAuthorPubKey, Serializable content, AgentImpl... readers) throws IllegalArgumentException, SerializationException, CryptoException Description copied from interface:L2pStorageInterface
Creates a new version of an Envelope. The Envelope uses by default the start version number.- Specified by:
createEnvelope
in interfaceL2pStorageInterface
- Parameters:
identifier
- An unique identifier for the Envelope.expectedAuthorPubKey
- The authors public key. Validated on store operation.content
- The actual content that should be stored.readers
- An arbitrary number of Agents, who are allowed to read the content.- Returns:
- Returns the Envelope instance.
- Throws:
IllegalArgumentException
- If the given identifier isnull
, the version number is below the start version number or too high.SerializationException
- If a problem occurs with object serialization.CryptoException
- If an cryptographic issue occurs.
-
createEnvelope
public EnvelopeVersion createEnvelope(String identifier, PublicKey expectedAuthorPubKey, Serializable content, Collection<?> readers) throws IllegalArgumentException, SerializationException, CryptoException Description copied from interface:L2pStorageInterface
Creates a new version of an Envelope. The Envelope uses by default the start version number.- Specified by:
createEnvelope
in interfaceL2pStorageInterface
- Parameters:
identifier
- An unique identifier for the Envelope.expectedAuthorPubKey
- The authors public key. Validated on store operation.content
- The actual content that should be stored.readers
- An arbitrary number of Agents, who are allowed to read the content.- Returns:
- Returns the Envelope instance.
- Throws:
IllegalArgumentException
- If the given identifier isnull
, the version number is below the start version number or too high.SerializationException
- If a problem occurs with object serialization.CryptoException
- If an cryptographic issue occurs.
-
createEnvelope
public EnvelopeVersion createEnvelope(EnvelopeVersion previousVersion, Serializable content) throws IllegalArgumentException, SerializationException, CryptoException Description copied from interface:L2pStorageInterface
Creates an continuous version instance for the given Envelope. This method copies the reader list from the previous Envelope instance.- Specified by:
createEnvelope
in interfaceL2pStorageInterface
- Parameters:
previousVersion
- The previous version of the Envelope that should be updated.content
- The updated content that should be stored.- Returns:
- Returns the Envelope instance.
- Throws:
IllegalArgumentException
- If the given identifier isnull
, the version number is below the start version number or too high.SerializationException
- If a problem occurs with object serialization.CryptoException
- If an cryptographic issue occurs.
-
createEnvelope
public EnvelopeVersion createEnvelope(EnvelopeVersion previousVersion, Serializable content, AgentImpl... readers) throws IllegalArgumentException, SerializationException, CryptoException Description copied from interface:L2pStorageInterface
Creates an continuous version instance for the given Envelope.- Specified by:
createEnvelope
in interfaceL2pStorageInterface
- Parameters:
previousVersion
- The previous version of the Envelope that should be updated.content
- The updated content that should be stored.readers
- An arbitrary number of Agents, who are allowed to read the content.- Returns:
- Returns the Envelope instance.
- Throws:
IllegalArgumentException
- If the given identifier isnull
, the version number is below the start version number or too high.SerializationException
- If a problem occurs with object serialization.CryptoException
- If an cryptographic issue occurs.
-
createEnvelope
public EnvelopeVersion createEnvelope(EnvelopeVersion previousVersion, Serializable content, Collection<?> readers) throws IllegalArgumentException, SerializationException, CryptoException Description copied from interface:L2pStorageInterface
Creates an continous version instance for the given Envelope.- Specified by:
createEnvelope
in interfaceL2pStorageInterface
- Parameters:
previousVersion
- The previous version of the Envelope that should be updated.content
- The updated content that should be stored.readers
- An arbitrary number of Agents, who are allowed to read the content.- Returns:
- Returns the Envelope instance.
- Throws:
IllegalArgumentException
- If the given identifier isnull
, the version number is below the start version number or too high.SerializationException
- If a problem occurs with object serialization.CryptoException
- If an cryptographic issue occurs.
-
createUnencryptedEnvelope
public EnvelopeVersion createUnencryptedEnvelope(String identifier, PublicKey expectedAuthorPubKey, Serializable content) throws IllegalArgumentException, SerializationException, CryptoException Description copied from interface:L2pStorageInterface
Creates a new version of an unencrypted Envelope. The Envelope uses by default the start version number.- Specified by:
createUnencryptedEnvelope
in interfaceL2pStorageInterface
- Parameters:
identifier
- An unique identifier for the Envelope.expectedAuthorPubKey
- The authors public key. Validated on store operation.content
- The updated content that should be stored.- Returns:
- Returns the Envelope instance.
- Throws:
IllegalArgumentException
- If the given identifier isnull
, the version number is below the start version number or too high.SerializationException
- If a problem occurs with object serialization.CryptoException
- If an cryptographic issue occurs.
-
createUnencryptedEnvelope
public EnvelopeVersion createUnencryptedEnvelope(EnvelopeVersion previousVersion, Serializable content) throws IllegalArgumentException, SerializationException, CryptoException Description copied from interface:L2pStorageInterface
Creates an continous unencrypted version instance for the given Envelope.- Specified by:
createUnencryptedEnvelope
in interfaceL2pStorageInterface
- Parameters:
previousVersion
- The previous version of the Envelope that should be updated.content
- The updated content that should be stored.- Returns:
- Returns the Envelope instance.
- Throws:
IllegalArgumentException
- If the given identifier isnull
, the version number is below the start version number or too high.SerializationException
- If a problem occurs with object serialization.CryptoException
- If an cryptographic issue occurs.
-
storeEnvelope
public void storeEnvelope(EnvelopeVersion envelope, AgentImpl author, long timeoutMs) throws EnvelopeException Description copied from interface:L2pStorageInterface
Stores the given Envelope in the network. The content is signed with the key from the given author. If an exception occurs it's wrapped as StorageException. With this method collisions are handled by throwing anEnvelopeAlreadyExistsException
.- Specified by:
storeEnvelope
in interfaceL2pStorageInterface
- Parameters:
envelope
- The Envelope to store in the network.author
- The author that is used to sign the content.timeoutMs
- A timeout after that anEnvelopeException
is thrown.- Throws:
EnvelopeAlreadyExistsException
- If an Envelope with the given identifier and version is already known in the network.EnvelopeException
- If an issue with the storage occurs.
-
storeEnvelopeAsync
public void storeEnvelopeAsync(EnvelopeVersion envelope, AgentImpl author, StorageStoreResultHandler resultHandler, StorageCollisionHandler collisionHandler, StorageExceptionHandler exceptionHandler) Description copied from interface:L2pStorageInterface
Stores the given Envelope in the network. The content is signed with the key from the given author. If an exception occurs the operation is canceled and the exception handler is called. Same for collisions. If the operations is completed the result handler is called.- Specified by:
storeEnvelopeAsync
in interfaceL2pStorageInterface
- Parameters:
envelope
- The Envelope to store in the network.author
- The author that is used to sign the content.resultHandler
- A result handler that is called, if the operation terminates.collisionHandler
- A collision handler that is called, if an Envelope with the given identifier and version already exists.exceptionHandler
- An exception handler that is called, if an exception occurs.
-
fetchEnvelope
public EnvelopeVersion fetchEnvelope(String identifier, long timeoutMs) throws EnvelopeNotFoundException, EnvelopeException Description copied from interface:L2pStorageInterface
Fetches the latest version for the given identifier from the network.- Specified by:
fetchEnvelope
in interfaceL2pStorageInterface
- Parameters:
identifier
- An unique identifier for the Envelope.timeoutMs
- A timeout after that anEnvelopeException
is thrown.- Returns:
- Returns the fetched Envelope from the network.
- Throws:
EnvelopeNotFoundException
- If no envelope or any part of it was not found in the network.EnvelopeException
- If an issue with the storage occurs.
-
fetchEnvelope
public EnvelopeVersion fetchEnvelope(String identifier, long version, long timeoutMs) throws EnvelopeNotFoundException, EnvelopeException -
fetchEnvelopeAsync
public void fetchEnvelopeAsync(String identifier, StorageEnvelopeHandler envelopeHandler, StorageExceptionHandler exceptionHandler) Description copied from interface:L2pStorageInterface
Fetches the latest version for the given identifier from the network.- Specified by:
fetchEnvelopeAsync
in interfaceL2pStorageInterface
- Parameters:
identifier
- An unique identifier for the Envelope.envelopeHandler
- A result handler that is called, if the operation terminates.exceptionHandler
- An exception handler that is called, if an exception occurs.
-
fetchEnvelopeAsync
public void fetchEnvelopeAsync(String identifier, long version, StorageEnvelopeHandler envelopeHandler, StorageExceptionHandler exceptionHandler) -
removeEnvelope
Description copied from interface:L2pStorageInterface
Removes the envelope with the given identifier from the network.- Specified by:
removeEnvelope
in interfaceL2pStorageInterface
- Parameters:
identifier
- An unique identifier for the Envelope.- Throws:
EnvelopeNotFoundException
- If no envelope or any part of it was not found in the network.EnvelopeException
- If an issue with the storage occurs.
-
storeHashedContentAsync
public void storeHashedContentAsync(byte[] content, StorageStoreResultHandler resultHandler, StorageExceptionHandler exceptionHandler) -
storeHashedContent
- Throws:
EnvelopeException
-
fetchHashedContentAsync
public void fetchHashedContentAsync(byte[] hash, StorageArtifactHandler artifactHandler, StorageExceptionHandler exceptionHandler) -
fetchHashedContent
- Throws:
EnvelopeException
-