Package org.jgroups.stack

Examples of org.jgroups.stack.Protocol


    }


    private void setCorrectPortRange(Channel ch) {
        ProtocolStack stack=((MuxChannel)ch).getProtocolStack();
        Protocol tcpping=stack.findProtocol("TCPPING");
        if(tcpping == null)
            return;

        Properties props=tcpping.getProperties();
        String port_range=props.getProperty("port_range");
        if(port_range != null) {
            System.out.println("port_range in TCPPING: " + port_range + ", setting it to 2");
            port_range="2";
            Properties p=new Properties();
            // p.putAll(props);
            p.setProperty("port_range", port_range);
            tcpping.setProperties(p);
        }
    }
View Full Code Here


   protected Channel createChannel() throws ChannelException
   {
      Channel ret = new JChannel(CHANNEL_CONFIG);
      ret.setOpt(Channel.BLOCK, Boolean.TRUE);
      Protocol flush = ((JChannel) ret).getProtocolStack().findProtocol("FLUSH");
      if (flush != null)
      {
         Properties p = new Properties();
         p.setProperty("timeout", "0");
         flush.setProperties(p);

         // send timeout up and down the stack, so other protocols can use the same value too
         Map map = new HashMap();
         map.put("flush_timeout", new Long(0));
         flush.passUp(new Event(Event.CONFIG, map));
         flush.passDown(new Event(Event.CONFIG, map));
      }
      return ret;
   }
View Full Code Here

        v=new View(a1, 1, members);
        s=new Simulator();
        s.setLocalAddress(a1);
        s.setView(v);
        s.addMember(a1);
        Protocol frag=createProtocol();
        System.out.println("protocol to be tested: " + frag);
        Properties props=new Properties();
        props.setProperty("frag_size", "512");
        props.setProperty("up_thread", "false");
        props.setProperty("down_thread", "false");
        frag.setPropertiesInternal(props);
        Protocol[] stack=new Protocol[]{frag};
        s.setProtocolStack(stack);
        s.start();
    }
View Full Code Here

    this.name = c.getLocalAddress().toString();
   
    Vector prots = c.getProtocolStack().getProtocols();
    for (int i = 0; i < prots.size(); i++)
    {
      Protocol prot = (Protocol) prots.elementAt(i);
      if ("TOTAL_TOKEN".equals(prot.getName()))
      {
        prot.setObserver(this);
      }
    }
  }
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.connect("demo");
        tp=PERF_TP.getInstance();
        local_addr=ch.getLocalAddress();
        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();
            Vector protocols=ch.getProtocolStack().getProtocols();
            transport=(Protocol)protocols.lastElement();
            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

    /**
     * Create PerfObservers for all protocols save PERF
     */
    void setupObservers() {
        Protocol p=null;
        String pname;
        PerfObserver po=null;

        for(int i=0; i < protocols.size(); i++) {
            p=(Protocol)protocols.elementAt(i);
            pname=p.getName();
            if(pname != null) {
                po=new PerfObserver(pname);
                p.setObserver(po);
            }
        }
    }
View Full Code Here

    }


    void initializeMessage(Message msg) {
        PerfHeader hdr=new PerfHeader(msg.getSrc(), msg.getDest());
        Protocol p;
        String pname=null;

        if(protocols == null) {
            log.error("PERF.initializeMessage(): 'protocols' variable is null");
            return;
        }

        for(int i=0; i < protocols.size(); i++) {
            p=(Protocol)protocols.elementAt(i);
            pname=p.getName();
            if(pname != null) {
                hdr.addEntry(pname);
            }
        }
        hdr.setReceived(name, PerfHeader.DOWN); // we do this here because down() didn't yet find a PerfHeader
View Full Code Here

      e.printStackTrace();
    }

    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

  }

  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();
    }

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

    // moved event processing to follow stack init (JGRP-843)
    bottom.up(new Event(Event.SET_LOCAL_ADDRESS, local_addr));
    if(view != null) {
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.