Example usage for com.google.common.net HostAndPort getPort

List of usage examples for com.google.common.net HostAndPort getPort

Introduction

In this page you can find the example usage for com.google.common.net HostAndPort getPort.

Prototype

public int getPort() 

Source Link

Document

Get the current port number, failing if no port is defined.

Usage

From source file:org.apache.brooklyn.entity.proxy.AbstractControllerImpl.java

/** returns URL, if it can be inferred; null otherwise */
protected String inferUrl(boolean requireManagementAccessible) {
    String protocol = checkNotNull(getProtocol(), "no protocol configured");
    String domain = getDomain();/*from  w  w  w. j av a 2  s  .c om*/
    if (domain != null && domain.startsWith("*.")) {
        domain = domain.replace("*.", ""); // Strip wildcard
    }
    Integer port = checkNotNull(getPort(), "no port configured (the requested port may be in use)");
    if (requireManagementAccessible) {
        HostAndPort accessible = BrooklynAccessUtils.getBrooklynAccessibleAddress(this, port);
        if (accessible != null) {
            domain = accessible.getHostText();
            port = accessible.getPort();
        }
    }
    if (domain == null)
        domain = Machines.findSubnetHostname(this).orNull();
    if (domain == null)
        return null;
    return protocol + "://" + domain + ":" + port + "/" + getConfig(SERVICE_UP_URL_PATH);
}

From source file:org.jclouds.ssh.jsch.JschSshClient.java

public JschSshClient(ProxyConfig proxyConfig, BackoffLimitedRetryHandler backoffLimitedRetryHandler,
        HostAndPort socket, LoginCredentials loginCredentials, int timeout) {
    this.user = checkNotNull(loginCredentials, "loginCredentials").getUser();
    this.host = checkNotNull(socket, "socket").getHostText();
    checkArgument(socket.getPort() > 0, "ssh port must be greater then zero" + socket.getPort());
    checkArgument(loginCredentials.getPassword() != null || loginCredentials.getPrivateKey() != null,
            "you must specify a password or a key");
    this.backoffLimitedRetryHandler = checkNotNull(backoffLimitedRetryHandler, "backoffLimitedRetryHandler");
    if (loginCredentials.getPrivateKey() == null) {
        this.toString = String.format("%s:pw[%s]@%s:%d", loginCredentials.getUser(),
                base16().lowerCase().encode(md5().hashString(loginCredentials.getPassword(), UTF_8).asBytes()),
                host, socket.getPort());
    } else {/*from  ww w.  j  av a2s  .  c o  m*/
        String fingerPrint = fingerprintPrivateKey(loginCredentials.getPrivateKey());
        String sha1 = sha1PrivateKey(loginCredentials.getPrivateKey());
        this.toString = String.format("%s:rsa[fingerprint(%s),sha1(%s)]@%s:%d", loginCredentials.getUser(),
                fingerPrint, sha1, host, socket.getPort());
    }
    sessionConnection = SessionConnection.builder().hostAndPort(HostAndPort.fromParts(host, socket.getPort()))
            .loginCredentials(loginCredentials).proxy(checkNotNull(proxyConfig, "proxyConfig"))
            .connectTimeout(timeout).sessionTimeout(timeout).build();
}

From source file:io.airlift.drift.transport.apache.client.ApacheThriftMethodInvoker.java

private TSocket createTSocket(HostAndPort address) throws TTransportException {
    Proxy proxy = socksProxy//from  w w w .j ava  2  s .  c om
            .map(socksAddress -> new Proxy(SOCKS,
                    InetSocketAddress.createUnresolved(socksAddress.getHost(), socksAddress.getPort())))
            .orElse(Proxy.NO_PROXY);

    Socket socket = new Socket(proxy);
    try {
        setSocketProperties(socket);
        socket.connect(new InetSocketAddress(address.getHost(), address.getPort()),
                Ints.saturatedCast(connectTimeoutMillis));

        if (sslContext.isPresent()) {
            SSLContext sslContext = this.sslContext.get();

            // SSL connect is to the socks address when present
            HostAndPort sslConnectAddress = socksProxy.orElse(address);

            socket = sslContext.getSocketFactory().createSocket(socket, sslConnectAddress.getHost(),
                    sslConnectAddress.getPort(), true);
            setSocketProperties(socket);
        }
        return new TSocket(socket);
    } catch (Throwable t) {
        // something went wrong, close the socket and rethrow
        try {
            socket.close();
        } catch (IOException e) {
            t.addSuppressed(e);
        }
        // unchecked exceptions are not transport exceptions
        // (any socket related exception will be a checked exception)
        throwIfUnchecked(t);
        throw new TTransportException(t);
    }
}

From source file:com.pinterest.secor.common.LegacyKafkaClient.java

private SimpleConsumer createConsumer(TopicPartition topicPartition) {
    HostAndPort leader = findLeader(topicPartition);
    if (leader == null) {
        LOG.warn("no leader for topic {} partition {}", topicPartition.getTopic(),
                topicPartition.getPartition());
        return null;
    }/*w ww.  j a  v a  2 s . c  o m*/
    LOG.debug("leader for topic {} partition {} is {}", topicPartition.getTopic(),
            topicPartition.getPartition(), leader);
    final String clientName = getClientName(topicPartition);
    return createConsumer(leader.getHostText(), leader.getPort(), clientName);
}

From source file:brooklyn.entity.nosql.elasticsearch.ElasticSearchNodeImpl.java

@Override
protected void connectSensors() {
    super.connectSensors();
    Integer rawPort = getAttribute(HTTP_PORT);
    checkNotNull(rawPort, "HTTP_PORT sensors not set for %s; is an acceptable port available?", this);
    HostAndPort hp = BrooklynAccessUtils.getBrooklynAccessibleAddress(this, rawPort);
    Function<Maybe<JsonElement>, String> getNodeId = new Function<Maybe<JsonElement>, String>() {
        @Override//from  w w w . j av a2 s  .  c  om
        public String apply(Maybe<JsonElement> input) {
            if (input.isAbsent()) {
                return null;
            }
            return input.get().getAsJsonObject().entrySet().iterator().next().getKey();
        }
    };
    httpFeed = HttpFeed.builder().entity(this).period(1000)
            .baseUri(String.format("http://%s:%s/_nodes/_local/stats", hp.getHostText(), hp.getPort()))
            .poll(new HttpPollConfig<Boolean>(SERVICE_UP).onSuccess(HttpValueFunctions.responseCodeEquals(200))
                    .onFailureOrException(Functions.constant(false)))
            .poll(new HttpPollConfig<String>(NODE_ID)
                    .onSuccess(Functionals.chain(HttpValueFunctions.jsonContents(),
                            MaybeFunctions.<JsonElement>wrap(), JsonFunctions.walkM("nodes"), getNodeId))
                    .onFailureOrException(Functions.constant("")))
            .poll(getSensorFromNodeStat(NODE_NAME, "name"))
            .poll(getSensorFromNodeStat(DOCUMENT_COUNT, "indices", "docs", "count"))
            .poll(getSensorFromNodeStat(STORE_BYTES, "indices", "store", "size_in_bytes"))
            .poll(getSensorFromNodeStat(GET_TOTAL, "indices", "get", "total"))
            .poll(getSensorFromNodeStat(GET_TIME_IN_MILLIS, "indices", "get", "time_in_millis"))
            .poll(getSensorFromNodeStat(SEARCH_QUERY_TOTAL, "indices", "search", "query_total"))
            .poll(getSensorFromNodeStat(SEARCH_QUERY_TIME_IN_MILLIS, "indices", "search",
                    "query_time_in_millis"))
            .poll(new HttpPollConfig<String>(CLUSTER_NAME)
                    .onSuccess(HttpValueFunctions.jsonContents("cluster_name", String.class)))
            .build();
}

From source file:org.apache.brooklyn.entity.brooklynnode.BrooklynNodeImpl.java

@Override
protected void connectSensors() {
    super.connectSensors();

    // TODO what sensors should we poll?
    ConfigToAttributes.apply(this);

    URI webConsoleUri;//www  .j  a va 2s  .c o m
    if (isHttpProtocolEnabled("http")) {
        int port = getConfig(PORT_MAPPER).apply(getAttribute(HTTP_PORT));
        HostAndPort accessible = BrooklynAccessUtils.getBrooklynAccessibleAddress(this, port);
        webConsoleUri = URI
                .create(String.format("http://%s:%s", accessible.getHostText(), accessible.getPort()));
    } else if (isHttpProtocolEnabled("https")) {
        int port = getConfig(PORT_MAPPER).apply(getAttribute(HTTPS_PORT));
        HostAndPort accessible = BrooklynAccessUtils.getBrooklynAccessibleAddress(this, port);
        webConsoleUri = URI
                .create(String.format("https://%s:%s", accessible.getHostText(), accessible.getPort()));
    } else {
        // web-console is not enabled
        webConsoleUri = null;
    }
    sensors().set(WEB_CONSOLE_URI, webConsoleUri);

    if (webConsoleUri != null) {
        httpFeed = HttpFeed.builder().entity(this).period(getConfig(POLL_PERIOD)).baseUri(webConsoleUri)
                .credentialsIfNotNull(getConfig(MANAGEMENT_USER), getConfig(MANAGEMENT_PASSWORD))
                .poll(new HttpPollConfig<Boolean>(WEB_CONSOLE_ACCESSIBLE).suburl("/v1/server/healthy")
                        .onSuccess(Functionals.chain(HttpValueFunctions.jsonContents(),
                                JsonFunctions.cast(Boolean.class)))
                        //if using an old distribution the path doesn't exist, but at least the instance is responding
                        .onFailure(HttpValueFunctions.responseCodeEquals(404)).setOnException(false))
                .poll(new HttpPollConfig<ManagementNodeState>(MANAGEMENT_NODE_STATE)
                        .suburl("/v1/server/ha/state")
                        .onSuccess(Functionals.chain(
                                Functionals.chain(HttpValueFunctions.jsonContents(),
                                        JsonFunctions.cast(String.class)),
                                Enums.fromStringFunction(ManagementNodeState.class)))
                        .setOnFailureOrException(null))
                // TODO sensors for load, size, etc
                .build();

        if (!Lifecycle.RUNNING.equals(getAttribute(SERVICE_STATE_ACTUAL))) {
            // TODO when updating the map, if it would change from empty to empty on a successful run (see in nginx)
            ServiceNotUpLogic.updateNotUpIndicator(this, WEB_CONSOLE_ACCESSIBLE,
                    "No response from the web console yet");
        }
        enrichers().add(Enrichers.builder().updatingMap(Attributes.SERVICE_NOT_UP_INDICATORS)
                .from(WEB_CONSOLE_ACCESSIBLE).computing(Functionals.ifNotEquals(true)
                        .value("URL where Brooklyn listens is not answering correctly"))
                .build());

        addEnricher(Enrichers.builder().transforming(WEB_CONSOLE_ACCESSIBLE).computing(Functions.identity())
                .publishing(SERVICE_PROCESS_IS_RUNNING).build());
    } else {
        connectServiceUpIsRunning();
    }
}

From source file:com.netflix.priam.resources.CassandraAdminResource.java

@Inject
public CassandraAdminResource(PriamServer priamServer, CassandraConfiguration cassandraConfiguration,
        PriamConfiguration priamConfiguration, ICassandraProcess cassProcess, Client jersey,
        HostAndPort hostAndPort) {
    this.priamServer = priamServer;
    this.cassandraConfiguration = cassandraConfiguration;
    this.priamConfiguration = priamConfiguration;
    this.cassProcess = cassProcess;
    this.jersey = jersey;
    this.port = hostAndPort.getPort();
}

From source file:org.wso2.mb.platform.tests.clustering.MultipleSubscriberMultiplePublisherTestCase.java

/**
 * Multiple subscribers and publishers in Multiple node for a single queue
 *
 * @param messageCount Number of message to send and receive
 * @throws AndesClientConfigurationException
 * @throws XPathExpressionException/*from   w  ww  .j a  va  2 s  .c  om*/
 * @throws NamingException
 * @throws JMSException
 * @throws IOException
 * @throws AndesClientException
 */
@Test(groups = "wso2.mb", description = "Multiple node single queue multiple subscriber "
        + "publisher test case")
@Parameters({ "messageCount" })
public void testMultiNodeSingleQueueMultipleSubscriberPublisher(long messageCount)
        throws AndesClientConfigurationException, XPathExpressionException, NamingException, JMSException,
        IOException, AndesClientException, CloneNotSupportedException, DataAccessUtilException,
        InterruptedException {
    // Number of messages expected
    long expectedCount = messageCount;
    // Number of messages send
    long sendCount = messageCount;
    String queueName = "singleQueue2";
    HostAndPort consumerBrokerAddress = getRandomAMQPBrokerAddress();

    AndesJMSConsumerClientConfiguration consumerConfig1 = new AndesJMSConsumerClientConfiguration(
            consumerBrokerAddress.getHostText(), consumerBrokerAddress.getPort(), ExchangeType.QUEUE,
            queueName);
    consumerConfig1.setMaximumMessagesToReceived(expectedCount);
    consumerConfig1.setPrintsPerMessageCount(expectedCount / 10L);

    HostAndPort publisherBrokerAddress = getRandomAMQPBrokerAddress();
    AndesJMSPublisherClientConfiguration publisherConfig1 = new AndesJMSPublisherClientConfiguration(
            publisherBrokerAddress.getHostText(), publisherBrokerAddress.getPort(), ExchangeType.QUEUE,
            queueName);
    publisherConfig1.setNumberOfMessagesToSend(sendCount);
    publisherConfig1.setPrintsPerMessageCount(sendCount / 10L);

    AndesClient consumerClient1 = new AndesClient(consumerConfig1, true);
    consumerClient1.startClient();

    AndesJMSConsumerClientConfiguration consumerConfig2 = consumerConfig1.clone();
    HostAndPort randomAMQPBrokerAddress = getRandomAMQPBrokerAddress();
    consumerConfig2.setHostName(randomAMQPBrokerAddress.getHostText());
    consumerConfig2.setPort(randomAMQPBrokerAddress.getPort());
    AndesClient consumerClient2 = new AndesClient(consumerConfig2, true);
    consumerClient2.startClient();

    AndesJMSConsumerClientConfiguration consumerConfig3 = consumerConfig1.clone();
    randomAMQPBrokerAddress = getRandomAMQPBrokerAddress();
    consumerConfig3.setHostName(randomAMQPBrokerAddress.getHostText());
    consumerConfig3.setPort(randomAMQPBrokerAddress.getPort());
    AndesClient consumerClient3 = new AndesClient(consumerConfig3, true);
    consumerClient3.startClient();

    AndesJMSConsumerClientConfiguration consumerConfig4 = consumerConfig1.clone();
    randomAMQPBrokerAddress = getRandomAMQPBrokerAddress();
    consumerConfig4.setHostName(randomAMQPBrokerAddress.getHostText());
    consumerConfig4.setPort(randomAMQPBrokerAddress.getPort());
    AndesClient consumerClient4 = new AndesClient(consumerConfig4, true);
    consumerClient4.startClient();

    AndesClient publisherClient1 = new AndesClient(publisherConfig1, true);
    publisherClient1.startClient();

    AndesJMSPublisherClientConfiguration publisherConfig2 = publisherConfig1.clone();
    randomAMQPBrokerAddress = getRandomAMQPBrokerAddress();
    publisherConfig2.setHostName(randomAMQPBrokerAddress.getHostText());
    publisherConfig2.setPort(randomAMQPBrokerAddress.getPort());
    AndesClient publisherClient2 = new AndesClient(publisherConfig2, true);
    publisherClient2.startClient();

    AndesJMSPublisherClientConfiguration publisherConfig3 = publisherConfig1.clone();
    randomAMQPBrokerAddress = getRandomAMQPBrokerAddress();
    publisherConfig3.setHostName(randomAMQPBrokerAddress.getHostText());
    publisherConfig3.setPort(randomAMQPBrokerAddress.getPort());
    AndesClient publisherClient3 = new AndesClient(publisherConfig3, true);
    publisherClient3.startClient();

    AndesJMSPublisherClientConfiguration publisherConfig4 = publisherConfig1.clone();
    randomAMQPBrokerAddress = getRandomAMQPBrokerAddress();
    publisherConfig4.setHostName(randomAMQPBrokerAddress.getHostText());
    publisherConfig4.setPort(randomAMQPBrokerAddress.getPort());
    AndesClient publisherClient4 = new AndesClient(publisherConfig4, true);
    publisherClient4.startClient();

    AndesClientUtils.waitForMessagesAndShutdown(consumerClient1, AndesClientConstants.DEFAULT_RUN_TIME);
    AndesClientUtils.shutdownClient(consumerClient2);
    AndesClientUtils.shutdownClient(consumerClient3);
    AndesClientUtils.shutdownClient(consumerClient4);

    Assert.assertEquals(publisherClient1.getSentMessageCount(), sendCount,
            "Message sending failed by publisherClient1.");
    Assert.assertEquals(publisherClient2.getSentMessageCount(), sendCount,
            "Message sending failed by publisherClient2.");
    Assert.assertEquals(publisherClient3.getSentMessageCount(), sendCount,
            "Message sending failed by publisherClient3.");
    Assert.assertEquals(publisherClient4.getSentMessageCount(), sendCount,
            "Message sending failed by publisherClient4.");
    Assert.assertEquals(consumerClient1.getReceivedMessageCount(), expectedCount,
            "Message receiving failed by consumerClient1.");
    Assert.assertEquals(consumerClient2.getReceivedMessageCount(), expectedCount,
            "Message receiving failed by consumerClient2.");
    Assert.assertEquals(consumerClient3.getReceivedMessageCount(), expectedCount,
            "Message receiving failed by consumerClient3.");
    Assert.assertEquals(consumerClient4.getReceivedMessageCount(), expectedCount,
            "Message receiving failed by consumerClient4.");

    long totalMessagesSent = publisherClient1.getSentMessageCount() + publisherClient2.getSentMessageCount()
            + publisherClient3.getSentMessageCount() + publisherClient4.getSentMessageCount();

    long totalMessagesReceived = consumerClient1.getReceivedMessageCount()
            + consumerClient2.getReceivedMessageCount() + consumerClient3.getReceivedMessageCount()
            + consumerClient4.getReceivedMessageCount();

    Assert.assertEquals(totalMessagesSent, totalMessagesReceived,
            "Message receiving failed " + "by all consumers");
    Assert.assertEquals(totalMessagesSent, sendCount * 4,
            "Message receiving by all consumers" + " does not match the message count " + "that was sent");

    // Evaluate messages left in database
    Assert.assertEquals(dataAccessUtil.getMessageCountForQueue(queueName), 0, "Messages left in database");
    // Evaluate slots left in database
    Assert.assertEquals(dataAccessUtil.getAssignedSlotCountForQueue(queueName), 0, "Slots left in database");
}

From source file:brooklyn.entity.mesos.framework.marathon.MarathonPortForwarder.java

private void addIptablesRule(Integer hostPort, HostAndPort container) {
    LOG.debug("Using iptables to add access for TCP/{} to {}", hostPort, host);
    List<String> commands = ImmutableList.of(
            BashCommands.sudo(/*from   w  w  w  . j  a  va 2  s. c  o  m*/
                    String.format("iptables -t nat -A PREROUTING -p tcp --dport %d -j DNAT --to-destination %s",
                            hostPort, container.toString())),
            BashCommands.sudo(String.format(
                    "iptables -A FORWARD -p tcp -d %s --dport %d -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT",
                    container.getHostText(), container.getPort())));
    int result = host.execCommands(MutableMap.of(SshTool.PROP_ALLOCATE_PTY.getName(), true),
            String.format("Open iptables TCP/%d", hostPort), commands);
    if (result != 0) {
        String msg = String.format("Error running iptables update for TCP/%d on %s", hostPort, host);
        LOG.error(msg);
        throw new RuntimeException(msg);
    }
}

From source file:org.wso2.mb.platform.tests.clustering.MultipleSubscriberMultiplePublisherTestCase.java

/**
 * Multiple subscribers and publishers in Multiple node for Multiple queues
 *
 * @param messageCount Number of message to send and receive
 * @throws AndesClientConfigurationException
 * @throws NamingException/*w w  w . j ava  2 s .co m*/
 * @throws JMSException
 * @throws XPathExpressionException
 * @throws IOException
 * @throws CloneNotSupportedException
 * @throws AndesClientException
 */
@Test(groups = "wso2.mb", description = "Multiple node Multiple queue multiple subscriber "
        + "publisher test case")
@Parameters({ "messageCount" })
public void testMultiNodeMultipleQueueMultipleSubscriberPublisher(long messageCount)
        throws AndesClientConfigurationException, NamingException, JMSException, XPathExpressionException,
        IOException, CloneNotSupportedException, AndesClientException, DataAccessUtilException,
        InterruptedException {
    // Number of messages expected
    long expectedCount = messageCount;
    // Number of messages send
    long sendCount = messageCount;
    String queue3 = "singleQueue3";
    String queue4 = "singleQueue4";
    String queue5 = "singleQueue5";
    String queue6 = "singleQueue6";

    HostAndPort consumerBrokerAddress = getRandomAMQPBrokerAddress();

    AndesJMSConsumerClientConfiguration consumerConfig = new AndesJMSConsumerClientConfiguration(
            consumerBrokerAddress.getHostText(), consumerBrokerAddress.getPort(), ExchangeType.QUEUE, queue3);
    consumerConfig.setMaximumMessagesToReceived(expectedCount);
    consumerConfig.setPrintsPerMessageCount(expectedCount / 10L);

    HostAndPort publisherBrokerAddress = getRandomAMQPBrokerAddress();

    AndesJMSPublisherClientConfiguration publisherConfig = new AndesJMSPublisherClientConfiguration(
            publisherBrokerAddress.getHostText(), publisherBrokerAddress.getPort(), ExchangeType.QUEUE, queue3);
    publisherConfig.setNumberOfMessagesToSend(sendCount);
    publisherConfig.setPrintsPerMessageCount(sendCount / 10L);

    AndesClient consumerClient1 = new AndesClient(consumerConfig, true);
    consumerClient1.startClient();

    AndesJMSConsumerClientConfiguration consumerConfig2 = consumerConfig.clone();
    consumerConfig2.setDestinationName(queue4);
    HostAndPort randomAMQPBrokerAddress = getRandomAMQPBrokerAddress();
    consumerConfig2.setHostName(randomAMQPBrokerAddress.getHostText());
    consumerConfig2.setPort(randomAMQPBrokerAddress.getPort());
    AndesClient consumerClient2 = new AndesClient(consumerConfig2, true);
    consumerClient2.startClient();

    AndesJMSConsumerClientConfiguration consumerConfig3 = consumerConfig.clone();
    consumerConfig3.setDestinationName(queue5);
    randomAMQPBrokerAddress = getRandomAMQPBrokerAddress();
    consumerConfig3.setHostName(randomAMQPBrokerAddress.getHostText());
    consumerConfig3.setPort(randomAMQPBrokerAddress.getPort());
    AndesClient consumerClient3 = new AndesClient(consumerConfig3, true);
    consumerClient3.startClient();

    AndesJMSConsumerClientConfiguration consumerConfig4 = consumerConfig.clone();
    consumerConfig4.setDestinationName(queue6);
    randomAMQPBrokerAddress = getRandomAMQPBrokerAddress();
    consumerConfig4.setHostName(randomAMQPBrokerAddress.getHostText());
    consumerConfig4.setPort(randomAMQPBrokerAddress.getPort());
    AndesClient consumerClient4 = new AndesClient(consumerConfig4, true);
    consumerClient4.startClient();

    AndesClient publisherClient1 = new AndesClient(publisherConfig, true);
    publisherClient1.startClient();

    AndesJMSPublisherClientConfiguration publisherConfig2 = publisherConfig.clone();
    publisherConfig2.setDestinationName(queue4);
    randomAMQPBrokerAddress = getRandomAMQPBrokerAddress();
    publisherConfig2.setHostName(randomAMQPBrokerAddress.getHostText());
    publisherConfig2.setPort(randomAMQPBrokerAddress.getPort());
    AndesClient publisherClient2 = new AndesClient(publisherConfig2, true);
    publisherClient2.startClient();

    AndesJMSPublisherClientConfiguration publisherConfig3 = publisherConfig.clone();
    publisherConfig3.setDestinationName(queue5);
    randomAMQPBrokerAddress = getRandomAMQPBrokerAddress();
    publisherConfig3.setHostName(randomAMQPBrokerAddress.getHostText());
    publisherConfig3.setPort(randomAMQPBrokerAddress.getPort());
    AndesClient publisherClient3 = new AndesClient(publisherConfig3, true);
    publisherClient3.startClient();

    AndesJMSPublisherClientConfiguration publisherConfig4 = publisherConfig.clone();
    publisherConfig4.setDestinationName(queue6);
    randomAMQPBrokerAddress = getRandomAMQPBrokerAddress();
    publisherConfig4.setHostName(randomAMQPBrokerAddress.getHostText());
    publisherConfig4.setPort(randomAMQPBrokerAddress.getPort());
    AndesClient publisherClient4 = new AndesClient(publisherConfig4, true);
    publisherClient4.startClient();

    AndesClientUtils.waitForMessagesAndShutdown(consumerClient1, AndesClientConstants.DEFAULT_RUN_TIME);
    AndesClientUtils.shutdownClient(consumerClient2);
    AndesClientUtils.shutdownClient(consumerClient3);
    AndesClientUtils.shutdownClient(consumerClient4);

    Assert.assertEquals(publisherClient1.getSentMessageCount(), sendCount,
            "Message sending failed by publisherClient1.");
    Assert.assertEquals(publisherClient2.getSentMessageCount(), sendCount,
            "Message sending failed by publisherClient2.");
    Assert.assertEquals(publisherClient3.getSentMessageCount(), sendCount,
            "Message sending failed by publisherClient3.");
    Assert.assertEquals(publisherClient4.getSentMessageCount(), sendCount,
            "Message sending failed by publisherClient4.");
    Assert.assertEquals(consumerClient1.getReceivedMessageCount(), expectedCount,
            "Message receiving failed by consumerClient1.");
    Assert.assertEquals(consumerClient2.getReceivedMessageCount(), expectedCount,
            "Message receiving failed by consumerClient2.");
    Assert.assertEquals(consumerClient3.getReceivedMessageCount(), expectedCount,
            "Message receiving failed by consumerClient3.");
    Assert.assertEquals(consumerClient4.getReceivedMessageCount(), expectedCount,
            "Message receiving failed by consumerClient4.");

    long totalMessagesSent = publisherClient1.getSentMessageCount() + publisherClient2.getSentMessageCount()
            + publisherClient3.getSentMessageCount() + publisherClient4.getSentMessageCount();

    long totalMessagesReceived = consumerClient1.getReceivedMessageCount()
            + consumerClient2.getReceivedMessageCount() + consumerClient3.getReceivedMessageCount()
            + consumerClient4.getReceivedMessageCount();

    Assert.assertEquals(totalMessagesSent, totalMessagesReceived,
            "Message receiving failed " + "by all consumers");
    Assert.assertEquals(totalMessagesSent, sendCount * 4,
            "Message receiving by all consumers" + " does not match the message count " + "that was sent");

    // Evaluate messages left in database
    Assert.assertEquals(dataAccessUtil.getMessageCountForQueue(queue3), 0, "Messages left in database");
    Assert.assertEquals(dataAccessUtil.getMessageCountForQueue(queue4), 0, "Messages left in database");
    Assert.assertEquals(dataAccessUtil.getMessageCountForQueue(queue5), 0, "Messages left in database");
    Assert.assertEquals(dataAccessUtil.getMessageCountForQueue(queue6), 0, "Messages left in database");
    // Evaluate slots left in database
    Assert.assertEquals(dataAccessUtil.getAssignedSlotCountForQueue(queue3), 0, "Slots left in database");
    Assert.assertEquals(dataAccessUtil.getAssignedSlotCountForQueue(queue4), 0, "Slots left in database");
    Assert.assertEquals(dataAccessUtil.getAssignedSlotCountForQueue(queue5), 0, "Slots left in database");
    Assert.assertEquals(dataAccessUtil.getAssignedSlotCountForQueue(queue6), 0, "Slots left in database");
}