public final InetAddress getIpAddress() { return ipAddr.getIpAddress(); }
/** * GemStoneAddition - internet protocol version compatibility check * @param addr the address of the other member * @return true if the member is using the same version of IP we are */ private boolean checkCompatibility(Address addr) { if (this.bind_address != null && addr != null) { return this.bind_address.getClass() == ((IpAddress)addr).getIpAddress().getClass(); } return true; }
/** Checks whether 2 Addresses are on the same host */ public static boolean sameHost(Address one, Address two) { InetAddress a, b; String host_a, host_b; if(one == null || two == null) return false; if(!(one instanceof IpAddress) || !(two instanceof IpAddress)) { return false; } a=((IpAddress)one).getIpAddress(); b=((IpAddress)two).getIpAddress(); if(a == null || b == null) return false; host_a=a.getHostAddress(); host_b=b.getHostAddress(); // System.out.println("host_a=" + host_a + ", host_b=" + host_b); return host_a.equals(host_b); }
/** * Print addresses in host_ip:port form to bypass DNS */ private String _addrToString(Object addr) { return ( addr == null ? "<null>" : ((addr instanceof com.gemstone.org.jgroups.stack.IpAddress) ? (((com.gemstone.org.jgroups.stack.IpAddress)addr).getIpAddress( ).getHostAddress() + ':' + ((com.gemstone.org.jgroups.stack.IpAddress)addr).getPort()) : addr.toString()) ); }
/** * Checks whether 2 Addresses are on the same host */ boolean sameHost(Address one, Address two) { InetAddress a, b; String host_a, host_b; if(one == null || two == null) return false; if(!(one instanceof IpAddress) || !(two instanceof IpAddress)) { if(log.isErrorEnabled()) log.error(ExternalStrings.FD_PID_ADDRESSES_HAVE_TO_BE_OF_TYPE_IPADDRESS_TO_BE_COMPARED); return false; } a=((IpAddress)one).getIpAddress(); b=((IpAddress)two).getIpAddress(); if(a == null || b == null) return false; host_a=a.getHostAddress(); host_b=b.getHostAddress(); return host_a.equals(host_b); }
new java.net.InetSocketAddress(dest.getIpAddress(), dest.getPort()); myThread.ping_sock.connect(address, connectTimeout);
if (isLoopback && !addr.getIpAddress().isLoopbackAddress()) { // GemStoneAddition throw new RuntimeException("This process is attempting to join with a loopback address ("+myAddress+") using a locator that does not have a local address ("+addr.getIpAddress()+"). On Unix this usually means that /etc/hosts is misconfigured.");
protected void initialize() { if (this.sock == null || this.sock.isClosed()) { return; } receivedAcks = new ConcurrentHashSet<IpAddress>(this.lastView.size()); addressConversionMap = new ConcurrentHashMap<SocketAddress, IpAddress>(this.lastView.size()); Vector<IpAddress> members = this.lastView.getMembers(); for (int i=0; i<members.size(); i++) { IpAddress addr = members.get(i); SocketAddress sockaddr = new InetSocketAddress(addr.getIpAddress(), addr.getPort()); addressConversionMap.put(sockaddr, addr); } startPingResponder(); }
public void beHealthy() { // GemStoneAddition srv_sock_handler.beSick = false; // synchronized(srv_sock_handler.sicknessGuard) { // srv_sock_handler.sicknessGuard.notifyAll(); // } // try to start up with the same address/port srv_sock=Util.createServerSocket(srv_sock_addr.getIpAddress(), srv_sock_addr.getPort(), 65535); if (srv_sock_addr.getPort() != srv_sock.getLocalPort()) { // oops - couldn't get the same port. Things won't work if we don't tell others about it sendIHaveSockMessage(null, local_addr, srv_sock_addr); } srv_sock_addr=new IpAddress(srv_sock_bind_addr, srv_sock.getLocalPort()); startServerSocket(); }
String hostname = ipAddr.getIpAddress().getHostAddress(); int pid = ipAddr.getProcessId(); Assert.assertTrue(" " + ipAddr, port == port0 || port == port1);
/** * For Externalizable * * @see java.io.Externalizable */ public void writeExternal(ObjectOutput out) throws IOException { if (ipAddr == null) throw new InternalGemFireError(LocalizedStrings.JGroupMember_ATTEMPT_TO_EXTERNALIZE_NULL_IP_ADDRESS.toLocalizedString()); // ipAddr.writeExternal(out); // do it the way we like byte[] address = ipAddr.getIpAddress().getAddress(); out.writeInt(address.length); // IPv6 compatible out.write(address); out.writeInt(ipAddr.getPort()); out.write(ipAddr.getFlags()); Version.writeOrdinal(out, ipAddr.getVersionOrdinal(), true); byte bytes[] = new MemberAttributes(ipAddr.getDirectPort(), ipAddr.getProcessId(), ipAddr.getVmKind(), ipAddr.getBirthViewId(), ipAddr.getName(), ipAddr.getRoles(), (DurableClientAttributes)ipAddr.getDurableClientAttributes()).toByteArray(); if (bytes == null) out.writeInt(0); else { out.writeInt(bytes.length); out.write(bytes); } }
InetAddress tmpDest=((IpAddress)dest).getIpAddress(); SocketAddress destAddr=new InetSocketAddress(tmpDest, ((IpAddress)dest).getPort()); sock=new Socket();
Socket sock=SocketCreator.getDefaultInstance().connect(ipAddr.getIpAddress(), ipAddr.getPort(), LOG.getLogWriter(), timeout, null, false); sock.setSoTimeout(timeout);
Socket sock=SocketCreator.getDefaultInstance().connect(ipAddr.getIpAddress(), ipAddr.getPort(), LOG.getLogWriter(), timeout, null, false); sock.setSoTimeout(timeout);
public boolean testRetransmitLargeMessage(byte[] bytesToSend) { IpAddress myAddress = (IpAddress)local_addr; int myPort = myAddress.getPort(); Message msg = new Message(new IpAddress(myAddress.getIpAddress(), myPort-1), this.local_addr, bytesToSend, 0, bytesToSend.length); msg.putHeader(name, new NakAckHeader(NakAckHeader.XMIT_RSP, 0, 0)); try { passDown(new Event(Event.MSG, msg)); } catch (RetransmissionTooLargeException e) { return true; } return false; }
next = new Socket(tokenReceiverAddress.getIpAddress(), tokenReceiverAddress.getPort()); next.setTcpNoDelay(true); oos = new ObjectOutputStream(next.getOutputStream());
public void testAddressEquality() throws Exception { IpAddress addr1 = new IpAddress(InetAddress.getLocalHost(), 1234); IpAddress addr2 = new IpAddress(addr1.getIpAddress(), addr1.getPort()); if (!addr1.equals(addr2)) { fail("expected addresses to be equal"); } addr2.setBirthViewId(4); if (!addr1.equals(addr2)) { fail("expected addresses to be equal"); } addr1.setBirthViewId(0); int comparison = addr1.compareTo(addr2); if (comparison >= 0) { fail("expected addresses to be unequal but compareTo returned " + comparison); } }
void closeMulticastSocket() { if(mcast_recv_sock != null) { try { if(mcast_addr != null) { mcast_recv_sock.leaveGroup(mcast_addr.getIpAddress()); } mcast_recv_sock.close(); // this will cause the mcast receiver thread to break out of its loop //mcast_recv_sock=null; if(log.isDebugEnabled()) log.debug("multicast receive socket closed"); } catch(IOException ex) { } mcast_addr=null; } if(mcast_send_sock != null) { mcast_send_sock.close(); //mcast_send_sock=null; if(log.isDebugEnabled()) log.debug("multicast send socket closed"); } if(mcast_send_sockets != null) { MulticastSocket s; for(int i=0; i < mcast_send_sockets.length; i++) { s=mcast_send_sockets[i]; s.close(); if(log.isDebugEnabled()) log.debug("multicast send socket " + s + " closed"); } mcast_send_sockets=null; } }
public void setPort(int p) { IpAddress i = new IpAddress(ipAddr.getIpAddress(), p); i.setFlags(ipAddr.getFlags()); i.setVmKind(ipAddr.getVmKind()); i.setDirectPort(ipAddr.getDirectPort()); i.setProcessId(ipAddr.getProcessId()); i.setRoles(ipAddr.getRoles()); i.setDurableClientAttributes(ipAddr.getDurableClientAttributes()); i.setVersionOrdinal(ipAddr.getVersionOrdinal()); this.ipAddr = i; } }
public IpAddress call() throws Exception { log.getLogWriter().info(ExternalStrings.SUSPECTING_MEMBER_WHICH_DIDNT_ACK, new Object[]{failedAddress.toString()}); if (sockAddress == null) { if (log.getLogWriter().fineEnabled()) { log.getLogWriter().fine("unable to find ping address for " + failedAddress + " - using direct port to verify if it's there"); } // fdSock can't perform the verification because it has no FD_SOCK // address for the member // If we can connect to the member's cache socket, then we know its machine is // up. It may be dead and its socket port reused, but we know there isn't a // network partition going on. sockAddress = new IpAddress(failedAddress.getIpAddress(), failedAddress.getDirectPort()); if (sockAddress.getPort() != 0 && fdSock.checkSuspect(failedAddress, sockAddress, ExternalStrings.MEMBER_DID_NOT_ACKNOWLEDGE_VIEW.toLocalizedString(), false, false)) { if (log.getLogWriter().infoEnabled()) { log.getLogWriter().info(ExternalStrings.ABLE_TO_CONNECT_TO_DC_PORT, new Object[]{failedAddress, sockAddress.getPort()}); } return failedAddress;//now we remove below using feature } } else if (fdSock.checkSuspect(failedAddress, sockAddress, ExternalStrings.MEMBER_DID_NOT_ACKNOWLEDGE_VIEW.toLocalizedString(), true, false)) { if (log.getLogWriter().infoEnabled()) { log.getLogWriter().info(ExternalStrings.ABLE_TO_CONNECT_TO_FD_PORT, new Object[]{failedAddress, sockAddress.getPort()}); } return failedAddress;//now we remove below using feature } return null; } }