gpt4 book ai didi

io.fabric8.zookeeper.utils.ZooKeeperUtils.delete()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-16 11:18:40 30 4
gpt4 key购买 nike

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

ZooKeeperUtils.delete介绍

[英]Deletes a path and (when there are no other children) also parent path - up to given parent
[中]删除一个路径,并且(当没有其他子路径时)还删除父路径,直到给定的父路径

代码示例

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

protected void unExportService(final ServiceReference reference) {
  try {
    ExportRegistration registration = exportedServices.remove(reference);
    if (registration != null) {
      server.unregisterService(registration.getExportedEndpoint().getId());
      delete(curator, registration.getZooKeeperNode());
    }
  } catch (Exception e) {
    LOGGER.info("Error when unexporting endpoint", e);
  }
}

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

/**
 * Unregister a webapp from the registry.
 * @param container
 * @param webEvent
 */
private void unRegisterWebapp(Container container, WebEvent webEvent) {
  try {
    String name = webEvent.getBundle().getSymbolicName();
    clearJolokiaUrl(container, name);
    webEvents.remove(webEvent.getBundle());
    delete(curator.get(), ZkPath.WEBAPPS_CONTAINER.getPath(name, webEvent.getBundle().getVersion().toString(), container.getId()));
  } catch (KeeperException.NoNodeException e) {
    // If the node does not exists, ignore the exception
  } catch (Exception e) {
    LOGGER.error("Failed to unregister webapp {}.", webEvent.getContextPath(), e);
  }
}

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

private void unregisterServlet(Container container, ServletEvent servletEvent) {
  try {
    String bundleName = servletEvent.getBundle().getSymbolicName();
    String bundleVersion = servletEvent.getBundle().getVersion().toString();
    clearJolokiaUrl(container, bundleName);
    Map<String, ServletEvent> events = servletEvents.get(servletEvent.getBundle());
    if (events != null) {
      events.remove(servletEvent.getAlias());
    }
    String id = container.getId();
    //We don't want to register / it's fabric-redirect for hawtio
    if (!servletEvent.getAlias().equals("/")) {
      String path = createServletPath(servletEvent, id, bundleName, bundleVersion);
      delete(curator.get(), path);
    }
  } catch (KeeperException.NoNodeException e) {
    // If the node does not exists, ignore the exception
  } catch (Exception e) {
    LOGGER.error("Failed to unregister servlet {}.", servletEvent.getAlias(), e);
  }
}

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

private void updateProcessId() {
  try {
    // TODO: this is Sun JVM specific ...
    //String processName = (String) mbeanServer.get().getAttribute(new ObjectName("java.lang:type=Runtime"), "Name");
    String processName = ManagementFactory.getRuntimeMXBean().getName();
    Long processId = Long.parseLong(processName.split("@")[0]);
    String runtimeIdentity = runtimeProperties.get().getRuntimeIdentity();
    String path = ZkPath.CONTAINER_PROCESS_ID.getPath(runtimeIdentity);
    Stat stat = exists(curator.get(), path);
    if (stat != null) {
      if (stat.getEphemeralOwner() != curator.get().getZookeeperClient().getZooKeeper().getSessionId()) {
        delete(curator.get(), path);
        if( processId!=null ) {
          create(curator.get(), path, processId.toString(), CreateMode.EPHEMERAL);
        }
      }
    } else {
      if( processId!=null ) {
        create(curator.get(), path, processId.toString(), CreateMode.EPHEMERAL);
      }
    }
  } catch (IllegalStateException e){
    handleException(e);
  } catch (Exception ex) {
    LOGGER.error("Error while updating the process id.", ex);
  }
}

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

@Override
  public void run() {
    if (isValid()) {
      String extender = getExtenderType();
      try {
        if (bundleStatus != null) {
          setData(getCurator(), ZkPath.CONTAINER_EXTENDER_BUNDLE.getPath(runtimeIdentity, extender, String.valueOf(bundleId)),
              bundleStatus.name(), CreateMode.EPHEMERAL);
        } else {
          delete(getCurator(), ZkPath.CONTAINER_EXTENDER_BUNDLE.getPath(runtimeIdentity, extender, String.valueOf(bundleId)));
        }
        setData(getCurator(), ZkPath.CONTAINER_EXTENDER_STATUS.getPath(runtimeIdentity, extender),
            extenderStatus.name(), CreateMode.EPHEMERAL);
      } catch (Exception e) {
        LOGGER.debug("Failed to update status of bundle {} for extender {}.", bundleId, extender);
      }
    }
  }
});

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

@Override
  public void run() {
    if (isValid()) {
      String extender = getExtenderType();
      try {
        if (bundleStatus != null) {
          setData(getCurator(), ZkPath.CONTAINER_EXTENDER_BUNDLE.getPath(runtimeIdentity, extender, String.valueOf(bundleId)),
              bundleStatus.name(), CreateMode.EPHEMERAL);
        } else {
          delete(getCurator(), ZkPath.CONTAINER_EXTENDER_BUNDLE.getPath(runtimeIdentity, extender, String.valueOf(bundleId)));
        }
        setData(getCurator(), ZkPath.CONTAINER_EXTENDER_STATUS.getPath(runtimeIdentity, extender),
            extenderStatus.name(), CreateMode.EPHEMERAL);
      } catch (Exception e) {
        LOGGER.debug("Failed to update status of bundle {} for extender {}.", bundleId, extender);
      }
    }
  }
});

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

private void zkCleanUp(Group<GitNode> group) {
  try {
    RuntimeProperties sysprops = runtimeProperties.get();
    String runtimeIdentity = sysprops.getRuntimeIdentity();
    curator.get().newNamespaceAwareEnsurePath(ZkPath.GIT.getPath()).ensure(curator.get().getZookeeperClient());
    List<String> allChildren = ZooKeeperUtils.getAllChildren(curator.get(), ZkPath.GIT.getPath());
    for (String path : allChildren) {
      String stringData = ZooKeeperUtils.getStringData(curator.get(), path);
      if (stringData.contains("\"container\":\"" + runtimeIdentity + "\"")) {
        LOGGER.info("Found older ZK \"/fabric/registry/clusters/git\" entry for node " + runtimeIdentity);
        ZooKeeperUtils.delete(curator.get(), path);
        LOGGER.info("Older ZK \"/fabric/registry/clusters/git\" entry for node " + runtimeIdentity + " has been removed");
      }
    }
  } catch (KeeperException.NoNodeException ignored) {
  } catch (Exception e) {
    handleException( e);
  }
}

代码示例来源:origin: io.fabric8.runtime/fabric-runtime-container-wildfly-registration

private void checkAlive() throws Exception {
  RuntimeProperties sysprops = runtimeProperties.get();
  String runtimeIdentity = sysprops.getRuntimeIdentity();
  String nodeAlive = CONTAINER_ALIVE.getPath(runtimeIdentity);
  Stat stat = ZooKeeperUtils.exists(curator.get(), nodeAlive);
  if (stat != null) {
    if (stat.getEphemeralOwner() != curator.get().getZookeeperClient().getZooKeeper().getSessionId()) {
      ZooKeeperUtils.delete(curator.get(), nodeAlive);
      ZooKeeperUtils.create(curator.get(), nodeAlive, CreateMode.EPHEMERAL);
    }
  } else {
    ZooKeeperUtils.create(curator.get(), nodeAlive, CreateMode.EPHEMERAL);
  }
}

代码示例来源:origin: io.fabric8.runtime/fabric-runtime-container-tomcat-registration

private void checkAlive() throws Exception {
  RuntimeProperties sysprops = runtimeProperties.get();
  String runtimeIdentity = sysprops.getRuntimeIdentity();
  String nodeAlive = CONTAINER_ALIVE.getPath(runtimeIdentity);
  Stat stat = ZooKeeperUtils.exists(curator.get(), nodeAlive);
  if (stat != null) {
    if (stat.getEphemeralOwner() != curator.get().getZookeeperClient().getZooKeeper().getSessionId()) {
      ZooKeeperUtils.delete(curator.get(), nodeAlive);
      ZooKeeperUtils.create(curator.get(), nodeAlive, CreateMode.EPHEMERAL);
    }
  } else {
    ZooKeeperUtils.create(curator.get(), nodeAlive, CreateMode.EPHEMERAL);
  }
}

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

private void checkAlive() throws Exception {
  RuntimeProperties sysprops = runtimeProperties.get();
  String runtimeIdentity = sysprops.getRuntimeIdentity();
  String nodeAlive = CONTAINER_ALIVE.getPath(runtimeIdentity);
  Stat stat = exists(curator.get(), nodeAlive);
  if (stat != null) {
    if (stat.getEphemeralOwner() != curator.get().getZookeeperClient().getZooKeeper().getSessionId()) {
      delete(curator.get(), nodeAlive);
      create(curator.get(), nodeAlive, CreateMode.EPHEMERAL);
    }
  } else {
    create(curator.get(), nodeAlive, CreateMode.EPHEMERAL);
  }
}

代码示例来源:origin: io.fabric8.runtime/fabric-runtime-container-karaf-registration

private void checkAlive() throws Exception {
  RuntimeProperties sysprops = runtimeProperties.get();
  String runtimeIdentity = sysprops.getRuntimeIdentity();
  String nodeAlive = CONTAINER_ALIVE.getPath(runtimeIdentity);
  Stat stat = exists(curator.get(), nodeAlive);
  if (stat != null) {
    if (stat.getEphemeralOwner() != curator.get().getZookeeperClient().getZooKeeper().getSessionId()) {
      delete(curator.get(), nodeAlive);
      create(curator.get(), nodeAlive, CreateMode.EPHEMERAL);
    }
  } else {
    create(curator.get(), nodeAlive, CreateMode.EPHEMERAL);
  }
}

代码示例来源:origin: io.fabric8.runtime/embedded

private void checkAlive() throws Exception {
  RuntimeProperties sysprops = runtimeProperties.get();
  String karafName = sysprops.getProperty(SystemProperties.KARAF_NAME);
  String nodeAlive = CONTAINER_ALIVE.getPath(karafName);
  Stat stat = ZooKeeperUtils.exists(curator.get(), nodeAlive);
  if (stat != null) {
    if (stat.getEphemeralOwner() != curator.get().getZookeeperClient().getZooKeeper().getSessionId()) {
      ZooKeeperUtils.delete(curator.get(), nodeAlive);
      ZooKeeperUtils.create(curator.get(), nodeAlive, CreateMode.EPHEMERAL);
    }
  } else {
    ZooKeeperUtils.create(curator.get(), nodeAlive, CreateMode.EPHEMERAL);
  }
}

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

private void checkAlive() throws Exception {
  RuntimeProperties sysprops = runtimeProperties.get();
  String runtimeIdentity = sysprops.getRuntimeIdentity();
  String nodeAlive = CONTAINER_ALIVE.getPath(runtimeIdentity);
  Stat stat = ZooKeeperUtils.exists(curator.get(), nodeAlive);
  if (stat != null) {
    if (stat.getEphemeralOwner() != curator.get().getZookeeperClient().getZooKeeper().getSessionId()) {
      ZooKeeperUtils.delete(curator.get(), nodeAlive);
      ZooKeeperUtils.create(curator.get(), nodeAlive, CreateMode.EPHEMERAL);
    }
  } else {
    ZooKeeperUtils.create(curator.get(), nodeAlive, CreateMode.EPHEMERAL);
  }
}

代码示例来源:origin: io.fabric8.runtime/fabric8-runtime-container-tomcat-registration

private void checkAlive() throws Exception {
  RuntimeProperties sysprops = runtimeProperties.get();
  String runtimeIdentity = sysprops.getRuntimeIdentity();
  String nodeAlive = CONTAINER_ALIVE.getPath(runtimeIdentity);
  Stat stat = ZooKeeperUtils.exists(curator.get(), nodeAlive);
  if (stat != null) {
    if (stat.getEphemeralOwner() != curator.get().getZookeeperClient().getZooKeeper().getSessionId()) {
      ZooKeeperUtils.delete(curator.get(), nodeAlive);
      ZooKeeperUtils.create(curator.get(), nodeAlive, CreateMode.EPHEMERAL);
    }
  } else {
    ZooKeeperUtils.create(curator.get(), nodeAlive, CreateMode.EPHEMERAL);
  }
}

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