org.apache.curator.framework.recipes.nodes.PersistentEphemeralNode Java Examples
The following examples show how to use
org.apache.curator.framework.recipes.nodes.PersistentEphemeralNode.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultZooKeeperClient.java From helios with Apache License 2.0 | 6 votes |
@Override public PersistentEphemeralNode persistentEphemeralNode(final String path, final PersistentEphemeralNode.Mode mode, final byte[] data) { assertClusterIdFlagTrue(); final PersistentEphemeralNode node = new PersistentEphemeralNode(client, mode, path, data); // ugly hack to work around a problem with curator, wherein PersistentEphemeralNode creates // all parent paths if they don't exist but applies the ACL for its own path to its parents try { final Field field = node.getClass().getDeclaredField("createMethod"); field.setAccessible(true); field.set(node, client.create()); } catch (NoSuchFieldException | IllegalAccessException e) { throw new RuntimeException(e); } return node; }
Example #2
Source File: AgentZooKeeperRegistrarTest.java From helios with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { registrar.startUp(); final PersistentEphemeralNode ephemeralNode = mock(PersistentEphemeralNode.class); when(client.persistentEphemeralNode(upPath, PersistentEphemeralNode.Mode.EPHEMERAL, new byte[]{})) .thenReturn(ephemeralNode); // default behavior for checking ID of the host registered in zookeeper - it is this host when(client.exists(idPath)).thenReturn(new Stat()); when(client.getData(idPath)).thenReturn(hostId.getBytes()); }
Example #3
Source File: ZkCuratorServer.java From schedule-spring-boot-starter with Apache License 2.0 | 4 votes |
public static void appendPersistentData(CuratorFramework client, String path, String data) throws Exception { PersistentEphemeralNode node = new PersistentEphemeralNode(client, PersistentEphemeralNode.Mode.EPHEMERAL, path, data.getBytes(Constants.Global.CHARSET_NAME)); node.start(); node.waitForInitialCreate(3, TimeUnit.SECONDS); }
Example #4
Source File: ReportingZooKeeperClient.java From helios with Apache License 2.0 | 4 votes |
@Override public PersistentEphemeralNode persistentEphemeralNode(final String path, final PersistentEphemeralNode.Mode mode, final byte[] data) { return client.persistentEphemeralNode(path, mode, data); }
Example #5
Source File: ZooKeeperClient.java From helios with Apache License 2.0 | 4 votes |
PersistentEphemeralNode persistentEphemeralNode(String path, final PersistentEphemeralNode.Mode mode, byte[] data);