@Override public String toString() { return address.toString(); } }
@Override public String toString() { if (cause != null) { return hostname + '/' + cause; } else { return address.toString(); } } }
@Override public String toString() { return ia.toString(); } }
@Override public String toString() { if (cause != null) { return hostname + '/' + cause; } else { return address.toString(); } } }
@Override public String toString() { return address.toString(); } }
/** * Get a human-readable representation of this principal. * * @return the string */ public String toString() { return "InetAddressPrincipal <" + inetAddress.toString() + ">"; }
private String getHostIpLockClientId() { try { return InetAddress.getLocalHost().toString(); } catch(Exception ex) { return DistributedLogConstants.UNKNOWN_CLIENT_ID; } }
@Override public void invoke(IN value, Context context) throws Exception { try { serializer.serialize(value, streamWriter); } catch (Exception e) { throw new IOException("Error sending data back to client (" + hostIp.toString() + ":" + port + ')', e); } }
@Override public void serialize(InetSocketAddress value, JsonGenerator jgen, SerializerProvider provider) throws IOException { InetAddress addr = value.getAddress(); String str = addr == null ? value.getHostName() : addr.toString().trim(); int ix = str.indexOf('/'); if (ix >= 0) { if (ix == 0) { // missing host name; use address str = addr instanceof Inet6Address ? "[" + str.substring(1) + "]" // bracket IPv6 addresses with : str.substring(1); } else { // otherwise use name str = str.substring(0, ix); } } jgen.writeString(str + ":" + value.getPort()); }
@Override public void serialize(InetAddress value, JsonGenerator g, SerializerProvider provider) throws IOException { String str; if (_asNumeric) { // since 2.9 str = value.getHostAddress(); } else { // Ok: get textual description; choose "more specific" part str = value.toString().trim(); int ix = str.indexOf('/'); if (ix >= 0) { if (ix == 0) { // missing host name; use address str = str.substring(1); } else { // otherwise use name str = str.substring(0, ix); } } } g.writeString(str); }
@Override public void serialize(InetSocketAddress value, JsonGenerator jgen, SerializerProvider provider) throws IOException { InetAddress addr = value.getAddress(); String str = addr == null ? value.getHostName() : addr.toString().trim(); int ix = str.indexOf('/'); if (ix >= 0) { if (ix == 0) { // missing host name; use address str = addr instanceof Inet6Address ? "[" + str.substring(1) + "]" // bracket IPv6 addresses with : str.substring(1); } else { // otherwise use name str = str.substring(0, ix); } } jgen.writeString(str + ":" + value.getPort()); }
@Override public void serialize(InetAddress value, JsonGenerator g, SerializerProvider provider) throws IOException { String str; if (_asNumeric) { // since 2.9 str = value.getHostAddress(); } else { // Ok: get textual description; choose "more specific" part str = value.toString().trim(); int ix = str.indexOf('/'); if (ix >= 0) { if (ix == 0) { // missing host name; use address str = str.substring(1); } else { // otherwise use name str = str.substring(0, ix); } } } g.writeString(str); }
public NetworkHealthCheck addAddress(InetAddress address) { if (!check(address)) { ActiveMQUtilLogger.LOGGER.addressWasntReacheable(address.toString()); } if (!ignoreLoopback && address.isLoopbackAddress()) { ActiveMQUtilLogger.LOGGER.addressloopback(address.toString()); } else { addresses.add(address); checkStart(); } return this; }
LoggerRepository configureHierarchy(InetAddress inetAddress) { cat.info("Locating configuration file for "+inetAddress); // We assume that the toSting method of InetAddress returns is in // the format hostname/d1.d2.d3.d4 e.g. torino/192.168.1.1 String s = inetAddress.toString(); int i = s.indexOf("/"); if(i == -1) { cat.warn("Could not parse the inetAddress ["+inetAddress+ "]. Using default hierarchy."); return genericHierarchy(); } else { String key = s.substring(0, i); File configFile = new File(dir, key+CONFIG_FILE_EXT); if(configFile.exists()) { Hierarchy h = new Hierarchy(new RootLogger(Level.DEBUG)); hierarchyMap.put(inetAddress, h); new PropertyConfigurator().doConfigure(configFile.getAbsolutePath(), h); return h; } else { cat.warn("Could not find config file ["+configFile+"]."); return genericHierarchy(); } } }
/** * permit() method is invoked for each incoming Thrift request * * @param context request context includes info about * @param operation operation name * @param topology_storm configuration of targeted topology * @return true if the request is authorized, false if reject */ public boolean permit(ReqContext context, String operation, Map topology_conf) { LOG.info("[req " + context.requestID() + "] Access " + " from: " + (context.remoteAddress() == null ? "null" : context.remoteAddress().toString()) + (context.principal() == null ? "" : (" principal:" + context.principal())) + " op:" + operation + (topology_conf == null ? "" : (" topoology:" + topology_conf.get(Config.TOPOLOGY_NAME)))); return true; } }
private void clientMetricRegisterAndMark(ObserverContext<RegionCoprocessorEnvironment> e) { String clientIP = RpcServer.getRemoteIp() != null ? RpcServer.getRemoteIp().toString() : ""; String clientRequestMeter = clientRequestMeterName(clientIP); registerLossyCountingMeterIfNotPresent(e, clientRequestMeter, clientMetricsLossyCounting); markMeterIfPresent(clientRequestMeter); }
@Test public void test1() throws UnknownHostException { String peersPacket = "F8 4E 11 F8 4B C5 36 81 " + "CC 0A 29 82 76 5F B8 40 D8 D6 0C 25 80 FA 79 5C " + "FC 03 13 EF DE BA 86 9D 21 94 E7 9E 7C B2 B5 22 " + "F7 82 FF A0 39 2C BB AB 8D 1B AC 30 12 08 B1 37 " + "E0 DE 49 98 33 4F 3B CF 73 FA 11 7E F2 13 F8 74 " + "17 08 9F EA F8 4C 21 B0"; byte[] payload = Hex.decode(peersPacket); byte[] ip = decodeIP4Bytes(payload, 5); assertEquals(InetAddress.getByAddress(ip).toString(), ("/54.204.10.41")); }
@Test public void setIp() { DummyConnectionConfiguration.Builder builder = newUnitTestBuilder(); final String ip = "192.168.0.1"; builder.setHostAddressByNameOrIp(ip); DummyConnectionConfiguration connectionConfiguration = builder.build(); assertEquals('/' + ip, connectionConfiguration.getHostAddress().toString()); }