org.apache.curator.framework.api.transaction
Code IndexAdd Codota to your IDE (free)

Best code snippets using org.apache.curator.framework.api.transaction(Showing top 15 results out of 315)

origin: shardingjdbc/sharding-jdbc

@Override
public void update(final String key, final String value) {
  try {
    client.inTransaction().check().forPath(key).and().setData().forPath(key, value.getBytes(Charsets.UTF_8)).and().commit();
  //CHECKSTYLE:OFF
  } catch (final Exception ex) {
  //CHECKSTYLE:ON
    RegExceptionHandler.handleException(ex);
  }
}

origin: elasticjob/elastic-job

  @Override
  public void execute(final CuratorTransactionFinal curatorTransactionFinal) throws Exception {
    for (Map.Entry<JobInstance, List<Integer>> entry : shardingResults.entrySet()) {
      for (int shardingItem : entry.getValue()) {
        curatorTransactionFinal.create().forPath(jobNodePath.getFullPath(ShardingNode.getInstanceNode(shardingItem)), entry.getKey().getJobInstanceId().getBytes()).and();
      }
    }
    curatorTransactionFinal.delete().forPath(jobNodePath.getFullPath(ShardingNode.NECESSARY)).and();
    curatorTransactionFinal.delete().forPath(jobNodePath.getFullPath(ShardingNode.PROCESSING)).and();
  }
}
origin: elasticjob/elastic-job-lite

@Override
public void update(final String key, final String value) {
  try {
    client.inTransaction().check().forPath(key).and().setData().forPath(key, value.getBytes(Charsets.UTF_8)).and().commit();
  //CHECKSTYLE:OFF
  } catch (final Exception ex) {
  //CHECKSTYLE:ON
    RegExceptionHandler.handleException(ex);
  }
}

origin: druid-io/druid

/**
 * Unannounces an announcement created at path.  Note that if all announcements get removed, the Announcer
 * will continue to have ZK watches on paths because clearing them out is a source of ugly race conditions.
 * <p/>
 * If you need to completely clear all the state of what is being watched and announced, stop() the Announcer.
 *
 * @param path the path to unannounce
 */
public void unannounce(String path)
{
 log.info("unannouncing [%s]", path);
 final ZKPaths.PathAndNode pathAndNode = ZKPaths.getPathAndNode(path);
 final String parentPath = pathAndNode.getPath();
 final ConcurrentMap<String, byte[]> subPaths = announcements.get(parentPath);
 if (subPaths == null || subPaths.remove(pathAndNode.getNode()) == null) {
  log.error("Path[%s] not announced, cannot unannounce.", path);
  return;
 }
 try {
  curator.inTransaction().delete().forPath(path).and().commit();
 }
 catch (KeeperException.NoNodeException e) {
  log.info("node[%s] didn't exist anyway...", path);
 }
 catch (Exception e) {
  throw Throwables.propagate(e);
 }
}
origin: elasticjob/elastic-job

/**
 * 在事务中执行操作.
 * 
 * @param callback 执行操作的回调
 */
public void executeInTransaction(final TransactionExecutionCallback callback) {
  try {
    CuratorTransactionFinal curatorTransactionFinal = getClient().inTransaction().check().forPath("/").and();
    callback.execute(curatorTransactionFinal);
    curatorTransactionFinal.commit();
  //CHECKSTYLE:OFF
  } catch (final Exception ex) {
  //CHECKSTYLE:ON
    RegExceptionHandler.handleException(ex);
  }
}

origin: MyCATApache/Mycat-Server

private static CuratorTransactionFinal modifyZkRules( CuratorTransactionFinal transactionFinal,String ruleName ,List<String> newDataNodes )
    throws Exception {
  CuratorFramework client= ZKUtils.getConnection();
  String rulePath= ZKUtils.getZKBasePath() + "rules/function";
  JSONArray jsonArray= JSON.parseArray(new String(client.getData().forPath(rulePath) ,"UTF-8"))  ;
  for (Object obj: jsonArray) {
    JSONObject func= (JSONObject) obj;
    if(ruleName.equalsIgnoreCase(func.getString("name"))) {
      JSONArray property=   func.getJSONArray("property") ;
      for (Object o : property) {
        JSONObject count= (JSONObject) o;
        if("count".equals(count.getString("name"))){
          Integer xcount=Integer.parseInt( count.getString("value")) ;
          count.put("value",String.valueOf(xcount+newDataNodes.size())) ;
          if(transactionFinal==null){
            transactionFinal=  ZKUtils.getConnection().inTransaction().setData().forPath(rulePath, JSON.toJSONBytes(jsonArray)).and();
          }  else {
            transactionFinal.setData().forPath(rulePath, JSON.toJSONBytes(jsonArray));
          }
        }
      }
    }
  }
  return transactionFinal;
}
origin: MyCATApache/Mycat-Server

prop.store(out, "WARNING   !!!Please do not modify or delete this file!!!");
if(transactionFinal==null){
  transactionFinal=  ZKUtils.getConnection().inTransaction().setData().forPath(rulePath, out.toByteArray()).and();
}  else {
  transactionFinal.setData().forPath(rulePath, out.toByteArray());
origin: druid-io/druid

for (String parent : parentsIBuilt) {
 try {
  transaction = transaction.delete().forPath(parent).and();
 ((CuratorTransactionFinal) transaction).commit();
origin: MyCATApache/Mycat-Server

tt.put("dataNode", Joiner.on(",").join(allDataNodes));
if(transactionFinal==null){
  transactionFinal=  ZKUtils.getConnection().inTransaction().setData().forPath(rulePath, JSON.toJSONBytes(jsonArray)).and();
}  else {
  transactionFinal.setData().forPath(rulePath, JSON.toJSONBytes(jsonArray));
origin: druid-io/druid

Announcer announcer = new Announcer(curator, exec);
try {
 curator.inTransaction().create().forPath("/somewhere").and().commit();
 announcer.start();
origin: druid-io/druid

final CuratorOp deleteOp = curator.transactionOp().delete().forPath(testPath1);
final Collection<CuratorTransactionResult> results = curator.transaction().forOperations(deleteOp);
Assert.assertEquals(1, results.size());
final CuratorTransactionResult result = results.iterator().next();
Assert.assertEquals(Code.OK.intValue(), result.getError()); // assert delete
origin: MyCATApache/Mycat-Server

  transactionFinal=   client.inTransaction() .setData().forPath(taskPath,JSON.toJSONBytes(taskNode)).and() ;
    List<MigrateTask> value=entry.getValue();
    String path= taskPath + "/" + key;
    transactionFinal=   transactionFinal.create().forPath(path, JSON.toJSONBytes(value)).and()  ;
  transactionFinal.commit();
} catch (Exception e) {
  LOGGER.error("migrate error", e);
origin: elasticjob/elastic-job

@Override
public void update(final String key, final String value) {
  try {
    client.inTransaction().check().forPath(key).and().setData().forPath(key, value.getBytes(Charsets.UTF_8)).and().commit();
  //CHECKSTYLE:OFF
  } catch (final Exception ex) {
  //CHECKSTYLE:ON
    RegExceptionHandler.handleException(ex);
  }
}

origin: elasticjob/elastic-job-lite

  @Override
  public void execute(final CuratorTransactionFinal curatorTransactionFinal) throws Exception {
    for (Map.Entry<JobInstance, List<Integer>> entry : shardingResults.entrySet()) {
      for (int shardingItem : entry.getValue()) {
        curatorTransactionFinal.create().forPath(jobNodePath.getFullPath(ShardingNode.getInstanceNode(shardingItem)), entry.getKey().getJobInstanceId().getBytes()).and();
      }
    }
    curatorTransactionFinal.delete().forPath(jobNodePath.getFullPath(ShardingNode.NECESSARY)).and();
    curatorTransactionFinal.delete().forPath(jobNodePath.getFullPath(ShardingNode.PROCESSING)).and();
  }
}
origin: elasticjob/elastic-job-lite

/**
 * 在事务中执行操作.
 * 
 * @param callback 执行操作的回调
 */
public void executeInTransaction(final TransactionExecutionCallback callback) {
  try {
    CuratorTransactionFinal curatorTransactionFinal = getClient().inTransaction().check().forPath("/").and();
    callback.execute(curatorTransactionFinal);
    curatorTransactionFinal.commit();
  //CHECKSTYLE:OFF
  } catch (final Exception ex) {
  //CHECKSTYLE:ON
    RegExceptionHandler.handleException(ex);
  }
}

org.apache.curator.framework.api.transaction

Most used classes

  • CuratorTransaction
    Transactional/atomic operations. See ZooKeeper#multi(Iterable) for details on ZooKeeper transaction
  • CuratorTransactionBridge
  • CuratorTransactionFinal
    Adds commit to the transaction interface
  • TransactionCreateBuilder
  • TransactionSetDataBuilder
  • TransactionCheckBuilder,
  • CuratorTransactionResult,
  • TransactionOp,
  • CuratorMultiTransaction,
  • CuratorOp,
  • TransactionCreateBuilder2,
  • TypeAndPath

For IntelliJ IDEA,
Android Studio or Eclipse

  • Codota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutContact Us
  • Terms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)