使用多个客户端执行并发更新时出现以下错误。在Apache Jmeter中创建了多个客户端线程。
2016/11/03 15:00:57错误 - jmeter.threads.JMeterThread:处理采样器'Java Request'时出错:java.lang.NullPointerException at ignite_client_jmeter.new_order(ignite_client_jmeter.java:857) at ignite_client_jmeter.runTest(ignite_client_jmeter.java:1659) 在org.apache.jmeter.protocol.java.sampler.JavaSampler.sample(JavaSampler.java:196) 在org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:465) 在org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:410) 在org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:241) 在java.lang.Thread.run(Thread.java:745)
以下是访问使用缓存get()操作检索的数据时在第857行发生错误的部分。代码适用于单个客户端。但是对于超过1个客户端,它会抛出上面提到的NullPointerException错误。
更新查询
//UPDATE district SET d_next_o_id = ? + 1 WHERE d_id = ? AND d_w_id = ?
districtKey dkey = new districtKey(district_num, warehouse_num);
System.out.println("Thread_ id = "+thread_num+", district_num = "+district_num+", warehouse_num = "+warehouse_num);
IgniteTransactions transactions = ignite.transactions();
try (Transaction tx = ignite.transactions().txStart(TransactionConcurrency.PESSIMISTIC,
TransactionIsolation.SERIALIZABLE)) {
district dist = (district) cache_district.get(dkey);
assert dist != null;
if(dist == null)
System.out.println("......Thread_ id = "+thread_num+", district_num = "+district_num+", warehouse_num = "+warehouse_num);
dist.d_next_o_id = d_next_o_id + 1; //Line number 857
d_next_o_id = d_next_o_id + 1;
cache_district.put(dkey, dist);
tx.commit();
}
catch (CacheException e) {
if (e.getCause() instanceof TransactionTimeoutException &&
e.getCause().getCause() instanceof TransactionDeadlockException)
System.out.println(e.getCause().getCause().getMessage());
}
Integer o_id;
o_id = d_next_o_id;