org.apache.zookeeper.data.Stat.setEphemeralOwner()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(10.2k)|赞(0)|评价(0)|浏览(108)

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

Stat.setEphemeralOwner介绍

暂无

代码示例

代码示例来源:origin: apache/zookeeper

ACLCB(ZooKeeper zk, CountDownLatch latch) {
  super(zk, latch);
  stat.setAversion(0);
  stat.setCversion(0);
  stat.setEphemeralOwner(0);
  stat.setVersion(0);
}

代码示例来源:origin: apache/zookeeper

DataCB(ZooKeeper zk, CountDownLatch latch) {
  super(zk, latch);
  stat.setAversion(0);
  stat.setCversion(0);
  stat.setEphemeralOwner(0);
  stat.setVersion(0);
}

代码示例来源:origin: apache/zookeeper

StatCB(ZooKeeper zk, CountDownLatch latch) {
  super(zk, latch);
  stat.setAversion(0);
  stat.setCversion(0);
  stat.setEphemeralOwner(0);
  stat.setVersion(0);
}

代码示例来源:origin: org.apache.zookeeper/zookeeper

public void copyStat(Stat to) {
  to.setAversion(stat.getAversion());
  to.setCtime(stat.getCtime());
  to.setCversion(stat.getCversion());
  to.setCzxid(stat.getCzxid());
  to.setMtime(stat.getMtime());
  to.setMzxid(stat.getMzxid());
  to.setVersion(stat.getVersion());
  to.setEphemeralOwner(stat.getEphemeralOwner());
  to.setDataLength(data.length);
  to.setNumChildren(children.size());
}

代码示例来源:origin: apache/zookeeper

synchronized public void copyStat(Stat to) {
  to.setAversion(stat.getAversion());
  to.setCtime(stat.getCtime());
  to.setCzxid(stat.getCzxid());
  to.setMtime(stat.getMtime());
  to.setMzxid(stat.getMzxid());
  to.setPzxid(stat.getPzxid());
  to.setVersion(stat.getVersion());
  to.setEphemeralOwner(getClientEphemeralOwner(stat));
  to.setDataLength(data == null ? 0 : data.length);
  int numChildren = 0;
  if (this.children != null) {
    numChildren = children.size();
  }
  // when we do the Cversion we need to translate from the count of the creates
  // to the count of the changes (v3 semantics)
  // for every create there is a delete except for the children still present
  to.setCversion(stat.getCversion()*2 - numChildren);
  to.setNumChildren(numChildren);
}

代码示例来源:origin: apache/zookeeper

/**
 * Create a new Stat, fill in dummy values trying to catch Assert.failure
 * to copy in client or server code.
 *
 * @return a new stat with dummy values
 */
private Stat newStat() {
  Stat stat = new Stat();
  stat.setAversion(100);
  stat.setCtime(100);
  stat.setCversion(100);
  stat.setCzxid(100);
  stat.setDataLength(100);
  stat.setEphemeralOwner(100);
  stat.setMtime(100);
  stat.setMzxid(100);
  stat.setNumChildren(100);
  stat.setPzxid(100);
  stat.setVersion(100);
  return stat;
}

代码示例来源:origin: apache/zookeeper

static public void copyStat(Stat from, Stat to) {
  to.setAversion(from.getAversion());
  to.setCtime(from.getCtime());
  to.setCversion(from.getCversion());
  to.setCzxid(from.getCzxid());
  to.setMtime(from.getMtime());
  to.setMzxid(from.getMzxid());
  to.setPzxid(from.getPzxid());
  to.setVersion(from.getVersion());
  to.setEphemeralOwner(from.getEphemeralOwner());
  to.setDataLength(from.getDataLength());
  to.setNumChildren(from.getNumChildren());
}

代码示例来源:origin: org.apache.zookeeper/zookeeper

synchronized public void copyStat(Stat to) {
  to.setAversion(stat.getAversion());
  to.setCtime(stat.getCtime());
  to.setCzxid(stat.getCzxid());
  to.setMtime(stat.getMtime());
  to.setMzxid(stat.getMzxid());
  to.setPzxid(stat.getPzxid());
  to.setVersion(stat.getVersion());
  to.setEphemeralOwner(stat.getEphemeralOwner());
  to.setDataLength(data == null ? 0 : data.length);
  int numChildren = 0;
  if (this.children != null) {
    numChildren = children.size();
  }
  // when we do the Cversion we need to translate from the count of the creates
  // to the count of the changes (v3 semantics)
  // for every create there is a delete except for the children still present
  to.setCversion(stat.getCversion()*2 - numChildren);
  to.setNumChildren(numChildren);
}

代码示例来源:origin: org.apache.zookeeper/zookeeper

static public void copyStat(Stat from, Stat to) {
  to.setAversion(from.getAversion());
  to.setCtime(from.getCtime());
  to.setCversion(from.getCversion());
  to.setCzxid(from.getCzxid());
  to.setMtime(from.getMtime());
  to.setMzxid(from.getMzxid());
  to.setVersion(from.getVersion());
  to.setEphemeralOwner(from.getEphemeralOwner());
  to.setDataLength(from.getDataLength());
  to.setNumChildren(from.getNumChildren());
}

代码示例来源:origin: org.apache.zookeeper/zookeeper

static public void copyStat(Stat from, Stat to) {
  to.setAversion(from.getAversion());
  to.setCtime(from.getCtime());
  to.setCversion(from.getCversion());
  to.setCzxid(from.getCzxid());
  to.setMtime(from.getMtime());
  to.setMzxid(from.getMzxid());
  to.setPzxid(from.getPzxid());
  to.setVersion(from.getVersion());
  to.setEphemeralOwner(from.getEphemeralOwner());
  to.setDataLength(from.getDataLength());
  to.setNumChildren(from.getNumChildren());
}

代码示例来源:origin: facebook/jcommon

private ZNode(
 long sessionId,
 ZNode parent,
 String name,
 byte[] data,
 List<ACL> acl,
 CreateMode createMode
) {
 this.parent = parent;
 this.name = name;
 this.data = data;
 this.acl = acl;
 this.createMode = createMode;
 stat.setEphemeralOwner(createMode.isEphemeral() ? sessionId : 0);
 stat.setDataLength((data == null) ? 0 : data.length);
 stat.setNumChildren(0);
 stat.setVersion(version.get());
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

/**
 * verify that successful znode create result becomes active and monitoring is
 * started
 */
@Test
public void testCreateNodeResultBecomeActive() throws Exception {
 mockNoPriorActive();
 
 elector.joinElection(data);
 elector.processResult(Code.OK.intValue(), ZK_LOCK_NAME, mockZK,
   ZK_LOCK_NAME);
 Mockito.verify(mockApp, Mockito.times(1)).becomeActive();
 verifyExistCall(1);
 // monitor callback verifies the leader is ephemeral owner of lock but does
 // not call becomeActive since its already active
 Stat stat = new Stat();
 stat.setEphemeralOwner(1L);
 Mockito.when(mockZK.getSessionId()).thenReturn(1L);
 elector.processResult(Code.OK.intValue(), ZK_LOCK_NAME, mockZK, stat);
 // should not call neutral mode/standby/active
 Mockito.verify(mockApp, Mockito.times(0)).enterNeutralMode();
 Mockito.verify(mockApp, Mockito.times(0)).becomeStandby();
 Mockito.verify(mockApp, Mockito.times(1)).becomeActive();
 // another joinElection not called.
 Mockito.verify(mockZK, Mockito.times(1)).create(ZK_LOCK_NAME, data,
   Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL, elector, mockZK);
 // no new monitor called
 verifyExistCall(1);
}

代码示例来源:origin: ch.cern.hadoop/hadoop-common

/**
 * verify that successful znode create result becomes active and monitoring is
 * started
 */
@Test
public void testCreateNodeResultBecomeActive() throws Exception {
 mockNoPriorActive();
 
 elector.joinElection(data);
 elector.processResult(Code.OK.intValue(), ZK_LOCK_NAME, mockZK,
   ZK_LOCK_NAME);
 Mockito.verify(mockApp, Mockito.times(1)).becomeActive();
 verifyExistCall(1);
 // monitor callback verifies the leader is ephemeral owner of lock but does
 // not call becomeActive since its already active
 Stat stat = new Stat();
 stat.setEphemeralOwner(1L);
 Mockito.when(mockZK.getSessionId()).thenReturn(1L);
 elector.processResult(Code.OK.intValue(), ZK_LOCK_NAME, mockZK, stat);
 // should not call neutral mode/standby/active
 Mockito.verify(mockApp, Mockito.times(0)).enterNeutralMode();
 Mockito.verify(mockApp, Mockito.times(0)).becomeStandby();
 Mockito.verify(mockApp, Mockito.times(1)).becomeActive();
 // another joinElection not called.
 Mockito.verify(mockZK, Mockito.times(1)).create(ZK_LOCK_NAME, data,
   Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL, elector, mockZK);
 // no new monitor called
 verifyExistCall(1);
}

代码示例来源:origin: ch.cern.hadoop/hadoop-common

stat.setEphemeralOwner(1L);
Mockito.when(mockZK.getSessionId()).thenReturn(1L);

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

/**
 * verify that retry of network errors verifies active by session id and
 * becomes standby if they dont match. monitoring is started.
 */
@Test
public void testCreateNodeResultRetryBecomeStandby() {
 elector.joinElection(data);
 elector.processResult(Code.CONNECTIONLOSS.intValue(), ZK_LOCK_NAME, mockZK,
   ZK_LOCK_NAME);
 elector.processResult(Code.NODEEXISTS.intValue(), ZK_LOCK_NAME, mockZK,
   ZK_LOCK_NAME);
 verifyExistCall(1);
 Stat stat = new Stat();
 stat.setEphemeralOwner(0);
 Mockito.when(mockZK.getSessionId()).thenReturn(1L);
 elector.processResult(Code.OK.intValue(), ZK_LOCK_NAME, mockZK, stat);
 Mockito.verify(mockApp, Mockito.times(1)).becomeStandby();
 verifyExistCall(1);
}

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

public void copyStat(Stat to) {
  to.setAversion(stat.getAversion());
  to.setCtime(stat.getCtime());
  to.setCversion(stat.getCversion());
  to.setCzxid(stat.getCzxid());
  to.setMtime(stat.getMtime());
  to.setMzxid(stat.getMzxid());
  to.setVersion(stat.getVersion());
  to.setEphemeralOwner(stat.getEphemeralOwner());
  to.setDataLength(data.length);
  to.setNumChildren(children.size());
}

代码示例来源:origin: ch.cern.hadoop/hadoop-common

/**
 * verify that retry of network errors verifies active by session id and
 * becomes standby if they dont match. monitoring is started.
 */
@Test
public void testCreateNodeResultRetryBecomeStandby() {
 elector.joinElection(data);
 elector.processResult(Code.CONNECTIONLOSS.intValue(), ZK_LOCK_NAME, mockZK,
   ZK_LOCK_NAME);
 elector.processResult(Code.NODEEXISTS.intValue(), ZK_LOCK_NAME, mockZK,
   ZK_LOCK_NAME);
 verifyExistCall(1);
 Stat stat = new Stat();
 stat.setEphemeralOwner(0);
 Mockito.when(mockZK.getSessionId()).thenReturn(1L);
 elector.processResult(Code.OK.intValue(), ZK_LOCK_NAME, mockZK, stat);
 Mockito.verify(mockApp, Mockito.times(1)).becomeStandby();
 verifyExistCall(1);
}

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

synchronized public void copyStat(Stat to) {
  to.setAversion(stat.getAversion());
  to.setCtime(stat.getCtime());
  to.setCversion(stat.getCversion());
  to.setCzxid(stat.getCzxid());
  to.setMtime(stat.getMtime());
  to.setMzxid(stat.getMzxid());
  to.setPzxid(stat.getPzxid());
  to.setVersion(stat.getVersion());
  to.setEphemeralOwner(stat.getEphemeralOwner());
  to.setDataLength(data == null ? 0 : data.length);
  if (this.children == null) {
    to.setNumChildren(0);
  } else {
    to.setNumChildren(children.size());
  }
}

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

static public void copyStat(Stat from, Stat to) {
  to.setAversion(from.getAversion());
  to.setCtime(from.getCtime());
  to.setCversion(from.getCversion());
  to.setCzxid(from.getCzxid());
  to.setMtime(from.getMtime());
  to.setMzxid(from.getMzxid());
  to.setVersion(from.getVersion());
  to.setEphemeralOwner(from.getEphemeralOwner());
  to.setDataLength(from.getDataLength());
  to.setNumChildren(from.getNumChildren());
}

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

static public void copyStat(Stat from, Stat to) {
  to.setAversion(from.getAversion());
  to.setCtime(from.getCtime());
  to.setCversion(from.getCversion());
  to.setCzxid(from.getCzxid());
  to.setMtime(from.getMtime());
  to.setMzxid(from.getMzxid());
  to.setPzxid(from.getPzxid());
  to.setVersion(from.getVersion());
  to.setEphemeralOwner(from.getEphemeralOwner());
  to.setDataLength(from.getDataLength());
  to.setNumChildren(from.getNumChildren());
}

相关文章