Search in sources :

Example 6 with DiscoveryEvent

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

the class DiscoveryEventMarshaller method tightMarshal2.

/**
 * Write a object instance to data output stream
 *
 * @param o the instance to be marshaled
 * @param dataOut the output stream
 * @throws IOException thrown if an error occurs
 */
public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataByteArrayOutputStream dataOut, BooleanStream bs) throws IOException {
    super.tightMarshal2(wireFormat, o, dataOut, bs);
    DiscoveryEvent info = (DiscoveryEvent) o;
    tightMarshalString2(info.getServiceName(), dataOut, bs);
    tightMarshalString2(info.getBrokerName(), dataOut, bs);
}
Also used : DiscoveryEvent(io.fabric8.gateway.handlers.detecting.protocol.openwire.command.DiscoveryEvent)

Example 7 with DiscoveryEvent

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

the class MQProfileTest method waitForBroker.

protected void waitForBroker(String groupName) throws Exception {
    ServiceProxy<CuratorFramework> curatorProxy = ServiceProxy.createServiceProxy(bundleContext, CuratorFramework.class);
    try {
        CuratorFramework curator = curatorProxy.getService();
        final CountDownLatch serviceLatch = new CountDownLatch(1);
        final FabricDiscoveryAgent discoveryAgent = new FabricDiscoveryAgent();
        discoveryAgent.setCurator(curator);
        discoveryAgent.setGroupName(groupName);
        discoveryAgent.setDiscoveryListener(new DiscoveryListener() {

            @Override
            public void onServiceAdd(DiscoveryEvent discoveryEvent) {
                System.out.println("Service added:" + discoveryEvent.getServiceName());
                serviceLatch.countDown();
                try {
                    discoveryAgent.stop();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onServiceRemove(DiscoveryEvent discoveryEvent) {
                System.out.println("Service removed:" + discoveryEvent.getServiceName());
            }
        });
        discoveryAgent.start();
        Assert.assertTrue(serviceLatch.await(15, TimeUnit.MINUTES));
    } finally {
        curatorProxy.close();
    }
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) FabricDiscoveryAgent(io.fabric8.mq.fabric.discovery.FabricDiscoveryAgent) DiscoveryEvent(org.apache.activemq.command.DiscoveryEvent) CountDownLatch(java.util.concurrent.CountDownLatch) DiscoveryListener(org.apache.activemq.transport.discovery.DiscoveryListener)

Aggregations

DiscoveryEvent (io.fabric8.gateway.handlers.detecting.protocol.openwire.command.DiscoveryEvent)5 DiscoveryEvent (org.apache.activemq.command.DiscoveryEvent)2 DiscoveryListener (org.apache.activemq.transport.discovery.DiscoveryListener)2 CuratorFramework (org.apache.curator.framework.CuratorFramework)2 FabricDiscoveryAgent (io.fabric8.mq.fabric.discovery.FabricDiscoveryAgent)1 OsgiFabricDiscoveryAgent (io.fabric8.mq.fabric.discovery.OsgiFabricDiscoveryAgent)1 File (java.io.File)1 InputStream (java.io.InputStream)1 Collection (java.util.Collection)1 Properties (java.util.Properties)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 CuratorFrameworkFactory (org.apache.curator.framework.CuratorFrameworkFactory)1 RetryNTimes (org.apache.curator.retry.RetryNTimes)1 Test (org.junit.Test)1