little enhancements
This commit is contained in:
parent
798b06ca91
commit
1f70d53c60
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/BesenBoincServer"/>
|
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/BesenBoincServer"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
/bin/
|
/bin/
|
||||||
|
/export.jardesc
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
/org.eclipse.jdt.core.prefs
|
|
@ -7,7 +7,8 @@ public class Starter {
|
||||||
|
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
System.out.println("Starting BesenBoincClient...");
|
System.out.println("Starting BesenBoincClient...");
|
||||||
|
System.out.println("user.dir: " + System.getProperty("user.dir"));
|
||||||
|
|
||||||
String host = BB.host;
|
String host = BB.host;
|
||||||
int port = BB.port;
|
int port = BB.port;
|
||||||
if(args.length >= 1) {
|
if(args.length >= 1) {
|
||||||
|
@ -48,8 +49,6 @@ public class Starter {
|
||||||
try {
|
try {
|
||||||
Client c = new Client(host, port, new Worker());
|
Client c = new Client(host, port, new Worker());
|
||||||
|
|
||||||
System.out.println("Connection Established.");
|
|
||||||
|
|
||||||
c.run();
|
c.run();
|
||||||
|
|
||||||
if(lost_counter > 0) {
|
if(lost_counter > 0) {
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
package Comunication;
|
package Comunication;
|
||||||
|
|
||||||
import java.io.EOFException;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.net.SocketException;
|
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
public class Client implements Runnable{
|
public class Client implements Runnable{
|
||||||
|
|
|
@ -3,6 +3,8 @@ package Job;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -64,7 +66,9 @@ public class Worker implements PacketHandler, Runnable{
|
||||||
try {
|
try {
|
||||||
File classfile = new File(j.classname+".class");//remove class file
|
File classfile = new File(j.classname+".class");//remove class file
|
||||||
if(classfile.exists())
|
if(classfile.exists())
|
||||||
classfile.delete();
|
classfile.delete();
|
||||||
|
|
||||||
|
System.out.println("File: " + classfile.getAbsolutePath());
|
||||||
|
|
||||||
/* System.out.println("Writing file size:" + j.code.length());
|
/* System.out.println("Writing file size:" + j.code.length());
|
||||||
FileWriter fw = new FileWriter(classfile);//file writing
|
FileWriter fw = new FileWriter(classfile);//file writing
|
||||||
|
@ -75,8 +79,18 @@ public class Worker implements PacketHandler, Runnable{
|
||||||
fos.write(j.classfile);
|
fos.write(j.classfile);
|
||||||
fos.close();
|
fos.close();
|
||||||
|
|
||||||
r = ((Jobsrc) Class.forName(j.classname).newInstance()).run();//load & run
|
//r = ((Jobsrc) Class.forName(j.classname).newInstance()).run();//load & run
|
||||||
|
String path = classfile.getAbsolutePath();
|
||||||
|
path = "file://" + path.substring(0, path.lastIndexOf(File.separator)+1);//remove file name
|
||||||
|
URL[] url = {new URL(path)};
|
||||||
|
URLClassLoader cl = new URLClassLoader(url);
|
||||||
|
r = ((Jobsrc) cl.loadClass(j.classname).newInstance()).run();
|
||||||
|
cl.close();
|
||||||
|
|
||||||
//unload?
|
//unload?
|
||||||
|
Runtime.getRuntime().gc();//hopefully delete loader
|
||||||
|
//should unload because the loader is in the gc
|
||||||
|
|
||||||
|
|
||||||
if(classfile.exists())
|
if(classfile.exists())
|
||||||
classfile.delete();
|
classfile.delete();
|
||||||
|
@ -104,7 +118,7 @@ public class Worker implements PacketHandler, Runnable{
|
||||||
}
|
}
|
||||||
|
|
||||||
private void requestnewjob() {
|
private void requestnewjob() {
|
||||||
if((System.currentTimeMillis()-lastasked) > 1500 & run & client.hasConnection()) {//request wenn letster unerfolg reicher lange genug her ist (Server nicht nerven)
|
if((System.currentTimeMillis()-lastasked) > 15 & run & client.hasConnection()) {//request wenn letster unerfolg reicher lange genug her ist (Server nicht nerven)
|
||||||
client.send(new Data("nextplease"));
|
client.send(new Data("nextplease"));
|
||||||
// System.out.println("asked for next job");
|
// System.out.println("asked for next job");
|
||||||
lastasked = System.currentTimeMillis();
|
lastasked = System.currentTimeMillis();
|
||||||
|
|
Loading…
Reference in New Issue