java.net.UnknownHostException Java Examples

The following examples show how to use java.net.UnknownHostException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AdminBrokerProcessor.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
private RemotingCommand consumeMessageDirectly(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final ConsumeMessageDirectlyResultRequestHeader requestHeader = (ConsumeMessageDirectlyResultRequestHeader)request
        .decodeCommandCustomHeader(ConsumeMessageDirectlyResultRequestHeader.class);

    request.getExtFields().put("brokerName", this.brokerController.getBrokerConfig().getBrokerName());
    SelectMappedBufferResult selectMappedBufferResult = null;
    try {
        MessageId messageId = MessageDecoder.decodeMessageId(requestHeader.getMsgId());
        selectMappedBufferResult = this.brokerController.getMessageStore().selectOneMessageByOffset(messageId.getOffset());

        byte[] body = new byte[selectMappedBufferResult.getSize()];
        selectMappedBufferResult.getByteBuffer().get(body);
        request.setBody(body);
    } catch (UnknownHostException e) {
    } finally {
        if (selectMappedBufferResult != null) {
            selectMappedBufferResult.release();
        }
    }

    return this.callConsumer(RequestCode.CONSUME_MESSAGE_DIRECTLY, request, requestHeader.getConsumerGroup(),
        requestHeader.getClientId());
}
 
Example #2
Source File: EasyHttpClient.java    From mobilecloud-15 with Apache License 2.0 6 votes vote down vote up
/**
 * @see org.apache.http.conn.scheme.SocketFactory#connectSocket(java.net.Socket,
 *      java.lang.String, int, java.net.InetAddress, int,
 *      org.apache.http.params.HttpParams)
 */
public Socket connectSocket(Socket sock, String host, int port,
		InetAddress localAddress, int localPort, HttpParams params)
		throws IOException, UnknownHostException, ConnectTimeoutException {
	int connTimeout = HttpConnectionParams.getConnectionTimeout(params);
	int soTimeout = HttpConnectionParams.getSoTimeout(params);

	InetSocketAddress remoteAddress = new InetSocketAddress(host, port);
	SSLSocket sslsock = (SSLSocket) ((sock != null) ? sock : createSocket());

	if ((localAddress != null) || (localPort > 0)) {
		// we need to bind explicitly
		if (localPort < 0) {
			localPort = 0; // indicates "any"
		}
		InetSocketAddress isa = new InetSocketAddress(localAddress,
				localPort);
		sslsock.bind(isa);
	}

	sslsock.connect(remoteAddress, connTimeout);
	sslsock.setSoTimeout(soTimeout);
	return sslsock;
}
 
Example #3
Source File: LoginOpenController.java    From JavaWeb with Apache License 2.0 6 votes vote down vote up
@GetMapping(value="/getHostInfo",produces=MediaType.APPLICATION_JSON_UTF8_VALUE)
@ResponseBody
public String getHostInfo(HttpServletRequest request,
						  HttpServletResponse response){
	JSONObject jo = new JSONObject();
	String path = request.getContextPath();
	String basePath = null;
	try {
		InetAddress addr = InetAddress.getLocalHost();
		basePath = request.getScheme()+"://"+addr.getHostAddress()+":"+request.getServerPort()+path+"/";
	} catch (UnknownHostException e) {
		basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
	} 
	jo.put("host", basePath);
	return jo.toString();
}
 
Example #4
Source File: MpdMonitor.java    From play-mpc with MIT License 6 votes vote down vote up
private MpdMonitor() throws UnknownHostException, MPDConnectionException
{
	Configuration config = Play.application().configuration();

	String hostname = config.getString("mpd.hostname");
	int port = config.getInt("mpd.port");
	String password = config.getString("mpd.password");
	int timeout = config.getInt("mpd.timeout", 10) * 1000;
	
	Logger.info("Connecting to MPD");
	
	mpd = new MPD(hostname, port, password, timeout);
	monitor = new MPDStandAloneMonitor(mpd, 1000);
	
	thread = new Thread(monitor);
	thread.start();
}
 
Example #5
Source File: OspfInterfaceChannelHandlerTest.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Utility for test method.
 */
private OspfInterfaceImpl createOspfInterface1() throws UnknownHostException {
    ospfInterface = new OspfInterfaceImpl();
    OspfAreaImpl ospfArea = new OspfAreaImpl();
    OspfInterfaceChannelHandler ospfInterfaceChannelHandler = EasyMock.createMock(
            OspfInterfaceChannelHandler.class);
    ospfNbr = new OspfNbrImpl(ospfArea, ospfInterface, ip4Address5,
                              ip4Address6, 2, topologyForDeviceAndLink);
    ospfNbr.setState(OspfNeighborState.FULL);
    ospfNbr.setNeighborId(ip4Address7);
    ospfInterface = new OspfInterfaceImpl();
    ospfInterface.setIpAddress(ip4Address5);
    ospfInterface.setIpNetworkMask(subnetAddress);
    ospfInterface.setBdr(ip4Address4);
    ospfInterface.setDr(ip4Address4);
    ospfInterface.setHelloIntervalTime(20);
    ospfInterface.setInterfaceType(2);
    ospfInterface.setReTransmitInterval(2000);
    ospfInterface.setMtu(6500);
    ospfInterface.setRouterDeadIntervalTime(1000);
    ospfInterface.setRouterPriority(1);
    ospfInterface.setInterfaceType(1);
    ospfInterface.addNeighbouringRouter(ospfNbr);
    return ospfInterface;
}
 
Example #6
Source File: TCPThriftAuthenticationService.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
public void start() throws TTransportException, UnknownHostException {
    InetAddress inetAddress = InetAddress.getByName(hostName);

    TSSLTransportFactory.TSSLTransportParameters params =
            new TSSLTransportFactory.TSSLTransportParameters();
    params.setKeyStore(keyStore, keyStorePassword);

    TServerSocket serverTransport;

    serverTransport = TSSLTransportFactory.getServerSocket(port, clientTimeout, inetAddress, params);


    AuthenticatorService.Processor<AuthenticatorServiceImpl> processor =
            new AuthenticatorService.Processor<AuthenticatorServiceImpl>(
                    new AuthenticatorServiceImpl(thriftAuthenticatorService));
    authenticationServer = new TThreadPoolServer(
            new TThreadPoolServer.Args(serverTransport).processor(processor));
    Thread thread = new Thread(new ServerRunnable(authenticationServer));
    if (log.isDebugEnabled()) {
        log.debug("Thrift Authentication Service started at ssl://" + hostName + ":" + port);
    }
    thread.start();
}
 
Example #7
Source File: ProtocolGenericBindingProvider.java    From openhab1-addons with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public List<InetSocketAddress> getInetSocketAddresses(String itemName) {
    List<InetSocketAddress> theList = new ArrayList<InetSocketAddress>();
    ProtocolBindingConfig config = (ProtocolBindingConfig) bindingConfigs.get(itemName);
    if (config != null) {
        for (Command command : config.keySet()) {
            InetSocketAddress anAddress = null;
            try {
                anAddress = new InetSocketAddress(InetAddress.getByName(config.get(command).getHost()),
                        Integer.parseInt(config.get(command).getPort()));
            } catch (UnknownHostException e) {
                logger.warn("Could not resolve the hostname {} for item {}", config.get(command).getHost(),
                        itemName);
            }
            theList.add(anAddress);
        }
    }
    return theList;
}
 
Example #8
Source File: ErrorHandler.java    From apiman with Apache License 2.0 6 votes vote down vote up
/**
 * This method handles a connection error that was caused while connecting the gateway to the backend.
 *
 * @param error the connection error to be handled
 * @return a new ConnectorException
 */
public static ConnectorException handleConnectionError(Throwable error) {
    ConnectorException ce = null;
    if (error instanceof UnknownHostException || error instanceof ConnectException || error instanceof NoRouteToHostException) {
        ce = new ConnectorException("Unable to connect to backend", error); //$NON-NLS-1$
        ce.setStatusCode(502); // BAD GATEWAY
    } else if (error instanceof InterruptedIOException || error instanceof java.util.concurrent.TimeoutException) {
        ce = new ConnectorException("Connection to backend terminated" + error.getMessage(), error); //$NON-NLS-1$
        ce.setStatusCode(504); // GATEWAY TIMEOUT

    }
    if (ce != null) {
        return ce;
    } else {
        return new ConnectorException(error.getMessage(), error);
    }
}
 
Example #9
Source File: RakNet.java    From JRakNet with MIT License 6 votes vote down vote up
/**
 * Parses a single String as an address and port and converts it to an
 * <code>InetSocketAddress</code>.
 * 
 * @param address
 *            the address to convert.
 * @param defaultPort
 *            the default port to use if one is not.
 * @return the parsed <code>InetSocketAddress</code>.
 * @throws UnknownHostException
 *             if the address is in an invalid format or if the host cannot
 *             be found.
 */
public static InetSocketAddress parseAddress(String address, int defaultPort) throws UnknownHostException {
	String[] addressSplit = address.split(":");
	if (addressSplit.length == 1 || addressSplit.length == 2) {
		InetAddress inetAddress = InetAddress.getByName(!addressSplit[0].startsWith("/") ? addressSplit[0]
				: addressSplit[0].substring(1, addressSplit[0].length()));
		int port = (addressSplit.length == 2 ? parseIntPassive(addressSplit[1]) : defaultPort);
		if (port >= 0x0000 && port <= 0xFFFF) {
			return new InetSocketAddress(inetAddress, port);
		} else {
			throw new UnknownHostException("Port number must be between 0-65535");
		}
	} else {
		throw new UnknownHostException("Format must follow address:port");
	}
}
 
Example #10
Source File: HostAddresses.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public InetAddress[] getInetAddresses() {

        if (addresses == null || addresses.length == 0)
            return null;

        ArrayList<InetAddress> ipAddrs = new ArrayList<>(addresses.length);

        for (int i = 0; i < addresses.length; i++) {
            try {
                if ((addresses[i].addrType == Krb5.ADDRTYPE_INET) ||
                    (addresses[i].addrType == Krb5.ADDRTYPE_INET6)) {
                    ipAddrs.add(addresses[i].getInetAddress());
                }
            } catch (java.net.UnknownHostException e) {
                // Should not happen since IP address given
                return null;
            }
        }

        InetAddress[] retVal = new InetAddress[ipAddrs.size()];
        return ipAddrs.toArray(retVal);

    }
 
Example #11
Source File: FastRetryWhen.java    From FastLib with Apache License 2.0 6 votes vote down vote up
/**
 * Applies this function to the given argument.
 *
 * @param observable the function argument
 * @return the function result
 */
@Override
public Observable<?> apply(Observable<? extends Throwable> observable) {
    return observable.flatMap(new Function<Throwable, ObservableSource<?>>() {
        @Override
        public ObservableSource<?> apply(Throwable throwable) {
            //未连接网络直接返回异常
            if (!NetworkUtil.isConnected(mContext)) {
                return Observable.error(throwable);
            }
            //仅仅对连接失败相关错误进行重试
            if (throwable instanceof ConnectException
                    || throwable instanceof UnknownHostException
                    || throwable instanceof SocketTimeoutException
                    || throwable instanceof SocketException
                    || throwable instanceof TimeoutException) {
                if (++mRetryCount <= mRetryMaxTime) {
                    LoggerManager.e(TAG, "网络请求错误,将在 " + mRetryDelay + " ms后进行重试, 重试次数 " + mRetryCount + ";throwable:" + throwable);
                    return Observable.timer(mRetryDelay, TimeUnit.MILLISECONDS);
                }
            }
            return Observable.error(throwable);
        }
    });
}
 
Example #12
Source File: ConnectionTest.java    From Hive2Hive with MIT License 6 votes vote down vote up
@Test
public void testConnectDisconnect() throws UnknownHostException {
	NetworkManager nodeA = new NetworkManager(new H2HDummyEncryption(), serializer, new TestFileConfiguration());
	NetworkManager nodeB = new NetworkManager(new H2HDummyEncryption(), serializer, new TestFileConfiguration());

	INetworkConfiguration netConfigA = NetworkConfiguration.createInitial("nodeA");
	INetworkConfiguration netConfigB = NetworkConfiguration.create("nodeB", InetAddress.getLocalHost());
	try {
		nodeA.connect(netConfigA);
		nodeB.connect(netConfigB);

		assertTrue(nodeB.disconnect(false));
		assertTrue(nodeB.connect(netConfigB));
	} finally {
		nodeA.disconnect(false);
		nodeB.disconnect(false);
	}
}
 
Example #13
Source File: PostBDMEventHandler.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void execute(final Event event) {
    final String fileContent = (String) event.getProperty(FILE_CONTENT);
    Map<String, String> content = new HashMap<>();
    content.put("bdmXml", fileContent);
    try {
        new ClientResource(String.format("http://%s:%s/bdm",
                InetAddress.getByName(null).getHostAddress(),
                InstanceScope.INSTANCE.getNode(BonitaStudioPreferencesPlugin.PLUGIN_ID)
                        .get(BonitaPreferenceConstants.DATA_REPOSITORY_PORT, "-1")))
                                .post(new JacksonRepresentation<Object>(content));
        BonitaStudioLog.info("BDM has been publish into Data Repository service", UIDesignerPlugin.PLUGIN_ID);
    } catch (ResourceException | UnknownHostException e) {
        BonitaStudioLog.error("An error occured while publishing the BDM into Data Repository service", e);
    }
    
}
 
Example #14
Source File: NetworkMonitor.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public InetAddress[] getAllByName(String host) throws UnknownHostException {
    // Always bypass Private DNS.
    final List<InetAddress> addrs = Arrays.asList(
            ResolvUtil.blockingResolveAllLocally(this, host));

    // Ensure the address family of the first address is tried first.
    LinkedHashMap<Class, InetAddress> addressByFamily = new LinkedHashMap<>();
    addressByFamily.put(addrs.get(0).getClass(), addrs.get(0));
    Collections.shuffle(addrs);

    for (InetAddress addr : addrs) {
        addressByFamily.put(addr.getClass(), addr);
    }

    return addressByFamily.values().toArray(new InetAddress[addressByFamily.size()]);
}
 
Example #15
Source File: ControllerThreadSocketFactory.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static Socket createSocket(final SocketTask task, int timeout)
 throws IOException, UnknownHostException, ConnectTimeoutException
{
        try {
            TimeoutController.execute(task, timeout);
        } catch (TimeoutController.TimeoutException e) {
            throw new ConnectTimeoutException(
                "The host did not accept the connection within timeout of " 
                + timeout + " ms");
        }
        Socket socket = task.getSocket();
        if (task.exception != null) {
            throw task.exception;
        }
        return socket;
}
 
Example #16
Source File: RouteSelector.java    From L.TileLayer.Cordova with MIT License 6 votes vote down vote up
/** Resets {@link #nextInetSocketAddress} to the first option. */
private void resetNextInetSocketAddress(Proxy proxy) throws UnknownHostException {
  socketAddresses = null; // Clear the addresses. Necessary if getAllByName() below throws!

  String socketHost;
  if (proxy.type() == Proxy.Type.DIRECT) {
    socketHost = uri.getHost();
    socketPort = getEffectivePort(uri);
  } else {
    SocketAddress proxyAddress = proxy.address();
    if (!(proxyAddress instanceof InetSocketAddress)) {
      throw new IllegalArgumentException(
          "Proxy.address() is not an " + "InetSocketAddress: " + proxyAddress.getClass());
    }
    InetSocketAddress proxySocketAddress = (InetSocketAddress) proxyAddress;
    socketHost = proxySocketAddress.getHostName();
    socketPort = proxySocketAddress.getPort();
  }

  // Try each address for best behavior in mixed IPv4/IPv6 environments.
  socketAddresses = dns.getAllByName(socketHost);
  nextSocketAddressIndex = 0;
}
 
Example #17
Source File: ElasticsearchTransportClientWriterTest.java    From incubator-gobblin with Apache License 2.0 6 votes vote down vote up
@Test
public void testBadSslConfiguration()
    throws UnknownHostException {
  Properties props = new Properties();
  props.setProperty(ElasticsearchWriterConfigurationKeys.ELASTICSEARCH_WRITER_INDEX_NAME, "test");
  props.setProperty(ElasticsearchWriterConfigurationKeys.ELASTICSEARCH_WRITER_INDEX_TYPE, "test");
  props.setProperty(ElasticsearchWriterConfigurationKeys.ELASTICSEARCH_WRITER_TYPEMAPPER_CLASS,
      AvroGenericRecordTypeMapper.class.getCanonicalName());
  props.setProperty(ElasticsearchWriterConfigurationKeys.ELASTICSEARCH_WRITER_ID_MAPPING_ENABLED, "true");
  props.setProperty(ElasticsearchWriterConfigurationKeys.ELASTICSEARCH_WRITER_SSL_ENABLED, "true");
  Config config = ConfigFactory.parseProperties(props);
  try {
    new ElasticsearchTransportClientWriter(config);
    Assert.fail("Writer should not be constructed");
  }
  catch (Exception e) {
  }
}
 
Example #18
Source File: HwvtepDataChangeListener.java    From ovsdb with Eclipse Public License 1.0 6 votes vote down vote up
private void disconnect(Collection<DataTreeModification<Node>> changes) {
    for (DataTreeModification<Node> change : changes) {
        final InstanceIdentifier<Node> key = change.getRootPath().getRootIdentifier();
        final DataObjectModification<Node> mod = change.getRootNode();
        Node deleted = getRemoved(mod);
        if (deleted != null) {
            HwvtepGlobalAugmentation hgDeleted = deleted.augmentation(HwvtepGlobalAugmentation.class);
            if (hgDeleted != null) {
                try {
                    hcm.disconnect(hgDeleted);
                    hcm.stopConnectionReconciliationIfActive(key, hgDeleted);
                } catch (UnknownHostException e) {
                    LOG.warn("Failed to disconnect HWVTEP Node", e);
                }
            }
        }
    }
}
 
Example #19
Source File: NtpBinding.java    From openhab1-addons with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Queries the given timeserver <code>hostname</code> and returns the time
 * in milliseconds.
 *
 * @param hostname the timeserver to query
 * @return the time in milliseconds or the current time of the system if an
 *         error occurs.
 */
protected static long getTime(String hostname) {

    try {
        NTPUDPClient timeClient = new NTPUDPClient();
        timeClient.setDefaultTimeout(NTP_TIMEOUT);
        InetAddress inetAddress = InetAddress.getByName(hostname);
        TimeInfo timeInfo = timeClient.getTime(inetAddress);

        return timeInfo.getReturnTime();
    } catch (UnknownHostException uhe) {
        logger.warn("the given hostname '{}' of the timeserver is unknown -> returning current sytem time instead",
                hostname);
    } catch (IOException ioe) {
        logger.warn("couldn't establish network connection [host '{}'] -> returning current sytem time instead",
                hostname);
    }

    return System.currentTimeMillis();
}
 
Example #20
Source File: MyRedisConfig.java    From code with Apache License 2.0 5 votes vote down vote up
/**
 * 自定义 RedisTemplate 序列化器
 */
@Bean
public RedisTemplate<Object, Employee> empRedisTemplate(
        RedisConnectionFactory redisConnectionFactory)
        throws UnknownHostException {
    RedisTemplate<Object, Employee> template = new RedisTemplate<Object, Employee>();
    template.setConnectionFactory(redisConnectionFactory);
    Jackson2JsonRedisSerializer<Employee> ser = new Jackson2JsonRedisSerializer<Employee>(Employee.class);
    template.setDefaultSerializer(ser);
    return template;
}
 
Example #21
Source File: PortHelper.java    From HttpInfo with Apache License 2.0 5 votes vote down vote up
public static void getPortParam() throws Exception {
    long startTime = LogTime.getLogTime();
    final PortBean portBean = new PortBean();
    portBean.setAddress(HttpModelHelper.getInstance().getAddress());
    final List<JSONObject> list = new ArrayList<>();
    try {

        PortScan.onAddress(Base.getUrlHost())
                .setPortsPrivileged()
                .setMethodTCP()
                .doScan(new PortScan.PortListener() {
                    @Override
                    public void onResult(PortBean.PortNetBean portNetBean) {
                        if (portNetBean.isConnected()) {
                            list.add(portNetBean.toJSONObject());
                        }
                    }


                    @Override
                    public void onFinished(ArrayList<Integer> openPorts) {
                        portBean.setStatus(BaseData.HTTP_SUCCESS);
                        portBean.setPortNetBeans(list);

                    }
                });
    } catch (UnknownHostException e) {
        portBean.setStatus(BaseData.HTTP_ERROR);
        e.printStackTrace();
    }
    portBean.setTotalTime(LogTime.getElapsedMillis(startTime));
    HttpLog.i("PortScan is end");
    Input.onSuccess(HttpType.PORT_SCAN, portBean.toJSONObject());

}
 
Example #22
Source File: BindingAddHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {

    PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
    String name = address.getLastElement().getValue();

    try {
        installBindingService(context, model, name);
    } catch (UnknownHostException e) {
        throw new OperationFailedException(e.toString());
    }

}
 
Example #23
Source File: Address.java    From freeacs with MIT License 5 votes vote down vote up
public InetAddress getInetAddress() throws UtilityException, UnknownHostException {
  byte[] address = new byte[4];
  address[0] = Utility.integerToOneByte(firstOctet);
  address[1] = Utility.integerToOneByte(secondOctet);
  address[2] = Utility.integerToOneByte(thirdOctet);
  address[3] = Utility.integerToOneByte(fourthOctet);
  return InetAddress.getByAddress(address);
}
 
Example #24
Source File: CubeServiceTest.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testBasics() throws JsonProcessingException, JobException, UnknownHostException, SQLException {
    Assert.assertNotNull(cubeService.getConfig());
    Assert.assertNotNull(cubeService.getConfig());
    Assert.assertNotNull(cubeService.getDataModelManager());
    Assert.assertNotNull(QueryConnection.getConnection(ProjectInstance.DEFAULT_PROJECT_NAME));

    List<CubeInstance> cubes = cubeService.listAllCubes(null, null, null, true);
    Assert.assertNotNull(cubes);
    CubeInstance cube = cubes.get(0);
}
 
Example #25
Source File: HttpClientService.java    From cppcheclipse with Apache License 2.0 5 votes vote down vote up
private Proxy getProxy(URI uri) throws UnknownHostException {
	IProxyData proxyData = getProxyData(uri);
	if (proxyData == null) {
		if (!isProxiesEnabled()) {
			return Proxy.NO_PROXY;
		}
		return null;
	}
	
	return getProxyFromProxyData(proxyData);

}
 
Example #26
Source File: WindowsAttachProvider.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a list of virtual machine descriptors derived from an enumeration
 * of the process list.
 */
private List<VirtualMachineDescriptor> listJavaProcesses() {
    ArrayList<VirtualMachineDescriptor> list =
        new ArrayList<VirtualMachineDescriptor>();

    // Use localhost in the display name
    String host = "localhost";
    try {
        host = InetAddress.getLocalHost().getHostName();
    } catch (UnknownHostException uhe) {
        // ignore
    }

    // Enumerate all processes.
    // For those processes that have loaded a library named "jvm.dll"
    // then we attempt to attach. If we succeed then we have a 6.0+ VM.
    int processes[] = new int[1024];
    int count = enumProcesses(processes, processes.length);
    for (int i=0; i<count; i++) {
        if (isLibraryLoadedByProcess("jvm.dll", processes[i])) {
            String pid = Integer.toString(processes[i]);
            try {
                new WindowsVirtualMachine(this, pid).detach();

                // FIXME - for now we don't have an appropriate display
                // name so we use pid@hostname
                String name = pid + "@" + host;

                list.add(new HotSpotVirtualMachineDescriptor(this, pid, name));
            } catch (AttachNotSupportedException x) {
            } catch (IOException ioe) {
            }
        }
    }

    return list;
}
 
Example #27
Source File: AddressUtilsTest.java    From mldht with Mozilla Public License 2.0 5 votes vote down vote up
@Test
public void testMappedBypass() throws UnknownHostException {
	byte[] v4mapped = new byte[16];
	v4mapped[11] = (byte) 0xff;
	v4mapped[10] = (byte) 0xff;
			
	assertThat(InetAddress.getByAddress(v4mapped), IsInstanceOf.instanceOf(Inet4Address.class));
	assertThat(AddressUtils.fromBytesVerbatim(v4mapped), IsInstanceOf.instanceOf(Inet6Address.class));
	
}
 
Example #28
Source File: NetSendTask.java    From apkextractor with GNU General Public License v3.0 5 votes vote down vote up
public void sendIpMessageByCommandToTargetIp(int command,String targetIp){
    IpMessage ipMessage=new IpMessage();
    ipMessage.setCommand(command);
    try {
        new UdpThread.UdpSendTask(ipMessage.toProtocolString(),InetAddress.getByName(targetIp),SPUtil.getPortNumber(context),null).start();
    } catch (UnknownHostException e) {
        e.printStackTrace();
    }
}
 
Example #29
Source File: URL.java    From sofa-registry with Apache License 2.0 5 votes vote down vote up
private String getIPAddressFromDomain(String domain) {
    try {
        InetAddress a = InetAddress.getByName(domain);
        return a.getHostAddress();
    } catch (UnknownHostException e) {
        LOGGER.error("Can not resolve " + domain + " really ip.");
    }
    return domain;
}
 
Example #30
Source File: ArchivedExecutionBuilder.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public ArchivedExecution build() throws UnknownHostException {
	return new ArchivedExecution(
		userAccumulators != null ? userAccumulators : new StringifiedAccumulatorResult[0],
		ioMetrics != null ? ioMetrics : new TestIOMetrics(),
		attemptId != null ? attemptId : new ExecutionAttemptID(),
		attemptNumber,
		state != null ? state : ExecutionState.FINISHED,
		failureCause != null ? failureCause : "(null)",
		assignedResourceLocation != null ? assignedResourceLocation : new TaskManagerLocation(new ResourceID("tm"), InetAddress.getLocalHost(), 1234),
		assignedAllocationID != null ? assignedAllocationID : new AllocationID(0L, 0L),
		parallelSubtaskIndex,
		stateTimestamps != null ? stateTimestamps : new long[]{1, 2, 3, 4, 5, 5, 5, 5}
	);
}