Example usage for java.net InetSocketAddress getPort

List of usage examples for java.net InetSocketAddress getPort

Introduction

In this page you can find the example usage for java.net InetSocketAddress getPort.

Prototype

public final int getPort() 

Source Link

Document

Gets the port number.

Usage

From source file:com.chinamobile.bcbsp.http.HttpServer.java

/**
 * Configure an ssl listener on the server.
 * @param addr//from  w  w w  .  j a  va2  s .c  o  m
 *        address to listen on
 * @param keystore
 *        location of the keystore
 * @param storPass
 *        password for the keystore
 * @param keyPass
 *        password for the key
 * @deprecated Use
 *        {@link #addSslListener(InetSocketAddress, Configuration, boolean)}
 */
@Deprecated
public void addSslListener(InetSocketAddress addr, String keystore, String storPass, String keyPass)
        throws IOException {
    if (webServer.isStarted()) {
        throw new IOException("Failed to add ssl listener");
    }
    SslSocketConnector sslListener = new SslSocketConnector();
    sslListener.setHost(addr.getHostName());
    sslListener.setPort(addr.getPort());
    sslListener.setKeystore(keystore);
    sslListener.setPassword(storPass);
    sslListener.setKeyPassword(keyPass);
    webServer.addConnector(sslListener);
}

From source file:org.eclipse.mylyn.internal.commons.repositories.http.core.PollingSslProtocolSocketFactory.java

public Socket connectSocket(Socket sock, InetSocketAddress remoteAddress, InetSocketAddress localAddress,
        HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
    Assert.isNotNull(params);//from  ww  w  .  j  a v a2s  . c  o m
    final Socket socket = (sock != null) ? sock : createSocket(params);

    if (localAddress != null) {
        socket.setReuseAddress(HttpConnectionParams.getSoReuseaddr(params));
        socket.bind(localAddress);
    }

    int connTimeout = HttpConnectionParams.getConnectionTimeout(params);
    socket.connect(remoteAddress, connTimeout);

    if (socket instanceof SSLSocket) {
        return socket;
    } else {
        return getSslSupport(params).getSocketFactory().createSocket(socket, remoteAddress.getHostName(),
                remoteAddress.getPort(), true);
    }
}

From source file:org.apache.hadoop.dfs.NameNode.java

/**
 * Initialize the server//from www .j a  v a2s.  co  m
 * 
 * @param address hostname:port to bind to
 * @param conf the configuration
 */
private void initialize(String address, Configuration conf) throws IOException {
    InetSocketAddress socAddr = NameNode.getAddress(address);
    this.handlerCount = conf.getInt("dfs.namenode.handler.count", 10);
    this.server = RPC.getServer(this, socAddr.getHostName(), socAddr.getPort(), handlerCount, false, conf);

    // The rpc-server port can be ephemeral... ensure we have the correct info
    this.nameNodeAddress = this.server.getListenerAddress();
    FileSystem.setDefaultUri(conf, getUri(nameNodeAddress));
    LOG.info("Namenode up at: " + this.nameNodeAddress);

    myMetrics = new NameNodeMetrics(conf, this);

    this.namesystem = new FSNamesystem(this, conf);
    this.server.start(); //start RPC server   

    this.emptier = new Thread(new Trash(conf).getEmptier(), "Trash Emptier");
    this.emptier.setDaemon(true);
    this.emptier.start();
}

From source file:org.apache.flink.runtime.webmonitor.WebRuntimeMonitor.java

public WebRuntimeMonitor(Configuration config, LeaderRetrievalService leaderRetrievalService,
        ActorSystem actorSystem) throws IOException, InterruptedException {

    this.leaderRetrievalService = checkNotNull(leaderRetrievalService);
    this.timeout = AkkaUtils.getTimeout(config);
    this.retriever = new JobManagerRetriever(this, actorSystem, AkkaUtils.getTimeout(config), timeout);

    final WebMonitorConfig cfg = new WebMonitorConfig(config);

    final String configuredAddress = cfg.getWebFrontendAddress();

    final int configuredPort = cfg.getWebFrontendPort();
    if (configuredPort < 0) {
        throw new IllegalArgumentException("Web frontend port is invalid: " + configuredPort);
    }//from w  w w  .j  a  v a2  s.com

    final WebMonitorUtils.LogFileLocation logFiles = WebMonitorUtils.LogFileLocation.find(config);

    // create an empty directory in temp for the web server
    String rootDirFileName = "flink-web-" + UUID.randomUUID();
    webRootDir = new File(getBaseDir(config), rootDirFileName);
    LOG.info("Using directory {} for the web interface files", webRootDir);

    final boolean webSubmitAllow = cfg.isProgramSubmitEnabled();
    if (webSubmitAllow) {
        // create storage for uploads
        this.uploadDir = getUploadDir(config);
        // the upload directory should either 1. exist and writable or 2. can be created and writable
        if (!(uploadDir.exists() && uploadDir.canWrite()) && !(uploadDir.mkdir() && uploadDir.canWrite())) {
            throw new IOException(String.format("Jar upload directory %s cannot be created or is not writable.",
                    uploadDir.getAbsolutePath()));
        }
        LOG.info("Using directory {} for web frontend JAR file uploads", uploadDir);
    } else {
        this.uploadDir = null;
    }

    ExecutionGraphHolder currentGraphs = new ExecutionGraphHolder();

    // - Back pressure stats ----------------------------------------------

    stackTraceSamples = new StackTraceSampleCoordinator(actorSystem.dispatcher(), 60000);

    // Back pressure stats tracker config
    int cleanUpInterval = config.getInteger(ConfigConstants.JOB_MANAGER_WEB_BACK_PRESSURE_CLEAN_UP_INTERVAL,
            ConfigConstants.DEFAULT_JOB_MANAGER_WEB_BACK_PRESSURE_CLEAN_UP_INTERVAL);

    int refreshInterval = config.getInteger(ConfigConstants.JOB_MANAGER_WEB_BACK_PRESSURE_REFRESH_INTERVAL,
            ConfigConstants.DEFAULT_JOB_MANAGER_WEB_BACK_PRESSURE_REFRESH_INTERVAL);

    int numSamples = config.getInteger(ConfigConstants.JOB_MANAGER_WEB_BACK_PRESSURE_NUM_SAMPLES,
            ConfigConstants.DEFAULT_JOB_MANAGER_WEB_BACK_PRESSURE_NUM_SAMPLES);

    int delay = config.getInteger(ConfigConstants.JOB_MANAGER_WEB_BACK_PRESSURE_DELAY,
            ConfigConstants.DEFAULT_JOB_MANAGER_WEB_BACK_PRESSURE_DELAY);

    Time delayBetweenSamples = Time.milliseconds(delay);

    backPressureStatsTracker = new BackPressureStatsTracker(stackTraceSamples, cleanUpInterval, numSamples,
            delayBetweenSamples);

    // --------------------------------------------------------------------

    executorService = new ForkJoinPool();

    ExecutionContextExecutor context = ExecutionContext$.MODULE$.fromExecutor(executorService);

    // Config to enable https access to the web-ui
    boolean enableSSL = config.getBoolean(ConfigConstants.JOB_MANAGER_WEB_SSL_ENABLED,
            ConfigConstants.DEFAULT_JOB_MANAGER_WEB_SSL_ENABLED) && SSLUtils.getSSLEnabled(config);

    if (enableSSL) {
        LOG.info("Enabling ssl for the web frontend");
        try {
            serverSSLContext = SSLUtils.createSSLServerContext(config);
        } catch (Exception e) {
            throw new IOException("Failed to initialize SSLContext for the web frontend", e);
        }
    } else {
        serverSSLContext = null;
    }
    metricFetcher = new MetricFetcher(actorSystem, retriever, context);

    String defaultSavepointDir = config.getString(ConfigConstants.SAVEPOINT_DIRECTORY_KEY, null);

    JobCancellationWithSavepointHandlers cancelWithSavepoint = new JobCancellationWithSavepointHandlers(
            currentGraphs, context, defaultSavepointDir);
    RuntimeMonitorHandler triggerHandler = handler(cancelWithSavepoint.getTriggerHandler());
    RuntimeMonitorHandler inProgressHandler = handler(cancelWithSavepoint.getInProgressHandler());

    router = new Router()
            // config how to interact with this web server
            .GET("/config", handler(new DashboardConfigHandler(cfg.getRefreshInterval())))

            // the overview - how many task managers, slots, free slots, ...
            .GET("/overview", handler(new ClusterOverviewHandler(DEFAULT_REQUEST_TIMEOUT)))

            // job manager configuration
            .GET("/jobmanager/config", handler(new JobManagerConfigHandler(config)))

            // overview over jobs
            .GET("/joboverview", handler(new CurrentJobsOverviewHandler(DEFAULT_REQUEST_TIMEOUT, true, true)))
            .GET("/joboverview/running",
                    handler(new CurrentJobsOverviewHandler(DEFAULT_REQUEST_TIMEOUT, true, false)))
            .GET("/joboverview/completed",
                    handler(new CurrentJobsOverviewHandler(DEFAULT_REQUEST_TIMEOUT, false, true)))

            .GET("/jobs", handler(new CurrentJobIdsHandler(DEFAULT_REQUEST_TIMEOUT)))

            .GET("/jobs/:jobid", handler(new JobDetailsHandler(currentGraphs, metricFetcher)))
            .GET("/jobs/:jobid/vertices", handler(new JobDetailsHandler(currentGraphs, metricFetcher)))

            .GET("/jobs/:jobid/vertices/:vertexid",
                    handler(new JobVertexDetailsHandler(currentGraphs, metricFetcher)))
            .GET("/jobs/:jobid/vertices/:vertexid/subtasktimes",
                    handler(new SubtasksTimesHandler(currentGraphs)))
            .GET("/jobs/:jobid/vertices/:vertexid/taskmanagers",
                    handler(new JobVertexTaskManagersHandler(currentGraphs, metricFetcher)))
            .GET("/jobs/:jobid/vertices/:vertexid/accumulators",
                    handler(new JobVertexAccumulatorsHandler(currentGraphs)))
            .GET("/jobs/:jobid/vertices/:vertexid/checkpoints",
                    handler(new JobVertexCheckpointsHandler(currentGraphs)))
            .GET("/jobs/:jobid/vertices/:vertexid/backpressure",
                    handler(new JobVertexBackPressureHandler(currentGraphs, backPressureStatsTracker,
                            refreshInterval)))
            .GET("/jobs/:jobid/vertices/:vertexid/metrics", handler(new JobVertexMetricsHandler(metricFetcher)))
            .GET("/jobs/:jobid/vertices/:vertexid/subtasks/accumulators",
                    handler(new SubtasksAllAccumulatorsHandler(currentGraphs)))
            .GET("/jobs/:jobid/vertices/:vertexid/subtasks/:subtasknum",
                    handler(new SubtaskCurrentAttemptDetailsHandler(currentGraphs, metricFetcher)))
            .GET("/jobs/:jobid/vertices/:vertexid/subtasks/:subtasknum/attempts/:attempt",
                    handler(new SubtaskExecutionAttemptDetailsHandler(currentGraphs, metricFetcher)))
            .GET("/jobs/:jobid/vertices/:vertexid/subtasks/:subtasknum/attempts/:attempt/accumulators",
                    handler(new SubtaskExecutionAttemptAccumulatorsHandler(currentGraphs)))

            .GET("/jobs/:jobid/plan", handler(new JobPlanHandler(currentGraphs)))
            .GET("/jobs/:jobid/config", handler(new JobConfigHandler(currentGraphs)))
            .GET("/jobs/:jobid/exceptions", handler(new JobExceptionsHandler(currentGraphs)))
            .GET("/jobs/:jobid/accumulators", handler(new JobAccumulatorsHandler(currentGraphs)))
            .GET("/jobs/:jobid/checkpoints", handler(new JobCheckpointsHandler(currentGraphs)))
            .GET("/jobs/:jobid/metrics", handler(new JobMetricsHandler(metricFetcher)))

            .GET("/taskmanagers", handler(new TaskManagersHandler(DEFAULT_REQUEST_TIMEOUT, metricFetcher)))
            .GET("/taskmanagers/:" + TaskManagersHandler.TASK_MANAGER_ID_KEY + "/metrics",
                    handler(new TaskManagersHandler(DEFAULT_REQUEST_TIMEOUT, metricFetcher)))
            .GET("/taskmanagers/:" + TaskManagersHandler.TASK_MANAGER_ID_KEY + "/log",
                    new TaskManagerLogHandler(retriever, context, jobManagerAddressPromise.future(), timeout,
                            TaskManagerLogHandler.FileMode.LOG, config, enableSSL))
            .GET("/taskmanagers/:" + TaskManagersHandler.TASK_MANAGER_ID_KEY + "/stdout",
                    new TaskManagerLogHandler(retriever, context, jobManagerAddressPromise.future(), timeout,
                            TaskManagerLogHandler.FileMode.STDOUT, config, enableSSL))
            .GET("/taskmanagers/:" + TaskManagersHandler.TASK_MANAGER_ID_KEY + "/metrics",
                    handler(new TaskManagerMetricsHandler(metricFetcher)))

            // log and stdout
            .GET("/jobmanager/log",
                    logFiles.logFile == null ? new ConstantTextHandler("(log file unavailable)")
                            : new StaticFileServerHandler(retriever, jobManagerAddressPromise.future(), timeout,
                                    logFiles.logFile, enableSSL))

            .GET("/jobmanager/stdout",
                    logFiles.stdOutFile == null ? new ConstantTextHandler("(stdout file unavailable)")
                            : new StaticFileServerHandler(retriever, jobManagerAddressPromise.future(), timeout,
                                    logFiles.stdOutFile, enableSSL))

            .GET("/jobmanager/metrics", handler(new JobManagerMetricsHandler(metricFetcher)))

            // Cancel a job via GET (for proper integration with YARN this has to be performed via GET)
            .GET("/jobs/:jobid/yarn-cancel", handler(new JobCancellationHandler()))

            // DELETE is the preferred way of canceling a job (Rest-conform)
            .DELETE("/jobs/:jobid/cancel", handler(new JobCancellationHandler()))

            .GET("/jobs/:jobid/cancel-with-savepoint", triggerHandler)
            .GET("/jobs/:jobid/cancel-with-savepoint/target-directory/:targetDirectory", triggerHandler)
            .GET(JobCancellationWithSavepointHandlers.IN_PROGRESS_URL, inProgressHandler)

            // stop a job via GET (for proper integration with YARN this has to be performed via GET)
            .GET("/jobs/:jobid/yarn-stop", handler(new JobStoppingHandler()))

            // DELETE is the preferred way of stopping a job (Rest-conform)
            .DELETE("/jobs/:jobid/stop", handler(new JobStoppingHandler()));

    if (webSubmitAllow) {
        router
                // fetch the list of uploaded jars.
                .GET("/jars", handler(new JarListHandler(uploadDir)))

                // get plan for an uploaded jar
                .GET("/jars/:jarid/plan", handler(new JarPlanHandler(uploadDir)))

                // run a jar
                .POST("/jars/:jarid/run", handler(new JarRunHandler(uploadDir, timeout, config)))

                // upload a jar
                .POST("/jars/upload", handler(new JarUploadHandler(uploadDir)))

                // delete an uploaded jar from submission interface
                .DELETE("/jars/:jarid", handler(new JarDeleteHandler(uploadDir)));
    } else {
        router
                // send an Access Denied message (sort of)
                // Every other GET request will go to the File Server, which will not provide
                // access to the jar directory anyway, because it doesn't exist in webRootDir.
                .GET("/jars", handler(new JarAccessDeniedHandler()));
    }

    // this handler serves all the static contents
    router.GET("/:*", new StaticFileServerHandler(retriever, jobManagerAddressPromise.future(), timeout,
            webRootDir, enableSSL));

    // add shutdown hook for deleting the directories and remaining temp files on shutdown
    try {
        Runtime.getRuntime().addShutdownHook(new Thread() {
            @Override
            public void run() {
                cleanup();
            }
        });
    } catch (IllegalStateException e) {
        // race, JVM is in shutdown already, we can safely ignore this
        LOG.debug("Unable to add shutdown hook, shutdown already in progress", e);
    } catch (Throwable t) {
        // these errors usually happen when the shutdown is already in progress
        LOG.warn("Error while adding shutdown hook", t);
    }

    ChannelInitializer<SocketChannel> initializer = new ChannelInitializer<SocketChannel>() {

        @Override
        protected void initChannel(SocketChannel ch) {
            Handler handler = new Handler(router);

            // SSL should be the first handler in the pipeline
            if (serverSSLContext != null) {
                SSLEngine sslEngine = serverSSLContext.createSSLEngine();
                sslEngine.setUseClientMode(false);
                ch.pipeline().addLast("ssl", new SslHandler(sslEngine));
            }

            ch.pipeline().addLast(new HttpServerCodec()).addLast(new ChunkedWriteHandler())
                    .addLast(new HttpRequestHandler(uploadDir)).addLast(handler.name(), handler)
                    .addLast(new PipelineErrorHandler(LOG));
        }
    };

    NioEventLoopGroup bossGroup = new NioEventLoopGroup(1);
    NioEventLoopGroup workerGroup = new NioEventLoopGroup();

    this.bootstrap = new ServerBootstrap();
    this.bootstrap.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
            .childHandler(initializer);

    ChannelFuture ch;
    if (configuredAddress == null) {
        ch = this.bootstrap.bind(configuredPort);
    } else {
        ch = this.bootstrap.bind(configuredAddress, configuredPort);
    }
    this.serverChannel = ch.sync().channel();

    InetSocketAddress bindAddress = (InetSocketAddress) serverChannel.localAddress();
    String address = bindAddress.getAddress().getHostAddress();
    int port = bindAddress.getPort();

    LOG.info("Web frontend listening at " + address + ':' + port);
}

From source file:edu.berkeley.sparrow.api.SparrowFrontendClient.java

/**
 * Initialize a connection to a sparrow scheduler.
 * @param sparrowSchedulerAddr. The socket address of the Sparrow scheduler.
 * @param app. The application id. Note that this must be consistent across frontends
 *             and backends./*from w  ww  .  j  av  a  2 s .co m*/
 * @param frontendServer. A class which implements the frontend server interface (for
 *                        communication from Sparrow).
 * @param listenPort. The port on which to listen for request from the scheduler.
 * @throws IOException
 */
public void initialize(InetSocketAddress sparrowSchedulerAddr, String app, FrontendService.Iface frontendServer,
        int listenPort) throws TException, IOException {

    FrontendService.Processor<FrontendService.Iface> processor = new FrontendService.Processor<FrontendService.Iface>(
            frontendServer);

    if (!launchedServerAlready) {
        try {
            TServers.launchThreadedThriftServer(listenPort, 8, processor);
        } catch (IOException e) {
            LOG.fatal("Couldn't launch server side of frontend", e);
        }
        launchedServerAlready = true;
    }

    for (int i = 0; i < NUM_CLIENTS; i++) {
        Client client = TClients.createBlockingSchedulerClient(
                sparrowSchedulerAddr.getAddress().getHostAddress(), sparrowSchedulerAddr.getPort(), 60000);
        clients.add(client);
    }
    clients.peek().registerFrontend(app,
            Network.getIPAddress(new PropertiesConfiguration()) + ":" + listenPort);
}

From source file:org.apache.hadoop.yarn.server.resourcemanager.TestRMHA.java

private void checkActiveRMWebServices() throws JSONException {

    // Validate web-service
    Client webServiceClient = Client.create(new DefaultClientConfig());
    InetSocketAddress rmWebappAddr = NetUtils.getConnectAddress(rm.getWebapp().getListenerAddress());
    String webappURL = "http://" + rmWebappAddr.getHostName() + ":" + rmWebappAddr.getPort();
    WebResource webResource = webServiceClient.resource(webappURL);
    String path = app.getApplicationId().toString();

    ClientResponse response = webResource.path("ws").path("v1").path("cluster").path("apps").path(path)
            .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    JSONObject json = response.getEntity(JSONObject.class);

    assertEquals("incorrect number of elements", 1, json.length());
    JSONObject appJson = json.getJSONObject("app");
    assertEquals("ACCEPTED", appJson.getString("state"));
    // Other stuff is verified in the regular web-services related tests
}

From source file:ch.epfl.eagle.api.EagleFrontendClient.java

/**
 * Initialize a connection to an eagle scheduler.
 * @param eagleSchedulerAddr. The socket address of the Eagle scheduler.
 * @param app. The application id. Note that this must be consistent across frontends
 *             and backends.//from  www .j  ava  2s  .c  o  m
 * @param frontendServer. A class which implements the frontend server interface (for
 *                        communication from Eagle).
 * @param listenPort. The port on which to listen for request from the scheduler.
 * @throws IOException
 */
public void initialize(InetSocketAddress eagleSchedulerAddr, String app, FrontendService.Iface frontendServer,
        int listenPort) throws TException, IOException {

    FrontendService.Processor<FrontendService.Iface> processor = new FrontendService.Processor<FrontendService.Iface>(
            frontendServer);

    if (!launchedServerAlready) {
        try {
            TServers.launchThreadedThriftServer(listenPort, 8, processor);
        } catch (IOException e) {
            LOG.fatal("Couldn't launch server side of frontend", e);
        }
        launchedServerAlready = true;
    }

    for (int i = 0; i < NUM_CLIENTS; i++) {
        Client client = TClients.createBlockingSchedulerClient(eagleSchedulerAddr.getAddress().getHostAddress(),
                eagleSchedulerAddr.getPort(), 60000);
        clients.add(client);
    }
    clients.peek().registerFrontend(app,
            Network.getIPAddress(new PropertiesConfiguration()) + ":" + listenPort);
}

From source file:Proxy.java

String toString(InetSocketAddress addr) {
    StringBuilder sb;/* w  w w.jav  a 2s.  c  o m*/
    sb = new StringBuilder();

    if (addr == null)
        return null;
    sb.append(addr.getAddress().getHostName()).append(':').append(addr.getPort());
    if (addr instanceof MyInetSocketAddress)
        sb.append(" [ssl=").append(((MyInetSocketAddress) addr).ssl()).append(']');
    return sb.toString();
}

From source file:com.blackducksoftware.integration.hub.jenkins.PostBuildHubScan.java

public void addProxySettingsToScanner(final IntLogger logger, final JenkinsScanExecutor scan)
        throws BDJenkinsHubPluginException, HubIntegrationException, URISyntaxException, MalformedURLException {
    final Jenkins jenkins = Jenkins.getInstance();
    if (jenkins != null) {
        final ProxyConfiguration proxyConfig = jenkins.proxy;
        if (proxyConfig != null) {

            final URL serverUrl = new URL(getHubServerInfo().getServerUrl());

            final Proxy proxy = ProxyConfiguration.createProxy(serverUrl.getHost(), proxyConfig.name,
                    proxyConfig.port, proxyConfig.noProxyHost);

            if (proxy != Proxy.NO_PROXY && proxy.address() != null) {
                final InetSocketAddress proxyAddress = (InetSocketAddress) proxy.address();
                if (StringUtils.isNotBlank(proxyAddress.getHostName()) && proxyAddress.getPort() != 0) {
                    if (StringUtils.isNotBlank(jenkins.proxy.getUserName())
                            && StringUtils.isNotBlank(jenkins.proxy.getPassword())) {
                        scan.setProxyHost(proxyAddress.getHostName());
                        scan.setProxyPort(proxyAddress.getPort());
                        scan.setProxyUsername(jenkins.proxy.getUserName());
                        scan.setProxyPassword(jenkins.proxy.getPassword());

                    } else {
                        scan.setProxyHost(proxyAddress.getHostName());
                        scan.setProxyPort(proxyAddress.getPort());
                    }/*from  w ww.  j  a va 2 s .  c o  m*/
                    if (logger != null) {
                        logger.debug("Using proxy: '" + proxyAddress.getHostName() + "' at Port: '"
                                + proxyAddress.getPort() + "'");
                    }
                }
            }
        }
    }
}

From source file:com.blackducksoftware.integration.hub.jenkins.PostBuildHubScan.java

public void addProxySettingsToCLIInstaller(final IntLogger logger, final CLIRemoteInstall remoteCLIInstall)
        throws BDJenkinsHubPluginException, HubIntegrationException, URISyntaxException, MalformedURLException {
    final Jenkins jenkins = Jenkins.getInstance();
    if (jenkins != null) {
        final ProxyConfiguration proxyConfig = jenkins.proxy;
        if (proxyConfig != null) {

            final URL serverUrl = new URL(getHubServerInfo().getServerUrl());

            final Proxy proxy = ProxyConfiguration.createProxy(serverUrl.getHost(), proxyConfig.name,
                    proxyConfig.port, proxyConfig.noProxyHost);

            if (proxy != Proxy.NO_PROXY && proxy.address() != null) {
                final InetSocketAddress proxyAddress = (InetSocketAddress) proxy.address();
                if (StringUtils.isNotBlank(proxyAddress.getHostName()) && proxyAddress.getPort() != 0) {
                    if (StringUtils.isNotBlank(jenkins.proxy.getUserName())
                            && StringUtils.isNotBlank(jenkins.proxy.getPassword())) {
                        remoteCLIInstall.setProxyHost(proxyAddress.getHostName());
                        remoteCLIInstall.setProxyPort(proxyAddress.getPort());
                        remoteCLIInstall.setProxyUserName(jenkins.proxy.getUserName());
                        remoteCLIInstall.setProxyPassword(jenkins.proxy.getPassword());

                    } else {
                        remoteCLIInstall.setProxyHost(proxyAddress.getHostName());
                        remoteCLIInstall.setProxyPort(proxyAddress.getPort());
                    }/*from ww w.  j  a v  a  2 s . c o  m*/
                    if (logger != null) {
                        logger.debug("Using proxy: '" + proxyAddress.getHostName() + "' at Port: '"
                                + proxyAddress.getPort() + "'");
                    }
                }
            }
        }
    }
}