Package org.jgroups.stack

Examples of org.jgroups.stack.IpAddress


     */
    private Vector createInitialHosts(String l) throws UnknownHostException {
        Vector tmp=new Vector();
        String host;
        int port;
        IpAddress addr;
        StringTokenizer tok=new StringTokenizer(l, ",");
        String t;

        while(tok.hasMoreTokens()) {
            try {
                t=tok.nextToken();
                host=t.substring(0, t.indexOf('['));
                port=Integer.parseInt(t.substring(t.indexOf('[') + 1, t.indexOf(']')));
                addr=new IpAddress(host, port);
                tmp.addElement(addr);
            }
            catch(NumberFormatException e) {
                if(log.isErrorEnabled()) log.error("exeption is " + e);
            }
View Full Code Here


       if(l != null) conn_listeners.removeElement(l);
   }

   public Address getLocalAddress() {
       if(local_addr == null)
           local_addr=bind_addr != null ? new IpAddress(bind_addr, srv_port) : null;
       return local_addr;
   }
View Full Code Here

                   if(log.isWarnEnabled())
                       log.warn(new StringBuffer("packet from ").append(client_addr).append(':').append(client_port).
                              append(" has different version (").append(version).append(") from ours (").
                                append(Version.version).append("). This may cause problems"));
               }
               client_peer_addr=new IpAddress();
               client_peer_addr.readFrom(in);

               updateLastAccessed();
           }
           return client_peer_addr;
View Full Code Here

      }
   }

   private void connectToStateProvider(StateHeader hdr)
   {     
      IpAddress address = hdr.bind_addr;
      String tmp_state_id = hdr.getStateId();
      StreamingInputStreamWrapper wrapper = null;
      StateTransferInfo sti = null;
      final Socket socket = new Socket();
      try
      {
         socket.bind(new InetSocketAddress(bind_addr, 0));
         int bufferSize = socket.getReceiveBufferSize();
         socket.setReceiveBufferSize(socket_buffer_size);
         if (log.isDebugEnabled())
            log.debug("Connecting to state provider " + address.getIpAddress() + ":" + address.getPort()
                  + ", original buffer size was " + bufferSize + " and was reset to " + socket.getReceiveBufferSize());
         socket.connect(new InetSocketAddress(address.getIpAddress(), address.getPort()));
         if (log.isDebugEnabled())
            log.debug("Connected to state provider, my end of the socket is " + socket.getLocalAddress() + ":"
                  + socket.getLocalPort() + " passing inputstream up...");

         //write out our state_id and address so state provider can clear this request
View Full Code Here

            case Event.CONNECT:
                passDown(evt);
                group_name=(String)evt.getArg();
                srv_sock=Util.createServerSocket(bind_addr, start_port); // grab a random unused port above 10000
                srv_sock_addr=new IpAddress(bind_addr, srv_sock.getLocalPort());
                startServerSocket();
                break;

            case Event.DISCONNECT:
                group_name=null;
View Full Code Here

     * nothing happens. In both cases, a new member to be monitored will be chosen and monitoring continues (unless
     * there are fewer than 2 members).
     */
    public void run() {
        Address tmp_ping_dest;
        IpAddress ping_addr;
        int max_fetch_tries=10// number of times a socket address is to be requested before giving up

        if(trace) log.trace("pinger_thread started"); // +++ remove
        while(pinger_thread != null && Thread.currentThread().equals(pinger_thread) && running) {
            tmp_ping_dest=determinePingDest(); // gets the neighbor to our right
View Full Code Here

    /**
     Attempts to obtain the ping_addr first from the cache, then by unicasting q request to <code>mbr</code>,
     then by multicasting a request to all members.
     */
    private IpAddress fetchPingAddress(Address mbr) {
        IpAddress ret;
        Message ping_addr_req;
        FdHeader hdr;

        if(mbr == null) {
            if(log.isErrorEnabled()) log.error("mbr == null");
View Full Code Here

            retval+=Util.size(sock_addr);

            retval+=Global.INT_SIZE; // cachedAddrs size
            Map.Entry entry;
            Address key;
            IpAddress val;
            if(cachedAddrs != null) {
                for(Iterator it=cachedAddrs.entrySet().iterator(); it.hasNext();) {
                    entry=(Map.Entry)it.next();
                    if((key=(Address)entry.getKey()) != null)
                        retval+=Util.size(key);
                    retval+=Global.BYTE_SIZE; // presence for val
                    if((val=(IpAddress)entry.getValue()) != null)
                        retval+=val.size();
                }
            }

            retval+=Global.INT_SIZE; // mbrs size
            if(mbrs != null) {
View Full Code Here

            out.writeInt(size);
            if(size > 0) {
                for(Iterator it=cachedAddrs.entrySet().iterator(); it.hasNext();) {
                    Map.Entry entry=(Map.Entry)it.next();
                    Address key=(Address)entry.getKey();
                    IpAddress val=(IpAddress)entry.getValue();
                    Util.writeAddress(key, out);
                    Util.writeStreamable(val, out);
                }
            }
            size=mbrs != null? mbrs.size() : 0;
View Full Code Here

            if(size > 0) {
                if(cachedAddrs == null)
                    cachedAddrs=new Hashtable();
                for(int i=0; i < size; i++) {
                    Address key=Util.readAddress(in);
                    IpAddress val=(IpAddress)Util.readStreamable(IpAddress.class, in);
                    cachedAddrs.put(key, val);
                }
            }
            size=in.readInt();
            if(size > 0) {
View Full Code Here

TOP

Related Classes of org.jgroups.stack.IpAddress

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.