Comments (4)
Hi, not sure about this. As you noted, a simple wrapper is basically what is required and its not clear what the service would 'provide' if your server is down. Should it continually try and finally get a connection? In effect, the end result is that you will get an exception when you try to ask the service to do something.
from jredis.
"I can not start my web application and initialize a client class for singleton usage at startup when the server is not available."
Sorry, I missed this. Let me think about it. Thanks for pointing out the issue.
/R
from jredis.
Alright: http://gist.github.com/480022
I don't know the ETA on this but its clearly doable and at this point I'm inclined to think it is the way to go forward.
There are two ways to play the downtime parameter. One would be in an asynch queuing architecture (which would be a pretty good fit) and the value a function of the queue size. And the other with the normal Req/Resp sync semantics -- e.g. container service - and here the macDowntime is the maximum latency you are willing to tolerate once per every redis.conf::timeout cycle.
from jredis.
Sounds like you are coming up with a more complicated approach then I did.
Changes like the following are already good enough for me
public class JRedisAsynchClient extends JRedisFutureSupport {
/**
* @param connectionSpec
*/
public JRedisAsynchClient (ConnectionSpec connectionSpec, boolean connectImmediately) {
// note: using a shared connection mod
connectionSpec.isReliable(true);
connection = new AsynchConnection(connectionSpec, true, connectImmediately);
}
public boolean isActive() {
return connection.isActive();
}
}
public class AsynchConnection {
private AtomicBoolean firstConnect = new AtomicBoolean(false);
public AsynchConnection(ConnectionSpec connectionSpec, boolean isShared, boolean connectImmediately) throws ClientRuntimeException,
ProviderException {
super(connectionSpec, connectImmediately);
tryFirstConnect();
}
public boolean isActive() {
if (! firstConnect.get()) {
tryFirstConnect();
}
return isConnected();
}
private void tryFirstConnect() {
try {
connect();
firstConnect.set(true);
} catch (IllegalStateException e) {
// some other thread already connected
firstConnect.set(true);
} catch (ClientRuntimeException e) {
Log.error(e.getMessage());
}
}
}
from jredis.
Related Issues (20)
- Expecting status code for size/count HOT 1
- Infinitive loop on reconnect (disconnect errors) HOT 3
- Connection re-established but last request not processed HOT 1
- java.util.concurrent.ExecutionException: Provider ExceptionBug? Expecting status code for size/count HOT 5
- add support for pub/sub
- full binary support HOT 11
- add support for hashes HOT 2
- add support for 2.2 (new unified request protocol) HOT 1
- invalid pom.xml configuration HOT 2
- pooling support & logging
- missing redis operations
- Build Failure HOT 2
- jreids ZINTERSTORE , ZUNIONSTORE wrong result HOT 2
- Occasional exception: org.jredis.connector.ConnectionReset: Connection re-established but last request not processed: in.read returned -1 HOT 10
- JRedis: specifying encoding for String opterations HOT 1
- can't call "sadd" sequentially HOT 1
- JRedisClient-tests error HOT 2
- Runtime Exception HOT 1
- ERR Protocol error: expected '$' got '*' on mset HOT 2
- Add support for time command
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jredis.