Skip to content

Commit

Permalink
Merge pull request #19 from rwth-acis/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
derjasper authored Sep 18, 2016
2 parents ac855e1 + c691dd4 commit aaeb57f
Show file tree
Hide file tree
Showing 148 changed files with 7,657 additions and 5,777 deletions.
2 changes: 1 addition & 1 deletion .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<classpathentry kind="src" path="src/test/java"/>
<classpathentry kind="src" path="src/test_help/java"/>
<classpathentry exported="true" kind="lib" path="lib/commons-codec-1.10.jar"/>
<classpathentry exported="true" kind="lib" path="lib/FreePastry-2.1.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/FreePastry-2.1.1.jar" sourcepath="/FreePastry"/>
<classpathentry kind="lib" path="lib/hamcrest-core-1.3.jar"/>
<classpathentry exported="true" kind="lib" path="lib/i5-simpleXML-0.2.jar"/>
<classpathentry kind="lib" path="lib/junit-4.11.jar"/>
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ ivy.jar
/.DS_Store
.settings/org.eclipse.jdt.core.prefs
.settings/org.eclipse.jdt.ui.prefs
/junitvmwatcher*.properties
/junit*.properties
74 changes: 54 additions & 20 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

<property name="ivy.organisation" value="i5" />
<property name="ivy.module" value="las2peer" />
<property name="ivy.revision" value="0.5" />
<property name="ivy.build.number" value="7" />
<property name="ivy.revision" value="0.6" />
<property name="ivy.build.number" value="0" />
<property name="ivy.deliver.revision" value="${ivy.revision}" />
<property name="ivy.pom.version" value="${ivy.revision}" />

Expand Down Expand Up @@ -55,6 +55,11 @@
</fileset>
</path>

<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="${ivy.jar.dir}/ant-contrib.jar"/>
</classpath>
</taskdef>

<!-- Download Dependencies (IVY) -->

Expand Down Expand Up @@ -362,7 +367,7 @@

<target name="javadoc" depends="java_doc, junit_doc" description="--> javadoc"/>

<target name="java_doc" depends="init_doc">
<target name="java_doc" depends="init_doc, compile_main">
<javadoc destdir="${export.doc}"
author="true"
version="true"
Expand All @@ -378,7 +383,7 @@
</javadoc>
</target>

<target name="junit_doc" depends="init_doc">
<target name="junit_doc" depends="init_doc, compile_junit">
<javadoc destdir="${export.junitdoc}"
author="true"
version="true"
Expand All @@ -397,6 +402,36 @@

<!-- JUnit Testing -->

<target name="execute.test">

<!-- we need to have relative path -->
<pathconvert property="test.source.relative">
<fileset file="${test.source.absolute}" />
<map from="${src.junit}/" to="" />
</pathconvert>

<!-- run one particular test -->
<junit fork="yes" haltonerror="yes" haltonfailure="yes" printsummary="yes">

<classpath>
<pathelement path="${tmp.classes}" />
<pathelement path="${tmp.junit}" />
<pathelement path="${lib.cp}" />
<pathelement path="${lib.junit}" />
</classpath>

<formatter type="plain" usefile="false" />
<formatter type="plain" />

<batchtest todir="${junit.report}">
<fileset dir="${src.junit}">
<filename name="${test.source.relative}" />
</fileset>
</batchtest>
</junit>

</target>

<target name="junit" depends="junit_tests, junit_clean" description="-->execute all junit tests" />

<target name="init_junit" depends="init_general">
Expand All @@ -408,22 +443,21 @@
</target>

<target name="junit_tests" depends="init_junit, junit_jars, compile_all">
<junit fork="yes" haltonerror="yes" haltonfailure="yes" printsummary="yes">
<classpath>
<pathelement path="${tmp.classes}" />
<pathelement path="${tmp.junit}" />
<pathelement path="${lib.cp}" />
<pathelement path="${lib.junit}" />
</classpath>
<formatter type="plain" usefile="false" />
<formatter type="plain" />
<batchtest fork="yes" todir="${junit.report}">
<fileset dir="${tmp.junit}">
<include name="**/*Test.class"/>
<exclude name="**/SandboxTest.class"/>
</fileset>
</batchtest>
</junit>
<foreach
target="execute.test"
maxthreads="9"
inheritall="true"
inheritrefs="true"
parallel="true"
param="test.source.absolute">
<path>
<fileset dir="${src.junit}">
<include name="**/*Test.java"/>
<exclude name="**/SandboxTest.java"/>
<exclude name="**/ReplicationTest.java"/>
</fileset>
</path>
</foreach>
</target>

<target name="test_colored" depends="init_general">
Expand Down
1 change: 1 addition & 0 deletions etc/las2peer.policy
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ grant {
// las2peer file read permissions
permission java.io.FilePermission "etc", "read";
permission java.io.FilePermission "etc${/}-", "read";
permission java.io.FilePermission "etc/startup${/}-", "read, write";
permission java.io.FilePermission "config", "read";
permission java.io.FilePermission "config${/}-", "read";
permission java.io.FilePermission "properties", "read";
Expand Down
Binary file added ivy/ant-contrib.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion src/main/java/i5/las2peer/api/Configurable.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ protected Hashtable<String, String> getProperties() {
* @param f The class field that is set.
* @param value The new value for the given class field.
*
* @throws IllegalAccessException if this Field object is enforcing Java language access control and the underlying field is either inaccessible or final.
* @throws IllegalAccessException if this Field object is enforcing Java language access control and the underlying
* field is either inaccessible or final.
* @throws InstantiationException if this Class represents an abstract class, an interface, an array.
*/
@SuppressWarnings("unchecked")
Expand Down
41 changes: 19 additions & 22 deletions src/main/java/i5/las2peer/api/Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import i5.las2peer.execution.L2pServiceException;
import i5.las2peer.execution.L2pThread;
import i5.las2peer.execution.NoSuchServiceMethodException;
import i5.las2peer.logging.L2pLogger;
import i5.las2peer.logging.NodeObserver.Event;
import i5.las2peer.p2p.AgentNotKnownException;
import i5.las2peer.p2p.Node;
Expand Down Expand Up @@ -104,10 +103,6 @@
* <p>
* For further tools like (testing) envelope XML file generators or the like, have a look into the classes of the
* {@link i5.las2peer.tools} package. There are e.g. some command line generators for XML helper files.
*
*
*
*
*/
public abstract class Service extends Configurable {

Expand All @@ -125,9 +120,7 @@ public abstract class Service extends Configurable {
* Executes a service method.
*
* @param method the service method
*
* @return result of the method invocation
*
* @throws SecurityException
* @throws NoSuchServiceMethodException
* @throws IllegalArgumentException
Expand All @@ -145,9 +138,7 @@ public Object execute(String method) throws SecurityException, NoSuchServiceMeth
*
* @param method the service method
* @param parameters
*
* @return result of the method invocation
*
* @throws SecurityException
* @throws NoSuchServiceMethodException
* @throws IllegalArgumentException
Expand Down Expand Up @@ -176,9 +167,7 @@ public Object execute(String method, Object... parameters) throws NoSuchServiceM
* If no version is specified, the newest version is picked.
* @param method the service method
* @param parameters list of parameters
*
* @return result of the method invocation
*
* @throws AgentNotKnownException
* @throws L2pServiceException
* @throws L2pSecurityException
Expand Down Expand Up @@ -206,9 +195,7 @@ public Object invokeServiceMethod(String service, String method, Serializable...
* If no version is specified, the newest version is picked.
* @param method the service method
* @param parameters list of parameters
*
* @return result of the method invocation
*
* @throws L2pServiceException
* @throws L2pSecurityException
* @throws AgentNotKnownException
Expand Down Expand Up @@ -319,7 +306,6 @@ public Method searchMethod(String methodName, Object[] params)
* Creates a string with all classes from an array of parameters.
*
* @param params
*
* @return a string describing a parameter list for the given actual parameters
*/
public static String getParameterString(Object[] params) {
Expand All @@ -338,7 +324,6 @@ public static String getParameterString(Object[] params) {
* Gets the agent corresponding to this service.
*
* @return the agent responsible for this service
*
* @throws AgentNotKnownException
*/
public final ServiceAgent getAgent() throws AgentNotKnownException {
Expand Down Expand Up @@ -395,7 +380,7 @@ public void launchedAt(Node node, ServiceAgent agent) throws L2pServiceException
e.printStackTrace();
}
}
System.out.println("Service " + this.getClass().getCanonicalName() + " has been started!");
System.out.println("Service " + this.agent.getServiceNameVersion() + " has been started!");
}

/**
Expand All @@ -404,12 +389,23 @@ public void launchedAt(Node node, ServiceAgent agent) throws L2pServiceException
* simple shutdown hook to be overwritten in subclasses
*/
public void close() {
System.out.println("Service " + this.getClass().getCanonicalName() + " has been stopped!");
System.out.println("Service " + this.agent.getServiceNameVersion() + " has been stopped!");
runningAt = null;
}

/**
* @deprecated Use {@link L2pLogger#logEvent(Event, String)} with {@link Event#SERVICE_MESSAGE} instead!
* Should return the service alias, which is registered on service start.
*
* @return the alias, or null if no alias should be registered
*/
public String getAlias() {
return null;
}

/**
*
* @deprecated Use {@link i5.las2peer.logging.L2pLogger#logEvent(Event, String)} with {@link Event#SERVICE_MESSAGE}
* instead!
* <p>
* Writes a log message.
*
Expand All @@ -421,7 +417,7 @@ protected void logMessage(String message) {
}

/**
* @deprecated Use {@link L2pLogger#logEvent(Event, Agent, String)} instead!
* @deprecated Use {@link i5.las2peer.logging.L2pLogger#logEvent(Event, Agent, String)} instead!
* <p>
* Writes a log message. The given index (1-99) can be used to differentiate between different log
* messages.
Expand All @@ -446,7 +442,8 @@ protected void logMessage(int index, Agent actingUser, String message) {
}

/**
* @deprecated Use {@link L2pLogger#logEvent(Event, String)} with {@link Event#SERVICE_ERROR} instead!
* @deprecated Use {@link i5.las2peer.logging.L2pLogger#logEvent(Event, String)} with {@link Event#SERVICE_ERROR}
* instead!
* <p>
* Writes an error log message.
*
Expand All @@ -458,7 +455,7 @@ protected void logError(String message) {
}

/**
* @deprecated Use {@link L2pLogger#logEvent(Event, Agent, String)} instead!
* @deprecated Use {@link i5.las2peer.logging.L2pLogger#logEvent(Event, Agent, String)} instead!
* <p>
* Writes an error message. The given index (1-99) can be used to differentiate between different log
* messages.
Expand All @@ -483,7 +480,7 @@ protected void logError(int index, Agent actingUser, String message) {
}

/**
* @deprecated Use {@link L2pLogger} instead!
* @deprecated Use {@link i5.las2peer.logging.L2pLogger} instead!
* <p>
* Writes an exception log message Additionally the stack trace is printed.
*
Expand Down
1 change: 0 additions & 1 deletion src/main/java/i5/las2peer/api/ServiceHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public static boolean isWrapperClass(Class<?> c) {
*
* @param subClass
* @param superClass
*
* @return true, if the first parameter class is a subclass of the second one
*/
public static boolean isSubclass(Class<?> subClass, Class<?> superClass) {
Expand Down
32 changes: 32 additions & 0 deletions src/main/java/i5/las2peer/api/StorageCollisionHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package i5.las2peer.api;

import java.io.Serializable;
import java.security.PublicKey;
import java.util.HashMap;
import java.util.List;

import i5.las2peer.api.exceptions.StopMergingException;
import i5.las2peer.persistency.Envelope;

/**
* This interface can be used to implement a handler that is called if a collision occurs during a store operation.
*/
public interface StorageCollisionHandler {

/**
* This method is called if an envelope is already known for the given identifier and version.
*
* @param toStore This is the envelope that was requested to be stored in the network.
* @param inNetwork This is the colliding envelope that was fetched from the network.
* @param numberOfCollisions This is an increasing counter on how often this method was called. It should be a hint
* to the developer to reconsider his storage structure if this value reaches often high values.
* @return Returns the merged content from both envelopes, which is automatically wrapped in a new store operation.
* @throws StopMergingException If there should be made no further merging attempt.
*/
public Serializable onCollision(Envelope toStore, Envelope inNetwork, long numberOfCollisions)
throws StopMergingException;

public List<PublicKey> mergeReaders(HashMap<PublicKey, byte[]> toStoreReaders,
HashMap<PublicKey, byte[]> inNetworkReaders);

}
17 changes: 17 additions & 0 deletions src/main/java/i5/las2peer/api/StorageEnvelopeHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package i5.las2peer.api;

import i5.las2peer.persistency.Envelope;

/**
* This interface can be used to implement a handler that receives successfully fetched envelopes from the network.
*/
public interface StorageEnvelopeHandler {

/**
* This method is called if the envelope was successfully fetched from the network.
*
* @param result The envelope that was retrieved from the network.
*/
public void onEnvelopeReceived(Envelope result);

}
17 changes: 17 additions & 0 deletions src/main/java/i5/las2peer/api/StorageExceptionHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package i5.las2peer.api;

/**
* This interface can be used to implement a handler that recieves exceptions occurring during network operations.
*
*/
public interface StorageExceptionHandler {

/**
* This method is called in its own thread to handle the given exception.
*
* @param e An execption that occurred during a network operation. Usually the reason or metadata should be known
* from the surrounding context and should be provided to this handler, too.
*/
public void onException(Exception e);

}
18 changes: 18 additions & 0 deletions src/main/java/i5/las2peer/api/StorageStoreResultHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package i5.las2peer.api;

import java.io.Serializable;

/**
* This interface can be used to implement a handler that receives the result from a store operation.
*/
public interface StorageStoreResultHandler {

/**
* This method is called in its own thread to handle the result of a store operation.
*
* @param serializable The serializable that was stored in the network.
* @param successfulOperations The number of successful insert operations (replications).
*/
public void onResult(Serializable serializable, int successfulOperations);

}
Loading

0 comments on commit aaeb57f

Please sign in to comment.