當前位置: 首頁>>代碼示例>>Java>>正文


Java InetSocketAddress.equals方法代碼示例

本文整理匯總了Java中java.net.InetSocketAddress.equals方法的典型用法代碼示例。如果您正苦於以下問題:Java InetSocketAddress.equals方法的具體用法?Java InetSocketAddress.equals怎麽用?Java InetSocketAddress.equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.net.InetSocketAddress的用法示例。


在下文中一共展示了InetSocketAddress.equals方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: equals

import java.net.InetSocketAddress; //導入方法依賴的package包/類
@Override
public boolean equals(Object obj) {
	if (this == obj) {
		return true;
	}
	if (obj == null) {
		return false;
	}
	if (getClass() != obj.getClass()) {
		return false;
	}
	PeerWireConnection other = (PeerWireConnection) obj;
	InetSocketAddress ipPort = getRemoteAddress();
	InetSocketAddress otheripPort = other.getRemoteAddress();
	if (ipPort == null) {
		if (otheripPort != null) {
			return false;
		}
	} else if (!ipPort.equals(otheripPort)) {
		return false;
	}

	return true;
}
 
開發者ID:jc0541,項目名稱:URTorrent,代碼行數:25,代碼來源:PeerWireConnection.java

示例2: createListenerHandler

import java.net.InetSocketAddress; //導入方法依賴的package包/類
private SimpleChannelInboundHandler<DatagramPacket> createListenerHandler(SeedNode thisNode, ByteBuf seedNodeInfo) {
    return new SimpleChannelInboundHandler<DatagramPacket>() {
        @Override
        public void channelRead0(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception {
            ByteBuf buf = msg.content();

            if (buf.readableBytes() > 4 && buf.readInt() == Utils.MAGIC_BYTES) {
                MessageTYpe msgType = MessageTYpe.values()[buf.readByte()];

                if (msgType == MessageTYpe.DISCOVERY) {
                    String cluster = decodeUtf(buf);
                    InetSocketAddress address = decodeAddress(buf);

                    if (thisNode.cluster().equals(cluster) && !address.equals(thisNode.address())) {
                        onDiscoveryMessage(address);

                        DatagramPacket response = new DatagramPacket(seedNodeInfo.copy(), msg.sender());

                        ctx.writeAndFlush(response);
                    }
                }
            }
        }
    };
}
 
開發者ID:hekate-io,項目名稱:hekate,代碼行數:26,代碼來源:MulticastSeedNodeProvider.java

示例3: checkAddressDuplicate

import java.net.InetSocketAddress; //導入方法依賴的package包/類
public void checkAddressDuplicate(QuorumServer s) throws BadArgumentsException {
    List<InetSocketAddress> otherAddrs = new ArrayList<InetSocketAddress>();
    otherAddrs.add(s.addr);
    otherAddrs.add(s.clientAddr);
    otherAddrs.add(s.electionAddr);
    otherAddrs = excludedSpecialAddresses(otherAddrs);

    for (InetSocketAddress my: this.myAddrs) {

        for (InetSocketAddress other: otherAddrs) {
            if (my.equals(other)) {
                String error = String.format("%s of server.%d conflicts %s of server.%d", my, this.id, other, s.id);
                throw new BadArgumentsException(error);
            }
        }
    }
}
 
開發者ID:didichuxing2,項目名稱:https-github.com-apache-zookeeper,代碼行數:18,代碼來源:QuorumPeer.java

示例4: getRmClient

import java.net.InetSocketAddress; //導入方法依賴的package包/類
private static ApplicationClientProtocol getRmClient(Token<?> token,
    Configuration conf) throws IOException {
  String[] services = token.getService().toString().split(",");
  for (String service : services) {
    InetSocketAddress addr = NetUtils.createSocketAddr(service);
    if (localSecretManager != null) {
      // return null if it's our token
      if (localServiceAddress.getAddress().isAnyLocalAddress()) {
        if (NetUtils.isLocalAddress(addr.getAddress()) &&
            addr.getPort() == localServiceAddress.getPort()) {
          return null;
        }
      } else if (addr.equals(localServiceAddress)) {
        return null;
      }
    }
  }
  return ClientRMProxy.createRMProxy(conf, ApplicationClientProtocol.class);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:20,代碼來源:RMDelegationTokenIdentifier.java

示例5: getSuffixIDs

import java.net.InetSocketAddress; //導入方法依賴的package包/類
/**
 * For given set of {@code keys} adds nameservice Id and or namenode Id
 * and returns {nameserviceId, namenodeId} when address match is found.
 * @see #getSuffixIDs(Configuration, String, String, String, AddressMatcher)
 */
static String[] getSuffixIDs(final Configuration conf,
    final InetSocketAddress address, final String... keys) {
  AddressMatcher matcher = new AddressMatcher() {
   @Override
    public boolean match(InetSocketAddress s) {
      return address.equals(s);
    } 
  };
  
  for (String key : keys) {
    String[] ids = getSuffixIDs(conf, key, null, null, matcher);
    if (ids != null && (ids [0] != null || ids[1] != null)) {
      return ids;
    }
  }
  return null;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:23,代碼來源:DFSUtil.java

示例6: dataToTarget

import java.net.InetSocketAddress; //導入方法依賴的package包/類
@Override
protected HAServiceTarget dataToTarget(byte[] data) {
  ActiveNodeInfo proto;
  try {
    proto = ActiveNodeInfo.parseFrom(data);
  } catch (InvalidProtocolBufferException e) {
    throw new RuntimeException("Invalid data in ZK: " +
        StringUtils.byteToHexString(data));
  }
  NNHAServiceTarget ret = new NNHAServiceTarget(
      conf, proto.getNameserviceId(), proto.getNamenodeId());
  InetSocketAddress addressFromProtobuf = new InetSocketAddress(
      proto.getHostname(), proto.getPort());
  
  if (!addressFromProtobuf.equals(ret.getAddress())) {
    throw new RuntimeException("Mismatched address stored in ZK for " +
        ret + ": Stored protobuf was " + proto + ", address from our own " +
        "configuration for this NameNode was " + ret.getAddress());
  }
  
  ret.setZkfcPort(proto.getZkfcPort());
  return ret;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:24,代碼來源:DFSZKFailoverController.java

示例7: handleHandlerException

import java.net.InetSocketAddress; //導入方法依賴的package包/類
/**
 * Called whenever the handler catches an exception in Netty.
 *
 * @param address the address that caused the exception.
 * @param cause   the exception caught by the handler.
 */
protected final void handleHandlerException(InetSocketAddress address, Throwable cause) {
    listener.onHandlerException(address, cause);
    if (preparation != null) {
        if (address.equals(preparation.address)) {
            preparation.cancelReason = new NettyHandlerException(this, handler, cause);
        }
    } else {
        if (session != null) {
            if (address.equals(preparation.address)) {
                this.disconnect(cause.getClass().getName() + ": " + cause.getLocalizedMessage());
            }
        }
    }
}
 
開發者ID:KernelFreeze,項目名稱:BedrockProxy,代碼行數:21,代碼來源:RakNetClient.java

示例8: handleMessage

import java.net.InetSocketAddress; //導入方法依賴的package包/類
/**
 * Handles a packet received by the handler.
 *
 * @param packet the packet to handle.
 * @param sender the address of the sender.
 */
public final void handleMessage(RakNetPacket packet, InetSocketAddress sender) {
    short packetId = packet.getId();

    // This packet has to do with server discovery so it isn't handled here
    if (packetId == ID_UNCONNECTED_PONG) {
        UnconnectedPong pong = new UnconnectedPong(packet);
        pong.decode();
        if (pong.identifier != null) {
            this.updateDiscoveryData(sender, pong);
        }
    }

    // Are we still logging in?
    if (preparation != null) {
        if (sender.equals(preparation.address)) {
            preparation.handleMessage(packet);
            return;
        }
    }

    // Only handle these from the server we're connected to!
    if (session != null) {
        if (sender.equals(session.getAddress())) {
            if (packetId >= ID_RESERVED_3 && packetId <= ID_RESERVED_9) {
                CustomPacket custom = new CustomPacket(packet);
                custom.decode();

                session.handleCustom(custom);
            } else if (packetId == Acknowledge.ACKNOWLEDGED || packetId == Acknowledge.NOT_ACKNOWLEDGED) {
                Acknowledge acknowledge = new Acknowledge(packet);
                acknowledge.decode();

                session.handleAcknowledge(acknowledge);
            }
        }
    }
}
 
開發者ID:KernelFreeze,項目名稱:BedrockProxy,代碼行數:44,代碼來源:RakNetClient.java

示例9: setLocalSocketAddress

import java.net.InetSocketAddress; //導入方法依賴的package包/類
@Override
protected void setLocalSocketAddress(InetSocketAddress a) {
	if (mappingResult != null && mappingResult.isUsable()) {
		// Advertise the external address to contacts
		if (a.equals(mappingResult.getInternal())) {
			InetSocketAddress external = mappingResult.getExternal();
			if (external != null) a = external;
		}
	}
	TransportProperties p = new TransportProperties();
	p.put(PROP_IP_PORT, getIpPortString(a));
	callback.mergeLocalProperties(p);
}
 
開發者ID:rafjordao,項目名稱:Nird2,代碼行數:14,代碼來源:WanTcpPlugin.java

示例10: onMooClientDisconnect

import java.net.InetSocketAddress; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
public void onMooClientDisconnect(MooClientDisconnectEvent event) {
    MooClient client = event.getClient();

    // if the moo client disconnects ..
    // BUNGEE BUNGEE BUNGEE if the type is PROXY
    if(client.getType() == ClientType.PROXY) {
        List<UUID> toRemove = new ArrayList<>();
        for(UUID uuid : Cloud.getInstance().getNetworkProxy().getPlayerServerMap().keySet()) {
            InetSocketAddress proxyAddress = Cloud.getInstance().getNetworkProxy().getPlayerServerMap().get(uuid);
            if(proxyAddress.equals(client.getAddress())) toRemove.add(uuid);
        }
        toRemove.forEach(uuid -> Cloud.getInstance().getNetworkProxy().getPlayerServerMap().remove(uuid));

        // update player count
        MooCache.getInstance().getConfigMap().fastPutAsync(NetworkConfigType.PLAYER_COUNT.getKey(),
                Cloud.getInstance().getNetworkProxy().getPlayers().size());
    }
    // SPIGOT SPIGOT SPIGOT ouh, the server went down, let's just unregister the server
    else if(client.getType() == ClientType.SERVER) {
        String ip = client.getAddress().getHostName() + ":" + client.getSubPort();
        Cloud.getInstance().getLogger().debug("Unregister server " + ip + " with type '" + client.getName() + "' ..");

        // unregister server
        Cloud.getInstance().getNetworkProxy().unregisterServer(client);

        // call event for new server start
        ServerPattern pattern = MooProxy.getPattern(client.getName());
        MooProxy.serverCycle(pattern);

        // Informing the PROXY!
        PacketMessenger.message(new PacketServerUnregister(client.getAddress()), ClientType.PROXY);
    }
}
 
開發者ID:Superioz,項目名稱:MooProject,代碼行數:35,代碼來源:MooClientDisconnectedListener.java

示例11: sendPacket0

import java.net.InetSocketAddress; //導入方法依賴的package包/類
@Override
public synchronized void sendPacket0(CoapPacket coapPacket, InetSocketAddress adr, TransportContext tranContext) throws CoapException, IOException {
    if (!adr.equals(this.destination)) {
        throw new IllegalStateException("No connection with: " + adr);
    }
    serialize(coapPacket);
    outputStream.flush();
}
 
開發者ID:ARMmbed,項目名稱:java-coap,代碼行數:9,代碼來源:SocketClientTransport.java

示例12: isConnectedToNN

import java.net.InetSocketAddress; //導入方法依賴的package包/類
/**
 * @param addr rpc address of the namenode
 * @return true if the datanode is connected to a NameNode at the
 * given address
 */
public boolean isConnectedToNN(InetSocketAddress addr) {
  for (BPOfferService bpos : getAllBpOs()) {
    for (BPServiceActor bpsa : bpos.getBPServiceActors()) {
      if (addr.equals(bpsa.getNNSocketAddress())) {
        return bpsa.isAlive();
      }
    }
  }
  return false;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:16,代碼來源:DataNode.java

示例13: modifyAddress

import java.net.InetSocketAddress; //導入方法依賴的package包/類
protected Map<InetSocketAddress,InetSocketAddress>
modifyAddress(
	Map<InetSocketAddress,InetSocketAddress>	map,
	InetSocketAddress							key,
	InetSocketAddress							value,
	boolean										add )
{
	// System.out.println( "ModAddress: " + key + " -> " + value + " - " + (add?"add":"remove"));

	InetSocketAddress	old_value = (InetSocketAddress)map.get(key);

	boolean	same = old_value != null && old_value.equals( value );

	Map<InetSocketAddress,InetSocketAddress>	new_map = map;

	if ( add ){

		if ( !same ){

			new_map	= new HashMap<>(map);

			new_map.put( key, value );
		}
	}else{

		if ( same ){

			new_map	= new HashMap<>(map);

			new_map.remove( key );
		}
	}

	return( new_map );
}
 
開發者ID:BiglySoftware,項目名稱:BiglyBT,代碼行數:36,代碼來源:ClientInstanceManagerImpl.java

示例14: checkAddressesEqual

import java.net.InetSocketAddress; //導入方法依賴的package包/類
private boolean checkAddressesEqual(InetSocketAddress addr1, InetSocketAddress addr2){
    if ((addr1 == null && addr2!=null) ||
        (addr1!=null && addr2==null) ||
        (addr1!=null && addr2!=null && !addr1.equals(addr2))) return false;
    return true;
}
 
開發者ID:didichuxing2,項目名稱:https-github.com-apache-zookeeper,代碼行數:7,代碼來源:QuorumPeer.java


注:本文中的java.net.InetSocketAddress.equals方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。