use of org.apache.flink.shaded.curator5.org.apache.curator.framework.CuratorFramework in project fabric8 by jboss-fuse.
the class Kill method createNewAction.
@Override
public Action createNewAction() {
assertValid();
// this is how we get hold of the curator framework
CuratorFramework curator = CuratorFrameworkLocator.getCuratorFramework();
return new KillAction(curator);
}
use of org.apache.flink.shaded.curator5.org.apache.curator.framework.CuratorFramework in project fabric8 by jboss-fuse.
the class List method createNewAction.
@Override
public Action createNewAction() {
assertValid();
// this is how we get hold of the curator framework
CuratorFramework curator = CuratorFrameworkLocator.getCuratorFramework();
return new ListAction(curator);
}
use of org.apache.flink.shaded.curator5.org.apache.curator.framework.CuratorFramework in project fabric8 by jboss-fuse.
the class Delete method createNewAction.
@Override
public Action createNewAction() {
assertValid();
// this is how we get hold of the curator framework
CuratorFramework curator = CuratorFrameworkLocator.getCuratorFramework();
return new DeleteAction(curator);
}
use of org.apache.flink.shaded.curator5.org.apache.curator.framework.CuratorFramework in project fabric8 by jboss-fuse.
the class ManagedCuratorFramework method bindConnectionStateListener.
void bindConnectionStateListener(ConnectionStateListener connectionStateListener) {
connectionStateListeners.add(connectionStateListener);
State curr = state.get();
CuratorFramework curator = curr != null ? curr.curator : null;
if (curator != null && curator.getZookeeperClient().isConnected()) {
connectionStateListener.stateChanged(curator, ConnectionState.CONNECTED);
}
}
use of org.apache.flink.shaded.curator5.org.apache.curator.framework.CuratorFramework in project fabric8 by jboss-fuse.
the class ManagerTest method testManager.
@Test
public void testManager() throws Exception {
ZKServerFactoryBean zkServerFactoryBean = null;
try {
int zooKeeperPort = getFreePort();
int serverPort = getFreePort();
zkServerFactoryBean = new ZKServerFactoryBean();
zkServerFactoryBean.setPurge(true);
zkServerFactoryBean.setClientPortAddress(new InetSocketAddress("localhost", zooKeeperPort));
zkServerFactoryBean.afterPropertiesSet();
CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder().connectString("localhost:" + zooKeeperPort).retryPolicy(new RetryOneTime(1000)).connectionTimeoutMs(60000);
CuratorFramework curator = builder.build();
curator.start();
curator.getZookeeperClient().blockUntilConnectedOrTimedOut();
BundleContext bundleContext = createMock(BundleContext.class);
ServiceRegistration registration = createMock(ServiceRegistration.class);
Manager manager = new Manager(bundleContext, curator, "tcp://localhost:" + serverPort, "localhost", TimeUnit.MINUTES.toMillis(5));
bundleContext.addServiceListener(manager, "(service.exported.interfaces=*)");
expect(bundleContext.getProperty("org.osgi.framework.uuid")).andReturn("the-framework-uuid");
expect(bundleContext.registerService(EasyMock.<String[]>anyObject(), same(manager), EasyMock.<Dictionary>same(null))).andReturn(registration);
expect(bundleContext.getServiceReferences((String) null, "(service.exported.interfaces=*)")).andReturn(null);
replay(bundleContext, registration);
manager.init();
verify(bundleContext, registration);
reset(bundleContext, registration);
BundleContext expBundleContext = createMock(BundleContext.class);
Bundle expBundle = createMock(Bundle.class);
ServiceReference reference = createMock(ServiceReference.class);
final Properties props = new Properties();
props.put(Constants.OBJECTCLASS, new String[] { ConfigurationAdmin.class.getName() });
expect(reference.getProperty(EasyMock.<String>anyObject())).andAnswer(new IAnswer<Object>() {
public Object answer() throws Throwable {
return props.get(EasyMock.getCurrentArguments()[0]);
}
}).anyTimes();
expect(reference.getPropertyKeys()).andReturn(props.keySet().toArray(new String[0]));
expect(reference.getBundle()).andReturn(expBundle).anyTimes();
expect(expBundle.getBundleContext()).andReturn(expBundleContext).anyTimes();
expect(expBundle.getState()).andReturn(Bundle.ACTIVE).anyTimes();
replay(bundleContext, registration, reference, expBundleContext, expBundle);
manager.serviceChanged(new ServiceEvent(ServiceEvent.REGISTERED, reference));
Thread.sleep(1000);
verify(bundleContext, registration, reference, expBundleContext, expBundle);
} finally {
try {
zkServerFactoryBean.destroy();
} catch (Throwable t) {
}
}
}
Aggregations