我正在使用Aerospike 3.12.1.1和Java 4客户端。
Aerospike命名空间配置为内存。我的目的是使用20个并行线程在内存单bin命名空间中写入1亿个整数,其中每个线程写入500万个。
在写了大约7500万条记录之后,我在客户端遇到了异常。冷冻片段如下。请帮忙。
Exception in thread "pool-1-thread-15" com.aerospike.client.AerospikeException$InvalidNode: Error Code -3: Invalid node
at com.aerospike.client.cluster.Cluster.getRandomNode(Cluster.java:717)
at com.aerospike.client.command.Command.getSequenceNode(Command.java:1050)
at com.aerospike.client.command.Command.getNode(Command.java:1020)
at com.aerospike.client.command.SyncCommand.execute(SyncCommand.java:61)
at com.aerospike.client.AerospikeClient.put(AerospikeClient.java:360)
at Write.run(Write.java:50)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
import com.aerospike.client.AerospikeClient;
import com.aerospike.client.Host;
import com.aerospike.client.policy.ClientPolicy;
import com.aerospike.client.Bin;
import com.aerospike.client.Key;
import com.aerospike.client.Record;
import java.io.*;
public class Write implements Runnable{
int start;
int count;
int end;
private long unixTime;
private long timeTaken;
private long totalTimeTaken;
private long totalRequests;
private long minLatency;
private long maxLatency;
private double avgLatency;
private FileOutputStream out;
public Write(int s, int c){
this.start = s;
this.count = c;
this.end = this.count;
this.totalTimeTaken = 0;
this.totalRequests = 0;
this.minLatency = 1000000;
this.maxLatency = 0;
//try{
// this.out = new FileOutputStream("output.txt");
//}catch(Exception e){
//}
}
public void run(){
Host[] hosts = new Host[] {
new Host("127.0.0.1", 3000),
};
AerospikeClient client = new AerospikeClient(new ClientPolicy(), hosts);
for(int k=this.start; k<=(this.end); k++){
Key key = new Key("mem", null, k);
Bin bin1 = new Bin("m", k+count);
Bin bin2 = new Bin("n", k+count);
Bin bin3 = new Bin("b", k+count);
//Bin bin = Bin.asNull("b");
unixTime = System.nanoTime();
client.put(null, key, bin1, bin2, bin3);
timeTaken = System.nanoTime() - unixTime;
totalTimeTaken += timeTaken;
if(timeTaken < minLatency){
minLatency = timeTaken;
}
if(timeTaken > maxLatency){
maxLatency = timeTaken;
}
totalRequests ++;
}
avgLatency = totalTimeTaken / totalRequests;
System.out.println("TotalReqs:" + totalRequests + " TotalTime:" + totalTimeTaken + " MinLatency:" + ((float)minLatency/1000000.0) + " MaxLatency:" + ((float)maxLatency/1000000.0) + " AvgLatency:" + ((float)avgLatency/1000000.0));
}
}
答案 0 :(得分:3)
为此命名空间定义的内存大小是多少? 您是否使用此命名空间的默认hwm(60%)和默认停止写入(90%)? 此节点上可用的RAM是多少?