gpt4 book ai didi

io.fabric8.groups.internal.ZooKeeperGroup类的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 00:58:49 27 4
gpt4 key购买 nike

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

ZooKeeperGroup介绍

[英]A utility that attempts to keep all data from all children of a ZK path locally cached. This class will watch the ZK path, respond to update/create/delete events, pull down the data, etc. You can register a listener that will get notified when changes occur.

IMPORTANT - it's not possible to stay transactionally in sync. Users of this class must be prepared for false-positives and false-negatives. Additionally, always use the version number when updating data to avoid overwriting another process' change.
[中]试图将ZK路径的所有子级的所有数据本地缓存的实用程序。这个类将监视ZK路径,响应更新/创建/删除事件,下拉数据,等等。您可以注册一个监听器,当发生更改时会收到通知。
重要信息-不可能保持交易同步。这门课的用户必须为假阳性和假阴性做好准备。此外,在更新数据时始终使用版本号,以避免覆盖另一个进程的更改。

代码示例

代码示例来源:origin: io.fabric8/fabric-groups

@Override
public <T extends NodeState> Group<T> createGroup(String path, Class<T> clazz) {
  return new ZooKeeperGroup<T>(curator, path, clazz);
}

代码示例来源:origin: io.fabric8/fabric-groups

/**
 * Clear out current data and begin a new query on the path
 *
 * @throws Exception errors
 */
public void clearAndRefresh() throws Exception {
  clearAndRefresh(false, false);
}

代码示例来源:origin: fabric8io/jube

@Inject
public Replicator(CuratorFramework curator,
         ApiMasterKubernetesModel model,
         ProcessManager processManager,
         @ConfigProperty(name = "REPLICATOR_POLL_TIME", defaultValue = "2000")
         long pollTime) {
  this.curator = curator;
  this.model = model;
  this.processManager = processManager;
  this.pollTime = pollTime;
  System.out.println("Starting the replicator with poll time: " + pollTime);
  group = new ZooKeeperGroup<ReplicatorNode>(curator, KUBERNETES_REPLICATOR, ReplicatorNode.class);
  groupListener = new GroupListener<ReplicatorNode>() {
    @Override
    public void groupEvent(Group<ReplicatorNode> group, GroupEvent event) {
      onGroupEvent(group, event);
    }
  };
  group.add(groupListener);
  group.update(createState());
  group.start();
  enableTimer();
}

代码示例来源:origin: io.fabric8/fabric-groups

protected void doUpdate(T state) throws Exception {
  if (isConnected()) {
    if (state == null) {
      if (id != null) {
      if (id == null) {
        refresh(RefreshMode.FORCE_GET_DATA_AND_STAT);
        Map<String, T> members = members();
        for (Map.Entry<String, T> entry : members.entrySet()) {
          T v = entry.getValue();
        id = client.create().creatingParentsIfNeeded()
          .withMode(CreateMode.EPHEMERAL_SEQUENTIAL)
          .forPath(path + "/0", encode(state));
      } else {
        try {
          client.setData().forPath(id, encode(state));
        } catch (KeeperException.NoNodeException e) {
          id = client.create().creatingParentsIfNeeded()
              .withMode(CreateMode.EPHEMERAL_SEQUENTIAL)
              .forPath(path + "/0", encode(state));

代码示例来源:origin: io.fabric8/fabric-groups

@Override
  public void process(WatchedEvent event) {
    try {
      if (event.getType() == Event.EventType.NodeDeleted) {
        remove(event.getPath());
      } else if (event.getType() == Event.EventType.NodeDataChanged) {
        offerOperation(new GetDataOperation(ZooKeeperGroup.this, event.getPath()));
      }
    } catch (Exception e) {
      handleException(e);
    }
  }
};

代码示例来源:origin: jboss-fuse/fabric8

private void processChildren(List<String> children, RefreshMode mode) throws Exception {
  List<String> fullPaths = Lists.newArrayList(Lists.transform
      (
          children,
          new Function<String, String>() {
            @Override
            public String apply(String child) {
              return ZKPaths.makePath(path, child);
            }
          }
      ));
  Set<String> removedNodes = Sets.newHashSet(currentData.keySet());
  removedNodes.removeAll(fullPaths);
  for (String fullPath : removedNodes) {
    remove(fullPath);
  }
  for (String name : children) {
    String fullPath = ZKPaths.makePath(path, name);
    if ((mode == RefreshMode.FORCE_GET_DATA_AND_STAT) || !currentData.containsKey(fullPath)) {
      getDataAndStat(fullPath);
    }
  }
}

代码示例来源:origin: io.fabric8.mq/mq-http-discovery

Map<String, ActiveMQNode> members = ZooKeeperGroup.members(curator, "/fabric/registry/clusters/amq/" + groupName, ActiveMQNode.class);
HashSet<String> masters = new HashSet<String>();
StringBuilder buff = new StringBuilder();

代码示例来源:origin: fabric8io/jube

@PreDestroy
public void destroy() {
  disableTimer();
  group.remove(groupListener);
  Closeables.closeQuietly(group);
  group = null;
  disableTimer();
}

代码示例来源:origin: jboss-fuse/fabric8

@Override
  public void process(WatchedEvent event) {
    try {
      if (event.getType() == Event.EventType.NodeDeleted) {
        remove(event.getPath());
      } else if (event.getType() == Event.EventType.NodeDataChanged) {
        offerOperation(new GetDataOperation(ZooKeeperGroup.this, event.getPath()));
      }
    } catch (Exception e) {
      handleException(e);
    }
  }
};

代码示例来源:origin: io.fabric8/fabric-groups

private void processChildren(List<String> children, RefreshMode mode) throws Exception {
  List<String> fullPaths = Lists.newArrayList(Lists.transform
      (
          children,
          new Function<String, String>() {
            @Override
            public String apply(String child) {
              return ZKPaths.makePath(path, child);
            }
          }
      ));
  Set<String> removedNodes = Sets.newHashSet(currentData.keySet());
  removedNodes.removeAll(fullPaths);
  for (String fullPath : removedNodes) {
    remove(fullPath);
  }
  for (String name : children) {
    String fullPath = ZKPaths.makePath(path, name);
    if ((mode == RefreshMode.FORCE_GET_DATA_AND_STAT) || !currentData.containsKey(fullPath)) {
      try {
        getDataAndStat(fullPath);
      } catch (KeeperException.NoNodeException ignore) {}
    }
  }
}

代码示例来源:origin: jboss-fuse/fabric8

Map<String, ActiveMQNode> members = ZooKeeperGroup.members(MAPPER, curator, "/fabric/registry/clusters/amq/" + groupName, ActiveMQNode.class);
HashSet<String> masters = new HashSet<String>();
StringBuilder buff = new StringBuilder();

代码示例来源:origin: io.fabric8/fabric-groups

@Override
public <T extends NodeState> Group<T> createGroup(String path, Class<T> clazz) {
  return new ZooKeeperGroup<T>(curator, path, clazz);
}

代码示例来源:origin: jboss-fuse/fabric8

/**
 * Clear out current data and begin a new query on the path
 *
 * @throws Exception errors
 */
public void clearAndRefresh() throws Exception {
  clearAndRefresh(false, false);
}

代码示例来源:origin: jboss-fuse/fabric8

@Override
public <T extends NodeState> Group<T> createGroup(String path, Class<T> clazz, ThreadFactory threadFactory) {
  return new ZooKeeperGroup<T>(curator, path, clazz, threadFactory);
}

代码示例来源:origin: jboss-fuse/fabric8

public void setGroup(final Group<CxfNodeState> group) throws Exception {
  this.group = group;
  group.add(new GroupListener<CxfNodeState>() {
    @Override
    public void groupEvent(Group<CxfNodeState> group, GroupEvent event) {
      onUpdate(group);
    }
  });
  if (group instanceof ZooKeeperGroup) {
    // trigger refresh synchronously so we have up to date state before being used by clients
    ((ZooKeeperGroup) group).clearAndRefresh(true, true);
  }
}

代码示例来源:origin: jboss-fuse/fabric8

@Override
public <T extends NodeState> Group<T> createGroup(String path, Class<T> clazz) {
  return new ZooKeeperGroup<T>(curator, path, clazz);
}

代码示例来源:origin: jboss-fuse/fabric8

private void prunePartialState(final T ourState, final String pathId) throws Exception {
  if (ourState.uuid != null) {
    clearAndRefresh(true, true);
    List<ChildData<T>> children = new ArrayList<ChildData<T>>(currentData.values());
    for (ChildData<T> child : children) {
      if (ourState.uuid.equals(child.getNode().uuid) && !child.getPath().equals(pathId)) {
        LOG.debug("Deleting partially created znode: " + child.getPath());
        client.delete().guaranteed().forPath(child.getPath());
      }
    }
  }
}

代码示例来源:origin: jboss-fuse/fabric8

@Override
public <T extends NodeState> Group<T> createGroup(String path, Class<T> clazz) {
  return new ZooKeeperGroup<T>(curator, path, clazz);
}

代码示例来源:origin: jboss-fuse/fabric8

@Override
public <T extends NodeState> Group<T> createGroup(String path, Class<T> clazz, ThreadFactory threadFactory) {
  return new ZooKeeperGroup<T>(curator, path, clazz, threadFactory);
}

代码示例来源:origin: jboss-fuse/fabric8

protected Group<T> createGroup(CuratorFramework client, String path, Class<T> clazz) {
  return new ZooKeeperGroup<T>(client, path, clazz);
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com