private String prefixedName(InetSocketAddress dstAddress) { if (null != dstAddress) { return PREFIX + dstAddress.toString(); } return ""; }
@Override public String toString() { return addr.toString(); } }
@Override public String toString() { return this.address.toString() + "/" + this.serviceName + "/" + this.ticket; }
@Override public String toString() { return address.toString(); } }
@NotNull @Override protected String connectedAddressToPresentation(@NotNull InetSocketAddress address, @NotNull Vm vm) { return address.toString(); } }
/** * @param addrs Addresses. */ protected static List<String> toOrderedList(Collection<InetSocketAddress> addrs) { List<String> res = new ArrayList<>(addrs.size()); for (InetSocketAddress addr : addrs) res.add(addr.toString()); Collections.sort(res); return res; }
/** * Add an address to the list of the failed servers list. */ public synchronized void addToFailedServers(InetSocketAddress address, Throwable throwable) { final long expiry = EnvironmentEdgeManager.currentTime() + recheckServersTimeout; this.failedServers.put(address.toString(), expiry); this.latestExpiry = expiry; if (LOG.isDebugEnabled()) { LOG.debug( "Added failed server with address " + address.toString() + " to list caused by " + throwable.toString()); } }
private InetSocketAddress resolve(InetSocketAddress address) { try { String curHostString = address.getHostString(); List<InetAddress> resolvedAddresses = new ArrayList<>(Arrays.asList(this.resolver.getAllByName(curHostString))); if (resolvedAddresses.isEmpty()) { return address; } Collections.shuffle(resolvedAddresses); return new InetSocketAddress(resolvedAddresses.get(0), address.getPort()); } catch (UnknownHostException e) { LOG.error("Unable to resolve address: {}", address.toString(), e); return address; } }
@Override public Object getState() { LOG.debug("Getting metrics for client connection to {}", dstAddressPrefixedName); HashMap<String, Object> ret = new HashMap<String, Object>(); ret.put("reconnects", totalConnectionAttempts.getAndSet(0)); ret.put("sent", messagesSent.getAndSet(0)); ret.put("pending", pendingMessages.get()); ret.put("lostOnSend", messagesLost.getAndSet(0)); ret.put("dest", dstAddress.toString()); String src = srcAddressName(); if (src != null) { ret.put("src", src); } return ret; }
protected void startHeartBeat(ErosaConnection connection) { lastEntryTime = 0L; // 初始化 if (timer == null) {// lazy初始化一下 String name = String.format("destination = %s , address = %s , HeartBeatTimeTask", destination, runningInfo == null ? null : runningInfo.getAddress().toString()); synchronized (AbstractEventParser.class) { // synchronized (MysqlEventParser.class) { // why use MysqlEventParser.class, u know, MysqlEventParser is // the child class 4 AbstractEventParser, // do this is ... if (timer == null) { timer = new Timer(name, true); } } } if (heartBeatTimerTask == null) {// fixed issue #56,避免重复创建heartbeat线程 heartBeatTimerTask = buildHeartBeatTimeTask(connection); Integer interval = detectingIntervalInSeconds; timer.schedule(heartBeatTimerTask, interval * 1000L, interval * 1000L); logger.info("start heart beat.... "); } }
@Override public int run(CommandLine cl) { MasterInquireClient inquireClient = MasterInquireClient.Factory.create(mFsContext.getConf()); try { InetSocketAddress leaderAddress = inquireClient.getPrimaryRpcAddress(); System.out.println("Current leader master: " + leaderAddress.toString()); } catch (UnavailableException e) { System.out.println("Failed to find leader master"); } try { List<InetSocketAddress> masterAddresses = inquireClient.getMasterRpcAddresses(); System.out.println(String.format("All masters: %s", masterAddresses)); } catch (UnavailableException e) { System.out.println("Failed to find all master addresses"); } return 0; }
/** * @summary get the address of the worker * @return the response object * @deprecated since version 1.4 and will be removed in version 2.0 * @see #getInfo(Boolean) */ @GET @Path(GET_RPC_ADDRESS) @ReturnType("java.lang.String") @Deprecated public Response getRpcAddress() { return RestUtils.call(() -> mWorkerProcess.getRpcAddress().toString(), ServerConfiguration.global()); }
@Override public String toString() { final MoreObjects.ToStringHelper helper = MoreObjects.toStringHelper(this); helper.add("id", getId()) .add("journalOffset", getJournalOffset()) .add("codec", getCodecName()) .add("payloadSize", getPayload().length) .add("timestamp", getTimestamp()); if (getRemoteAddress() != null) { helper.add("remoteAddress", getRemoteAddress().getInetSocketAddress().toString()); } return helper.toString(); }
/** * @summary get the master rpc address * @return the response object * @deprecated since version 1.4 and will be removed in version 2.0 * @see #getInfo(Boolean) */ @GET @Path(GET_RPC_ADDRESS) @ReturnType("java.lang.String") @Deprecated public Response getRpcAddress() { return RestUtils .call(() -> mMasterProcess.getRpcAddress().toString(), ServerConfiguration.global()); }
protected TServer getTNonBlockingServer(TNonblockingServerTransport serverTransport, TProtocolFactory protocolFactory, TProcessor processor, TTransportFactory transportFactory, InetSocketAddress inetSocketAddress) { LOG.info("starting HBase Nonblocking Thrift server on " + inetSocketAddress.toString()); TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport); serverArgs.processor(processor); serverArgs.transportFactory(transportFactory); serverArgs.protocolFactory(protocolFactory); return new TNonblockingServer(serverArgs); }
public void run() { List<ClientIdentity> tasks = new ArrayList<ClientIdentity>(updateCursorTasks); for (ClientIdentity clientIdentity : tasks) { MDC.put("destination", String.valueOf(clientIdentity.getDestination())); try { // 定时将内存中的最新值刷到file中,多次变更只刷一次 if (logger.isInfoEnabled()) { LogPosition cursor = (LogPosition) getCursor(clientIdentity); logger.info("clientId:{} cursor:[{},{},{},{},{}] address[{}]", new Object[] { clientIdentity.getClientId(), cursor.getPostion().getJournalName(), cursor.getPostion().getPosition(), cursor.getPostion().getTimestamp(), cursor.getPostion().getServerId(), cursor.getPostion().getGtid(), cursor.getIdentity().getSourceAddress().toString() }); } flushDataToFile(clientIdentity.getDestination()); updateCursorTasks.remove(clientIdentity); } catch (Throwable e) { // ignore logger.error("period update" + clientIdentity.toString() + " curosr failed!", e); } } } },
@Test public void testAddToFailedServersLogging() { Throwable nullException = new NullPointerException(); FailedServers fs = new FailedServers(new Configuration()); addr = new InetSocketAddress(TEST_PORT); fs.addToFailedServers(addr, nullException); Mockito.verify(mockAppender).doAppend((LoggingEvent) captorLoggingEvent.capture()); LoggingEvent loggingEvent = (LoggingEvent) captorLoggingEvent.getValue(); assertThat(loggingEvent.getLevel(), is(Level.DEBUG)); assertEquals("Added failed server with address " + addr.toString() + " to list caused by " + nullException.toString(), loggingEvent.getRenderedMessage()); }
@Test public void testLiteralIPNoReverseNS() { byte size = 30; HostProvider hostProvider = getHostProviderUnresolved(size); for (int i = 0; i < size; i++) { InetSocketAddress next = hostProvider.next(0); assertThat(next, instanceOf(InetSocketAddress.class)); assertFalse(next.isUnresolved()); assertTrue(next.toString().startsWith("/")); // Do NOT trigger the reverse name service lookup. String hostname = next.getHostString(); // In this case, the hostname equals literal IP address. assertEquals(next.getAddress().getHostAddress(), hostname); } }
/** * @param clientIdx Client index. * @param srvIdx Server index. * @throws Exception In case of error. */ private void setClientRouter(int clientIdx, int srvIdx) throws Exception { TcpDiscoverySpi disco = (TcpDiscoverySpi)G.ignite("client-" + clientIdx).configuration().getDiscoverySpi(); TcpDiscoveryVmIpFinder ipFinder = (TcpDiscoveryVmIpFinder)disco.getIpFinder(); String addr = new ArrayList<>(IP_FINDER.getRegisteredAddresses()).get(srvIdx).toString(); if (addr.startsWith("/")) addr = addr.substring(1); ipFinder.setAddresses(Collections.singletonList(addr)); }