Esempio n. 1
0
  public static void main(String[] args) {
    String groupName = "TestGroup";
    MulticastStrategy tree = new TreeBaseMulticast();
    Orderer causal = new CausalOrderer();

    try {

      ComMember mbr1 = new ComMember(tree, "mbr1");
      ComObserver m = new MemberImpl(causal, mbr1);
      mbr1.addObserver(m);
      mbr1.addObserver(new groupRegisteringTest());
      Registry dictionary = LocateRegistry.getRegistry(NamingService.SERVER_PORT);
      NamingServiceRemote server =
          (NamingServiceRemote) dictionary.lookup(NamingService.SERVICE_NAME);
      LinkedList<String> groups = server.getGroups();
      if (!(groups.isEmpty())) {
        System.out.println("Available groups : ");
        for (String grp : groups) System.out.println("\t- " + grp);
      }
      RemoteMember leader = server.joinGroup("TestGroup", mbr1);
      System.out.println(leader.toString());
      leader.deliver(new ComMessage<String>(new String("Hej Hej!")));
      // mbr.post( new CommMessage<String>( new String("Hej Hej!") ), server.getSharedObjects() ) ;
    } catch (RemoteException e) {
      e.printStackTrace();
    } catch (NotBoundException e) {
      e.printStackTrace();
    }
  }
Esempio n. 2
0
 /**
  * Notify observer when new member want to join a group
  *
  * @param member New member joining to the group
  * @param groupID Group name to join
  */
 @Override
 public void notifyNewMember(RemoteMember member, String groupID) {
   System.out.println(member.toString() + " asked to join group " + groupID);
 }