Java Code Examples for javax.net.SocketFactory

The following examples show how to use javax.net.SocketFactory. These examples are extracted from open source projects. 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 Project: hadoop   Source File: RPC.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Get a protocol proxy that contains a proxy connection to a remote server
 * and a set of methods that are supported by the server
 *
 * @param protocol protocol
 * @param clientVersion client's version
 * @param addr server address
 * @param ticket security ticket
 * @param conf configuration
 * @param factory socket factory
 * @param rpcTimeout max time for each rpc; 0 means no timeout
 * @param connectionRetryPolicy retry policy
 * @param fallbackToSimpleAuth set to true or false during calls to indicate if
 *   a secure client falls back to simple auth
 * @return the proxy
 * @throws IOException if any error occurs
 */
 public static <T> ProtocolProxy<T> getProtocolProxy(Class<T> protocol,
                              long clientVersion,
                              InetSocketAddress addr,
                              UserGroupInformation ticket,
                              Configuration conf,
                              SocketFactory factory,
                              int rpcTimeout,
                              RetryPolicy connectionRetryPolicy,
                              AtomicBoolean fallbackToSimpleAuth)
     throws IOException {
  if (UserGroupInformation.isSecurityEnabled()) {
    SaslRpcServer.init(conf);
  }
  return getProtocolEngine(protocol, conf).getProxy(protocol, clientVersion,
      addr, ticket, conf, factory, rpcTimeout, connectionRetryPolicy,
      fallbackToSimpleAuth);
}
 
Example 2
Source Project: pulsar   Source File: AbstractHdfsConnector.java    License: Apache License 2.0 6 votes vote down vote up
protected void checkHdfsUriForTimeout(Configuration config) throws IOException {
    URI hdfsUri = FileSystem.getDefaultUri(config);
    String address = hdfsUri.getAuthority();
    int port = hdfsUri.getPort();
    if (address == null || address.isEmpty() || port < 0) {
        return;
    }
    InetSocketAddress namenode = NetUtils.createSocketAddr(address, port);
    SocketFactory socketFactory = NetUtils.getDefaultSocketFactory(config);
    Socket socket = null;
    try {
        socket = socketFactory.createSocket();
        NetUtils.connect(socket, namenode, 1000); // 1 second timeout
    } finally {
        IOUtils.closeQuietly(socket);
    }
}
 
Example 3
Source Project: elasticsearch-hadoop   Source File: SSLSocketFactory.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Socket createSocket(String host, int port, InetAddress localAddress, int localPort, HttpConnectionParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
    if (params == null) {
        throw new IllegalArgumentException("Parameters may not be null");
    }
    int timeout = params.getConnectionTimeout();
    SocketFactory socketfactory = getSSLContext().getSocketFactory();
    if (timeout == 0) {
        return socketfactory.createSocket(host, port, localAddress, localPort);
    }
    else {
        Socket socket = socketfactory.createSocket();
        SocketAddress localaddr = new InetSocketAddress(localAddress, localPort);
        SocketAddress remoteaddr = new InetSocketAddress(host, port);
        socket.bind(localaddr);
        socket.connect(remoteaddr, timeout);
        return socket;
    }
}
 
Example 4
Source Project: jdk8u-jdk   Source File: CloseSocket.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    try (Server server = new Server()) {
        new Thread(server).start();

        SocketFactory factory = SSLSocketFactory.getDefault();
        try (SSLSocket socket = (SSLSocket) factory.createSocket("localhost",
                server.getPort())) {
            socket.setSoTimeout(2000);
            System.out.println("Client established TCP connection");
            boolean failed = false;
            for (TestCase testCase : testCases) {
                try {
                    testCase.test(socket);
                    System.out.println("ERROR: no exception");
                    failed = true;
                } catch (IOException e) {
                    System.out.println("Failed as expected: " + e);
                }
            }
            if (failed) {
                throw new Exception("One or more tests failed");
            }
        }
    }
}
 
Example 5
Source Project: hadoop   Source File: NetUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Get the socket factory for the given class according to its
 * configuration parameter
 * <tt>hadoop.rpc.socket.factory.class.&lt;ClassName&gt;</tt>. When no
 * such parameter exists then fall back on the default socket factory as
 * configured by <tt>hadoop.rpc.socket.factory.class.default</tt>. If
 * this default socket factory is not configured, then fall back on the JVM
 * default socket factory.
 * 
 * @param conf the configuration
 * @param clazz the class (usually a {@link VersionedProtocol})
 * @return a socket factory
 */
public static SocketFactory getSocketFactory(Configuration conf,
    Class<?> clazz) {

  SocketFactory factory = null;

  String propValue =
      conf.get("hadoop.rpc.socket.factory.class." + clazz.getSimpleName());
  if ((propValue != null) && (propValue.length() > 0))
    factory = getSocketFactoryFromProperty(conf, propValue);

  if (factory == null)
    factory = getDefaultSocketFactory(conf);

  return factory;
}
 
Example 6
Source Project: hadoop   Source File: ClientCache.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Construct & cache an IPC client with the user-provided SocketFactory 
 * if no cached client exists.
 * 
 * @param conf Configuration
 * @param factory SocketFactory for client socket
 * @param valueClass Class of the expected response
 * @return an IPC client
 */
public synchronized Client getClient(Configuration conf,
    SocketFactory factory, Class<? extends Writable> valueClass) {
  // Construct & cache client.  The configuration is only used for timeout,
  // and Clients have connection pools.  So we can either (a) lose some
  // connection pooling and leak sockets, or (b) use the same timeout for all
  // configurations.  Since the IPC is usually intended globally, not
  // per-job, we choose (a).
  Client client = clients.get(factory);
  if (client == null) {
    client = new Client(valueClass, conf, factory);
    clients.put(factory, client);
  } else {
    client.incCount();
  }
  if (Client.LOG.isDebugEnabled()) {
    Client.LOG.debug("getting client out of cache: " + client);
  }
  return client;
}
 
Example 7
private MqttConnectOptions buildMqttConnectOptions(AbstractAwsIotClient client, SocketFactory socketFactory) {
    MqttConnectOptions options = new MqttConnectOptions();

    options.setSocketFactory(socketFactory);
    options.setCleanSession(client.isCleanSession());
    options.setConnectionTimeout(client.getConnectionTimeout() / 1000);
    options.setKeepAliveInterval(client.getKeepAliveInterval() / 1000);
    if(client.isClientEnableMetrics()) {
        options.setUserName(USERNAME_METRIC_STRING);
    }

    Set<String> serverUris = getServerUris();
    if (serverUris != null && !serverUris.isEmpty()) {
        String[] uriArray = new String[serverUris.size()];
        serverUris.toArray(uriArray);
        options.setServerURIs(uriArray);
    }

    if (client.getWillMessage() != null) {
        AWSIotMessage message = client.getWillMessage();

        options.setWill(message.getTopic(), message.getPayload(), message.getQos().getValue(), false);
    }

    return options;
}
 
Example 8
Source Project: flink   Source File: SSLUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates a factory for SSL Client Sockets from the given configuration.
 * SSL Client Sockets are always part of internal communication.
 */
public static SocketFactory createSSLClientSocketFactory(Configuration config) throws Exception {
	SSLContext sslContext = createInternalSSLContext(config, true);
	if (sslContext == null) {
		throw new IllegalConfigurationException("SSL is not enabled");
	}

	return sslContext.getSocketFactory();
}
 
Example 9
Source Project: Tomcat8-Source-Read   Source File: Http2TestBase.java    License: MIT License 5 votes vote down vote up
protected void openClientConnection() throws IOException {
    // Open a connection
    s = SocketFactory.getDefault().createSocket("localhost", getPort());
    s.setSoTimeout(30000);

    os = s.getOutputStream();
    InputStream is = s.getInputStream();

    input = new TestInput(is);
    output = new TestOutput();
    parser = new Http2Parser("-1", input, output);
    hpackEncoder = new HpackEncoder();
}
 
Example 10
Source Project: presto   Source File: HdfsConfigurationInitializer.java    License: Apache License 2.0 5 votes vote down vote up
public void initializeConfiguration(Configuration config)
{
    copy(resourcesConfiguration, config);

    // this is to prevent dfs client from doing reverse DNS lookups to determine whether nodes are rack local
    config.setClass(NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY, NoOpDNSToSwitchMapping.class, DNSToSwitchMapping.class);

    if (socksProxy != null) {
        config.setClass(HADOOP_RPC_SOCKET_FACTORY_CLASS_DEFAULT_KEY, SocksSocketFactory.class, SocketFactory.class);
        config.set(HADOOP_SOCKS_SERVER_KEY, socksProxy.toString());
    }

    if (domainSocketPath != null) {
        config.setStrings(DFS_DOMAIN_SOCKET_PATH_KEY, domainSocketPath);
    }

    // only enable short circuit reads if domain socket path is properly configured
    if (!config.get(DFS_DOMAIN_SOCKET_PATH_KEY, "").trim().isEmpty()) {
        config.setBooleanIfUnset(HdfsClientConfigKeys.Read.ShortCircuit.KEY, true);
    }

    config.setInt(DFS_CLIENT_SOCKET_TIMEOUT_KEY, toIntExact(dfsTimeout.toMillis()));
    config.setInt(IPC_PING_INTERVAL_KEY, toIntExact(ipcPingInterval.toMillis()));
    config.setInt(IPC_CLIENT_CONNECT_TIMEOUT_KEY, toIntExact(dfsConnectTimeout.toMillis()));
    config.setInt(IPC_CLIENT_CONNECT_MAX_RETRIES_KEY, dfsConnectMaxRetries);
    config.setInt(DFS_CLIENT_KEY_PROVIDER_CACHE_EXPIRY_MS, dfsKeyProviderCacheTtlMillis);

    if (wireEncryptionEnabled) {
        config.set(HADOOP_RPC_PROTECTION, "privacy");
        config.setBoolean("dfs.encrypt.data.transfer", true);
    }

    config.setInt("fs.cache.max-size", fileSystemMaxCacheSize);

    configurationInitializers.forEach(configurationInitializer -> configurationInitializer.initializeConfiguration(config));
}
 
Example 11
Source Project: Flink-CEPplus   Source File: SSLUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates a factory for SSL Client Sockets from the given configuration.
 * SSL Client Sockets are always part of internal communication.
 */
public static SocketFactory createSSLClientSocketFactory(Configuration config) throws Exception {
	SSLContext sslContext = createInternalSSLContext(config);
	if (sslContext == null) {
		throw new IllegalConfigurationException("SSL is not enabled");
	}

	return sslContext.getSocketFactory();
}
 
Example 12
private SocketConnector createDirectRawSocket(String host, int port, boolean secure, int timeout) throws IOException {
    // Select a socket factory.
    SocketFactory factory = mSocketFactorySettings.selectSocketFactory(secure);

    // Let the socket factory create a socket.
    Socket socket = factory.createSocket();

    // The address to connect to.
    Address address = new Address(host, port);

    // Create an instance that will execute the task to connect to the server later.
    return new SocketConnector(socket, address, timeout);
}
 
Example 13
Source Project: astor   Source File: DeepStubbingTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test that deep stubbing work with primitive expected values with
 * pattern method arguments
 */
@Test
public void withPatternPrimitive() throws Exception {
    int a = 12, b = 23, c = 34;

    SocketFactory sf = mock(SocketFactory.class, RETURNS_DEEP_STUBS);
    when(sf.createSocket(eq("stackoverflow.com"), eq(80)).getPort()).thenReturn(a);
    when(sf.createSocket(eq("google.com"), anyInt()).getPort()).thenReturn(b);
    when(sf.createSocket(eq("stackoverflow.com"), eq(8080)).getPort()).thenReturn(c);

    assertEquals(b, sf.createSocket("google.com", 80).getPort());
    assertEquals(c, sf.createSocket("stackoverflow.com", 8080).getPort());
    assertEquals(a, sf.createSocket("stackoverflow.com", 80).getPort());
}
 
Example 14
Source Project: hadoop   Source File: NetUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get the default socket factory as specified by the configuration
 * parameter <tt>hadoop.rpc.socket.factory.default</tt>
 * 
 * @param conf the configuration
 * @return the default socket factory as specified in the configuration or
 *         the JVM default socket factory if the configuration does not
 *         contain a default socket factory property.
 */
public static SocketFactory getDefaultSocketFactory(Configuration conf) {

  String propValue = conf.get(
      CommonConfigurationKeysPublic.HADOOP_RPC_SOCKET_FACTORY_CLASS_DEFAULT_KEY,
      CommonConfigurationKeysPublic.HADOOP_RPC_SOCKET_FACTORY_CLASS_DEFAULT_DEFAULT);
  if ((propValue == null) || (propValue.length() == 0))
    return SocketFactory.getDefault();

  return getSocketFactoryFromProperty(conf, propValue);
}
 
Example 15
Source Project: hadoop-gpu   Source File: NetUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get the socket factory corresponding to the given proxy URI. If the
 * given proxy URI corresponds to an absence of configuration parameter,
 * returns null. If the URI is malformed raises an exception.
 * 
 * @param propValue the property which is the class name of the
 *        SocketFactory to instantiate; assumed non null and non empty.
 * @return a socket factory as defined in the property value.
 */
public static SocketFactory getSocketFactoryFromProperty(
    Configuration conf, String propValue) {

  try {
    Class<?> theClass = conf.getClassByName(propValue);
    return (SocketFactory) ReflectionUtils.newInstance(theClass, conf);

  } catch (ClassNotFoundException cnfe) {
    throw new RuntimeException("Socket Factory class not found: " + cnfe);
  }
}
 
Example 16
Source Project: nettythrift   Source File: ClientInterfaceFactory.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 获得与服务端通信的接口对象
 * <p>
 * 调用者可以实现自定义的 SocketFactory来内部配置Socket参数(如超时时间,SSL等),也可以通过返回包装的Socket来实现连接池<br/>
 * SocketFactory::createSocket(String host,int ip)//NOTE: 实际传入createSocket(methodName,flag)
 * 
 * @param ifaceClass
 *            - 接口class
 * @param factory
 *            - 套接字工厂类, 注意:需要实现 createSocket() 方法,需要实现hashCode()方法来区分factory
 * @return 接口对象
 */
@SuppressWarnings("unchecked")
public static <INTERFACE> INTERFACE getClientInterface(Class<INTERFACE> ifaceClass, SocketFactory factory) {
	long part1 = ifaceClass.getName().hashCode();
	final Long KEY = (part1 << 32) | factory.hashCode();
	INTERFACE iface = (INTERFACE) ifaceCache.get(KEY);
	if (iface == null) {
		iface = (INTERFACE) Proxy.newProxyInstance(ifaceClass.getClassLoader(), new Class[] { ifaceClass },
				new Handler(factory));
		ifaceCache.putIfAbsent(KEY, iface);
	}
	return iface;
}
 
Example 17
Source Project: hadoop   Source File: WritableRpcEngine.java    License: Apache License 2.0 5 votes vote down vote up
/** Construct a client-side proxy object that implements the named protocol,
 * talking to a server at the named address. 
 * @param <T>*/
@Override
public <T> ProtocolProxy<T> getProxy(Class<T> protocol, long clientVersion,
                       InetSocketAddress addr, UserGroupInformation ticket,
                       Configuration conf, SocketFactory factory,
                       int rpcTimeout, RetryPolicy connectionRetryPolicy)
  throws IOException {
  return getProxy(protocol, clientVersion, addr, ticket, conf, factory,
    rpcTimeout, connectionRetryPolicy, null);
}
 
Example 18
Source Project: bce-sdk-java   Source File: MqttConnection.java    License: Apache License 2.0 5 votes vote down vote up
public MqttConnection(String serverURI, String clientId, String userName, String
        password, SocketFactory socketFactory, MqttCallback mqttCallbackListener,
                      IMqttActionListener mqttMessageListener) throws MqttException {

    if (serverURI == null || mqttCallbackListener == null || mqttMessageListener == null) {
        throw new IllegalArgumentException("serverURI, mqttCallbackListener, mqttMessageListener can't be null!");
    }
    this.mqttAsyncClient = new MqttAsyncClient(serverURI, clientId, new MemoryPersistence());
    this.mqttAsyncClient.setManualAcks(true);
    this.connectionOptions = new MqttConnectOptions();
    this.initOptions(userName, password, socketFactory);
    this.mqttMessageListener = mqttMessageListener;
    this.mqttAsyncClient.setCallback(mqttCallbackListener);
}
 
Example 19
Source Project: gameserver   Source File: ApnsFeedbackConnectionTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void feedbackWitherrorOnce() {
    SocketFactory sf = mockClosedThenOpenSocket(null, simpleStream, true, 2);
    ApnsFeedbackConnection connection = new ApnsFeedbackConnection(sf, "localhost", 80);
    connection.DELAY_IN_MS = 0;
    checkParsedSimple(connection.getInactiveDevices());
}
 
Example 20
Source Project: ratis   Source File: ProtobufRpcEngineShaded.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public ProtocolProxy<ProtocolMetaInfoPB> getProtocolMetaInfoProxy(
    ConnectionId connId, Configuration conf, SocketFactory factory)
    throws IOException {
  Class<ProtocolMetaInfoPB> protocol = ProtocolMetaInfoPB.class;
  return new ProtocolProxy<ProtocolMetaInfoPB>(protocol,
      (ProtocolMetaInfoPB) Proxy.newProxyInstance(protocol.getClassLoader(),
          new Class[] { protocol }, new Invoker(protocol, connId, conf,
              factory)), false);
}
 
Example 21
private void setupMockNetworks(MockNetworkConfig[] configs) {
    if (configs == null) {
        when(mMockConnMan.getAllNetworks()).thenReturn(null);
        return;
    }

    List<Network> networkList = new ArrayList<Network>(configs.length);

    for (MockNetworkConfig config : configs) {
        if (config.isNull) {
            networkList.add(null);
            continue;
        }

        Network network = mock(Network.class);

        NetworkCapabilities networkCapabilities = createNetworkCapabilitiesWithTransport(config.transportType);
        when(mMockConnMan.getNetworkCapabilities(network)).thenReturn(networkCapabilities);

        SocketFactory factory = null;
        switch (config.factoryReturnValue) {
            case RETURNS_NULL:
                break;
            case RETURNS_CORRECT_FACTORY:
                factory = mMockSocketFactory;
                break;
            case RETURNS_ANOTHER_FACTORY:
                // create another mock SocketFactory instance
                factory = mock(SocketFactory.class);
                break;
        }
        when(network.getSocketFactory()).thenReturn(factory);

        networkList.add(network);
    }

    when(mMockConnMan.getAllNetworks()).thenReturn(networkList.toArray(new Network[networkList.size()]));
}
 
Example 22
Source Project: jTDS   Source File: SharedSocket.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Enable TLS encryption by creating a TLS socket over the
 * existing TCP/IP network socket.
 *
 * @param ssl the SSL URL property value
 * @throws IOException if an I/O error occurs
 */
void enableEncryption(String ssl) throws IOException {
    Logger.println("Enabling TLS encryption");
    SocketFactory sf = SocketFactories.getSocketFactory(ssl, socket);
    sslSocket = sf.createSocket(getHost(), getPort());
    setOut(new DataOutputStream(sslSocket.getOutputStream()));
    setIn(new DataInputStream(sslSocket.getInputStream()));
}
 
Example 23
Source Project: nomulus   Source File: DnsMessageTransport.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Class constructor.
 *
 * @param factory a factory for TCP sockets
 * @param updateHost host name of the DNS server
 * @param updateTimeout update I/O timeout
 */
@Inject
public DnsMessageTransport(
    SocketFactory factory,
    @Config("dnsUpdateHost") String updateHost,
    @Config("dnsUpdateTimeout") Duration updateTimeout) {
  this.factory = factory;
  this.updateHost = updateHost;
  this.updateTimeout = Ints.checkedCast(updateTimeout.getMillis());
}
 
Example 24
Source Project: DeviceConnect-Android   Source File: HttpClient.java    License: MIT License 5 votes vote down vote up
public HttpClient(final Credentials credentials, final SocketFactory socketFactory) {
    OkHttpClient.Builder builder = new OkHttpClient.Builder()
            .connectTimeout(60, TimeUnit.SECONDS)
            .writeTimeout(60, TimeUnit.SECONDS)
            .readTimeout(60, TimeUnit.SECONDS);
    if (credentials != null) {
        builder.authenticator(new DigestAuthenticator(credentials));
    }
    if (socketFactory != null) {
        builder.socketFactory(socketFactory);
    }
    mOkHttpClient = builder.build();
}
 
Example 25
Source Project: big-c   Source File: RpcEngine.java    License: Apache License 2.0 5 votes vote down vote up
/** Construct a client-side proxy object. */
<T> ProtocolProxy<T> getProxy(Class<T> protocol,
                long clientVersion, InetSocketAddress addr,
                UserGroupInformation ticket, Configuration conf,
                SocketFactory factory, int rpcTimeout,
                RetryPolicy connectionRetryPolicy,
                AtomicBoolean fallbackToSimpleAuth) throws IOException;
 
Example 26
Source Project: hadoop   Source File: RpcEngine.java    License: Apache License 2.0 5 votes vote down vote up
/** Construct a client-side proxy object. */
<T> ProtocolProxy<T> getProxy(Class<T> protocol,
                long clientVersion, InetSocketAddress addr,
                UserGroupInformation ticket, Configuration conf,
                SocketFactory factory, int rpcTimeout,
                RetryPolicy connectionRetryPolicy,
                AtomicBoolean fallbackToSimpleAuth) throws IOException;
 
Example 27
Source Project: styT   Source File: Address.java    License: Apache License 2.0 5 votes vote down vote up
public Address(String uriHost, int uriPort, Dns dns, SocketFactory socketFactory,
    SSLSocketFactory sslSocketFactory, HostnameVerifier hostnameVerifier,
    CertificatePinner certificatePinner, Authenticator proxyAuthenticator, Proxy proxy,
    List<Protocol> protocols, List<ConnectionSpec> connectionSpecs, ProxySelector proxySelector) {
  this.url = new HttpUrl.Builder()
      .scheme(sslSocketFactory != null ? "https" : "http")
      .host(uriHost)
      .port(uriPort)
      .build();

  if (dns == null) throw new NullPointerException("dns == null");
  this.dns = dns;

  if (socketFactory == null) throw new NullPointerException("socketFactory == null");
  this.socketFactory = socketFactory;

  if (proxyAuthenticator == null) {
    throw new NullPointerException("proxyAuthenticator == null");
  }
  this.proxyAuthenticator = proxyAuthenticator;

  if (protocols == null) throw new NullPointerException("protocols == null");
  this.protocols = Util.immutableList(protocols);

  if (connectionSpecs == null) throw new NullPointerException("connectionSpecs == null");
  this.connectionSpecs = Util.immutableList(connectionSpecs);

  if (proxySelector == null) throw new NullPointerException("proxySelector == null");
  this.proxySelector = proxySelector;

  this.proxy = proxy;
  this.sslSocketFactory = sslSocketFactory;
  this.hostnameVerifier = hostnameVerifier;
  this.certificatePinner = certificatePinner;
}
 
Example 28
@Override
protected void before() throws Throwable {

	Socket socket = SocketFactory.getDefault().createSocket();
	try {
		socket.connect(new InetSocketAddress(host, port), Math.toIntExact(timeout.toMillis()));
	} catch (IOException e) {
		throw new AssumptionViolatedException(
				String.format("Couchbase not available on on %s:%d. Skipping tests.", host, port), e);
	} finally {
		socket.close();
	}
}
 
Example 29
Source Project: big-c   Source File: ProtobufRpcEngine.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * This constructor takes a connectionId, instead of creating a new one.
 */
private Invoker(Class<?> protocol, Client.ConnectionId connId,
    Configuration conf, SocketFactory factory) {
  this.remoteId = connId;
  this.client = CLIENTS.getClient(conf, factory, RpcResponseWrapper.class);
  this.protocolName = RPC.getProtocolName(protocol);
  this.clientProtocolVersion = RPC
      .getProtocolVersion(protocol);
}
 
Example 30
Source Project: hadoop   Source File: ProtobufRpcEngine.java    License: Apache License 2.0 5 votes vote down vote up
private Invoker(Class<?> protocol, InetSocketAddress addr,
    UserGroupInformation ticket, Configuration conf, SocketFactory factory,
    int rpcTimeout, RetryPolicy connectionRetryPolicy,
    AtomicBoolean fallbackToSimpleAuth) throws IOException {
  this(protocol, Client.ConnectionId.getConnectionId(
      addr, protocol, ticket, rpcTimeout, connectionRetryPolicy, conf),
      conf, factory);
  this.fallbackToSimpleAuth = fallbackToSimpleAuth;
}