Package org.jgroups.stack

Examples of org.jgroups.stack.Protocol


    }

    public void setSocketFactory(SocketFactory factory) {
        socket_factory=factory;
        ProtocolStack stack=getProtocolStack();
        Protocol prot=stack != null? stack.getTopProtocol() : null;
        if(prot != null)
            prot.setSocketFactory(factory);
    }
View Full Code Here


                           "[-size <msg size (in bytes)] [-file_name <filename>] [-write] [-read]");
    }

    void start(String props, int num_msgs, int size, String file_name, boolean write) throws Exception {
        Message msg;
        Protocol transport;
        byte[] buf=new byte[size];
        Address local_addr;
        View    view;

        if(file_name != null) {
            if(write)
                out=new DataOutputStream(new FileOutputStream(file_name));
            else
                in=new DataInputStream(new FileInputStream(file_name));
        }

        ch=new JChannel(props);
        ch.setReceiver(new ExtendedReceiverAdapter());
        ch.connect("demo");
        tp=PERF_TP.getInstance();
        local_addr=ch.getAddress();
        Vector members=new Vector();
        members.add(local_addr);
        view=new View(local_addr, 0, members);
        ch.down(new Event(Event.BECOME_SERVER));
        ch.down(new Event(Event.VIEW_CHANGE, view));

        if(write) {
            tp.setExpectedMessages(num_msgs);
            for(int i=0; i < num_msgs; i++) {
                msg=new Message(null, local_addr, buf);
                ch.send(msg);
                if(out != null)
                    msg.writeTo(out);
                if(i % 1000 == 0)
                    System.out.println("sent " + i + " messages");
            }
        }
        else {
            List msgs=new LinkedList();
            List protocols=ch.getProtocolStack().getProtocols();
            transport=(Protocol)protocols.get(protocols.size() -1);
            int i=0;
            while(true) {
                msg=new Message();
                try {
                    msg.readFrom(in);
                    msgs.add(msg);
                }
                catch(EOFException eof) {
                    break;
                }
            }

            num_msgs=msgs.size();
            System.out.println("read " + num_msgs + " msgs from file");
            tp.setExpectedMessages(msgs.size()); // this starts the time
            for(Iterator it=msgs.iterator(); it.hasNext();) {
                msg=(Message)it.next();
                i++;
                transport.up(new Event(Event.MSG, msg));
                if(i % 10000 == 0) {
                    System.out.println("passed up " + i + " messages");
                }
            }
        }
View Full Code Here

            this.stack = channel.getProtocolStack();
            Iterator iter = stack.getProtocols().iterator();
            String debugLevels [] = new String[]{"DEBUG","INFO","ERROR"};
            while (iter.hasNext())
            {
                Protocol p = (Protocol) iter.next();
                JLabel field = new JLabel(p.getName());
                JComboBox pane = new JComboBox(debugLevels);
                this.add(field);
                this.add(pane);

            }
View Full Code Here

            }
        }
    }

    private void printConnections() {
        Protocol prot=channel.getProtocolStack().findProtocol(unicast_protocols);
        if(prot instanceof UNICAST)
            System.out.println("connections:\n" + ((UNICAST)prot).printConnections());
        else if(prot instanceof UNICAST2)
            System.out.println("connections:\n" + ((UNICAST2)prot).printConnections());
    }
View Full Code Here

        prot_stack=new ProtocolStack();

        if(protStack.length > 1) {
      for(int i=0; i < protStack.length; i++) {
        Protocol p1=protStack[i];
        p1.setProtocolStack(prot_stack);
        Protocol p2=i+1 >= protStack.length? null : protStack[i+1];
        if(p2 != null) {
          p1.setDownProtocol(p2);
          p2.setUpProtocol(p1);
        }
      }
    }
  }
View Full Code Here

    }

    private void removeConnection() {
        Address member=getReceiver();
        if(member != null) {
            Protocol prot=channel.getProtocolStack().findProtocol(unicast_protocols);
            if(prot instanceof UNICAST)
                ((UNICAST)prot).removeConnection(member);
            else if(prot instanceof UNICAST2)
                ((UNICAST2)prot).removeConnection(member);
        }
View Full Code Here

                ((UNICAST2)prot).removeConnection(member);
        }
    }

    private void removeAllConnections() {
        Protocol prot=channel.getProtocolStack().findProtocol(unicast_protocols);
        if(prot instanceof UNICAST)
            ((UNICAST)prot).removeAllConnections();
        else if(prot instanceof UNICAST2)
            ((UNICAST2)prot).removeAllConnections();
    }
View Full Code Here

  }

  public String dumpStats() {
    StringBuilder sb=new StringBuilder();
    for(int i=0; i < protStack.length; i++) {
      Protocol p1=protStack[i];
      sb.append(p1.getName()).append(":\n").append(p1.dumpStats()).append("\n");
    }
    return sb.toString();
  }
View Full Code Here

    if(protStack == null)
      throw new Exception("protocol stack is null");


    for(int i=0; i < protStack.length; i++) {
      Protocol p=protStack[i];
      p.setProtocolStack(prot_stack);
    }

    for(int i=0; i < protStack.length; i++) {
      Protocol p=protStack[i];
      p.init();
    }

        // bottom.up(new Event(Event.SET_LOCAL_ADDRESS, local_addr));
        protStack[0].down(new Event(Event.SET_LOCAL_ADDRESS, local_addr));

    for(int i=0; i < protStack.length; i++) {
      Protocol p=protStack[i];
      p.start();
    }

    // moved event processing to follow stack init (JGRP-843)

    if(view != null) {
View Full Code Here

        // top.setUpProtocol(harness);
    }

    public Vector<Protocol> getProtocols() {
        Vector<Protocol> retval=new Vector<Protocol>();
        Protocol tmp=top;
        while(tmp != null) {
            retval.add(tmp);
            tmp=tmp.getDownProtocol();
        }
        return retval;
    }
View Full Code Here

TOP

Related Classes of org.jgroups.stack.Protocol

Copyright © 2018 www.massapicom. 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.