private void privateCreate(String path, Optional<byte[]> data) throws Exception { final long start = System.currentTimeMillis(); try { ProtectACLCreateModePathAndBytesable<String> createBuilder = curator.create().creatingParentsIfNeeded(); if (data.isPresent()) { createBuilder.forPath(path, data.get()); } else { createBuilder.forPath(path); } } finally { log(OperationType.WRITE, Optional.<Integer> absent(), Optional.<Integer> of(data.or(EMPTY_BYTES).length), start, path); } }
protected static void createNode(CuratorFramework curator, String path, byte[] data, List<ACL> acls, CreateMode mode) throws Exception { ProtectACLCreateModePathAndBytesable<String> builder = curator.create().creatingParentsIfNeeded(); if (acls == null) { if (mode == null ) { TransactionalState.forPath(builder, path, data); } else { TransactionalState.forPath(builder.withMode(mode), path, data); } return; } TransactionalState.forPath(builder.withACL(acls), path, data); }
private void privateCreate(String path, Optional<byte[]> data) throws Exception { final long start = System.currentTimeMillis(); try { ProtectACLCreateModePathAndBytesable<String> createBuilder = curator.create().creatingParentsIfNeeded(); if (data.isPresent()) { createBuilder.forPath(path, data.get()); } else { createBuilder.forPath(path); } } finally { log(OperationType.WRITE, Optional.absent(), Optional.of(data.or(EMPTY_BYTES).length), start, path); } }
protected void createNode(CuratorFramework curator, String path, byte[] data, List<ACL> acls, CreateMode mode) throws Exception { ProtectACLCreateModePathAndBytesable<String> builder = curator.create().creatingParentsIfNeeded(); if (acls == null) { if (mode == null) { forPath(builder, path, data); } else { forPath(builder.withMode(mode), path, data); } return; } forPath(builder.withACL(acls), path, data); }
public void writeBytes(String path, byte[] bytes) { try { if (_curator.checkExists().forPath(path) == null) { CreateBuilder builder = _curator.create(); ProtectACLCreateModePathAndBytesable<String> createAble = (ProtectACLCreateModePathAndBytesable<String>) builder .creatingParentsIfNeeded(); createAble.withMode(CreateMode.PERSISTENT).forPath(path, bytes); } else { _curator.setData().forPath(path, bytes); } } catch (Exception e) { throw new RuntimeException(e); } }
protected static void createNode(CuratorFramework curator, String path, byte[] data, List<ACL> acls, CreateMode mode) throws Exception { ProtectACLCreateModePathAndBytesable<String> builder = curator.create().creatingParentsIfNeeded(); if (acls == null) { if (mode == null) { TransactionalState.forPath(builder, path, data); } else { TransactionalState.forPath(builder.withMode(mode), path, data); } return; } TransactionalState.forPath(builder.withACL(acls), path, data); }
@Override public ProtectACLCreateModePathAndBytesable<String> creatingParentsIfNeeded() { createParents = true; return this; }
@Override public ProtectACLCreateModePathAndBytesable<String> creatingParentContainersIfNeeded() { // TODO: Add proper support for container nodes, see https://issues.apache.org/jira/browse/ZOOKEEPER-2163. return creatingParentsIfNeeded(); }