当前位置: 首页>>代码示例>>Java>>正文


Java AerospikeClient.getNodes方法代码示例

本文整理汇总了Java中com.aerospike.client.AerospikeClient.getNodes方法的典型用法代码示例。如果您正苦于以下问题:Java AerospikeClient.getNodes方法的具体用法?Java AerospikeClient.getNodes怎么用?Java AerospikeClient.getNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.aerospike.client.AerospikeClient的用法示例。


在下文中一共展示了AerospikeClient.getNodes方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setServerSpecificParameters

import com.aerospike.client.AerospikeClient; //导入方法依赖的package包/类
/**
 * Retrieves and sets the server specific parameters
 * Validates the existence of user provided namespace and validates for single binned
 * namespaces
 *
 * @param client aerospike client used to connect with the server
 */
public void setServerSpecificParameters(AerospikeClient client) {

  String namespaceTokens = null;
  for (Node node : client.getNodes()) {
    String namespaceFilter = "namespace/" + aerospikeMapping.getNamespace();
    namespaceTokens = Info.request(null, node, namespaceFilter);

    if (namespaceTokens != null) {
      isSingleBinEnabled = parseBoolean(namespaceTokens, "single-bin");
      break;
    }
  }
  if (namespaceTokens == null) {
    LOG.error("Failed to get namespace info from Aerospike");
    throw new RuntimeException("Failed to get namespace info from Aerospike");
  }
}
 
开发者ID:apache,项目名称:gora,代码行数:25,代码来源:AerospikeParameters.java

示例2: printNodes

import com.aerospike.client.AerospikeClient; //导入方法依赖的package包/类
public static void printNodes(AerospikeClient client) {
    if (client == null) {
        LOG.warn("null client has been sent returning");
        return;
    }
    for (Node node : client.getNodes()) {
        LOG.info("node name is " + node.getAddress().getHostString());
    }
}
 
开发者ID:maverickgautam,项目名称:Aerospike-unit,代码行数:10,代码来源:AerospikeUtils.java

示例3: infoAll

import com.aerospike.client.AerospikeClient; //导入方法依赖的package包/类
public static String[] infoAll(AerospikeClient client, String name) {
  String[] result = new String[client.getNodes().length];
  int i = 0;
  for (Node node : client.getNodes()) {
    result[i++] = info(node, name);
  }
  return result;
}
 
开发者ID:aerospike,项目名称:geospatial-samples,代码行数:9,代码来源:InfoParser.java

示例4: infoAll

import com.aerospike.client.AerospikeClient; //导入方法依赖的package包/类
/**
 * Sends an "Info" command to all nodes in the cluster
 *
 * @param client AerospikeClient instance
 * @param cmd	Info command to be sent to the cluster
 * @return A string containing the results from all nodes in the cluster
 */
public static String infoAll(AerospikeClient client, String cmd) {
	Node[] nodes = client.getNodes();
	StringBuilder results = new StringBuilder();
	for (Node node : nodes) {
		results.append(Info.request(node.getHost().name, node.getHost().port, cmd)).append("\n");
	}
	return results.toString();
}
 
开发者ID:aerospike,项目名称:aerospike-helper,代码行数:16,代码来源:Utils.java

示例5: getSplits

import com.aerospike.client.AerospikeClient; //导入方法依赖的package包/类
public org.apache.hadoop.mapred.InputSplit[]
    getSplits(JobConf job, int numSplits) throws IOException {
    try {

        String oper = AerospikeConfigUtil.getInputOperation(job);
        String host = AerospikeConfigUtil.getInputHost(job);
        int port = AerospikeConfigUtil.getInputPort(job);
        String namespace = AerospikeConfigUtil.getInputNamespace(job);
        String setName = AerospikeConfigUtil.getInputSetName(job);
        String[] binNames = AerospikeConfigUtil.getInputBinNames(job);
        String numrangeBin = "";
        long numrangeBegin = 0;
        long numrangeEnd = 0;
        if (oper.equals("numrange")) {
            numrangeBin = AerospikeConfigUtil.getInputNumRangeBin(job);
            numrangeBegin = AerospikeConfigUtil.getInputNumRangeBegin(job);
            numrangeEnd = AerospikeConfigUtil.getInputNumRangeEnd(job);
        }
        
        log.info(String.format("using: %s %d %s %s",
                               host, port, namespace, setName));

        AerospikeClient client =
            AerospikeClientSingleton.getInstance(new ClientPolicy(),
                                                 host, port);
        Node[] nodes = client.getNodes();
        int nsplits = nodes.length;
        if (nsplits == 0) {
            throw new IOException("no Aerospike nodes found");
        }
        log.info(String.format("found %d nodes", nsplits));
        AerospikeSplit[] splits = new AerospikeSplit[nsplits];
        for (int ii = 0; ii < nsplits; ii++) {
            Node node = nodes[ii];
            String nodeName = node.getName();

            // We want to avoid 127.0.0.1 as a hostname
            // because this value will be transferred to a
            // different hadoop node to be processed.
            //
            Host[] aliases = node.getAliases();
            Host nodehost = aliases[0];
            if (aliases.length > 1) {
                for (int jj = 0; jj < aliases.length; ++jj) {
                    if (!aliases[jj].name.equals("127.0.0.1")) {
                        nodehost = aliases[jj];
                        break;
                    }
                }
            }
            splits[ii] = new AerospikeSplit(oper, nodeName,
                                            nodehost.name, nodehost.port,
                                            namespace, setName, binNames,
                                            numrangeBin, numrangeBegin,
                                            numrangeEnd);
            log.info("split: " + splits[ii]);
        }
        return splits;
    }
    catch (Exception ex) {
        throw new IOException("exception in getSplits", ex);
    }
}
 
开发者ID:Stratio,项目名称:deep-spark,代码行数:64,代码来源:AerospikeInputFormat.java

示例6: getSplits

import com.aerospike.client.AerospikeClient; //导入方法依赖的package包/类
public org.apache.hadoop.mapred.InputSplit[]
    getSplits(JobConf job, int numSplits) throws IOException {
    try {

        String oper = AerospikeConfigUtil.getInputOperation(job);
        String host = AerospikeConfigUtil.getInputHost(job);
        int port = AerospikeConfigUtil.getInputPort(job);
        String namespace = AerospikeConfigUtil.getInputNamespace(job);
        String setName = AerospikeConfigUtil.getInputSetName(job);
        String[] binNames = AerospikeConfigUtil.getInputBinNames(job);
        String numrangeBin = "";
        long numrangeBegin = 0;
        long numrangeEnd = 0;
        int scanPercent = 100;
        if (oper.equals("numrange")) {
            numrangeBin = AerospikeConfigUtil.getInputNumRangeBin(job);
            numrangeBegin = AerospikeConfigUtil.getInputNumRangeBegin(job);
            numrangeEnd = AerospikeConfigUtil.getInputNumRangeEnd(job);
        } else if (oper.equals("scan")) {
            scanPercent = AerospikeConfigUtil.getInputScanPercent(job);
        }
        
        log.info(String.format("using: %s %d %s %s",
                               host, port, namespace, setName));

        AerospikeClient client =
            AerospikeClientSingleton.getInstance(new ClientPolicy(),
                                                 host, port);
        Node[] nodes = client.getNodes();
        int nsplits = nodes.length;
        if (nsplits == 0) {
            throw new IOException("no Aerospike nodes found");
        }
        log.info(String.format("found %d nodes", nsplits));
        AerospikeSplit[] splits = new AerospikeSplit[nsplits];
        for (int ii = 0; ii < nsplits; ii++) {
            Node node = nodes[ii];
            String nodeName = node.getName();

            // We want to avoid 127.0.0.1 as a hostname
            // because this value will be transferred to a
            // different hadoop node to be processed.
            //
            List<Host> aliases = getAliases(node.getHost());
            Host nodehost = aliases.get(0);
            if (aliases.size() > 1) {
                for (Host a : aliases) {
                    if (!a.name.equals("127.0.0.1")) {
                        nodehost = a;
                        break;
                    }
                }
            }
            splits[ii] = new AerospikeSplit(oper, nodeName,
                                            nodehost.name, nodehost.port,
                                            namespace, setName, binNames,
                                            numrangeBin, numrangeBegin,
                                            numrangeEnd, scanPercent);
            log.info("split: " + splits[ii]);
        }
        return splits;
    }
    catch (Exception ex) {
        throw new IOException("exception in getSplits", ex);
    }
}
 
开发者ID:aerospike,项目名称:aerospike-hadoop,代码行数:67,代码来源:AerospikeInputFormat.java


注:本文中的com.aerospike.client.AerospikeClient.getNodes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。