當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。