gpt4 book ai didi

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

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

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

ZooKeeperUtils.getSubstitutedData介绍

暂无

代码示例

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

public static String getSubstitutedPath(final CuratorFramework curator, String path) throws Exception {
  String normalized = path != null && path.contains("#") ? path.substring(0, path.lastIndexOf('#')) : path;
  if (normalized != null && exists(curator, normalized) != null) {
    byte[] data = ZkPath.loadURL(curator, path);
    if (data != null && data.length > 0) {
      String str = new String(ZkPath.loadURL(curator, path), "UTF-8");
      return getSubstitutedData(curator, str);
    }
  }
  return null;
}

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

public static String getSubstitutedPath(final CuratorFramework curator, String path) throws Exception {
  String normalized = path != null && path.contains("#") ? path.substring(0, path.lastIndexOf('#')) : path;
  if (normalized != null && exists(curator, normalized) != null) {
    byte[] data = ZkPath.loadURL(curator, path);
    if (data != null && data.length > 0) {
      String str = new String(ZkPath.loadURL(curator, path), "UTF-8");
      return getSubstitutedData(curator, str);
    }
  }
  return null;
}

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

protected String getFirstServiceName(String containerPath) throws Exception {
  CuratorFramework curatorFramework = curator.get();
  if (curatorFramework != null) {
    byte[] data = curatorFramework.getData().forPath(containerPath);
    if (data != null && data.length > 0) {
      String text = new String(data).trim();
      if (!text.isEmpty()) {
        ObjectMapper mapper = new ObjectMapper();
        Map<String, Object> map = mapper.readValue(data, HashMap.class);
        Object serviceValue = map.get("services");
        if (serviceValue instanceof List) {
          List services = (List) serviceValue;
          if (!services.isEmpty()) {
            List<String> serviceTexts = new ArrayList<String>();
            for (Object service : services) {
              String serviceText = getSubstitutedData(curatorFramework, service.toString());
              if (io.fabric8.common.util.Strings.isNotBlank(serviceText)) {
                return (String) map.get("container");
              }
            }
          }
        }
      }
    }
  }
  return null;
}

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

public String getContents(String path, boolean escape) throws Exception {
    CuratorFramework curator = getCurator();
    String answer = getStringData(curator, path);
    if (answer != null) {
      return ZooKeeperUtils.getSubstitutedData(curator, answer);
    }
    return answer;
  }
}

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

protected String getFirstService(String containerPath) throws Exception {
  CuratorFramework curatorFramework = curator.get();
  if (curatorFramework != null) {
    byte[] data = curatorFramework.getData().forPath(containerPath);
    if (data != null && data.length > 0) {
      String text = new String(data).trim();
      if (!text.isEmpty()) {
        ObjectMapper mapper = new ObjectMapper();
        Map<String, Object> map = mapper.readValue(data, HashMap.class);
        Object serviceValue = map.get("services");
        if (serviceValue instanceof List) {
          List services = (List) serviceValue;
          if (!services.isEmpty()) {
            List<String> serviceTexts = new ArrayList<String>();
            for (Object service : services) {
              String serviceText = getSubstitutedData(curatorFramework, service.toString());
              if (io.fabric8.common.util.Strings.isNotBlank(serviceText)) {
                return serviceText;
              }
            }
          }
        }
      }
    }
  }
  return null;
}

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

if (value != null) {
  if (value instanceof String && !dontSubstituteKeys.contains(key)) {
    value = getSubstitutedData(curator, value.toString());
  } else if (value instanceof List) {
    List list = (List) value;
    value = substitutedValues;
    for (Object item : list) {
      String serviceText = getSubstitutedData(curator, item.toString());
      substitutedValues.add(serviceText);

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

resolved = ZooKeeperUtils.getSubstitutedData(curator, service);
} catch (Exception e) {

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

private String getWebUrl(String containerPath) throws Exception {
  if (curator.get().checkExists().forPath(containerPath) != null) {
    byte[] bytes = ZkPath.loadURL(curator.get(), containerPath);
    String text = new String(bytes);
    // NOTE this is a bit naughty, we should probably be doing
    // Jackson parsing here; but we only need 1 String and
    // this avoids the jackson runtime dependency - its just a bit brittle
    // only finding http endpoints and all
    String prefix = "\"services\":[\"";
    int idx = text.indexOf(prefix);
    String answer = text;
    if (idx > 0) {
      int startIndex = idx + prefix.length();
      int endIdx = text.indexOf("\"]", startIndex);
      if (endIdx > 0) {
        answer = text.substring(startIndex, endIdx);
        if (answer.length() > 0) {
          // lets expand any variables
          answer = ZooKeeperUtils.getSubstitutedData(curator.get(), answer);
          return answer;
        }
      }
    }
  }
  return null;
}

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

answer =  uri.getScheme() + "://" + hostname + ":" + port + "/" + path;
curator.getZookeeperClient().blockUntilConnectedOrTimedOut();
answer = ZooKeeperUtils.getSubstitutedData(curator, answer);

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

/**
 * Tries to find the prefix for relative jaxws/jaxrs service addresses. It uses discovered CXF servlet prefix and
 * ZK-registered URL of the container
 *
 * @return
 */
private String getAddressPrefix() {
  // TODO: won't work outside of Karaf
  String containerId = System.getProperty("karaf.name");
  if (containerId == null || containerId.trim().equals("")) {
    return "";
  }
  if (curator != null) {
    try {
      // it'll be either http or https
      String httpUrl = "${zk:" + containerId + "/http}";
      String cxfPrefix = cxfContextResolver.getCxfServletContext();
      curator.getZookeeperClient().blockUntilConnectedOrTimedOut();
      httpUrl = ZooKeeperUtils.getSubstitutedData(curator, httpUrl);
      return httpUrl + cxfPrefix;
    } catch (Exception e) {
      LOG.warn(e.getMessage(), e);
      return "";
    }
  } else {
    return "";
  }
}

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

public Processor getProcessor(String uri) throws URISyntaxException {
  uri = ZooKeeperUtils.getSubstitutedData(component.getCurator(), uri);
  LOG.info("Creating endpoint for " + uri);
  final Endpoint endpoint = getCamelContext().getEndpoint(uri);
  return new Processor() {
    public void process(Exchange exchange) throws Exception {
      ProducerCache producerCache = component.getProducerCache();
      Producer producer = producerCache.acquireProducer(endpoint);
      try {
        producer.process(exchange);
      } finally {
        producerCache.releaseProducer(endpoint, producer);
      }
    }
    @Override
    public String toString() {
      return "Producer for " + endpoint;
    }
  };
}

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

answer =  schemes.toString() + uri.getScheme() + "://" + hostname + ":" + port + path;
  getComponent().getCurator().getZookeeperClient().blockUntilConnectedOrTimedOut();
  answer = ZooKeeperUtils.getSubstitutedData(getComponent().getCurator(), answer);
} else {
  answer =  schemes.toString() + uri.getScheme() + "://" + uri.getHost() + ":" + port + path;

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

public Processor getProcessor(String uri) throws URISyntaxException {
  uri = ZooKeeperUtils.getSubstitutedData(component.getCurator(), uri);
  LOG.info("Creating endpoint for " + uri);
  final Endpoint endpoint = getCamelContext().getEndpoint(uri);
  return new Processor() {
    public void process(Exchange exchange) throws Exception {
      ProducerCache producerCache = component.getProducerCache();
      Producer producer = producerCache.acquireProducer(endpoint);
      try {
        producer.process(exchange);
      } finally {
        producerCache.releaseProducer(endpoint, producer);
      }
    }
    @Override
    public String toString() {
      return "Producer for " + endpoint;
    }
  };
}

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

private void updateMasterUrl(Group<GitNode> group) {
  try {
    if (group.isMaster()) {
      LOGGER.debug("Git repo is the master");
      if (!isMaster.getAndSet(true)) {
        registerServlet(dataPath, realm, roles);
      }
    } else {
      LOGGER.debug("Git repo is not the master");
      if (isMaster.getAndSet(false)) {
        unregisterServlet();
      }
    }
    GitNode state = createState();
    group.update(state);
    String url = state.getUrl();
    gitRemoteUrl.set(ZooKeeperUtils.getSubstitutedData(curator.get(), url));
  } catch (Exception e) {
    LOGGER.debug("Failed to update master git server url.", e);
  }
}

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

private void updateMasterUrl(Group<GitNode> group) {
  try {
    if (group.isMaster()) {
      LOGGER.debug("Git repo is the master");
      if (!isMaster.getAndSet(true)) {
        registerServlet(dataPath, realm, role);
      }
    } else {
      LOGGER.debug("Git repo is not the master");
      if (isMaster.getAndSet(false)) {
        unregisterServlet();
      }
    }
    GitNode state = createState();
    group.update(state);
    String url = state.getUrl();
    gitRemoteUrl.set(ZooKeeperUtils.getSubstitutedData(curator.get(), url));
  } catch (Exception e) {
    // Ignore
  }
}

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

/**
 * Updates the git master url, if needed.
 */
private void updateMasterUrl(Group<GitNode> group) {
  GitNode master = group.master();
  String masterUrl = master != null ? master.getUrl() : null;
  try {
    if (masterUrl != null) {
      GitService gitservice = gitService.get();
      String substitutedUrl = getSubstitutedData(curator.get(), masterUrl);
      if (!Strings.isNotBlank(substitutedUrl)) {
        LOGGER.warn("Could not render git master URL {}.", masterUrl);
      }
      //Catch any possible issue indicating that the URL is invalid.
      if (!FabricValidations.isURIValid(substitutedUrl)) {
        LOGGER.warn("Not changing master Git URL to \"" + substitutedUrl + "\". There may be pending ZK connection shutdown.");
      } else {
        gitservice.notifyRemoteChanged(substitutedUrl);
      }
    }
  } catch (Exception e) {
    LOGGER.error("Failed to point origin to the new master.", e);
  }
}

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

/**
 * Updates the git master url, if needed.
 */
private void updateMasterUrl(Group<GitNode> group) {
  GitNode master = group.master();
  String masterUrl = master != null ? master.getUrl() : null;
  try {
    if (masterUrl != null) {
      GitService gitservice = gitService.get();
      String substitutedUrl = getSubstitutedData(curator.get(), masterUrl);
      if (!Strings.isNotBlank(substitutedUrl)) {
        LOGGER.warn("Could not render git master URL {}.", masterUrl);
      }
      //Catch any possible issue indicating that the URL is invalid.
      URIish uri = new URIish(substitutedUrl);
      gitservice.notifyRemoteChanged(substitutedUrl);
    }
  } catch (Exception e) {
    LOGGER.error("Failed to point origin to the new master.", e);
  }
}

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

@Override
public synchronized void groupEvent(Group<InfluxDBNode> group, GroupEvent event) {
  switch (event) {
    case CONNECTED:
      InfluxDBNode master = group.master();
      if (master != null) {
        try {
          String url = getSubstitutedData(curator.get(), master.getUrl());
          influxDB = InfluxDBFactory.connect(url, "root", "root");
          unregister();
          registration = bundleContext.registerService(InfluxDB.class, influxDB, null);
        } catch (URISyntaxException e) {
          throw FabricException.launderThrowable(e);
        }
      }
    case CHANGED:
      break;
    case DISCONNECTED:
      unregister();
  }
}

代码示例来源:origin: io.fabric8.insight/insight-influxdb-metrics

@Override
public synchronized void groupEvent(Group<InfluxDBNode> group, GroupEvent event) {
  switch (event) {
    case CONNECTED:
      InfluxDBNode master = group.master();
      if (master != null) {
        try {
          String url = getSubstitutedData(curator.get(), master.getUrl());
          influxDB = InfluxDBFactory.connect(url, "root", "root");
          unregister();
          registration = bundleContext.registerService(InfluxDB.class, influxDB, null);
        } catch (URISyntaxException e) {
          throw FabricException.launderThrowable(e);
        }
      }
    case CHANGED:
      break;
    case DISCONNECTED:
      unregister();
  }
}

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

Map<String, String> zookeeperConfig = profile.getConfiguration(Constants.ZOOKEEPER_CLIENT_PID);
if (zookeeperConfig != null) {
  zooKeeperUrl = getSubstitutedData(curator.get(), zookeeperConfig.get(name));

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