little enhancements

master
mrbesen 6 years ago
parent 798b06ca91
commit 1f70d53c60
  1. 4
      Client/BesenBoincClient/.classpath
  2. 1
      Client/BesenBoincClient/.gitignore
  3. 1
      Client/BesenBoincClient/.settings/.gitignore
  4. 5
      Client/BesenBoincClient/src/Core/Starter.java
  5. 2
      Server/BesenBoincServer/src/Comunication/Client.java
  6. 20
      Server/BesenBoincServer/src/Job/Worker.java

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry combineaccessrules="false" kind="src" path="/BesenBoincServer"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/BesenBoincServer"/>
<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"/>
</classpath>

@ -1 +1,2 @@
/bin/
/export.jardesc

@ -0,0 +1 @@
/org.eclipse.jdt.core.prefs

@ -7,7 +7,8 @@ public class Starter {
public static void main(String args[]) {
System.out.println("Starting BesenBoincClient...");
System.out.println("user.dir: " + System.getProperty("user.dir"));
String host = BB.host;
int port = BB.port;
if(args.length >= 1) {
@ -48,8 +49,6 @@ public class Starter {
try {
Client c = new Client(host, port, new Worker());
System.out.println("Connection Established.");
c.run();
if(lost_counter > 0) {

@ -1,12 +1,10 @@
package Comunication;
import java.io.EOFException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.net.SocketException;
import java.net.UnknownHostException;
public class Client implements Runnable{

@ -3,6 +3,8 @@ package Job;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List;
@ -64,7 +66,9 @@ public class Worker implements PacketHandler, Runnable{
try {
File classfile = new File(j.classname+".class");//remove class file
if(classfile.exists())
classfile.delete();
classfile.delete();
System.out.println("File: " + classfile.getAbsolutePath());
/* System.out.println("Writing file size:" + j.code.length());
FileWriter fw = new FileWriter(classfile);//file writing
@ -75,8 +79,18 @@ public class Worker implements PacketHandler, Runnable{
fos.write(j.classfile);
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?
Runtime.getRuntime().gc();//hopefully delete loader
//should unload because the loader is in the gc
if(classfile.exists())
classfile.delete();
@ -104,7 +118,7 @@ public class Worker implements PacketHandler, Runnable{
}
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"));
// System.out.println("asked for next job");
lastasked = System.currentTimeMillis();

Loading…
Cancel
Save