Examples of ConnectionSpec


Examples of org.jredis.connector.ConnectionSpec

public class UsingJRedisPipeline extends UsingJRedisFuture {

  public static void main (String[] args) {
    int database = 11;
    ConnectionSpec connectionSpec = DefaultConnectionSpec.newSpec("localhost", 6379, database, "jredis".getBytes());
   
    connectionSpec.setDatabase (13);
      new UsingJRedisPipeline (connectionSpec);
     
      exampleUseofSyncInPipeline(connectionSpec);
    }
View Full Code Here

Examples of org.jredis.connector.ConnectionSpec

          String password = "jredis";
          InetAddress address = InetAddress.getLocalHost();
         
          // 1 - get the default connection spec
          //
          ConnectionSpec connectionSpec = DefaultConnectionSpec.newSpec();
         
          // 2 - customize it
          // here we're demonstrating the full set of parameters -- obviously you can just set what you need
          // but DO NOTE that the SO_PREF_XXX properties of TCP sockets must be defined as a set.  See
          // ConnectionSpec for javadoc details.
          //
          // Here we are spec'ing a connection that is NOT kept alive, and obviously is really keen on making sure
          // we connect as fast as possible.  This is a good connectionspec for disposable JRedisClients that are used
          // to issue a few commands and then discarded.  We're minimizing the connection overhead cost.
         
          connectionSpec
            // to be or not to be -- you decide
            //
            .setSocketFlag(SocketFlag.SO_KEEP_ALIVE, false)        // DO NOT keep socket allive

            // connect retries on connection breaks
View Full Code Here

Examples of org.jredis.connector.ConnectionSpec

      // 1st example: using defaults
      // if your server expects a AUTH password, this will fail so see next block
      {
        // Note that if your localhost:6379 redis server expects a password
        // this will fail
        ConnectionSpec connectionSpec = DefaultConnectionSpec.newSpec();
        JRedisClient jredis = new JRedisClient(connectionSpec);
        try {
            jredis.ping();
            Log.log("Sweet success -- we're connected using all default values.");
          }
          catch (RedisException e) {
            Log.error("Failed to connect to Redis using JRedisClient default ConnectionSpec -- password perhaps? => " + e.getLocalizedMessage());
          }
      }
     
      // 2nd example: using defaults but setting the password and the database. 
      // also demonstrated using the method chaining on the ConnectionSpec property setters.
      {
        // Note that if your localhost:6379 redis server expects a password
        // this will fail
        String password = "jredis";
        int database = 11;
        ConnectionSpec connectionSpec = DefaultConnectionSpec.newSpec();
        connectionSpec
          .setCredentials(password.getBytes())
          .setDatabase(database);
       
        JRedisClient jredis = new JRedisClient(connectionSpec);
        try {
            jredis.ping();
            Log.log("Sweet success -- we're connected using %s as password to %d database.", password, database);
          }
          catch (RedisException e) {
            Log.error("Failed to connect to Redis using JRedisClient default ConnectionSpec -- password perhaps? => " + e.getLocalizedMessage());
          }
      }
     
      // final example: using defaults but setting the full set of basic settings 
      {
        // Note that if your localhost:6379 redis server expects a password
        // this will fail
        try {
          String password = "jredis";
          int     port = 6379;
          int     database = 11;
          InetAddress address = InetAddress.getLocalHost();
         
          // 1 - get the default connection spec for the basic settings
          //
          ConnectionSpec connectionSpec = DefaultConnectionSpec.newSpec(address, port, database, password.getBytes());
         
          // finally - use it to create the JRedisClient instance
          //
          JRedisClient jredis = new JRedisClient(connectionSpec);
            jredis.ping();
View Full Code Here

Examples of org.jredis.connector.ConnectionSpec

*
*/

public class PipelineInAction {
  public static void main (String[] args) {
      final ConnectionSpec spec = DefaultConnectionSpec.newSpec();
      spec.setCredentials("jredis".getBytes());
      spec.setDatabase(13);
      spec.setSocketProperty(SocketProperty.SO_RCVBUF, 1024 * 512);
      spec.setSocketProperty(SocketProperty.SO_SNDBUF, 1024 * 512);
     
      usingSynchSemantics(spec);
      final boolean forever = true;
     
      runJRedisPipelineSET (spec, 10000, 3, forever);
View Full Code Here

Examples of org.jredis.connector.ConnectionSpec

  private ClusterSuiteTestData () {
//    ClusterNodeSpec nodeSpec = null;
    connSpecs = new ConnectionSpec[NODE_CNT];
    for(int i=0;i<NODE_CNT; i++) {
      InetAddress address = getInetAddressFor(CLUSTER_NODES_ADDRESS_BASE);
      ConnectionSpec connSpec = getConnectionSpecFor(address, CLUSTER_NODES_PORT_BASE+i, db);
      connSpecs[i] = connSpec;
//      nodeSpec = new DefaultClusterNodeSpec (connSpec);
//      clusterNodeSpecs.add(nodeSpec);
    }
View Full Code Here

Examples of org.jredis.connector.ConnectionSpec

      fail("In suite setup for random address <"+hostName+">", e);
    }
    return address;
  }
  static public ConnectionSpec getConnectionSpecFor (InetAddress address, int port, int db) {
    ConnectionSpec connSpec = DefaultConnectionSpec.newSpec().setAddress(address).setPort(port).setDatabase(db);
    return connSpec;
  }
View Full Code Here

Examples of org.jredis.connector.ConnectionSpec

  @Test
  public void testIdentityContract () {
    Log.log("Testing ClusterNodeSpec identity contract enforcement: [Object.equals() | Object.hashCode()]");
    int db = 10;
    int anotherDb = 2;
    ConnectionSpec node1Spec = DefaultConnectionSpec.newSpec("127.0.0.1", 6379, db, null);
    ConnectionSpec node2Spec = DefaultConnectionSpec.newSpec("127.0.0.1", 6379, db, null);
    ConnectionSpec node3Spec = DefaultConnectionSpec.newSpec("127.0.0.1", 6379, anotherDb, null);
   
    ClusterNodeSpec node1 = newProviderInstance(node1Spec);
    ClusterNodeSpec node2 = newProviderInstance(node2Spec);
    ClusterNodeSpec node3 = newProviderInstance(node3Spec);
   
View Full Code Here

Examples of org.jredis.connector.ConnectionSpec

   * Don't forget to flush db#11 after running this as it adds a whole bunch of keys.
   * @param args
   */
  public static void main (String[] args) {
    int database = 11;
    ConnectionSpec connectionSpec = DefaultConnectionSpec.newSpec("localhost", 6379, database, "jredis".getBytes());
    int connCnt = 7;
    int userCnt = 10;
    int opsCnt = 100000;
   
    // create the service -- well this is it as far as usage goes:  set the number of connections for the service pool
View Full Code Here

Examples of org.jredis.connector.ConnectionSpec

 
  /**
   * Using the synchronous interface
   */
  public static void usingSyncClient () {
    ConnectionSpec spec = DefaultConnectionSpec.newSpec()
    .setCredentials("jredis".getBytes())
    .setDatabase(10);

    JRedis jredis = new JRedisClient(spec);

View Full Code Here

Examples of org.jredis.connector.ConnectionSpec

 
  /**
   * Using the asynchronous interface
   */
  public static void usingAsyncClient () {
    ConnectionSpec spec = DefaultConnectionSpec.newSpec()
    .setCredentials("jredis".getBytes())
    .setDatabase(10);

    JRedisFuture jredis = new JRedisAsynchClient(spec);

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.