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


Java InetSocketAddress.createUnresolved方法代码示例

本文整理汇总了Java中java.net.InetSocketAddress.createUnresolved方法的典型用法代码示例。如果您正苦于以下问题:Java InetSocketAddress.createUnresolved方法的具体用法?Java InetSocketAddress.createUnresolved怎么用?Java InetSocketAddress.createUnresolved使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.net.InetSocketAddress的用法示例。


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

示例1: getAddress

import java.net.InetSocketAddress; //导入方法依赖的package包/类
public InetSocketAddress getAddress(HttpClientImpl client) {
    URI uri = uri();
    if (uri == null) {
        return authority();
    }
    int port = uri.getPort();
    if (port == -1) {
        if (uri.getScheme().equalsIgnoreCase("https")) {
            port = 443;
        } else {
            port = 80;
        }
    }
    String host = uri.getHost();
    if (proxy(client) == null) {
        return new InetSocketAddress(host, port);
    } else {
        return InetSocketAddress.createUnresolved(host, port);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:HttpRequestImpl.java

示例2: testStartLocalizer

import java.net.InetSocketAddress; //导入方法依赖的package包/类
@Test (timeout = 5000)
public void testStartLocalizer() throws IOException {


  InetSocketAddress address = InetSocketAddress.createUnresolved("localhost", 8040);
  Path nmPrivateCTokensPath= new Path("file:///bin/nmPrivateCTokensPath");
 
  try {
    mockExec.startLocalizer(new LocalizerStartContext.Builder()
        .setNmPrivateContainerTokens(nmPrivateCTokensPath)
        .setNmAddr(address)
        .setUser("test")
        .setAppId("application_0")
        .setLocId("12345")
        .setDirsHandler(dirsHandler)
        .build());

    List<String> result=readMockParams();
    Assert.assertEquals(result.size(), 18);
    Assert.assertEquals(result.get(0), YarnConfiguration.DEFAULT_NM_NONSECURE_MODE_LOCAL_USER);
    Assert.assertEquals(result.get(1), "test");
    Assert.assertEquals(result.get(2), "0" );
    Assert.assertEquals(result.get(3),"application_0" );
    Assert.assertEquals(result.get(4), "/bin/nmPrivateCTokensPath");
    Assert.assertEquals(result.get(8), "-classpath" );
    Assert.assertEquals(result.get(11), "-Xmx256m" );
    Assert.assertEquals(result.get(12),"org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.ContainerLocalizer" );
    Assert.assertEquals(result.get(13), "test");
    Assert.assertEquals(result.get(14), "application_0");
    Assert.assertEquals(result.get(15),"12345" );
    Assert.assertEquals(result.get(16),"localhost" );
    Assert.assertEquals(result.get(17),"8040" );

  } catch (InterruptedException e) {
    LOG.error("Error:"+e.getMessage(),e);
    Assert.fail();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:39,代码来源:TestLinuxContainerExecutorWithMocks.java

示例3: testHttpPolicy

import java.net.InetSocketAddress; //导入方法依赖的package包/类
@Test
public void testHttpPolicy() throws Exception {
  conf.set(DFSConfigKeys.DFS_HTTP_POLICY_KEY, policy.name());
  conf.set(DFSConfigKeys.DFS_NAMENODE_HTTPS_ADDRESS_KEY, "localhost:0");

  InetSocketAddress addr = InetSocketAddress.createUnresolved("localhost", 0);
  NameNodeHttpServer server = null;
  try {
    server = new NameNodeHttpServer(conf, null, addr);
    server.start();

    Assert.assertTrue(implies(policy.isHttpEnabled(),
        canAccess("http", server.getHttpAddress())));
    Assert.assertTrue(implies(!policy.isHttpEnabled(),
        server.getHttpAddress() == null));

    Assert.assertTrue(implies(policy.isHttpsEnabled(),
        canAccess("https", server.getHttpsAddress())));
    Assert.assertTrue(implies(!policy.isHttpsEnabled(),
        server.getHttpsAddress() == null));

  } finally {
    if (server != null) {
      server.stop();
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:28,代码来源:TestNameNodeHttpServer.java

示例4: readSerializedGiveBackSimilarCoapPacket

import java.net.InetSocketAddress; //导入方法依赖的package包/类
@Test
public void readSerializedGiveBackSimilarCoapPacket() throws CoapException {
    InetSocketAddress addr = InetSocketAddress.createUnresolved("some.host", 1234);
    CoapPacket cp = new CoapPacket(Code.C205_CONTENT, MessageType.Acknowledgement, addr);
    cp.setPayload("TEST");
    cp.setMessageId(13);

    byte[] rawCp = CoapPacket.serialize(cp);
    CoapPacket cp2 = CoapPacket.read(addr, rawCp);

    assertArrayEquals(rawCp, CoapPacket.serialize(cp2));
    assertSimilar(cp, cp2);
}
 
开发者ID:ARMmbed,项目名称:java-coap,代码行数:14,代码来源:CoapPacketTest.java

示例5: getCompatibleClientBuilder

import java.net.InetSocketAddress; //导入方法依赖的package包/类
/**
 * Makes a Builder with the maximum range of TLS versions and cipher suites enabled.
 * <p>
 * It first tries the "approved" list of cipher suites given in OkHttp (the default in
 * ConnectionSpec.MODERN_TLS) and if that doesn't work falls back to the set of ALL enabled,
 * then falls back to plain http.
 * <p>
 * API level 24 has a regression in elliptic curves where it only supports secp256r1, so this
 * first tries a fallback without elliptic curves at all, and then tries them after.
 * <p>
 * TLS 1.1 and 1.2 have to be manually enabled on API levels 16-20.
 */
@NonNull
public static OkHttpClient.Builder getCompatibleClientBuilder(SharedPreferences preferences) {
    boolean httpProxyEnabled = preferences.getBoolean("httpProxyEnabled", false);
    String httpServer = preferences.getString("httpProxyServer", "");
    int httpPort = Integer.parseInt(preferences.getString("httpProxyPort", "-1"));

    ConnectionSpec fallback = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
            .allEnabledCipherSuites()
            .supportsTlsExtensions(true)
            .build();

    List<ConnectionSpec> specList = new ArrayList<>();
    specList.add(ConnectionSpec.MODERN_TLS);
    addNougatFixConnectionSpec(specList);
    specList.add(fallback);
    specList.add(ConnectionSpec.CLEARTEXT);

    OkHttpClient.Builder builder = new OkHttpClient.Builder()
            .addInterceptor(getUserAgentInterceptor())
            .readTimeout(30, TimeUnit.SECONDS)
            .writeTimeout(30, TimeUnit.SECONDS)
            .connectionSpecs(specList);

    if (httpProxyEnabled && !httpServer.isEmpty() && (httpPort > 0) && (httpPort < 65535)) {
        InetSocketAddress address = InetSocketAddress.createUnresolved(httpServer, httpPort);
        builder.proxy(new Proxy(Proxy.Type.HTTP, address));
    }

    return enableHigherTlsOnPreLollipop(builder);
}
 
开发者ID:Vavassor,项目名称:Tusky,代码行数:43,代码来源:OkHttpUtils.java

示例6: getServiceAddress

import java.net.InetSocketAddress; //导入方法依赖的package包/类
public static InetSocketAddress getServiceAddress(Configuration conf, InetSocketAddress fallback) {
  String addr = conf.get(NUCYPHER_EXT_NAMENODE_SERVICE_RPC_ADDRESS_KEY);
  if (addr == null || addr.isEmpty()) {
    return InetSocketAddress.createUnresolved(fallback.getHostName(), DEFAULT_PORT);
  }
  return NuCypherExtRpcServer.getAddress(addr);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:8,代码来源:NuCypherExtRpcServer.java

示例7: getNNAddressCheckLogical

import java.net.InetSocketAddress; //导入方法依赖的package包/类
/**
 * Get the NN address from the URI. If the uri is logical, default address is
 * returned. Otherwise return the DNS-resolved address of the URI.
 *
 * @param conf configuration
 * @param filesystemURI URI of the file system
 * @return address of file system
 */
public static InetSocketAddress getNNAddressCheckLogical(Configuration conf,
                                                         URI filesystemURI) {
  InetSocketAddress retAddr;
  if (HAUtilClient.isLogicalUri(conf, filesystemURI)) {
    retAddr = InetSocketAddress.createUnresolved(filesystemURI.getAuthority(),
        HdfsClientConfigKeys.DFS_NAMENODE_RPC_PORT_DEFAULT);
  } else {
    retAddr = getNNAddress(filesystemURI);
  }
  return retAddr;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:20,代码来源:NuCypherExtUtilClient.java

示例8: toSocketAddress

import java.net.InetSocketAddress; //导入方法依赖的package包/类
public InetSocketAddress toSocketAddress() {
    // Reconstruct the InetSocketAddress properly
    if (hostname != null) {
        return InetSocketAddress.createUnresolved(hostname, port);
    } else {
        return new InetSocketAddress(addr, port);
    }
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:9,代码来源:PeerAddress.java

示例9: parse

import java.net.InetSocketAddress; //导入方法依赖的package包/类
public static @Nullable InetSocketAddress parse(@Nullable String value) {
  if (Strings.isBlank(value)) {
    return null;
  }
  String[] parts = value.split(":", 2);
  if (parts.length == 0) {
    return null;
  }
  String host = parts[0];
  int port = parts.length > 1 ? Integer.parseInt(parts[1]) : 80;
  return InetSocketAddress.createUnresolved(host, port);
}
 
开发者ID:rogues-dev,项目名称:superglue,代码行数:13,代码来源:InetSocketAddressPreferenceAdapter.java

示例10: testDecode

import java.net.InetSocketAddress; //导入方法依赖的package包/类
/**
 * Tests decode() method.
 */
@Test
public void testDecode() throws Exception {
    channel = EasyMock.createMock(Channel.class);
    socketAddress = InetSocketAddress.createUnresolved("127.0.0.1", 7000);
    channelBuffer = ChannelBuffers.copiedBuffer(hellopacket);
    ospfMessageDecoder.decode(ctx, channel, channelBuffer);
    assertThat(ospfMessageDecoder, is(notNullValue()));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:12,代码来源:OspfMessageDecoderTest.java

示例11: updateRegionFavoredNodesMapping

import java.net.InetSocketAddress; //导入方法依赖的package包/类
@Override public void updateRegionFavoredNodesMapping(String encodedRegionName,
    List<org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.ServerName> favoredNodes) {
  InetSocketAddress[] addr = new InetSocketAddress[favoredNodes.size()];
  // Refer to the comment on the declaration of regionFavoredNodesMap on why
  // it is a map of region name to InetSocketAddress[]
  for (int i = 0; i < favoredNodes.size(); i++) {
    addr[i] = InetSocketAddress
        .createUnresolved(favoredNodes.get(i).getHostName(), favoredNodes.get(i).getPort());
  }
  regionFavoredNodesMap.put(encodedRegionName, addr);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:12,代码来源:HRegionServer.java

示例12: setRemoteAddress

import java.net.InetSocketAddress; //导入方法依赖的package包/类
/**
 * set remote address.
 *
 * @param host the host
 * @param port the port
 * @return context remote address
 */
public RpcContext setRemoteAddress(String host, int port) {
    if (host == null) {
        return this;
    }
    if (port < 0 || port > 0xFFFF) {
        port = 0;
    }
    // 提前检查是否为空,防止createUnresolved抛出异常,损耗性能
    this.remoteAddress = InetSocketAddress.createUnresolved(host, port);
    return this;
}
 
开发者ID:tiglabs,项目名称:jsf-sdk,代码行数:19,代码来源:RpcContext.java

示例13: registerServer

import java.net.InetSocketAddress; //导入方法依赖的package包/类
/**
 * Registers a server
 *
 * @param name       The name of the server
 * @param host       The host
 * @param port       The port
 * @param motd       The motd
 * @param restricted Is the server restricted
 * @return The server
 */
public ServerInfo registerServer(String name, String host, int id, int port, String motd, boolean restricted) {
    getLogs().debugInfo("Register server '" + name + "'(" + host + ":" + port + ") ..");
    name = name + MooServer.SERVER_SPLIT + id;
    if(ProxyServer.getInstance().getServers().containsKey(name)) return ProxyServer.getInstance().getServers().get(name);

    //
    InetSocketAddress address = InetSocketAddress.createUnresolved(host, port);
    ServerInfo info = ProxyServer.getInstance().constructServerInfo(name, address, motd, restricted);
    return ProxyServer.getInstance().getServers().put(name, info);
}
 
开发者ID:Superioz,项目名称:MooProject,代码行数:21,代码来源:Thunder.java

示例14: testConcurrentAddApplication

import java.net.InetSocketAddress; //导入方法依赖的package包/类
@Test(timeout=20000)                                                         
public void testConcurrentAddApplication()                                  
    throws IOException, InterruptedException, BrokenBarrierException {       
  final CyclicBarrier startBarrier = new CyclicBarrier(2);                   
  final CyclicBarrier endBarrier = new CyclicBarrier(2);                     
                                                                             
  // this token uses barriers to block during renew                          
  final Credentials creds1 = new Credentials();                              
  final Token<DelegationTokenIdentifier> token1 = mock(Token.class);    
  when(token1.getKind()).thenReturn(new Text("HDFS_DELEGATION_TOKEN"));
  DelegationTokenIdentifier dtId1 = 
      new DelegationTokenIdentifier(new Text("user1"), new Text("renewer"),
        new Text("user1"));
  when(token1.decodeIdentifier()).thenReturn(dtId1);
  creds1.addToken(new Text("token"), token1);                                
  doReturn(true).when(token1).isManaged();                                   
  doAnswer(new Answer<Long>() {                                              
    public Long answer(InvocationOnMock invocation)                          
        throws InterruptedException, BrokenBarrierException { 
      startBarrier.await();                                                  
      endBarrier.await();                                                    
      return Long.MAX_VALUE;                                                 
    }}).when(token1).renew(any(Configuration.class));                        
                                                                             
  // this dummy token fakes renewing                                         
  final Credentials creds2 = new Credentials();                              
  final Token<DelegationTokenIdentifier> token2 = mock(Token.class);           
  when(token2.getKind()).thenReturn(new Text("HDFS_DELEGATION_TOKEN"));
  when(token2.decodeIdentifier()).thenReturn(dtId1);
  creds2.addToken(new Text("token"), token2);                                
  doReturn(true).when(token2).isManaged();                                   
  doReturn(Long.MAX_VALUE).when(token2).renew(any(Configuration.class));     
                                                                             
  // fire up the renewer                                                     
  final DelegationTokenRenewer dtr =
      createNewDelegationTokenRenewer(conf, counter);           
  RMContext mockContext = mock(RMContext.class);
  when(mockContext.getSystemCredentialsForApps()).thenReturn(
    new ConcurrentHashMap<ApplicationId, ByteBuffer>());
  ClientRMService mockClientRMService = mock(ClientRMService.class);         
  when(mockContext.getClientRMService()).thenReturn(mockClientRMService);    
  InetSocketAddress sockAddr =                                               
      InetSocketAddress.createUnresolved("localhost", 1234);                 
  when(mockClientRMService.getBindAddress()).thenReturn(sockAddr);           
  dtr.setRMContext(mockContext);  
  when(mockContext.getDelegationTokenRenewer()).thenReturn(dtr);
  dtr.init(conf);
  dtr.start();                                                                           
  // submit a job that blocks during renewal                                 
  Thread submitThread = new Thread() {                                       
    @Override                                                                
    public void run() {
      dtr.addApplicationAsync(mock(ApplicationId.class), creds1, false, "user");
    }                                                                        
  };                                                                         
  submitThread.start();                                                      
                                                                             
  // wait till 1st submit blocks, then submit another
  startBarrier.await();                           
  dtr.addApplicationAsync(mock(ApplicationId.class), creds2, false, "user");
  // signal 1st to complete                                                  
  endBarrier.await();                                                        
  submitThread.join(); 
}
 
开发者ID:naver,项目名称:hadoop,代码行数:65,代码来源:TestDelegationTokenRenewer.java

示例15: getLocalAddress

import java.net.InetSocketAddress; //导入方法依赖的package包/类
public InetSocketAddress getLocalAddress() {
    Channel channel = getChannel();
    if (channel == null)
        return InetSocketAddress.createUnresolved(NetUtils.getLocalHost(), 0);
    return channel.getLocalAddress();
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:7,代码来源:AbstractClient.java


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