Permalink
Browse files

part of skeleton

  • Loading branch information...
1 parent e69cd96 commit 05a84d5d052e83d3572b10b169d0442487885c61 @kiarash-rezahanjani committed Sep 30, 2011
@@ -1,5 +1,8 @@
package Events;
-public class CreatePost {
+import se.sics.kompics.Request;
+
+public class CreatePost extends Request
+{
}
@@ -1,5 +1,8 @@
package Events;
-public class CreateTopic {
+import se.sics.kompics.Request;
+
+public class CreateTopic extends Request
+{
}
@@ -2,6 +2,8 @@
import se.sics.kompics.*;
-public class InitEvent extends Init{
+public class InitEvent extends Init
+{
+
}
@@ -1,5 +1,17 @@
package Events;
+import se.sics.kompics.*;
-public class JoinRequest {
+public class JoinRequest extends Request
+{
+ String message;
+
+ public void setMessage(String msg)
+ {
+ message=msg;
+ }
+
+ public String getMessage() {
+ return message;
+ }
}
@@ -1,5 +1,22 @@
package Events;
+import se.sics.kompics.*;
-public class JoinResponse {
+public class JoinResponse extends Response
+{
+ String message;
+
+ public JoinResponse(Request request)
+ {
+ super(request);
+ }
+
+ public void setMessage(String msg)
+ {
+ message=msg;
+ }
+
+ public String getMessage() {
+ return message;
+ }
}
@@ -1,5 +1,8 @@
package Events;
-public class LatestPostsRequest {
+import se.sics.kompics.Request;
+
+public class LatestPostsRequest extends Request
+{
}
View
@@ -24,15 +24,17 @@
public class Client extends ComponentDefinition
{
+ int rand;
+
public Client()
{
//fdRequests = new HashMap<Address, UUID>();
//fdPeers = new HashMap<Address, PeerAddress>();
- server=Configuration.server;
+ //bootstrap = create(BootstrapClient.class);
rand = new Random(System.currentTimeMillis());
fd = create(PingFailureDetector.class);
- bootstrap = create(BootstrapClient.class);
+
connect(network, fd.getNegative(Network.class));
connect(network, bootstrap.getNegative(Network.class));
@@ -50,6 +52,7 @@ public Client()
Handler<InitEvent> handleInit = new Handler<InitEvent>() {
public void handle(InitEvent init) {
+
/*
peerSelf = init.getMSPeerSelf();
self = peerSelf.getPeerAddress();
@@ -30,12 +30,12 @@
int webPort = 8080;
int bootId = Integer.MAX_VALUE;
-// Address bootServerAddress = new Address(ip, networkPort, bootId);
+ Address bootServerAddress = new Address(ip, networkPort, bootId);
Address server = new Address(ip, networkPort, 0);
-// BootstrapConfiguration bootConfiguration = new BootstrapConfiguration(bootServerAddress, 60000, 4000, 3, 30000, webPort, webPort);
+ BootstrapConfiguration bootConfiguration = new BootstrapConfiguration(bootServerAddress, 60000, 4000, 3, 30000, webPort, webPort);
PingFailureDetectorConfiguration fdConfiguration = new PingFailureDetectorConfiguration(10000, 50000, 5000, 1000, Transport.TCP);
-// NetworkConfiguration networkConfiguration = new NetworkConfiguration(ip, networkPort, 0);
+ NetworkConfiguration networkConfiguration = new NetworkConfiguration(ip, networkPort, 0);
// PeerConfiguration peerConfiguration = new PeerConfiguration(3, 10000);
//-------------------------------------------------------------------
@@ -44,15 +44,15 @@ public void set() throws IOException {
String c = File.createTempFile("ping.fd.", ".conf").getAbsolutePath();
fdConfiguration.store(c);
System.setProperty("ping.fd.configuration", c);
-/*
+
c = File.createTempFile("bootstrap.", ".conf").getAbsolutePath();
bootConfiguration.store(c);
System.setProperty("bootstrap.configuration", c);
c = File.createTempFile("network.", ".conf").getAbsolutePath();
networkConfiguration.store(c);
System.setProperty("network.configuration", c);
-
+ /*
c = File.createTempFile("ms.", ".conf").getAbsolutePath();
peerConfiguration.store(c);
System.setProperty("ms.configuration", c);
View
@@ -1,44 +1,54 @@
package Task1;
import Events.*;
-import src.*;
+import id2210.system.peer.PeerAddress;
import java.util.Random;
import java.util.Vector;
-import se.sics.kompics.Handler;
+import se.sics.kompics.*;
+import se.sics.kompics.address.Address;
import se.sics.kompics.network.Network;
import se.sics.kompics.p2p.bootstrap.client.BootstrapClient;
import se.sics.kompics.p2p.bootstrap.client.BootstrapClientInit;
+import se.sics.kompics.p2p.bootstrap.server.BootstrapServer;
import se.sics.kompics.p2p.fd.FailureDetector;
+import se.sics.kompics.p2p.fd.PeerFailureSuspicion;
import se.sics.kompics.p2p.fd.ping.PingFailureDetector;
import se.sics.kompics.p2p.fd.ping.PingFailureDetectorInit;
import se.sics.kompics.timer.Timer;
+import src.*;
-public class Server
+public class Server extends ComponentDefinition
{
- Address self;
+ Address myAddress;
+ PeerAddress myPeerAdress;
+ Component fd;
+ Random rand;
- public Client()
+ public Server()
{
//fdRequests = new HashMap<Address, UUID>();
//fdPeers = new HashMap<Address, PeerAddress>();
- server=Configuration.server;
- rand = new Random(System.currentTimeMillis());
-
+ //server=Configuration.server;
+ //bootStrapServer= create(BootstrapServer.class);
+
fd = create(PingFailureDetector.class);
- //bootstrap = create(BootstrapClient.class);
+ rand = new Random(System.currentTimeMillis());
connect(network, fd.getNegative(Network.class));
connect(network, bootstrap.getNegative(Network.class));
connect(timer, fd.getNegative(Timer.class));
connect(timer, bootstrap.getNegative(Timer.class));
subscribe(handleInit, control);
- subscribe(handleJoinResponse, msPeerPort);
- subscribe(handleLatestPostReponse, timer);
- subscribe(handleNewPost, fd.getPositive(FailureDetector.class));
+ subscribe(handleJoinRequest, );
+ subscribe(handleCreateTopic, );
+ subscribe(handleCreatePost, );
+ subscribe(handleLatestPostsRequest, );
+ subscribe(handleClientFailureSuspicion, fd.getPositive(FailureDetector.class));
+
}
@@ -61,4 +71,39 @@ public void handle(InitEvent init) {
*/
}
};
+
+ Handler<JoinRequest> handleJoinRequest = new Handler<JoinRequest>() {
+ public void handle(JoinRequest event)
+ {
+
+ }
+ };
+
+ Handler<CreateTopic> handleCreateTopic = new Handler<CreateTopic>() {
+ public void handle(CreateTopic event)
+ {
+
+ }
+ };
+
+ Handler<CreatePost> handleCreatePost = new Handler<CreatePost>() {
+ public void handle(CreatePost event)
+ {
+
+ }
+ };
+
+ Handler<LatestPostsRequest> handleLatestPostsRequest = new Handler<LatestPostsRequest>() {
+ public void handle(LatestPostsRequest event)
+ {
+
+ }
+ };
+
+ Handler<PeerFailureSuspicion> handleClientFailureSuspicion = new Handler<PeerFailureSuspicion>() {
+ public void handle(PeerFailureSuspicion event)
+ {
+
+ }
+ };
}

0 comments on commit 05a84d5

Please sign in to comment.