@Override public void sampleEnd() { if (subSample != null) { subSampleEnd(true); } if (getEndTime() == 0) { super.sampleEnd(); } } }
/** * Mark the sample result as @{code end}ed and not {@code successful}, and set the * {@code responseCode} to {@code reason}. * * @param result the sample result to change * @param reason the failure reason */ private void sampleResultFailed(SampleResult result, String reason) { result.sampleEnd(); result.setSuccessful(false); result.setResponseCode(reason); }
private ByteArrayOutputStream readResponse(SampleResult res) throws IOException { ByteArrayOutputStream response = new ByteArrayOutputStream(); int cnt = 0; ByteBuffer recvBuf = getRecvBuf(); recvBuf.clear(); if ((cnt = channel.read(recvBuf)) != -1) { res.latencyEnd(); //log.debug("Read " + recvBuf.toString()); recvBuf.flip(); byte[] bytes = new byte[cnt]; recvBuf.get(bytes); response.write(bytes); recvBuf.clear(); } res.sampleEnd(); res.setBytes(response.size()); return response; }
/*************************************************************************** * This will do the unbind for the User defined TestCase as well as inbuilt * test case * **************************************************************************/ private void unbindOp(DirContext dirContext, SampleResult res) { try { res.sampleStart(); LdapExtClient.disconnect(dirContext); } finally { res.sampleEnd(); } ldapContexts.remove(getThreadName()); log.info("context and LdapExtClients removed"); }
private ByteArrayOutputStream readResponse(SampleResult res) throws IOException { ByteArrayOutputStream response = new ByteArrayOutputStream(); int cnt; ByteBuffer recvBuf = getRecvBuf(); recvBuf.clear(); if ((cnt = channel.read(recvBuf)) != -1) { res.latencyEnd(); //log.debug("Read " + recvBuf.toString()); recvBuf.flip(); byte[] bytes = new byte[cnt]; recvBuf.get(bytes); response.write(bytes); recvBuf.clear(); } res.latencyEnd(); res.sampleEnd(); res.setBytes(response.size()); return response; }
/*************************************************************************** * This will do the delete test for the User defined TestCase * **************************************************************************/ private void deleteTest(DirContext dirContext, SampleResult res) throws NamingException { try { res.sampleStart(); LdapExtClient.deleteTest(dirContext, getPropertyAsString(DELETE)); } finally { res.sampleEnd(); } }
private byte[] noResponseFinish(SampleResult res) throws IOException { res.latencyEnd(); res.sampleEnd(); if (isCloseChannel()) { channel.close(); } return new byte[0]; }
public void subSampleEnd(boolean success) { if (subSample == null) { log.warn("There is no sub-sample started, use subSampleStart() to have one"); return; } subSample.sampleEnd(); subSample.setSuccessful(success); super.addSubResult(subSample); subSample = null; }
/*************************************************************************** * This will do the add test for the User defined TestCase * **************************************************************************/ private void addTest(DirContext dirContext, SampleResult res) throws NamingException { try { res.sampleStart(); DirContext ctx = LdapExtClient.createTest(dirContext, getUserAttributes(), getBaseEntryDN()); ctx.close(); // the createTest() method creates an extra context which needs to be closed } finally { res.sampleEnd(); } }
/*************************************************************************** * This will do a moddn Opp for the User new DN defined * **************************************************************************/ private void renameTest(DirContext dirContext, SampleResult res) throws NamingException { try { res.sampleStart(); LdapExtClient.moddnOp(dirContext, getPropertyAsString(MODDDN), getPropertyAsString(NEWDN)); } finally { res.sampleEnd(); } }
/*************************************************************************** * This will do the modify test for the User defined TestCase * **************************************************************************/ private void modifyTest(DirContext dirContext, SampleResult res) throws NamingException { try { res.sampleStart(); LdapExtClient.modifyTest(dirContext, getUserModAttributes(), getBaseEntryDN()); } finally { res.sampleEnd(); } }
/*************************************************************************** * This will do the bind for the User defined Thread, this bind is used for * the whole context * **************************************************************************/ private void bindOp(SampleResult res) throws NamingException { DirContext ctx = ldapContexts.remove(getThreadName()); if (ctx != null) { log.warn("Closing previous context for thread: " + getThreadName()); ctx.close(); } try { res.sampleStart(); ctx = LdapExtClient.connect(getServername(), getPort(), getRootdn(), getUserDN(), getUserPw(),getConnTimeOut(),isSecure()); } finally { res.sampleEnd(); } ldapContexts.put(getThreadName(), ctx); }
/** * This will do the add test for the User defined TestCase as well as * inbuilt test case. * */ private void addTest(LdapClient ldap, SampleResult res) throws NamingException { if (getPropertyAsBoolean(USER_DEFINED)) { res.sampleStart(); ldap.createTest(getUserAttributes(), getPropertyAsString(BASE_ENTRY_DN)); res.sampleEnd(); } else { res.sampleStart(); ldap.createTest(getBasicAttributes(), getPropertyAsString(ADD)); res.sampleEnd(); ldap.deleteTest(getPropertyAsString(ADD)); } }
protected void saveLogRecord(String marker, String threadName, String arrivalID) { SampleResult res = new SampleResult(); res.sampleStart(); res.setSampleLabel(arrivalID); res.setResponseMessage(marker); res.setThreadName(threadName); res.sampleEnd(); SampleEvent evt = new SampleEvent(res, getName()); logFile.sampleOccurred(evt); }
protected void saveLogRecord(String marker, String threadName, String arrivalID) { SampleResult res = new SampleResult(); res.sampleStart(); res.setSampleLabel(arrivalID); res.setResponseMessage(marker); res.setThreadName(threadName); res.sampleEnd(); SampleEvent evt = new SampleEvent(res, getName()); logFile.sampleOccurred(evt); }
protected void saveLogRecord(String marker, String threadName, String arrivalID) { SampleResult res = new SampleResult(); res.sampleStart(); res.setSampleLabel(arrivalID); res.setResponseMessage(marker); res.setThreadName(threadName); res.sampleEnd(); SampleEvent evt = new SampleEvent(res, getName()); logFile.sampleOccurred(evt); }
/*************************************************************************** * This will do the bind and unbind for the User defined TestCase * **************************************************************************/ private void singleBindOp(SampleResult res) throws NamingException { try { res.sampleStart(); DirContext ctx = LdapExtClient.connect(getServername(), getPort(), getRootdn(), getUserDN(), getUserPw(),getConnTimeOut(),isSecure()); LdapExtClient.disconnect(ctx); } finally { res.sampleEnd(); } }
/** * This will do the delete test for the User defined TestCase as well as * inbuilt test case. * */ private void deleteTest(LdapClient ldap, SampleResult res) throws NamingException { if (!getPropertyAsBoolean(USER_DEFINED)) { ldap.createTest(getBasicAttributes(), getPropertyAsString(ADD)); setProperty(new StringProperty(DELETE, getPropertyAsString(ADD))); } res.sampleStart(); ldap.deleteTest(getPropertyAsString(DELETE)); res.sampleEnd(); }
@SuppressWarnings("deprecation") @Override public SampleResult sample(Entry entry) { SampleResult res = new SampleResult(); res.setSampleLabel(getName()); res.sampleStart(); //构造请求数据 res.setSamplerData(getSampleData()); //调用dubbo res.setResponseData(JsonUtils.toJson(callDubbo(res))); //构造响应数据 res.setDataType(SampleResult.TEXT); res.setResponseCodeOK(); res.setResponseMessageOK(); res.sampleEnd(); return res; }
/** * This will do the search test for the User defined TestCase as well as * inbuilt test case. * */ private void searchTest(LdapClient ldap, SampleResult res) throws NamingException { if (!getPropertyAsBoolean(USER_DEFINED)) { ldap.createTest(getBasicAttributes(), getPropertyAsString(ADD)); setProperty(new StringProperty(SEARCHBASE, getPropertyAsString(ADD))); setProperty(new StringProperty(SEARCHFILTER, getPropertyAsString(ADD))); } res.sampleStart(); searchFoundEntries = ldap.searchTest(getPropertyAsString(SEARCHBASE), getPropertyAsString(SEARCHFILTER)); res.sampleEnd(); if (!getPropertyAsBoolean(USER_DEFINED)) { ldap.deleteTest(getPropertyAsString(ADD)); } }