GithubHelp home page GithubHelp logo

beeop's Introduction

中文

BeeOP:A light high-performance java object pool

Maven artifactId(Java7 and higher)

<dependency>
   <groupId>com.github.chris2018998</groupId>
   <artifactId>beeop</artifactId>
   <version>1.0.8</version>
</dependency>

Performance

One million borrow/return (1000 threads x 1000 times)

Pool type commons-pool2-2.9.0 BeeOP-0.3_Fair BeeOP-0.3_Compete
Average time(ms) 2.677456 0.000347 0.000187

PC:I5-4210M(2.6Hz,dual core4threads),12G memory Java:JAVA8_64 Pool:init-size10,max-size:10

Test log file:https://github.com/Chris2018998/BeeOP/blob/main/doc/temp/ObjectPool.log

Test source:https://github.com/Chris2018998/BeeOP/blob/main/doc/temp/BeeOP_Test.rar


Example

public interface Book {
    public String getName();
    public long getNumber();
}
public class JavaBook implements Book{
    private String name;
    private long number;
    public JavaBook() {
        this("Java核心技术·卷2", System.currentTimeMillis());
    }
    public JavaBook(String name, long number) {
        this.name = name;
        this.number = number;
    }
    public String getName() {
        return name;
    }
    public long getNumber() {
        return number;
    }
    public String toString() {
        return name;
    }
}
public class JavaBookFactory implements BeeObjectFactory {
    public Object create(Properties prop) throws BeeObjectException {
        return new JavaBook("Java核心技术·卷1", System.currentTimeMillis());
    }
    public void setDefault(Object obj) throws BeeObjectException { }
    public void reset(Object obj) throws BeeObjectException { }
    public void destroy(Object obj) { }
    public boolean isAlive(Object obj, int timeout) {
        return true;
    }
}
public class TestBookPool{
  public static void main(String[]){
      BeeObjectSourceConfig config = new BeeObjectSourceConfig();
      config.setObjectFactory(new JavaBookFactory());
      BeeObjectSource obs = new BeeObjectSource(config);
      
      BeeObjectHandle handle = null;
      try {
           handle = obs.getObject();
           Object v=handle.call("getName");
           System.out.println("Book name:"+v);
       } catch (BeeObjectException e) {
       } finally {
           if (handle != null)
               handle.close();
       }
    }
}

Features

1:Borrow timeout

2:Fair mode and compete mode for borrowing

3:Proxy object safe close when return

4:Pooled object cleared when network bad,pooled object recreate when network restore OK

5:Idle timeout and hold timeout(long time inactively hold by borrower)

6:Pooled object closed when exception,then create new one and transfer it to waiter

7:Pooled object reset when return

8:Pool can be reset

9:Jmx support


configuration

Field name Description Remark
poolName pool name name auto generated when not set
fairMode boolean indicator for borrow fair mode true:fair mode,false:comepete mode;default is false
initialSize pooled object creation size when pool initialized default is 0
maxActive max size for pooled object instances in pool default is 10
borrowSemaphoreSize borrow concurrent thread size default val=min(maxActive/2,cpu size)
maxWait max wait time to borrow one object instance time unit is ms,default is 8000 ms
idleTimeout max idle time of object instance in pool time unit is ms,default is 18000 ms
holdTimeout max inactive time hold by borrower time unit is ms,default is 300000 ms
forceCloseUsingOnClear object close indicator when pool closing or reseting true:close;false:wait object return, default is false
objectFactoryClassName object factory class name default is null
enableJmx JMX boolean indicator for pool default is false

Donate

If the software can help you, please donate fee of one coffe to us,thanks.

beeop's People

Contributors

chris2018998 avatar

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.