Search in sources :

Example 16 with BrokerId

use of io.fabric8.gateway.handlers.detecting.protocol.openwire.command.BrokerId in project fabric8 by jboss-fuse.

the class BrokerInfoMarshaller method looseUnmarshal.

/**
 * Un-marshal an object instance from the data input stream
 *
 * @param o the object to un-marshal
 * @param dataIn the data input stream to build the object from
 * @throws IOException
 */
public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataByteArrayInputStream dataIn) throws IOException {
    super.looseUnmarshal(wireFormat, o, dataIn);
    BrokerInfo info = (BrokerInfo) o;
    info.setBrokerId((BrokerId) looseUnmarsalCachedObject(wireFormat, dataIn));
    info.setBrokerURL(looseUnmarshalString(dataIn));
    if (dataIn.readBoolean()) {
        short size = dataIn.readShort();
        BrokerInfo[] value = new BrokerInfo[size];
        for (int i = 0; i < size; i++) {
            value[i] = (BrokerInfo) looseUnmarsalNestedObject(wireFormat, dataIn);
        }
        info.setPeerBrokerInfos(value);
    } else {
        info.setPeerBrokerInfos(null);
    }
    info.setBrokerName(looseUnmarshalString(dataIn));
    info.setSlaveBroker(dataIn.readBoolean());
    info.setMasterBroker(dataIn.readBoolean());
    info.setFaultTolerantConfiguration(dataIn.readBoolean());
}
Also used : BrokerInfo(io.fabric8.gateway.handlers.detecting.protocol.openwire.command.BrokerInfo)

Example 17 with BrokerId

use of io.fabric8.gateway.handlers.detecting.protocol.openwire.command.BrokerId in project fabric8 by jboss-fuse.

the class BrokerInfoMarshaller method tightUnmarshal.

/**
 * Un-marshal an object instance from the data input stream
 *
 * @param o the object to un-marshal
 * @param dataIn the data input stream to build the object from
 * @throws IOException
 */
public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataByteArrayInputStream dataIn, BooleanStream bs) throws IOException {
    super.tightUnmarshal(wireFormat, o, dataIn, bs);
    BrokerInfo info = (BrokerInfo) o;
    info.setBrokerId((BrokerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));
    info.setBrokerURL(tightUnmarshalString(dataIn, bs));
    if (bs.readBoolean()) {
        short size = dataIn.readShort();
        BrokerInfo[] value = new BrokerInfo[size];
        for (int i = 0; i < size; i++) {
            value[i] = (BrokerInfo) tightUnmarsalNestedObject(wireFormat, dataIn, bs);
        }
        info.setPeerBrokerInfos(value);
    } else {
        info.setPeerBrokerInfos(null);
    }
    info.setBrokerName(tightUnmarshalString(dataIn, bs));
    info.setSlaveBroker(bs.readBoolean());
    info.setMasterBroker(bs.readBoolean());
    info.setFaultTolerantConfiguration(bs.readBoolean());
}
Also used : BrokerInfo(io.fabric8.gateway.handlers.detecting.protocol.openwire.command.BrokerInfo)

Example 18 with BrokerId

use of io.fabric8.gateway.handlers.detecting.protocol.openwire.command.BrokerId in project fabric8 by jboss-fuse.

the class ConnectionInfoMarshaller method tightUnmarshal.

/**
 * Un-marshal an object instance from the data input stream
 *
 * @param o the object to un-marshal
 * @param dataIn the data input stream to build the object from
 * @throws IOException
 */
public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataByteArrayInputStream dataIn, BooleanStream bs) throws IOException {
    super.tightUnmarshal(wireFormat, o, dataIn, bs);
    ConnectionInfo info = (ConnectionInfo) o;
    info.setConnectionId((ConnectionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));
    info.setClientId(tightUnmarshalString(dataIn, bs));
    info.setPassword(tightUnmarshalString(dataIn, bs));
    info.setUserName(tightUnmarshalString(dataIn, bs));
    if (bs.readBoolean()) {
        short size = dataIn.readShort();
        BrokerId[] value = new BrokerId[size];
        for (int i = 0; i < size; i++) {
            value[i] = (BrokerId) tightUnmarsalNestedObject(wireFormat, dataIn, bs);
        }
        info.setBrokerPath(value);
    } else {
        info.setBrokerPath(null);
    }
    info.setBrokerMasterConnector(bs.readBoolean());
    info.setManageable(bs.readBoolean());
}
Also used : BrokerId(io.fabric8.gateway.handlers.detecting.protocol.openwire.command.BrokerId) ConnectionInfo(io.fabric8.gateway.handlers.detecting.protocol.openwire.command.ConnectionInfo)

Example 19 with BrokerId

use of io.fabric8.gateway.handlers.detecting.protocol.openwire.command.BrokerId in project fabric8 by jboss-fuse.

the class ConnectionInfoMarshaller method looseUnmarshal.

/**
 * Un-marshal an object instance from the data input stream
 *
 * @param o the object to un-marshal
 * @param dataIn the data input stream to build the object from
 * @throws IOException
 */
public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataByteArrayInputStream dataIn) throws IOException {
    super.looseUnmarshal(wireFormat, o, dataIn);
    ConnectionInfo info = (ConnectionInfo) o;
    info.setConnectionId((ConnectionId) looseUnmarsalCachedObject(wireFormat, dataIn));
    info.setClientId(looseUnmarshalString(dataIn));
    info.setPassword(looseUnmarshalString(dataIn));
    info.setUserName(looseUnmarshalString(dataIn));
    if (dataIn.readBoolean()) {
        short size = dataIn.readShort();
        BrokerId[] value = new BrokerId[size];
        for (int i = 0; i < size; i++) {
            value[i] = (BrokerId) looseUnmarsalNestedObject(wireFormat, dataIn);
        }
        info.setBrokerPath(value);
    } else {
        info.setBrokerPath(null);
    }
    info.setBrokerMasterConnector(dataIn.readBoolean());
    info.setManageable(dataIn.readBoolean());
}
Also used : BrokerId(io.fabric8.gateway.handlers.detecting.protocol.openwire.command.BrokerId) ConnectionInfo(io.fabric8.gateway.handlers.detecting.protocol.openwire.command.ConnectionInfo)

Example 20 with BrokerId

use of io.fabric8.gateway.handlers.detecting.protocol.openwire.command.BrokerId in project strimzi by strimzi.

the class KafkaClusterTest method testKafkaScaleUpScaleDown.

@Test
@KafkaCluster(name = "my-cluster", kafkaNodes = 3)
public void testKafkaScaleUpScaleDown() {
    // kafka cluster already deployed via annotation
    String clusterName = "my-cluster";
    LOGGER.info("Running kafkaScaleUpScaleDown {}", clusterName);
    // kubeClient.waitForStatefulSet(kafkaStatefulSetName(clusterName), 3);
    KubernetesClient client = new DefaultKubernetesClient();
    final int initialReplicas = client.apps().statefulSets().inNamespace(NAMESPACE).withName(kafkaStatefulSetName(clusterName)).get().getStatus().getReplicas();
    assertEquals(3, initialReplicas);
    // scale up
    final int scaleTo = initialReplicas + 1;
    final int newPodId = initialReplicas;
    final int newBrokerId = newPodId;
    final String newPodName = kafkaPodName(clusterName, newPodId);
    final String firstPodName = kafkaPodName(clusterName, 0);
    LOGGER.info("Scaling Kafka up to {}", scaleTo);
    replaceCm(clusterName, "kafka-nodes", String.valueOf(initialReplicas + 1));
    kubeClient.waitForStatefulSet(kafkaStatefulSetName(clusterName), initialReplicas + 1);
    // Test that the new broker has joined the kafka cluster by checking it knows about all the other broker's API versions
    // (execute bash because we want the env vars expanded in the pod)
    String versions = getBrokerApiVersions(newPodName);
    for (int brokerId = 0; brokerId < scaleTo; brokerId++) {
        assertTrue(versions, versions.indexOf("(id: " + brokerId + " rack: ") >= 0);
    }
    // TODO Check for k8s events, logs for errors
    // scale down
    LOGGER.info("Scaling down");
    // client.apps().statefulSets().inNamespace(NAMESPACE).withName(kafkaStatefulSetName(clusterName)).scale(initialReplicas, true);
    replaceCm(clusterName, "kafka-nodes", String.valueOf(initialReplicas));
    kubeClient.waitForStatefulSet(kafkaStatefulSetName(clusterName), initialReplicas);
    final int finalReplicas = client.apps().statefulSets().inNamespace(NAMESPACE).withName(kafkaStatefulSetName(clusterName)).get().getStatus().getReplicas();
    assertEquals(initialReplicas, finalReplicas);
    versions = getBrokerApiVersions(firstPodName);
    assertTrue("Expect the added broker, " + newBrokerId + ",  to no longer be present in output of kafka-broker-api-versions.sh", versions.indexOf("(id: " + newBrokerId + " rack: ") == -1);
// TODO Check for k8s events, logs for errors
}
Also used : DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) KafkaCluster(io.strimzi.test.KafkaCluster) Test(org.junit.Test)

Aggregations

BrokerId (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.BrokerId)15 BrokerInfo (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.BrokerInfo)2 ConnectionInfo (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.ConnectionInfo)2 ConsumerInfo (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.ConsumerInfo)2 DestinationInfo (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.DestinationInfo)2 Message (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.Message)2 NetworkBridgeFilter (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.NetworkBridgeFilter)2 ProducerInfo (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.ProducerInfo)2 DefaultKubernetesClient (io.fabric8.kubernetes.client.DefaultKubernetesClient)1 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)1 KafkaCluster (io.strimzi.test.KafkaCluster)1 Test (org.junit.Test)1