Commit 098b3bd7 authored by Lukáš Marek's avatar Lukáš Marek

Another step to class information

parent 5ee66531
......@@ -60,7 +60,7 @@
</target>
<target name="compile-test" depends="compile-disl,compile-dislre-dispatch">
<javac srcdir="${src.dislre.server}" includes="ch/usi/dag/dislreserver/remoteanalysis/** ch/usi/dag/dislreserver/objectid/** ch/usi/dag/dislreserver/classid/**" destdir="bin" debug="true" includeAntRuntime="false">
<javac srcdir="${src.dislre.server}" includes="ch/usi/dag/dislreserver/remoteanalysis/** ch/usi/dag/dislreserver/netreference/** ch/usi/dag/dislreserver/classid/**" destdir="bin" debug="true" includeAntRuntime="false">
<classpath refid="buildpath" />
</javac>
<javac srcdir="${src.test}" destdir="bin" debug="true" includeAntRuntime="false">
......
This diff is collapsed.
......@@ -46,4 +46,7 @@ public class REDispatch {
sendDoubleAsLong(sid, Double.doubleToLongBits(doubleToSend));
}
// TODO re - basic type array support
// - send length + all values in for cycle
}
......@@ -11,7 +11,7 @@ import java.util.List;
import ch.usi.dag.dislreserver.classid.InvalidClass;
import ch.usi.dag.dislreserver.exception.DiSLREServerException;
import ch.usi.dag.dislreserver.msg.analyze.AnalysisResolver.AnalysisMethodHolder;
import ch.usi.dag.dislreserver.objectid.ObjectId;
import ch.usi.dag.dislreserver.netreference.NetReference;
import ch.usi.dag.dislreserver.reqdispatch.RequestHandler;
public class AnalysisHandler implements RequestHandler {
......@@ -36,7 +36,7 @@ public class AnalysisHandler implements RequestHandler {
+ amh.getAnalysisMethod().getName()
+ "()");
}
// *** retrieve method argument values ***
Method analysisMethod = amh.getAnalysisMethod();
......@@ -133,7 +133,7 @@ public class AnalysisHandler implements RequestHandler {
// read id only
if(argClass.equals(Object.class)) {
return new ObjectId(is.readLong());
return new NetReference(is.readLong());
}
// return "invalid" class object
......
......@@ -7,7 +7,7 @@ import java.util.Set;
import ch.usi.dag.dislreserver.exception.DiSLREServerException;
import ch.usi.dag.dislreserver.msg.analyze.AnalysisResolver;
import ch.usi.dag.dislreserver.objectid.ObjectId;
import ch.usi.dag.dislreserver.netreference.NetReference;
import ch.usi.dag.dislreserver.remoteanalysis.RemoteAnalysis;
import ch.usi.dag.dislreserver.reqdispatch.RequestHandler;
......@@ -17,12 +17,12 @@ public class ObjectFreeHandler implements RequestHandler {
throws DiSLREServerException {
try {
ObjectId objectId = new ObjectId(is.readLong());
NetReference netRef = new NetReference(is.readLong());
Set<RemoteAnalysis> raSet = AnalysisResolver.getAllAnalyses();
for(RemoteAnalysis ra : raSet) {
ra.objectFree(objectId);
ra.objectFree(netRef);
}
} catch (IOException e) {
......
package ch.usi.dag.dislreserver.objectid;
package ch.usi.dag.dislreserver.netreference;
public class ObjectId {
// should be in sync with net_reference on the client
public class NetReference {
// TODO re ! rename
long id;
public ObjectId(long id) {
public NetReference(long id) {
super();
this.id = id;
}
public long getId() {
public long getObjectId() {
// TODO re ! should contain only object id
return id;
}
// TODO re ! should hash only object id
@Override
public int hashCode() {
final int prime = 31;
......@@ -21,6 +25,7 @@ public class ObjectId {
return result;
}
// TODO re ! should equal only object id
@Override
public boolean equals(Object obj) {
if (this == obj)
......@@ -29,7 +34,7 @@ public class ObjectId {
return false;
if (getClass() != obj.getClass())
return false;
ObjectId other = (ObjectId) obj;
NetReference other = (NetReference) obj;
if (id != other.id)
return false;
return true;
......
package ch.usi.dag.dislreserver.remoteanalysis;
import ch.usi.dag.dislreserver.objectid.ObjectId;
import ch.usi.dag.dislreserver.netreference.NetReference;
/**
* Each analysis evaluated remotely have to implement this interface.
......@@ -18,11 +18,11 @@ import ch.usi.dag.dislreserver.objectid.ObjectId;
* On the client, the int argument should not be transmitted (should be ignored).
* Valid only in the case, that transmission is done manually.
*
* Object argument on the client will contain ObjectId instnace.
* Object argument on the client will contain NetReference instnace.
*/
public abstract class RemoteAnalysis {
public abstract void atExit();
public abstract void objectFree(ObjectId objectId);
public abstract void objectFree(NetReference netRef);
}
package ch.usi.dag.disl.test.dispatch;
import ch.usi.dag.dislreserver.classid.InvalidClass;
import ch.usi.dag.dislreserver.objectid.ObjectId;
import ch.usi.dag.dislreserver.netreference.NetReference;
import ch.usi.dag.dislreserver.remoteanalysis.RemoteAnalysis;
// NOTE that this class is not static anymore
......@@ -50,27 +50,27 @@ public class CodeExecuted extends RemoteAnalysis {
}
public static void testingAdvanced(String s, Object o, Class<?> c,
int classID) {
int classId) {
if(! s.equals("ěščřžýáíé")) {
throw new RuntimeException("Incorect transfer of String");
}
long objID = ((ObjectId)o).getId();
long objId = ((NetReference)o).getObjectId();
// object id should be non 0
if(! (o instanceof ObjectId) || objID == 0) {
if(! (o instanceof NetReference) || objId == 0) {
throw new RuntimeException("Incorect transfer of Object");
}
System.out.println("Received object id: " + objID);
System.out.println("Received object id: " + objId);
// class id should be non 0
if(! c.equals(InvalidClass.class) || classID == 0) {
if(! c.equals(InvalidClass.class) || classId == 0) {
throw new RuntimeException("Incorect transfer of Class");
}
System.out.println("Received class id: " + classID);
System.out.println("Received class id: " + classId);
}
public void atExit() {
......@@ -78,8 +78,8 @@ public class CodeExecuted extends RemoteAnalysis {
+ totalExecutedBytecodes);
}
public void objectFree(ObjectId objectId) {
System.out.println("Object free for id " + objectId.getId());
public void objectFree(NetReference netRef) {
System.out.println("Object free for id " + netRef.getObjectId());
}
}
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