GithubHelp home page GithubHelp logo

Comments (13)

happybyron avatar happybyron commented on June 1, 2024

thanks a lot for reporting the issues. could you list step by step how did you produce the problem?

from memcached-java-client.

weiqinyang avatar weiqinyang commented on June 1, 2024

Thanks happybyron.
My test steps is like this:
1)copy TestMemcachedSet.jar and memcached-client2.5.1.jar to JMeter_home/lib/ext/ ;
2)Create a JAVA Request JMeter Sampler,select TestMemcachedSet to run .
Jmeter's manual :http://jakarta.apache.org/jmeter/usermanual/component_reference.html#Java_Request
But,when I used memcached-client 2.0.1, it runs well.

from memcached-java-client.

xuhuleon avatar xuhuleon commented on June 1, 2024

hi weiqian, I've done same thing as you said. But how can I get the result? There is no response when I click run->start

from memcached-java-client.

weiqinyang avatar weiqinyang commented on June 1, 2024

You can new some listeners under Test Plan for Graph Results, for example: Aggregate Report,View Results Tree.
The manual url: http://jakarta.apache.org/jmeter/usermanual/component_reference.html#Graph_Results

from memcached-java-client.

happybyron avatar happybyron commented on June 1, 2024

Hi Yang:
try to copy all the resources jar file in memcached client and your project into %JMETER_HOME%/lib and then give a try.

from memcached-java-client.

weiqinyang avatar weiqinyang commented on June 1, 2024

hi happybyron:
I have tried it,but the same NullPointerException occurred when more than 100 threads runing every 1 second.And there was a new error like below when more than 100 threads :
com.schooner.MemCached.SchoonerSockIOPool Thu Jun 24 09:37:34 CST 2010 - ++++ fa
iled to get SockIO obj for: 172.20.67.105:11211

Any ideas can help me solve the problem ?

from memcached-java-client.

xuhuleon avatar xuhuleon commented on June 1, 2024

I think this error is caused by TIME_WAIT status during TCP connection closing.
Run "netstat -an|grep 11211" on your server to check if I'm right.
If I'm right, try sudo sysctl -w net.ipv4.tcp_tw_recycle=1.

from memcached-java-client.

xuhuleon avatar xuhuleon commented on June 1, 2024

I found the error is caused by your code not memcached client. The initialize() and shutdown() of pool should not be called in each thread. They should only be called once. The java.lang.NullPointerException happens when some thread try get connection from pool after another thread has shutdown the pool.
BTW: SampleResult results should not be shared with all threads, please see jmeter.log for the error info.

Please refer my code for more info:

package com.schooner.MemCached;

import java.util.concurrent.atomic.AtomicInteger;

import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient;
import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext;
import org.apache.jmeter.samplers.SampleResult;
import com.danga.MemCached.MemCachedClient;
import com.danga.MemCached.SockIOPool;

public class JmetTest extends AbstractJavaSamplerClient{

private String key;
private String value;
private static SockIOPool pool = null;
private static AtomicInteger flag = new AtomicInteger();
static MemCachedClient mc;
private String serverlist;
private static int timeout;

public void setupTest(JavaSamplerContext arg0) {        


    timeout = arg0.getIntParameter("timeout");
    key = arg0.getParameter("key");
    value = arg0.getParameter("value");
    serverlist = arg0.getParameter("serverlist");

    if(flag.get() == 0) {
        init();
    }
}

synchronized private void init(){
    System.out.println(serverlist + " "  + key + " " + value);
    pool = SockIOPool.getInstance();
    pool.setServers(serverlist.split(","));

// Integer[] weights={1,2};
// pool.setWeights(weights);

// pool.setNagle( false );
pool.setSocketTO(timeout );

// pool.setHashingAlg(2);

    pool.setMaxConn(100);
    pool.initialize();
    mc = new MemCachedClient();

// mc.setPrimitiveAsString(true);
// mc.setSanitizeKeys(false);
flag.set(1);

}

public Arguments getDefaultParameters() {
    Arguments params = new Arguments();

    params.addArgument("serverlist", "172.16.11.40:11211");
    params.addArgument("timeout", "5000"); 
    params.addArgument("key", "key"); 
    params.addArgument("value", "value");                                   

    return params;
}



public SampleResult runTest(JavaSamplerContext arg0) {
    SampleResult results = new SampleResult();
    results.setSampleLabel("memcached" );
    boolean result=false;

    try{
      results.sampleStart();  
      result = mc.set(key,value);   
      results.setSuccessful(result);
    }catch(Exception e){
        e.printStackTrace();
        results.setSuccessful(result);
    }finally {
        // Record end time and populate the results.
      results.sampleEnd();

    }
    return results;
}

public void teardownTest(JavaSamplerContext arg0) {
}

}

from memcached-java-client.

xuhuleon avatar xuhuleon commented on June 1, 2024

I can't find any function to write pool.shutdown() ... I think jmeter is not suitable to test app with connection pools.. If you want use it, you'd better modify its source code.

from memcached-java-client.

weiqinyang avatar weiqinyang commented on June 1, 2024

Thanks very much for xuhuleon's reply.
May Be your are right, I will try other method to test .
But I have another question, if it cansed by Jmeter tool, why java-memcached-2.0.1client can run well when more then 100 theads.

from memcached-java-client.

xuhuleon avatar xuhuleon commented on June 1, 2024

I have tried your code in 2.0.1, but the same error happened...

from memcached-java-client.

weiqinyang avatar weiqinyang commented on June 1, 2024

Thanks very much. I will try other ways for memcached's concurrent test .

from memcached-java-client.

newroot avatar newroot commented on June 1, 2024

Thanks, Weiqin.

from memcached-java-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.