Code Search for Developers
 
 
  

PMTest.java from SmartFrog at Krugle


Show PMTest.java syntax highlighted

/** (C) Copyright 1998-2005 Hewlett-Packard Development Company, LP

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

For more information: www.smartfrog.org

*/
package org.smartfrog.services.anubis.partition;


import java.rmi.RemoteException;

import org.smartfrog.services.anubis.partition.comms.MessageConnection;
import org.smartfrog.services.anubis.partition.views.View;
import org.smartfrog.sfcore.common.SmartFrogException;
import org.smartfrog.sfcore.prim.Prim;
import org.smartfrog.sfcore.prim.PrimImpl;
import org.smartfrog.sfcore.prim.TerminationRecord;

public class PMTest extends PrimImpl implements Prim, PartitionNotification {

    class Tester extends Thread {
        Partition         partition    = null;
        int               remote       = 0;
        Tester(Partition p, int r) {
            super("Anubis: Test Driver");
            partition = p;
            remote = r;
        }
        public void run() {
            MessageConnection c = partition.connect(remote);
            c.sendObject("Hello World");
            c.sendObject("Goodbye World");
            // c.disconnect();
        }
    }

    boolean   done      = false;
    Partition partition = null;
    String    myName    = null;
    int       remote    = -1;

    public PMTest() throws RemoteException {
        super();
        System.out.println("Created test");
    }

    public void sfDeploy() throws SmartFrogException, RemoteException  {
        super.sfDeploy();
        partition = (Partition)sfResolve("partition");
        myName = sfCompleteName().toString();
        partition.register(this);
        try { remote = ((Integer)sfResolve("remote")).intValue(); }
        catch (Exception ex) { remote = -1; done = true; }
        System.out.println("Deployed test");
    }

    public void sfStart() throws SmartFrogException, RemoteException  {
        super.sfStart();
        System.out.println(myName + "Started test");
    }

    public void sfTerminateWith(TerminationRecord status) {
        System.out.println(myName + "Terminating test");
        super.sfTerminateWith(status);
    }

    public void partitionNotification(View view, int leader) {
        System.out.println(myName + "Test: notification " + view + " leader is " + leader);
        if( !done && view.contains(remote)) {
            done = true;
            new Tester(partition, remote).start();
        }
    }

    public void objectNotification(Object obj, int node, long time) {
        System.out.println(myName + "Test: received object " + obj);
    }


}




See more files for this project here

SmartFrog

SmartFrog (Smart Framework for Object Groups) is a framework for configuring and automatically activating distributed applications. \r\nThe SmartFrog framework is released under LGPL license.\r\nMore info at: www.smartfrog.org

Project homepage: http://sourceforge.net/projects/smartfrog
Programming language(s): Java,XML
License: other

  comms/
    blocking/
      BlockingConnectionInitiator.java
      MessageConnectionImpl.java
      MessageConnectionServer.java
      MessageConnectionServerFactory.java
    multicast/
      HeartbeatComms.java
      HeartbeatCommsFactory.java
      HeartbeatCommsIntf.java
      HeartbeatConnection.java
      MessageHandler.java
    nonblocking/
      ConnectWorker.java
      MessageNioHandler.java
      MessageNioServer.java
      MessageNioServerFactory.java
      NonBlockingConnectionInitiator.java
      RxJob.java
      RxQueue.java
      RxQueueWorker.java
      SendingListener.java
    Connection.java
    IOConnection.java
    IOConnectionServer.java
    IOConnectionServerFactory.java
    MessageConnection.java
    SelfConnection.java
    components.sf
  protocols/
    heartbeat/
      ping/
        PingProtocolFactory.java
        PingProtocolImpl.java
      timed/
        TimedProtocolFactory.java
        TimedProtocolImpl.java
      HeartbeatProtocol.java
      HeartbeatProtocolAdapter.java
      HeartbeatProtocolFactory.java
      HeartbeatReceiver.java
      components.sf
    leader/
      Candidate.java
      CandidateImpl.java
      LeaderMgr.java
      LeaderProtocolFactory.java
      components.sf
    partitionmanager/
      ConnectionSet.java
      IntervalExec.java
      PartitionProtocol.java
    Sender.java
    Timed.java
  test/
    colors/
      ColorAllocator.java
      ColorMap.java
    mainconsole/
      AsymetryReportFrame.java
      Controller.java
      MainConsoleFrame.java
      NodeButton.java
      NodeData.java
      NodeFrame.java
      Snoop.java
      SnugTable.java
      TestConnection.java
    msg/
      GetStatsMsg.java
      GetThreadsMsg.java
      IgnoringMsg.java
      PartitionMsg.java
      SetIgnoringMsg.java
      SetTimingMsg.java
      StatsMsg.java
      TestConnectionMsg.java
      ThreadsMsg.java
      TimingMsg.java
    node/
      CommsTestIntf.java
      TestConnection.java
      TestMgr.java
      TestServer.java
    stats/
      AveCalculator.java
      Heartbeats.java
      Scheduling.java
      StatsManager.java
      TimedAveCalculator.java
  util/
    Config.java
    ConfigException.java
    Epoch.java
    Identity.java
    NodeIdSet.java
    Test.java
    components.sf
  views/
    BitView.java
    NumberedView.java
    View.java
    ViewListener.java
  wire/
    msg/
    Test.java
    Wire.java
    WireFormException.java
    WireMsg.java
    WireSizes.java
  PMTest.java
  Partition.java
  PartitionManager.java
  PartitionNotification.java
  Status.java
  components.sf