org.apache.hadoop.util.curator.ZKCuratorManager.createTransaction()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(3.4k)|赞(0)|评价(0)|浏览(101)

本文整理了Java中org.apache.hadoop.util.curator.ZKCuratorManager.createTransaction()方法的一些代码示例,展示了ZKCuratorManager.createTransaction()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKCuratorManager.createTransaction()方法的具体详情如下:
包路径:org.apache.hadoop.util.curator.ZKCuratorManager
类名称:ZKCuratorManager
方法名:createTransaction

ZKCuratorManager.createTransaction介绍

暂无

代码示例

代码示例来源:origin: org.apache.hadoop/hadoop-common

public void safeSetData(String path, byte[] data, int version,
  List<ACL> fencingACL, String fencingNodePath)
  throws Exception {
 SafeTransaction transaction = createTransaction(fencingACL,
   fencingNodePath);
 transaction.setData(path, data, version);
 transaction.commit();
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

public void safeCreate(String path, byte[] data, List<ACL> acl,
  CreateMode mode, List<ACL> fencingACL, String fencingNodePath)
  throws Exception {
 if (!exists(path)) {
  SafeTransaction transaction = createTransaction(fencingACL,
    fencingNodePath);
  transaction.create(path, data, acl, mode);
  transaction.commit();
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

/**
 * Deletes the path. Checks for existence of path as well.
 * @param path Path to be deleted.
 * @throws Exception if any problem occurs while performing deletion.
 */
public void safeDelete(final String path, List<ACL> fencingACL,
  String fencingNodePath) throws Exception {
 if (exists(path)) {
  SafeTransaction transaction = createTransaction(fencingACL,
    fencingNodePath);
  transaction.delete(path);
  transaction.commit();
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

@Override
protected synchronized void storeReservationState(
  ReservationAllocationStateProto reservationAllocation, String planName,
  String reservationIdName) throws Exception {
 SafeTransaction trx = zkManager.createTransaction(zkAcl, fencingNodePath);
 addOrUpdateReservationState(reservationAllocation, planName,
   reservationIdName, trx, false);
 trx.commit();
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

@Override
 public void run() {
  try {
   while (!isFencedState()) {
    // Create and delete fencing node
    zkManager.createTransaction(zkAcl, fencingNodePath).commit();
    Thread.sleep(zkSessionTimeout);
   }
  } catch (InterruptedException ie) {
   LOG.info(getName() + " thread interrupted! Exiting!");
   interrupt();
  } catch (Exception e) {
   notifyStoreOperationFailed(new StoreFencedException());
  }
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

@Override
protected synchronized void storeRMDelegationTokenState(
  RMDelegationTokenIdentifier rmDTIdentifier, Long renewDate)
  throws Exception {
 String nodeCreatePath = getLeafDelegationTokenNodePath(
   rmDTIdentifier.getSequenceNumber(), true);
 if (LOG.isDebugEnabled()) {
  LOG.debug("Storing " + DELEGATION_TOKEN_PREFIX
    + rmDTIdentifier.getSequenceNumber());
 }
 RMDelegationTokenIdentifierData identifierData =
   new RMDelegationTokenIdentifierData(rmDTIdentifier, renewDate);
 ByteArrayOutputStream seqOs = new ByteArrayOutputStream();
 try (DataOutputStream seqOut = new DataOutputStream(seqOs)) {
  SafeTransaction trx = zkManager.createTransaction(zkAcl,
    fencingNodePath);
  trx.create(nodeCreatePath, identifierData.toByteArray(), zkAcl,
    CreateMode.PERSISTENT);
  // Update Sequence number only while storing DT
  seqOut.writeInt(rmDTIdentifier.getSequenceNumber());
  if (LOG.isDebugEnabled()) {
   LOG.debug("Storing " + dtSequenceNumberPath + ". SequenceNumber: "
     + rmDTIdentifier.getSequenceNumber());
  }
  trx.setData(dtSequenceNumberPath, seqOs.toByteArray(), -1);
  trx.commit();
 }
}

相关文章