List of usage examples for java.net InetAddress equals
public boolean equals(Object obj)
From source file:com.bigdata.dastor.service.StorageService.java
/** * Called when an endPoint is removed from the ring without proper * STATE_LEAVING -> STATE_LEFT sequence. This function checks * whether this node becomes responsible for new ranges as a * consequence and streams data if needed. * * This is rather ineffective, but it does not matter so much * since this is called very seldom// www.j ava 2 s . c o m * * @param endPoint node that has left */ private void restoreReplicaCount(InetAddress endPoint) { InetAddress myAddress = FBUtilities.getLocalAddress(); for (String table : DatabaseDescriptor.getNonSystemTables()) { // get all ranges that change ownership (that is, a node needs // to take responsibility for new range) Multimap<Range, InetAddress> changedRanges = getChangedRangesForLeaving(table, endPoint); // check if any of these ranges are coming our way Set<Range> myNewRanges = new HashSet<Range>(); for (Map.Entry<Range, InetAddress> entry : changedRanges.entries()) { if (entry.getValue().equals(myAddress)) myNewRanges.add(entry.getKey()); } if (!myNewRanges.isEmpty()) { if (logger_.isDebugEnabled()) logger_.debug( endPoint + " was removed, my added ranges: " + StringUtils.join(myNewRanges, ", ")); Multimap<Range, InetAddress> rangeAddresses = getReplicationStrategy(table) .getRangeAddresses(tokenMetadata_, table); Multimap<InetAddress, Range> sourceRanges = HashMultimap.create(); IFailureDetector failureDetector = FailureDetector.instance; // find alive sources for our new ranges for (Range myNewRange : myNewRanges) { List<InetAddress> sources = DatabaseDescriptor.getEndPointSnitch(table) .getSortedListByProximity(myAddress, rangeAddresses.get(myNewRange)); assert (!sources.contains(myAddress)); for (InetAddress source : sources) { if (source.equals(endPoint)) continue; if (failureDetector.isAlive(source)) { sourceRanges.put(source, myNewRange); break; } } } // Finally we have a list of addresses and ranges to // stream. Proceed to stream for (Map.Entry<InetAddress, Collection<Range>> entry : sourceRanges.asMap().entrySet()) { if (logger_.isDebugEnabled()) logger_.debug("Requesting from " + entry.getKey() + " ranges " + StringUtils.join(entry.getValue(), ", ")); StreamIn.requestRanges(entry.getKey(), table, entry.getValue()); } } } }
From source file:com.bigdata.dastor.service.StorageService.java
public void removeToken(String tokenString) { Token token = partitioner_.getTokenFactory().fromString(tokenString); // Here we could refuse the operation from continuing if we // cannot find the endpoint for this token from metadata, but // that would prevent this command from being issued by a node // that has never seen the failed node. InetAddress endPoint = tokenMetadata_.getEndPoint(token); if (endPoint != null) { if (endPoint.equals(FBUtilities.getLocalAddress())) throw new UnsupportedOperationException("Cannot remove node's own token"); // Let's make sure however that we're not removing a live // token (member) if (Gossiper.instance.getLiveMembers().contains(endPoint)) throw new UnsupportedOperationException("Node " + endPoint + " is alive and owns this token. Use decommission command to remove it from the ring"); removeEndPointLocally(endPoint); calculatePendingRanges();//from w ww .j a v a 2 s .c o m } // bundle two states together. include this nodes state to keep the status quo, but indicate the leaving token so that it can be dealt with. Gossiper.instance.addLocalApplicationState(MOVE_STATE, new ApplicationState(STATE_NORMAL + Delimiter + partitioner_.getTokenFactory().toString(getLocalToken()) + Delimiter + REMOVE_TOKEN + Delimiter + partitioner_.getTokenFactory().toString(token))); }
From source file:com.mirth.connect.connectors.tcp.TcpReceiver.java
private void createServerSocket() throws IOException { // Create the server socket int backlog = DEFAULT_BACKLOG; String host = getLocalAddress(); int port = getLocalPort(); InetAddress hostAddress = InetAddress.getByName(host); int bindAttempts = 0; boolean success = false; // If an error occurred during binding, try again. If the JVM fails to bind ten times, throw the exception. while (!success) { try {//from w ww.j a v a 2 s . c o m bindAttempts++; boolean isLoopback = false; try { isLoopback = (hostAddress.isLoopbackAddress() || host.trim().equals("localhost") || hostAddress.equals(InetAddress.getLocalHost())); } catch (UnknownHostException e) { logger.warn("Failed to determine if '" + hostAddress.getHostAddress() + "' is a loopback address. Could not resolve the system's host name to an address.", e); } if (isLoopback) { serverSocket = configuration.createServerSocket(port, backlog); } else { serverSocket = configuration.createServerSocket(port, backlog, hostAddress); } success = true; } catch (BindException e) { if (bindAttempts >= 10) { throw e; } else { try { Thread.sleep(1000); } catch (InterruptedException e2) { Thread.currentThread().interrupt(); } } } } }
From source file:com.vuze.plugin.azVPN_Air.Checker.java
private int handleBound(InetAddress bindIP, StringBuilder sReply) { int newStatusID = STATUS_ID_OK; String s;/*from w w w .jav a 2 s .co m*/ boolean isGoodExistingBind = matchesVPNIP(bindIP); if (isGoodExistingBind) { String niName = "Unknown Interface"; try { NetworkInterface networkInterface = NetworkInterface.getByInetAddress(bindIP); niName = networkInterface.getName() + " (" + networkInterface.getDisplayName() + ")"; } catch (Throwable e) { } addReply(sReply, CHAR_GOOD, "airvpn.bound.good", new String[] { "" + bindIP, niName }); vpnIP = bindIP; } else { addReply(sReply, CHAR_BAD, "airvpn.bound.bad", new String[] { "" + bindIP }); newStatusID = STATUS_ID_BAD; } try { // Check if default routing goes through 10.*, by connecting to address // via socket. Address doesn't need to be reachable, just routable. // This works on Windows (in some cases), but on Mac returns a wildcard // address DatagramSocket socket = new DatagramSocket(); socket.connect(testSocketAddress, 0); InetAddress localAddress = socket.getLocalAddress(); socket.close(); if (!localAddress.isAnyLocalAddress()) { NetworkInterface networkInterface = NetworkInterface.getByInetAddress(localAddress); s = texts.getLocalisedMessageText("airvpn.nonvuze.probable.route", new String[] { "" + localAddress, networkInterface.getName() + " (" + networkInterface.getDisplayName() + ")" }); char replyChar = ' '; if ((localAddress instanceof Inet4Address) && matchesVPNIP(localAddress)) { if (localAddress.equals(bindIP)) { replyChar = isGoodExistingBind ? CHAR_GOOD : CHAR_WARN; s += " " + texts.getLocalisedMessageText("airvpn.same.as.vuze"); } else { // Vuze is bound, default routing goes somewhere else // This is ok, since Vuze will not accept incoming from "somewhere else" // We'll warn, but not update the status id replyChar = CHAR_WARN; s += " " + texts.getLocalisedMessageText("airvpn.not.same"); if (isGoodExistingBind) { s += " " + texts.getLocalisedMessageText("default.routing.not.vpn.network.splitting"); } } addLiteralReply(sReply, replyChar + " " + s); if (!isGoodExistingBind && rebindNetworkInterface) { rebindNetworkInterface(networkInterface, localAddress, sReply); // Should we redo test? } } else { // Vuze is bound, default routing goes to somewhere else. // Probably network splitting replyChar = isGoodExistingBind ? CHAR_WARN : CHAR_BAD; if (isGoodExistingBind) { s += " " + texts.getLocalisedMessageText("default.routing.not.vpn.network.splitting"); } addLiteralReply(sReply, replyChar + " " + s); } } } catch (Throwable t) { t.printStackTrace(); } return newStatusID; }
From source file:org.lealone.cluster.service.StorageService.java
/** * Handle node move to normal state. That is, node is entering token ring and participating * in reads.//w w w .ja v a2 s .c o m * * @param endpoint node */ private void handleStateNormal(final InetAddress endpoint) { Collection<Token> tokens; tokens = getTokensFor(endpoint); Set<Token> tokensToUpdateInTokenMetaData = new HashSet<>(); Set<Token> tokensToUpdateInClusterMetaData = new HashSet<>(); Set<Token> localTokensToRemove = new HashSet<>(); Set<InetAddress> endpointsToRemove = new HashSet<>(); if (logger.isDebugEnabled()) logger.debug("Node {} state normal, token {}", endpoint, tokens); if (tokenMetaData.isMember(endpoint)) logger.info("Node {} state jump to normal", endpoint); updatePeerInfo(endpoint); // Order Matters, TM.updateHostID() should be called before TM.updateNormalToken(), (see Cassandra-4300). if (Gossiper.instance.usesHostId(endpoint)) { UUID hostId = Gossiper.instance.getHostId(endpoint); InetAddress existing = tokenMetaData.getEndpointForHostId(hostId); if (DatabaseDescriptor.isReplacing() && Gossiper.instance.getEndpointStateForEndpoint(DatabaseDescriptor.getReplaceAddress()) != null && (hostId.equals(Gossiper.instance.getHostId(DatabaseDescriptor.getReplaceAddress())))) logger.warn("Not updating token metadata for {} because I am replacing it", endpoint); else { if (existing != null && !existing.equals(endpoint)) { if (existing.equals(Utils.getBroadcastAddress())) { logger.warn("Not updating host ID {} for {} because it's mine", hostId, endpoint); tokenMetaData.removeEndpoint(endpoint); endpointsToRemove.add(endpoint); } else if (Gossiper.instance.compareEndpointStartup(endpoint, existing) > 0) { logger.warn("Host ID collision for {} between {} and {}; {} is the new owner", hostId, existing, endpoint, endpoint); tokenMetaData.removeEndpoint(existing); endpointsToRemove.add(existing); tokenMetaData.updateHostId(hostId, endpoint); } else { logger.warn("Host ID collision for {} between {} and {}; ignored {}", hostId, existing, endpoint, endpoint); tokenMetaData.removeEndpoint(endpoint); endpointsToRemove.add(endpoint); } } else tokenMetaData.updateHostId(hostId, endpoint); } } for (final Token token : tokens) { // we don't want to update if this node is responsible for the token // and it has a later startup time than endpoint. InetAddress currentOwner = tokenMetaData.getEndpoint(token); if (currentOwner == null) { logger.debug("New node {} at token {}", endpoint, token); tokensToUpdateInTokenMetaData.add(token); tokensToUpdateInClusterMetaData.add(token); } else if (endpoint.equals(currentOwner)) { // set state back to normal, since the node may have tried to leave, but failed and is now back up tokensToUpdateInTokenMetaData.add(token); tokensToUpdateInClusterMetaData.add(token); } else if (Gossiper.instance.compareEndpointStartup(endpoint, currentOwner) > 0) { tokensToUpdateInTokenMetaData.add(token); tokensToUpdateInClusterMetaData.add(token); // currentOwner is no longer current, endpoint is. Keep track of these moves, because when // a host no longer has any tokens, we'll want to remove it. Multimap<InetAddress, Token> epToTokenCopy = tokenMetaData.getEndpointToTokenMapForReading(); epToTokenCopy.get(currentOwner).remove(token); if (epToTokenCopy.get(currentOwner).size() < 1) endpointsToRemove.add(currentOwner); logger.info(String.format("Nodes %s and %s have the same token %s. %s is the new owner", endpoint, currentOwner, token, endpoint)); } else { logger.info(String.format("Nodes %s and %s have the same token %s. Ignoring %s", endpoint, currentOwner, token, endpoint)); } } tokenMetaData.updateNormalTokens(tokensToUpdateInTokenMetaData, endpoint); for (InetAddress ep : endpointsToRemove) { removeEndpoint(ep); if (DatabaseDescriptor.isReplacing() && DatabaseDescriptor.getReplaceAddress().equals(ep)) Gossiper.instance.replacementQuarantine(ep); // quarantine locally longer than normally; see // Cassandra-8260 } if (!tokensToUpdateInClusterMetaData.isEmpty()) ClusterMetaData.updateTokens(endpoint, tokensToUpdateInClusterMetaData); if (!localTokensToRemove.isEmpty()) ClusterMetaData.updateLocalTokens(Collections.<Token>emptyList(), localTokensToRemove); if (tokenMetaData.isMoving(endpoint)) // if endpoint was moving to a new token { tokenMetaData.removeFromMoving(endpoint); for (IEndpointLifecycleSubscriber subscriber : lifecycleSubscribers) subscriber.onMove(endpoint); } else { for (IEndpointLifecycleSubscriber subscriber : lifecycleSubscribers) subscriber.onJoinCluster(endpoint); } }
From source file:net.sbbi.upnp.DiscoveryAdvertisement.java
private void listenBroadCast() throws IOException { skt.receive(input);/*from w w w. j av a 2 s. c om*/ InetAddress from = input.getAddress(); String received = new String(input.getData(), input.getOffset(), input.getLength()); HttpResponse msg = null; try { msg = new HttpResponse(received); } catch (IllegalArgumentException ex) { // crappy http sent if (log.isDebugEnabled()) log.debug("Skipping uncompliant HTTP message " + received); return; } String header = msg.getHeader(); if (header != null && header.startsWith("NOTIFY")) { if (log.isDebugEnabled()) log.debug(received); String ntsField = msg.getHTTPHeaderField("nts"); if (ntsField == null || ntsField.trim().length() == 0) { if (log.isDebugEnabled()) log.debug("Skipping SSDP message, missing HTTP header 'ntsField' field"); return; } if (ntsField.equals(NTS_SSDP_ALIVE)) { String deviceDescrLoc = msg.getHTTPHeaderField("location"); if (deviceDescrLoc == null || deviceDescrLoc.trim().length() == 0) { if (log.isDebugEnabled()) log.debug("Skipping SSDP message, missing HTTP header 'location' field"); return; } URL loc = new URL(deviceDescrLoc); if (MATCH_IP) { InetAddress locHost = InetAddress.getByName(loc.getHost()); if (!from.equals(locHost)) { log.warn("Discovery message sender IP " + from + " does not match device description IP " + locHost + " skipping message, set the net.sbbi.upnp.ddos.matchip system property" + " to false to avoid this check"); return; } } String nt = msg.getHTTPHeaderField("nt"); if (nt == null || nt.trim().length() == 0) { if (log.isDebugEnabled()) log.debug("Skipping SSDP message, missing HTTP header 'nt' field"); return; } String maxAge = msg.getHTTPFieldElement("Cache-Control", "max-age"); if (maxAge == null || maxAge.trim().length() == 0) { if (log.isDebugEnabled()) log.debug("Skipping SSDP message, missing HTTP header 'max-age' field"); return; } String usn = msg.getHTTPHeaderField("usn"); if (usn == null || usn.trim().length() == 0) { if (log.isDebugEnabled()) log.debug("Skipping SSDP message, missing HTTP header 'usn' field"); return; } USNPerIP.put(usn, from); String udn = usn; int index = udn.indexOf("::"); if (index != -1) udn = udn.substring(0, index); synchronized (REGISTRATION_PROCESS) { Set handlers = (Set) aliveRegistered.get(NT_ALL_EVENTS); if (handlers != null) { for (Iterator i = handlers.iterator(); i.hasNext();) { DiscoveryEventHandler eventHandler = (DiscoveryEventHandler) i.next(); eventHandler.eventSSDPAlive(usn, udn, nt, maxAge, loc); } } handlers = (Set) aliveRegistered.get(nt); if (handlers != null) { for (Iterator i = handlers.iterator(); i.hasNext();) { DiscoveryEventHandler eventHandler = (DiscoveryEventHandler) i.next(); eventHandler.eventSSDPAlive(usn, udn, nt, maxAge, loc); } } } } else if (ntsField.equals(NTS_SSDP_BYE_BYE)) { String usn = msg.getHTTPHeaderField("usn"); if (usn == null || usn.trim().length() == 0) { if (log.isDebugEnabled()) log.debug("Skipping SSDP message, missing HTTP header 'usn' field"); return; } String nt = msg.getHTTPHeaderField("nt"); if (nt == null || nt.trim().length() == 0) { if (log.isDebugEnabled()) log.debug("Skipping SSDP message, missing HTTP header 'nt' field"); return; } InetAddress originalAliveSenderIp = (InetAddress) USNPerIP.get(usn); if (originalAliveSenderIp != null) { // we check that the sender ip of message for the usn // match the sender ip of the alive message for wich the usn // has been received if (!originalAliveSenderIp.equals(from)) { // someone else is trying to say that the usn is leaving // since IP do not match we skip the message return; } } String udn = usn; int index = udn.indexOf("::"); if (index != -1) udn = udn.substring(0, index); synchronized (REGISTRATION_PROCESS) { Set handlers = (Set) byeByeRegistered.get(NT_ALL_EVENTS); if (handlers != null) { for (Iterator i = handlers.iterator(); i.hasNext();) { DiscoveryEventHandler eventHandler = (DiscoveryEventHandler) i.next(); eventHandler.eventSSDPByeBye(usn, udn, nt); } } handlers = (Set) byeByeRegistered.get(nt); if (handlers != null) { for (Iterator i = handlers.iterator(); i.hasNext();) { DiscoveryEventHandler eventHandler = (DiscoveryEventHandler) i.next(); eventHandler.eventSSDPByeBye(usn, udn, nt); } } } } else { log.warn("Unvalid NTS field value (" + ntsField + ") received in NOTIFY message :" + received); } } }
From source file:org.apache.cassandra.repair.RepairRunnable.java
private Thread createQueryThread(final int cmd, final UUID sessionId) { return new Thread(new WrappedRunnable() { // Query events within a time interval that overlaps the last by one second. Ignore duplicates. Ignore local traces. // Wake up upon local trace activity. Query when notified of trace activity with a timeout that doubles every two timeouts. public void runMayThrow() throws Exception { TraceState state = Tracing.instance.get(sessionId); if (state == null) throw new Exception("no tracestate"); String format = "select event_id, source, activity from %s.%s where session_id = ? and event_id > ? and event_id < ?;"; String query = String.format(format, TraceKeyspace.NAME, TraceKeyspace.EVENTS); SelectStatement statement = (SelectStatement) QueryProcessor.parseStatement(query) .prepare().statement; ByteBuffer sessionIdBytes = ByteBufferUtil.bytes(sessionId); InetAddress source = FBUtilities.getBroadcastAddress(); HashSet<UUID>[] seen = new HashSet[] { new HashSet<>(), new HashSet<>() }; int si = 0; UUID uuid;/*from w w w . j ava2 s . c om*/ long tlast = System.currentTimeMillis(), tcur; TraceState.Status status; long minWaitMillis = 125; long maxWaitMillis = 1000 * 1024L; long timeout = minWaitMillis; boolean shouldDouble = false; while ((status = state.waitActivity(timeout)) != TraceState.Status.STOPPED) { if (status == TraceState.Status.IDLE) { timeout = shouldDouble ? Math.min(timeout * 2, maxWaitMillis) : timeout; shouldDouble = !shouldDouble; } else { timeout = minWaitMillis; shouldDouble = false; } ByteBuffer tminBytes = ByteBufferUtil.bytes(UUIDGen.minTimeUUID(tlast - 1000)); ByteBuffer tmaxBytes = ByteBufferUtil .bytes(UUIDGen.maxTimeUUID(tcur = System.currentTimeMillis())); QueryOptions options = QueryOptions.forInternalCalls(ConsistencyLevel.ONE, Lists.newArrayList(sessionIdBytes, tminBytes, tmaxBytes)); ResultMessage.Rows rows = statement.execute(QueryState.forInternalCalls(), options); UntypedResultSet result = UntypedResultSet.create(rows.result); for (UntypedResultSet.Row r : result) { if (source.equals(r.getInetAddress("source"))) continue; if ((uuid = r.getUUID("event_id")).timestamp() > (tcur - 1000) * 10000) seen[si].add(uuid); if (seen[si == 0 ? 1 : 0].contains(uuid)) continue; String message = String.format("%s: %s", r.getInetAddress("source"), r.getString("activity")); fireProgressEvent("repair:" + cmd, new ProgressEvent(ProgressEventType.NOTIFICATION, 0, 0, message)); } tlast = tcur; si = si == 0 ? 1 : 0; seen[si].clear(); } } }); }
From source file:com.vuze.plugin.azVPN_PIA.Checker.java
private int handleUnboundOrLoopback(InetAddress bindIP, StringBuilder sReply) { int newStatusID = STATUS_ID_OK; InetAddress newBindIP = null; NetworkInterface newBindNetworkInterface = null; String s;// w w w . j a va 2s . c o m if (bindIP.isAnyLocalAddress()) { addReply(sReply, CHAR_WARN, "pia.vuze.unbound"); } else { addReply(sReply, CHAR_BAD, "pia.vuze.loopback"); } try { NetworkAdmin networkAdmin = NetworkAdmin.getSingleton(); // Find a bindable address that starts with 10. InetAddress[] bindableAddresses = networkAdmin.getBindableAddresses(); for (InetAddress bindableAddress : bindableAddresses) { if (matchesVPNIP(bindableAddress)) { newBindIP = bindableAddress; newBindNetworkInterface = NetworkInterface.getByInetAddress(newBindIP); addReply(sReply, CHAR_GOOD, "pia.found.bindable.vpn", new String[] { "" + newBindIP }); break; } } // Find a Network Interface that has an address that starts with 10. NetworkAdminNetworkInterface[] interfaces = networkAdmin.getInterfaces(); boolean foundNIF = false; for (NetworkAdminNetworkInterface networkAdminInterface : interfaces) { NetworkAdminNetworkInterfaceAddress[] addresses = networkAdminInterface.getAddresses(); for (NetworkAdminNetworkInterfaceAddress a : addresses) { InetAddress address = a.getAddress(); if (address instanceof Inet4Address) { if (matchesVPNIP(address)) { s = texts.getLocalisedMessageText("pia.possible.vpn", new String[] { "" + address, networkAdminInterface.getName() + " (" + networkAdminInterface.getDisplayName() + ")" }); if (newBindIP == null) { foundNIF = true; newBindIP = address; // Either one should work //newBindNetworkInterface = NetworkInterface.getByInetAddress(newBindIP); newBindNetworkInterface = NetworkInterface .getByName(networkAdminInterface.getName()); s = CHAR_GOOD + " " + s + ". " + texts.getLocalisedMessageText("pia.assuming.vpn"); } else if (address.equals(newBindIP)) { s = CHAR_GOOD + " " + s + ". " + texts.getLocalisedMessageText("pia.same.address"); foundNIF = true; } else { if (newStatusID != STATUS_ID_BAD) { newStatusID = STATUS_ID_WARN; } s = CHAR_WARN + " " + s + ". " + texts.getLocalisedMessageText("pia.not.same.address"); } addLiteralReply(sReply, s); if (rebindNetworkInterface) { // stops message below from being added, we'll rebind later foundNIF = true; } } } } } if (!foundNIF) { addReply(sReply, CHAR_BAD, "pia.interface.not.found"); } // Check if default routing goes through 10.*, by connecting to address // via socket. Address doesn't need to be reachable, just routable. // This works on Windows, but on Mac returns a wildcard address DatagramSocket socket = new DatagramSocket(); socket.connect(testSocketAddress, 0); InetAddress localAddress = socket.getLocalAddress(); socket.close(); if (!localAddress.isAnyLocalAddress()) { NetworkInterface networkInterface = NetworkInterface.getByInetAddress(localAddress); s = texts.getLocalisedMessageText("pia.nonvuze.probable.route", new String[] { "" + localAddress, networkInterface == null ? "null" : networkInterface.getName() + " (" + networkInterface.getDisplayName() + ")" }); if ((localAddress instanceof Inet4Address) && matchesVPNIP(localAddress)) { if (newBindIP == null) { newBindIP = localAddress; newBindNetworkInterface = networkInterface; s = CHAR_GOOD + " " + s + " " + texts.getLocalisedMessageText("pia.assuming.vpn"); } else if (localAddress.equals(newBindIP)) { s = CHAR_GOOD + " " + s + " " + texts.getLocalisedMessageText("pia.same.address"); } else { // Vuze not bound. We already found a boundable address, but it's not this one /* Possibly good case: * - Vuze: unbound * - Found Bindable: 10.100.1.6 * - Default Routing: 10.255.1.1 * -> Split network */ if (newStatusID != STATUS_ID_BAD) { newStatusID = STATUS_ID_WARN; } s = CHAR_WARN + " " + s + " " + texts.getLocalisedMessageText("pia.not.same.future.address") + " " + texts.getLocalisedMessageText("default.routing.not.vpn.network.splitting") + " " + texts.getLocalisedMessageText( "default.routing.not.vpn.network.splitting.unbound"); } addLiteralReply(sReply, s); } else { s = CHAR_WARN + " " + s; if (!bindIP.isLoopbackAddress()) { s += " " + texts.getLocalisedMessageText("default.routing.not.vpn.network.splitting"); } if (newBindIP == null && foundNIF) { if (newStatusID != STATUS_ID_BAD) { newStatusID = STATUS_ID_WARN; } s += " " + texts .getLocalisedMessageText("default.routing.not.vpn.network.splitting.unbound"); } addLiteralReply(sReply, s); } } } catch (Exception e) { e.printStackTrace(); addReply(sReply, CHAR_BAD, "pia.nat.error", new String[] { e.toString() }); } if (newBindIP == null) { addReply(sReply, CHAR_BAD, "pia.vpn.ip.detect.fail"); return STATUS_ID_BAD; } rebindNetworkInterface(newBindNetworkInterface, newBindIP, sReply); return newStatusID; }
From source file:org.openspaces.pu.container.servicegrid.deploy.Deploy.java
private boolean isOnGsmHost() throws UnknownHostException, RemoteException { InetAddress localHost = InetAddress.getLocalHost(); InetAddress gsmHostByName = null; InetAddress gsmHostByAddress = null; try {// w ww . j a v a2 s . c o m gsmHostByName = InetAddress.getByName(gsm.getOSDetails().getHostName()); } catch (UnknownHostException e1) { try { gsmHostByAddress = InetAddress.getByName(gsm.getOSDetails().getHostAddress()); } catch (UnknownHostException e2) { throw new UnknownHostException("failed to resolve host by name (" + gsm.getOSDetails().getHostName() + ") - caused by " + e1 + "; failed to resolve host by address (" + gsm.getOSDetails().getHostAddress() + ") - caused by " + e2.toString()); } } if (logger.isDebugEnabled()) { logger.debug("local host: " + localHost + " GSM host-by-name: " + gsmHostByName + " host-by-address: " + gsmHostByAddress); } return localHost.equals(gsmHostByName) || localHost.equals(gsmHostByAddress); }
From source file:org.apache.cassandra.service.StorageService.java
/** * Handle notification that a node being actively removed from the ring via 'removetoken' * * @param endpoint node//from w ww .java 2s . c o m * @param state either REMOVED_TOKEN (node is gone) or REMOVING_TOKEN (replicas need to be restored) */ private void handleStateRemoving(InetAddress endpoint, Token removeToken, String state) { InetAddress removeEndpoint = tokenMetadata_.getEndpoint(removeToken); if (removeEndpoint == null) return; if (removeEndpoint.equals(FBUtilities.getLocalAddress())) { logger_.info("Received removeToken gossip about myself. Is this node a replacement for a removed one?"); return; } if (VersionedValue.REMOVED_TOKEN.equals(state)) { excise(removeToken, removeEndpoint); } else if (VersionedValue.REMOVING_TOKEN.equals(state)) { if (logger_.isDebugEnabled()) logger_.debug("Token " + removeToken + " removed manually (endpoint was " + removeEndpoint + ")"); // Note that the endpoint is being removed tokenMetadata_.addLeavingEndpoint(removeEndpoint); calculatePendingRanges(); // grab any data we are now responsible for and notify responsible node restoreReplicaCount(removeEndpoint, endpoint); } }