Examples of OtpNode


Examples of com.ericsson.otp.erlang.OtpNode

    */

    public static void main(String argv[]) {

  try {
      OtpNode node = new OtpNode("javanode");
      OtpMbox mbox1 = node.createMbox();
      mbox1.registerName("mbox1");
      node.createMbox("mbox2");
      OtpMbox mbox3 = node.createMbox();
      node.registerName("mbox3",mbox3);

        ArrayList<String> existing_names = new ArrayList<String>();
      existing_names.add("mbox3");
      existing_names.add("mbox2");
      existing_names.add("mbox1");

      String[] names = node.getNames();
      if (names.length != existing_names.size()) fail(1);

      for(int i=0; i<names.length; i++) {
    System.out.println("" + names[i]);
    existing_names.remove(names[i]);
View Full Code Here

Examples of com.ericsson.otp.erlang.OtpNode

  cookie = argv[0];
  erlNode = argv[1];

  try {
    OtpNode javaNode = new OtpNode("javanode", cookie);
    mbox = javaNode.createMbox();
  }
  catch (Exception e) {
      dbg("EXCEPTION when creating javanode: " + e);
      System.exit(1);
  }

  try {
      OtpNode node1 = new OtpNode("javanode1", cookie);
      node1.registerStatusHandler(new NodeStatusHandler());

      switch (Integer.parseInt(argv[2])) {

      case status_handler_localStatus:
    dbg("java running test case \"status_handler_localStatus\"");

    Thread.sleep(200); // Give 'nodeup' message a chance
                       // before closing
    node1.close();
    Thread.sleep(500);
    break;

      case status_handler_remoteStatus:
    dbg("java running test case \"status_handler_remoteStatus\"");

    OtpNode node2 = new OtpNode("javanode2", cookie);
    node2.ping(node1.node(),2000);
    node2.close();
    Thread.sleep(500);
    break;

      case status_handler_connAttempt:
    dbg("java running test case \"status_handler_connAttempt\"");

    OtpNode node3 = new OtpNode("javanode3","othercookie");
    node3.ping(node1.node(),2000);
    node1.ping(node3.node(),2000);
    break;

      }

      OtpErlangObject o = mbox.receive(recTime);
View Full Code Here

Examples of com.ericsson.otp.erlang.OtpNode

  msgArray[1] = new OtpErlangAtom("hello world");
  OtpErlangTuple msg = null;

  try {
      // Initiate: create javanode and mboxes
      OtpNode node = new OtpNode("javanode",cookie);
      OtpMbox mbox = node.createMbox();
      OtpMbox mbox2 = node.createMbox("java_echo_server2");

      // Send the pid of mbox to erlang and wait for test case
      // instruction: {TestCaseTag, Pid}
      mbox.send("erl_send_receive_server", erlNode, mbox.self());
      OtpErlangObject o = mbox.receive(recTime);
      if (o == null) System.exit(1);
      OtpErlangTuple testCase = (OtpErlangTuple)o;
      dbg("mbox received " + testCase);
      int tag = (int)((OtpErlangLong)testCase.elementAt(0)).longValue();
      OtpErlangPid erlangPid = (OtpErlangPid)testCase.elementAt(1);

      switch (tag) {

      case java_erlang_send_receive:

    // Test1 (happened during initiation):
    // Send mbox pid to erlang process with registered name.
    // Erlang process sent back its pid to the mbox pid.

    // Test2: Register name and sent it to the erlang pid. Erlang
    // process shall send message back to my registered name.

    mbox.registerName("java_echo_server");
    msgArray[0] = getNameNode("java_echo_server",node);
    msg = new OtpErlangTuple(msgArray);

    dbg("java_echo_server sending " + msg);
    mbox.send(erlangPid,msg);

    o = mbox.receive(recTime);
    dbg("java_echo_server received " + o);
    if (o == null) System.exit(2);
    if (!((OtpErlangAtom)o).equals(msgArray[1])) System.exit(3);

    // Test3: Same as Test2, but using a new mbox2 which
    // got its name already when it is created - i.e. not
    // using mbox.registerName
    msgArray[0] = getNameNode("java_echo_server2",node);
    msg = new OtpErlangTuple(msgArray);

    dbg("java_echo_server2 sending " + msg);
    mbox2.send(erlangPid,msg);

    o = mbox2.receive(recTime);
    dbg("java_echo_server received " + o);
    if (o == null) System.exit(4);
    if (!((OtpErlangAtom)o).equals(msgArray[1])) System.exit(5);

    break;

      case java_internal_send_receive_same_node:

    // Test1: Sending message between mboxes on same node
    // given registered name and node without host.
    mbox.send("java_echo_server2","javanode",msgArray[1]);
    o = mbox2.receive(recTime);
    dbg("Mbox at same node: " + o);
    if (o == null) System.exit(6);
    if(!((OtpErlangAtom)o).equals(msgArray[1])) System.exit(7);

    // Test2: Sending message between mboxes on same node
    // given registered name and node with host.
    mbox.send("java_echo_server2",mbox2.self().node(),msgArray[1]);
    o = mbox2.receive(recTime);
    dbg("Mbox at same node: " + o);
    if (o == null) System.exit(8);
    if(!((OtpErlangAtom)o).equals(msgArray[1])) System.exit(9);

    // Test3: Sending message between mboxes on same node
    // given registered name but not node.
    mbox.send("java_echo_server2",msgArray[1]);
    o = mbox2.receive(recTime);
    dbg("Mbox at same node: " + o);
    if (o == null) System.exit(10);
    if(!((OtpErlangAtom)o).equals(msgArray[1])) System.exit(11);

    // Test4: Sending message between mboxes on same node
    // given pid.
    mbox.send(mbox2.self(),msgArray[1]);
    o = mbox2.receive(recTime);
    dbg("Mbox at same node: " + o);
    if (o == null) System.exit(12);
    if(!((OtpErlangAtom)o).equals(msgArray[1])) System.exit(13);

    break;

      case java_internal_send_receive_different_nodes:

    OtpNode node2 = new OtpNode("javanode2", cookie);
    OtpMbox mboxOtherNode = node2.createMbox("mboxOtherNode");

    // Test1: Sending message between mboxes on different
    // nodes given registered name and node without host.
    mbox.send("mboxOtherNode","javanode2",msgArray[1]);
    o = mboxOtherNode.receive(recTime);
View Full Code Here

Examples of com.ericsson.otp.erlang.OtpNode

    System.out.println("Wrong number of arguments!");
    System.exit(1);
      }

      // Start node and mbox
      final OtpNode node = new OtpNode(argv[0], argv[1]);
      if (argv.length == 5 && argv[4].equals("unicode")) {
    System.out.println("Setting unicode string mode.");
    node.setFlags(OtpInputStream.DECODE_INT_LISTS_AS_STRINGS);
      }
      final OtpMbox mbox = node.createMbox();

      // Announce our presence
      final OtpErlangObject[] amsg = new OtpErlangObject[3];
      amsg[0] = new OtpErlangAtom("echo_server");
      amsg[1] = new OtpErlangAtom(argv[0]);
View Full Code Here

Examples of com.ericsson.otp.erlang.OtpNode

  String erlNode = argv[1];
  OtpErlangObject expected = null;
  boolean waiting = false;

  try { //
      OtpNode node = new OtpNode("javanode");
      OtpMbox mainMbox = node.createMbox();

      try {
    // Initiate and set up connection to erlang process
    OtpMbox mbox = node.createMbox();
    OtpMbox mbox2;

    OtpErlangObject[] msg = {mainMbox.self(),mbox.self()};
    mbox.send("erl_link_server", erlNode, new OtpErlangTuple(msg));
    OtpErlangObject o = mbox.receive(1000);
        if (o == null) {
            System.exit(1);
            return;
        }
    OtpErlangTuple tuple = (OtpErlangTuple)o;
    int tag = (int)((OtpErlangLong)tuple.elementAt(0)).longValue();

    switch (tag) {

    case java_exit_with_reason_any_term:
    case java_link_and_exit:
        dbg("Java got \"java_link_and_exit\" or " +
      "\"java_exit_with_reason_any_term\"");
        mbox.link((OtpErlangPid)tuple.elementAt(1));
        mbox.send((OtpErlangPid)tuple.elementAt(1),
            new OtpErlangAtom("ok"));
        mbox.exit(tuple.elementAt(2));
        break;
    case erl_exit_with_reason_any_term:
    case erl_link_and_exit:
        dbg("Java got \"erl_link_and_exit\" or " +
      "\"erl_exit_with_reason_any_term\"");
        mbox.send((OtpErlangPid)tuple.elementAt(1),
            new OtpErlangAtom("ok"));
        waiting = true;
        expected = tuple.elementAt(2);
        mbox.receive(1000);
        System.exit(2);
            break;
    case erl_link_java_exit:
        dbg("Java got \"erl_link_java_exit\"");
        mbox.exit(tuple.elementAt(2));
        break;
    case java_link_erl_exit:
        dbg("Java got \"java_link_erl_exit\"");
        mbox.link((OtpErlangPid)tuple.elementAt(1));
        mbox.send((OtpErlangPid)tuple.elementAt(1),
            new OtpErlangAtom("ok"));
        waiting = true;
        expected = tuple.elementAt(2);
        mbox.receive(1000);
        System.exit(3);
            break;
    case internal_link_linking_exits:
        dbg("Java got \"internal_link_linking_exits\"");
        mbox2 = node.createMbox();
        mbox.link(mbox2.self());
        mbox.exit(tuple.elementAt(2));
        waiting = true;
        expected = tuple.elementAt(2);
        mbox2.receive(1000); // hanging waiting for exit
        System.exit(4)// got someting other than exit
            break;
    case internal_link_linked_exits:
        dbg("Java got \"internal_link_linked_exits\"");
        mbox2 = node.createMbox();
        mbox.link(mbox2.self());
        mbox2.exit(tuple.elementAt(2));
        waiting = true;
        expected = tuple.elementAt(2);
        mbox.receive(1000); // hanging waiting for exit
        System.exit(5)// got someting other than exit
            break;
    case internal_unlink_linking_exits:
        dbg("Java got \"internal_unlink_linking_exits\"");
        mbox2 = node.createMbox();
        mbox.link(mbox2.self());
        mbox.unlink(mbox2.self());
        mbox.link(mbox2.self());
        mbox2.unlink(mbox.self());
        mbox2.exit(tuple.elementAt(2));
        if (mbox.receive(500)!=null) System.exit(6);
        break;
    case internal_unlink_linked_exits:
        dbg("Java got \"internal_unlink_linked_exits\"");
        mbox2 = node.createMbox();
        mbox.link(mbox2.self());
        mbox.unlink(mbox2.self());
        mbox.link(mbox2.self());
        mbox2.unlink(mbox.self());
        mbox.exit(tuple.elementAt(2));
View Full Code Here

Examples of com.ericsson.otp.erlang.OtpNode

        : "lucene_server_java@localhost";
    try {
      if (args.length >= 5)
        System.getProperties().setProperty("OtpConnection.trace",
            args[4]);
      NODE = args.length >= 3 ? new OtpNode(nodeName, args[2])
          : new OtpNode(nodeName);
      PEER = peerName;
      ALLOWED_THREADS = args.length >= 4 ? Integer.parseInt(args[3]) : 25;
      final OtpGenServer server = new LuceneServer(NODE, ALLOWED_THREADS);
      jlog.info("Java Lucene Node Started at: " + nodeName
          + "\nConnected to: " + PEER);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.