当前位置: 首页>>代码示例>>Java>>正文


Java UnresolvedAddressException类代码示例

本文整理汇总了Java中java.nio.channels.UnresolvedAddressException的典型用法代码示例。如果您正苦于以下问题:Java UnresolvedAddressException类的具体用法?Java UnresolvedAddressException怎么用?Java UnresolvedAddressException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UnresolvedAddressException类属于java.nio.channels包,在下文中一共展示了UnresolvedAddressException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getClient

import java.nio.channels.UnresolvedAddressException; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public <X extends TAsyncClient> X getClient(final Class<X> clazz) {
    return (X) super.clients.computeIfAbsent(ClassNameUtils.getOuterClassName(clazz), (className) -> {
        TProtocolFactory protocolFactory = (TProtocolFactory) tTransport -> {
            TProtocol protocol = new TBinaryProtocol(tTransport);
            return new TMultiplexedProtocol(protocol, className);
        };
        try {
            return clazz.getConstructor(TProtocolFactory.class, TAsyncClientManager.class, TNonblockingTransport.class)
                    .newInstance(protocolFactory, this.clientManager, this.transport);
        } catch (Throwable e) {
            if (e instanceof UnresolvedAddressException) {
                this.isOpen = false;
            }
            return null;
        }
    });
}
 
开发者ID:sofn,项目名称:trpc,代码行数:20,代码来源:AsyncTrpcClient.java

示例2: onError

import java.nio.channels.UnresolvedAddressException; //导入依赖的package包/类
@Override
public void onError(Exception ex) {
    StringWriter stringWriter = new StringWriter();
    JsonWriter writer = new JsonWriter(stringWriter);

    try {
        writer.beginObject();
        writer.name("event").value("onError");

        if (ex instanceof UnresolvedAddressException) {
            writer.name("errorCode").value("ERR_NAME_NOT_RESOLVED");
            writer.name("errorMessage").value("Unable to resolve address. Please check the url and your network connection");
        } else {
            writer.name("errorCode").value("ERR_NAME_UNKNOWN");
            writer.name("errorMessage").value("Unknown error was thrown");
        }

        writer.endObject();
    } catch (IOException e) {
        e.printStackTrace();
    }

    this.callback(PluginResult.Status.OK, stringWriter.toString());
}
 
开发者ID:flynetworks,项目名称:cordova-websocket-clientcert,代码行数:25,代码来源:WebSocketClient.java

示例3: sendMessageToHyVarRec

import java.nio.channels.UnresolvedAddressException; //导入依赖的package包/类
protected String sendMessageToHyVarRec(String message, URI uri) throws UnresolvedAddressException, ExecutionException, InterruptedException, TimeoutException {
	HttpClient hyvarrecClient = new HttpClient();
	try {
		hyvarrecClient.start();
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		return null;
	}
	URI hyvarrecUri = uri;
	Request hyvarrecRequest = hyvarrecClient.POST(hyvarrecUri);
	hyvarrecRequest.header(HttpHeader.CONTENT_TYPE, "application/json");
	hyvarrecRequest.content(new StringContentProvider(message), "application/json");
	ContentResponse hyvarrecResponse;
	String hyvarrecAnswerString = "";
	hyvarrecResponse = hyvarrecRequest.send();
	hyvarrecAnswerString = hyvarrecResponse.getContentAsString();

	// Only for Debug
	System.err.println("HyVarRec Answer: "+hyvarrecAnswerString);
	
	return hyvarrecAnswerString;
}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:24,代码来源:DwAnalysesClient.java

示例4: newOutgoingConnection

import java.nio.channels.UnresolvedAddressException; //导入依赖的package包/类
public T newOutgoingConnection(InetSocketAddress dest, ConnectionListener listener) throws IOException {
	SocketChannel	channel;
	
	channel = SocketChannel.open();
	if (dest.isUnresolved()) {
           Log.warning("Unresolved InetSocketAddress: "+ dest);
           throw new ConnectException("Unresolved InetSocketAddress"+ dest.toString());
	}
	LWTThreadUtil.setBlocked();
	try {
		channel.socket().connect(dest, defSocketConnectTimeout);
	    //channel.connect(dest);
	} catch (UnresolvedAddressException uae) {
	    Log.logErrorWarning(uae);
	    Log.warning(dest);
	    throw new ConnectException(dest.toString());
	} finally {
        LWTThreadUtil.setNonBlocked();
	}
	return addConnection(channel, listener);
}
 
开发者ID:Morgan-Stanley,项目名称:SilverKing,代码行数:22,代码来源:AsyncBase.java

示例5: connect

import java.nio.channels.UnresolvedAddressException; //导入依赖的package包/类
public boolean connect (SocketAddress remote, int timeout) throws IOException
{
  if (!isOpen())
    throw new ClosedChannelException();

  if (isConnected())
    throw new AlreadyConnectedException();

  if (connectionPending)
    throw new ConnectionPendingException();

  if (!(remote instanceof InetSocketAddress))
    throw new UnsupportedAddressTypeException();

  connectAddress = (InetSocketAddress) remote;

  if (connectAddress.isUnresolved())
    throw new UnresolvedAddressException();

  connected = channel.connect(connectAddress, timeout);
  connectionPending = !connected;
  return connected;
}
 
开发者ID:vilie,项目名称:javify,代码行数:24,代码来源:SocketChannelImpl.java

示例6: connect

import java.nio.channels.UnresolvedAddressException; //导入依赖的package包/类
public boolean connect (SocketAddress remote, int timeout) throws IOException
{
  if (!isOpen())
    throw new ClosedChannelException();
  
  if (isConnected())
    throw new AlreadyConnectedException();

  if (connectionPending)
    throw new ConnectionPendingException();

  if (!(remote instanceof InetSocketAddress))
    throw new UnsupportedAddressTypeException();
  
  connectAddress = (InetSocketAddress) remote;

  if (connectAddress.isUnresolved())
    throw new UnresolvedAddressException();
  
  connected = channel.connect(connectAddress, timeout);
  connectionPending = !connected;
  return connected;
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:24,代码来源:SocketChannelImpl.java

示例7: connect

import java.nio.channels.UnresolvedAddressException; //导入依赖的package包/类
public ConnectFuture connect() {
    connectFuture = new ConnectFuture();

    runLoop.execute(new Runnable() {
        public void run() {
            try {
                channel = SocketChannel.open();
                channel.configureBlocking(false);
                channel.connect(new InetSocketAddress(origin.getHost(), origin.getPort()));
                reregister();
            } catch (IOException | UnresolvedAddressException e) {
                connectFuture.fail(e);
                closed = true;
            }
        }
    });

    return connectFuture;
}
 
开发者ID:twitter,项目名称:whiskey,代码行数:20,代码来源:Socket.java

示例8: testUnresolvedException

import java.nio.channels.UnresolvedAddressException; //导入依赖的package包/类
@Test
public void testUnresolvedException() throws IOException, InterruptedException
{
  final DefaultEventLoop eventLoop = DefaultEventLoop.createEventLoop("test");
  final CountDownLatch handled = new CountDownLatch(1);
  final ClientImpl client = new ClientImpl()
  {
    @Override
    public void handleException(Exception cce, EventLoop el)
    {
      assertSame(el, eventLoop);
      assertTrue(cce instanceof RuntimeException);
      assertTrue(cce.getCause() instanceof UnresolvedAddressException);
      super.handleException(cce, el);
      handled.countDown();
    }
  };
  verifyUnresolvedException(client, eventLoop, handled);
}
 
开发者ID:DataTorrent,项目名称:Netlet,代码行数:20,代码来源:AbstractClientTest.java

示例9: testUnresolvedException

import java.nio.channels.UnresolvedAddressException; //导入依赖的package包/类
@Test
public void testUnresolvedException() throws IOException, InterruptedException
{
  final DefaultEventLoop eventLoop = DefaultEventLoop.createEventLoop("test");
  final CountDownLatch handled = new CountDownLatch(1);
  final AbstractLengthPrependerClient ci = new AbstractLengthPrependerClient()
  {
    @Override
    public void onMessage(byte[] buffer, int offset, int size)
    {
      fail();
    }

    @Override
    public void handleException(Exception cce, EventLoop el)
    {
      assertSame(el, eventLoop);
      assertTrue(cce instanceof RuntimeException);
      assertTrue(cce.getCause() instanceof UnresolvedAddressException);
      super.handleException(cce, el);
      handled.countDown();
    }
  };
  verifyUnresolvedException(ci, eventLoop, handled);
}
 
开发者ID:DataTorrent,项目名称:Netlet,代码行数:26,代码来源:AbstractLengthPrependerClientTest.java

示例10: testConstructor_InvalidHost

import java.nio.channels.UnresolvedAddressException; //导入依赖的package包/类
@Test
public void testConstructor_InvalidHost() throws Exception {

	Throwable thrown = null;
	try {
		client = new SyncMqttClient("tcp://foo:1883", listener, 5, config);
		fail("expected exception");
	} catch (MqttInvocationException e) {
		thrown = e.getRootCause();
		assertEquals(UnresolvedAddressException.class, thrown.getClass());
	}

	verify(listener, timeout(5000)).disconnected(any(SyncMqttClient.class), same(thrown), eq(false));
	verify(reconnectionStrategy).clone();

	verifyNoMoreInteractions(listener, reconnectionStrategy);
}
 
开发者ID:TwoGuysFromKabul,项目名称:xenqtt,代码行数:18,代码来源:SyncMqttClientIT.java

示例11: testConstructor_InvalidHost

import java.nio.channels.UnresolvedAddressException; //导入依赖的package包/类
@Test
public void testConstructor_InvalidHost() throws Exception {

	Throwable thrown = null;
	try {
		client = new AsyncMqttClient("tcp://foo:1883", listener, 5, config);
		fail("expected exception");
	} catch (MqttInvocationException e) {
		thrown = e.getRootCause();
		assertEquals(UnresolvedAddressException.class, thrown.getClass());
	}

	verify(listener, timeout(5000)).disconnected(any(AsyncMqttClient.class), same(thrown), eq(false));
	verify(reconnectionStrategy).clone();

	verifyNoMoreInteractions(listener, reconnectionStrategy);
}
 
开发者ID:TwoGuysFromKabul,项目名称:xenqtt,代码行数:18,代码来源:AsyncMqttClientIT.java

示例12: testConnect_Unresolved

import java.nio.channels.UnresolvedAddressException; //导入依赖的package包/类
/**
 * Test method for 'DatagramChannelImpl.connect(SocketAddress)'
 *
 * @throws IOException
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "Verifies UnresolvedAddressException.",
    method = "connect",
    args = {java.net.SocketAddress.class}
)
public void testConnect_Unresolved() throws IOException {
    assertFalse(this.channel1.isConnected());
    InetSocketAddress unresolved = new InetSocketAddress(
            "unresolved address", 1080);
    try {
        this.channel1.connect(unresolved);
        fail("Should throw an UnresolvedAddressException here.");
    } catch (UnresolvedAddressException e) {
        // OK.
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:23,代码来源:DatagramChannelTest.java

示例13: testSerializationSelf

import java.nio.channels.UnresolvedAddressException; //导入依赖的package包/类
/**
 * @tests serialization/deserialization compatibility.
 */
@TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "!SerializationSelf",
        args = {}
    ),
    @TestTargetNew(
        level = TestLevel.PARTIAL_COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "UnresolvedAddressException",
        args = {}
    )
})
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(new UnresolvedAddressException());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:22,代码来源:UnresolvedAddressExceptionTest.java

示例14: testSerializationCompatibility

import java.nio.channels.UnresolvedAddressException; //导入依赖的package包/类
/**
 * @tests serialization/deserialization compatibility with RI.
 */
@TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "!SerializationGolden",
        args = {}
    ),
    @TestTargetNew(
        level = TestLevel.PARTIAL_COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "UnresolvedAddressException",
        args = {}
    )
})
public void testSerializationCompatibility() throws Exception {

    SerializationTest.verifyGolden(this, new UnresolvedAddressException());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:22,代码来源:UnresolvedAddressExceptionTest.java

示例15: openSocketChannel

import java.nio.channels.UnresolvedAddressException; //导入依赖的package包/类
public SocketChannel openSocketChannel() throws JournalNetworkException {
    if (getNodeCount() == 0) {
        if (isMultiCastEnabled()) {
            addNode(pollServerAddress());
        } else {
            throw new JournalNetworkException("No server nodes");
        }
    }

    List<ServerNode> nodes = getServerNodes();

    for (int i = 0, k = nodes.size(); i < k; i++) {
        ServerNode node = nodes.get(i);
        try {
            return openSocketChannel0(node);
        } catch (UnresolvedAddressException | IOException e) {
            LOG.info().$("Node ").$(node).$(" is unavailable [").$(e.getMessage()).$(']').$();
        }
    }

    throw new JournalNetworkException("Could not connect to any node");
}
 
开发者ID:bluestreak01,项目名称:questdb,代码行数:23,代码来源:ClientConfig.java


注:本文中的java.nio.channels.UnresolvedAddressException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。