本文整理汇总了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");
}
}
示例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());
}
}
示例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;
}
示例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();
}
示例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);
}
}
示例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);
}
}