use of io.fabric8.groups.internal.ZooKeeperGroup in project fabric8 by jboss-fuse.
the class OpenShiftDeployAgent method activate.
@Activate
void activate(Map<String, ?> configuration) {
// this.realm = properties != null && properties.containsKey(REALM_PROPERTY_NAME) ? properties.get(REALM_PROPERTY_NAME) : DEFAULT_REALM;
// this.role = properties != null && properties.containsKey(ROLE_PROPERTY_NAME) ? properties.get(ROLE_PROPERTY_NAME) : DEFAULT_ROLE;
group = new ZooKeeperGroup(curator.get(), ZkPath.OPENSHIFT.getPath(), ControllerNode.class);
group.add(this);
group.update(createState());
group.start();
activateComponent();
}
use of io.fabric8.groups.internal.ZooKeeperGroup in project fabric8 by jboss-fuse.
the class ZooKeeperGroupTest method putChildData.
private static void putChildData(ZooKeeperGroup<NodeState> group, String path, String container) throws Exception {
NodeState node = new NodeState("test", container);
ByteArrayOutputStream data = new ByteArrayOutputStream();
new ObjectMapper().disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES).writeValue(data, node);
ChildData<NodeState> child = new ChildData<>(path, new Stat(), data.toByteArray(), node);
group.currentData.put(path, child);
}
use of io.fabric8.groups.internal.ZooKeeperGroup in project fabric8 by jboss-fuse.
the class ZooKeeperGroupTest method setUp.
@Before
public void setUp() throws Exception {
int port = findFreePort();
curator = CuratorFrameworkFactory.builder().connectString("localhost:" + port).retryPolicy(new RetryOneTime(1)).build();
// curator.start();
group = new ZooKeeperGroup<>(curator, PATH, NodeState.class);
// group.start();
// Starting curator and group is not necessary for the current tests.
}
use of io.fabric8.groups.internal.ZooKeeperGroup in project fabric8 by jboss-fuse.
the class GitHttpServerRegistrationHandler method activate.
@Activate
void activate(Map<String, ?> configuration) throws Exception {
RuntimeProperties sysprops = runtimeProperties.get();
realm = getConfiguredRealm(sysprops, configuration);
roles = getConfiguredRoles(sysprops, configuration);
dataPath = sysprops.getDataPath();
activateComponent();
group = new ZooKeeperGroup<GitNode>(curator.get(), ZkPath.GIT.getPath(), GitNode.class, new NamedThreadFactory("zkgroup-git-httpreg"));
// if anything went wrong in a previous deactivation we still have to clean up the registry
zkCleanUp(group);
group.add(this);
group.update(createState());
group.start();
}
use of io.fabric8.groups.internal.ZooKeeperGroup in project fabric8 by jboss-fuse.
the class GroupTest method testJoinBeforeConnect.
@Test
public void testJoinBeforeConnect() throws Exception {
int port = findFreePort();
CuratorFramework curator = CuratorFrameworkFactory.builder().connectString("localhost:" + port).retryPolicy(new RetryNTimes(10, 100)).build();
curator.start();
Group<NodeState> group = new ZooKeeperGroup<NodeState>(curator, "/singletons/test" + System.currentTimeMillis(), NodeState.class);
group.add(listener);
group.start();
GroupCondition groupCondition = new GroupCondition();
group.add(groupCondition);
assertFalse(group.isConnected());
assertFalse(group.isMaster());
group.update(new NodeState("foo"));
NIOServerCnxnFactory cnxnFactory = startZooKeeper(port);
curator.getZookeeperClient().blockUntilConnectedOrTimedOut();
assertTrue(groupCondition.waitForConnected(5, TimeUnit.SECONDS));
assertTrue(groupCondition.waitForMaster(5, TimeUnit.SECONDS));
group.close();
curator.close();
cnxnFactory.shutdown();
cnxnFactory.join();
}
Aggregations