Coder Social home page Coder Social logo

neoagent's People

Contributors

cubicdaiya avatar marktan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

neoagent's Issues

Checking for C library ev... no

[root@mem2 neoagent]# scons configure
scons: Reading SConscript files ...
Python 2.4.3.final.0
SCons 1.2.0
Checking whether the C compiler worksyes
error: no result
Checking for C library pthread... yes
Checking for C library ev... no
library ev not installed!

OS:CentOS5.4
What should i do ?
I have to install C environment.(gcc g++ cmake make)

I have installed the necessary software,they are:
libevent-1.1a-3.2.1
libev-4.03-2.el5
json-c-0.10-2.el5

backup server configuration

Currently backup server must be nominated. but it is necessary for an environment has only single server not to nominate backup server.

select event loop method

neoagent uses libev. libev enables to select event loop method when ev_loop_new is called.
Currentl ev_loop_new in neoagent use EVFLAG_AUTO(0).
I want to make neoagent enable to select following.

  • EVFLAG_AUTO
  • EVBACKEND_SELECT
  • EVBACKEND_POLL
  • EVBACKEND_EPOLL
  • EVBACKEND_KQUEUE

connpool may switch from active to backup between na_connpool_select and na_connpool_assign

https://github.com/cubicdaiya/neoagent/blob/master/neoagent/event.c#L552-561

Imagine the connpool_select at line 552 returns env->connpool_active.
Now, connpool_select is called again in na_connpool_assign at line 561 and 567, which may return env->connpool_backup if the value of env->is_refused_active is changed since line 552.

(probably solved by the below patch, but not tested)

diff --git neoagent/connpool.c neoagent/connpool.c
index a20dc41..9464e0c 100644
--- neoagent/connpool.c
+++ neoagent/connpool.c
@@ -95,13 +95,10 @@ void na_connpool_reconnect (na_env_t *env, int i)
     }
 }

-bool na_connpool_assign (na_env_t *env, int *cur, int *fd)
+bool na_connpool_assign (na_env_t *env, na_connpool_t *connpool, int *cur, int *fd)
 {
-    na_connpool_t *connpool;
     int ri;

-    connpool = na_connpool_select(env);
-
     pthread_mutex_lock(&env->lock_connpool);

     ri = rand() % env->connpool_max;
diff --git neoagent/connpool.h neoagent/connpool.h
index 3c2b3a2..e425f53 100644
--- neoagent/connpool.h
+++ neoagent/connpool.h
@@ -38,7 +38,7 @@

 void na_connpool_create (na_connpool_t *connpool, int c);
 void na_connpool_destroy (na_connpool_t *connpool);
-bool na_connpool_assign (na_env_t *env, int *cur, int *fd);
+bool na_connpool_assign (na_env_t *env, na_connpool_t *connpool, int *cur, int *fd);
 void na_connpool_init (na_env_t *env);
 na_connpool_t *na_connpool_select(na_env_t *env);
 void na_connpool_switch (na_env_t *env);
diff --git neoagent/event.c neoagent/event.c
index 5934a9c..ae7f5c4 100644
--- neoagent/event.c
+++ neoagent/event.c
@@ -558,13 +558,13 @@ void na_front_server_callback (EV_P_ struct ev_io *w, int revents)
             goto unlock_reconf;
         }
         pthread_mutex_unlock(&env->lock_current_conn);
-        if (!na_connpool_assign(env, &cur_pool, &tsfd)) {
+        if (!na_connpool_assign(env, connpool, &cur_pool, &tsfd)) {
             na_error_count_up(env);
             NA_STDERR("failed assign connection from connpool.");
             goto unlock_reconf;
         }
     } else {
-        if (!na_connpool_assign(env, &cur_pool, &tsfd)) {
+        if (!na_connpool_assign(env, connpool, &cur_pool, &tsfd)) {
             na_server_t *server;
             tsfd = na_target_server_tcpsock_init();
             if (tsfd < 0) {

Can't build on debian wheezy

buildlog is followings:

scons: Reading SConscript files ...
Python 2.7.3.final.0
SCons  2.1.0
scons: done reading SConscript files.
scons: Building targets ...
gcc -o neoagent/bm.o -c -std=c99 -Wall -g -O2 -D_GNU_SOURCE -Wimplicit-function-declaration -Wunused-variable neoagent/bm.c
In file included from neoagent/bm.c:9:0:
neoagent/defines.h:25:18: fatal error: json.h: No such file or directory
compilation terminated.
scons: *** [neoagent/bm.o] Error 1
scons: building terminated because of errors.

I think "json.h" needs with the prefix "json/" on debian wheezy. (e.g. json/json.h)

improve ability of checking health of server

neoagent has a function of 'health check'. But this checks whether connecting a target server with the system call of connect.
This method is not very good at all. when a target server is down this behaves efficiently, this doesn't in other case.(for example, a target server is too busy because of overload with many disk I/Os)

A new method of 'health check' uses memcached commands(get & set).
A health checker executes multiple set commands, then executes get commands corresponding to each set command.
A health checker switches server when all set and get commands fail.

Can't build on OSX

buildlog is followings:

scons: Reading SConscript files ...
Python 2.7.3.final.0
SCons 2.2.0
scons: done reading SConscript files.
scons: Building targets ...
gcc -o neoagent/slowlog.o -c -std=c99 -Wall -g -O2 -D_GNU_SOURCE -Wimplicit-function-declaration neoagent/slowlog.c
neoagent/slowlog.c: In function 'na_slow_query_gettime':
neoagent/slowlog.c:42: warning: implicit declaration of function 'clock_gettime'
neoagent/slowlog.c:42: error: 'CLOCK_MONOTONIC' undeclared (first use in this function)
neoagent/slowlog.c:42: error: (Each undeclared identifier is reported only once
neoagent/slowlog.c:42: error: for each function it appears in.)
neoagent/slowlog.c: In function 'na_slow_query_check':
neoagent/slowlog.c:67: warning: passing argument 2 of 'getpeername' from incompatible pointer type
scons: *** [neoagent/slowlog.o] Error 1
scons: building terminated because of errors.

It may help this probrem followings:
http://code.google.com/p/nativeclient/issues/detail?id=1159

I'll research it.

re-configuration with SIGUSR2

when neoagent received SIGUSR2, reconfigure the following parameters from a configuration file.

  • error_count_max
  • conn_max
  • is_connpool_only
  • request_bufsize
  • request_bufsize_max
  • response_bufsize
  • response_bufsize_max

implicit declaration of function 'pthread_mutex_(un)?lock' in env.c

-Wimplicit-function-declaration makes gcc output following warinings.

neoagent/env.c: In function 'na_error_count_up':
neoagent/env.c:108: warning: implicit declaration of function 'pthread_mutex_lock'
neoagent/env.c:110: warning: implicit declaration of function 'pthread_mutex_unlock'

Remove this warning and add -Wimplicit-function-declaration when compiling.

extensible buffer

buffer size of each connections(env->buffersize) is fixed. Make it extensible.

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.