Package org.jredis.cluster

Examples of org.jredis.cluster.ClusterSpec$Support


      Log.log("Basic nodemap test of Consistent Hashing cluster model");
     
      ConsistentHashCluster model = (ConsistentHashCluster) newProviderInstance();
      assertNotNull(model, "model should not be null");
     
      ClusterSpec spec = model.getSpec();
      assertNotNull(spec, "spec should not be null");
     
      ConsistentHashCluster.NodeMap nodeMap = model.getNodeMap();
      assertNotNull(nodeMap, "node map should not be null");
     
      Collection<ClusterNodeSpec> nodes = nodeMap.values();
      assertNotNull(nodes, "value set of node map should not be null");
     
      // regardless of what hash (key) they are mapped to,
      // we expected the value set of NodeMap to contain each and every
      // ClusterNodeSpec in the ClusterSpec of the model
      //
    Log.log("NOTE: %d nodes", spec.getNodeSpecs().size());
    Log.log("NOTE: size of value set is %d ", nodes.size());
    int missCnt = 0;
      for(ClusterNodeSpec node : spec.getNodeSpecs()){
        if(!nodes.contains(node)){
          missCnt ++;
        }
//        assertTrue(nodes.contains(node), "nodeSpec should be in the value set of NodeMap: " + node);
      }
View Full Code Here


  }

  /* (non-Javadoc) @see org.jredis.cluster.ClusterModelProviderTestBase#newClusterSpec() */
  @Override
  protected ClusterSpec newClusterSpec () {
    ClusterSpec spec = new DefaultClusterSpec();
    for(int i=0; i<100; i++){
      ClusterNodeSpec node = new DefaultClusterNodeSpec(DefaultConnectionSpec.newSpec("localhost", 6379+i, 0, null));
      spec.addNode(node);
    }
    return spec;
  }
View Full Code Here

      // 2 - Must not be reconfigurable
      assertFalse(provider.supportsReconfiguration(), "Static hash clusters can not be reconfigured.");
     
      // 3 - Must not support any of the NodeMap modification ops, indicated by raising the specified ProviderException class
      boolean didRaiseEx;     
    ClusterSpec clusterSpec = this.newClusterSpec();
    Set<ClusterNodeSpec> nodeSpecs =  clusterSpec.getNodeSpecs();
    assertTrue(nodeSpecs.size() > 0, "node specs set size must be greater than zero.");
    ClusterNodeSpec aNodeSpec =  (ClusterNodeSpec) nodeSpecs.toArray()[0];
   
      didRaiseEx = false;
      try {
View Full Code Here

      Log.log("Basic nodemap test of Consistent Hashing cluster model");
     
      StaticHashCluster model = (StaticHashCluster) newProviderInstance();
      assertNotNull(model, "model should not be null");
     
      ClusterSpec spec = model.getSpec();
      assertNotNull(spec, "spec should not be null");
    }   
View Full Code Here

  }

  /* (non-Javadoc) @see org.jredis.cluster.ClusterModelProviderTestBase#newClusterSpec() */
  @Override
  protected ClusterSpec newClusterSpec () {
    ClusterSpec spec = new DefaultClusterSpec();
    for(int i=0; i<100; i++){
      ClusterNodeSpec node = new DefaultClusterNodeSpec(DefaultConnectionSpec.newSpec("localhost", 6379+i, 0, null));
      spec.addNode(node);
    }
    return spec;
  }
View Full Code Here

  {
    this.model = notNull(model, "ClusterModel param for constructor", ClientRuntimeException.class);

    // model integrity checks
    //
    ClusterSpec spec = notNull(model.getSpec(), "ClusterModel's ClusterSpec property", ClientRuntimeException.class);
    Collection<ClusterNodeSpec> nodeSpecs = notNull(spec.getNodeSpecs(), "ClusterSpec's nodes", ClientRuntimeException.class);
    isTrue(nodeSpecs.size() > 1, "ClusterSpec node count", ClientRuntimeException.class);

    // initialize cluster's connections
    initialize();
  }
View Full Code Here

   * @param lastPort
   * @param templateConnSpec
   * @return
   */
  public static ClusterSpec newSpecForRange (ConnectionSpec templateConnSpec, int firstPort, int lastPort) {
    ClusterSpec spec = new DefaultClusterSpec();
    for(int i=firstPort; i<=lastPort; i++){
      ConnectionSpec connSpec = DefaultConnectionSpec.newSpec()
        .setAddress(templateConnSpec.getAddress())
        .setPort(i)
        .setDatabase(templateConnSpec.getDatabase())
        .setCredentials(templateConnSpec.getCredentials());
      ClusterNodeSpec nodeSpec = new DefaultClusterNodeSpec(connSpec);
      spec.addNode(nodeSpec);
    }
    return spec;
  }
View Full Code Here

TOP

Related Classes of org.jredis.cluster.ClusterSpec$Support

Copyright © 2018 www.massapicom. 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.