当前位置: 首页>>代码示例>>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;未经允许,请勿转载。