Open source: common-remote-pool

Apache common object pool can help user to manager resource, but if use it , you will find you can only share resources in one machine,not between multi-process or multi-machine. So we use the object pool to constructor one web service to provide distributed pool to share resources between multiple machines. The web common remote pool provide one default implement which can add any json string to pool and borrow json resource from it.What’s more, the resource object factory’s class can be uploaded into the web service. In short, the project is restful style web object pool for global access.

http://code.google.com/p/common-remote-pool/

How to initial it

1. mvn tomcat7:run to start the webservice;

2. If you need define your implement, you should upload your resource factory class , if you have no need, omit this step.

How to use it

http request style

  • borrow the object from pool
 	Request:
 	        GET http://localhost:8080/common-remote-pool/service/object/borrow

 

Response: has resource response code:200 response body: json example: {“domain”:”10.224.64.225″,”user”:”6731″}

Response: no resource response code:404

 

  • return resource to pool
 	Request:
 		POST http://localhost:8080/common-remote-pool/service/object/return                 
                body: json
 		example:{"domain":"10.224.64.225","user":"6731"}

 

Response: response code:204

  • get borrowed resouce number
 	Request:
 		GET http://localhost:8080/common-remote-pool/service/object/active

 

Response: response code:200 response body: number

  • add resource to pool
 	Request:
 		POST http://localhost:8080/common-remote-pool/service/object/add

 

body: json example: {“domain”:”10.224.64.225″,”user”:”6731″} or [{“domain”:”10.224.64.225″,”user”:”6731″},{“domain”:”10.224.64.13″,”user”:”6732″}]

Response: response code:200

  • flush all resource
 	Request:
 		GET http://localhost:8080/common-remote-pool/service/object/drain

 

Response: response code:200

  • get idle resource number
 	Request:
 		GET http://localhost:8080/common-remote-pool/service/object/idle

 

Response: response code:200 response body: number

  • get pools resource amount info
 	Request:
 		GET http://localhost:8080/common-remote-pool/service/object/idle

 

Response: response code:200 response body: {“idleNumber”:3,”borrowedNumber”:3,”totalNumber”:6}

  • query current enabled resource factory
 	Request:
 		GET http://localhost:8080/common-remote-pool/service/object/getFactory

 

Response: response code:200 response content: such as com.googlecode.common.remote.pool.resource.DefaultResourceFactory

  • list all resource in pool
 	Request:
 		GET http://localhost:8080/common-remote-pool/service/object/list

 

Response: response code:200 response content: “no any resource” or {file=1.txt, owner=jiafu}:2014-04-28 14:29:34

client style

The client’s code amount is so small that you can copy the code directly.

 

        com.googlecode.common.remote.pool.client.CommonRemotePoolClient.CommonRemotePoolClient(String)
        com.googlecode.common.remote.pool.client.CommonRemotePoolClient.borrowObject(Class<T>)
        com.googlecode.common.remote.pool.client.CommonRemotePoolClient.returnObject(Object)
        com.googlecode.common.remote.pool.client.CommonRemotePoolClient.addObject(Object...)

Dependence:

        <dependency>
          <groupId>org.jboss.resteasy</groupId>
          <artifactId>resteasy-jackson-provider</artifactId>
          <version>2.3.1.GA</version>
        </dependency>
        <dependency>
          <groupId>org.jboss.resteasy</groupId>
          <artifactId>resteasy-client</artifactId>
          <version>3.0.2.Final</version>
        </dependency>

How to manage resource

you can manage resource by default implement.

Open source: server-test-toolkit

SST is an open source project which is designed for test automation of server applications.

 Code

Code SVN: https://server-test-toolkit.googlecode.com/svn/trunk/

Apache Maven: http://search.maven.org/#browse%7C779006397

<dependency>
   <groupId>com.googlecode.server-test-toolkit</groupId>
   <artifactId>server-test-toolkit</artifactId>
   <version>2.2.6</version>
</dependency>

Release Version: http://code.google.com/p/server-test-toolkit/wiki/ReleaseVersion?ts=1398301402&updated=ReleaseVersion

 Features

– Remote Shell Tool

  • Feature; shell commands’ execute and results retrieve based on remote linux server;
  • Use: grep server logs, modify config, block connection, get cpu/io/memory/swap performance data etc.

– Remote Storage Tool

  • Feature: download/upload file with remote ftp/sftp server;
  • Use: prepare and use test data in one centra ftp/sftp server.

– Random File Tool

  • Feature: generate several kinds of file: doc/txt/jpg/pdf for test data
  • Use: test data prepare, used for storage applications.

– General DB Access Tool

  • Feature: access db and do operations.
  • Use: check records in database

– Job Schedule Tool

  • Feature: encapsulate quartz to supported job config/execute and register mbean for monitor support
  • Use: define some jobs to do some tasks.

– Popular Services Access Tool

  • Feature: provide the access interfaces for popular services such as memcached/zookeeper
  • Use: server applications often contain popular open source services, so this tool provide the common access methods for popular ones.

– Effetive Util tool

  • Feature: disk/io/memory/trackid/sleep/validation/performance etc
  • Use: util tool will help coder code more effectivly

 Feedback

Welcome to contact me with email:fujian1115@gmail.com if you has followed cases:

– Bugs or Issues

– Design improve advices

– Other uncovered requirements

Thanks for your sharing!