Package org.jredis.connector

Examples of org.jredis.connector.Connection


   * @return
   */
  protected Connection createSynchConnection (String host, int port, int database, byte[] credentials, boolean isShared, RedisVersion redisVersion)
  {
    InetAddress   address = null;
    Connection     synchConnection = null;
    try {
     
      address = InetAddress.getByName(host);
      ConnectionSpec spec = DefaultConnectionSpec.newSpec(address, port, database, credentials);
      synchConnection = createSynchConnection(spec, isShared, redisVersion);
View Full Code Here


   * @param connectionSpec connection's specification
   * @param redisVersion redis protocol compliance
   * @return
   */
  protected Connection createSynchConnection(ConnectionSpec connectionSpec, boolean isShared, RedisVersion redisVersion){
    Connection     synchConnection = null;
    try {
      synchConnection = new SynchConnection(connectionSpec, isShared, redisVersion);
      Assert.notNull(synchConnection, "connection delegate", ClientRuntimeException.class);
    }
    catch (NotSupportedException e) {
View Full Code Here

   */
  private final void initialize () {
    connPoolAccess = new Semaphore(connCount);
    conns = new Connection[connCount];
    connInUse = new boolean [connCount];
    Connection conn = null;
    connectionSpec.isReliable(true);
    for(int i=0; i< connCount;i++) {
      try {
        conn = Assert.notNull(createSynchConnection(connectionSpec, true, RedisVersion.current_revision), "Connection " + i, ClientRuntimeException.class);
        conns[i] = conn;
View Full Code Here

   * TODO: monitor all connections and deal with faults
   */
  // ------------------------------------------------------------------------

  public void onEvent(Connection.Event event) {
    Connection conn = event.getSource();
    if(!connections.containsKey(conn)){
      throw new ProviderException("ClusterConnection receiving events for unrelated connection!");
    }
   
    // TODO: deal with it!
View Full Code Here

    initializeComponents();
  }

  final private void initializeConnections () throws ClientRuntimeException, ProviderException {
    for(ClusterNodeSpec nodeSpec : model.getSpec().getNodeSpecs()){
      Connection conn = null;
      if(getModality() == Connection.Modality.Synchronous){
        conn = notNull(createSynchConnection(nodeSpec), "", ProviderException.class);
      }
      else {
        conn = notNull(createAsynchConnection(nodeSpec), "", ProviderException.class);
View Full Code Here

  /**
     * @param nodeSpec
     * @return
     */
    protected Connection createSynchConnection (ClusterNodeSpec nodeSpec) {
      Connection conn = null;
      conn = new SynchConnection(nodeSpec.getConnectionSpec(), true);
      return conn;
    }
View Full Code Here

  // ------------------------------------------------------------------------

  public JRedisClient (ConnectionSpec connectionSpec){
    connectionSpec.setConnectionFlag(Connection.Flag.RELIABLE, Boolean.TRUE);
    connectionSpec.setConnectionFlag(Connection.Flag.SHARED, Boolean.FALSE);
    Connection syncConnection = createSyncConnection (connectionSpec);
    setConnection (syncConnection);
  }
View Full Code Here

   * @param redisVersion redis protocol compliance
   * @return
   */
  protected Connection createSyncConnection(ConnectionSpec connSpec){
    Connection.Factory cfact = (Connection.Factory) connSpec.getConnectionProperty(Property.CONNECTION_FACTORY);
    Connection   conn = null;
    try {
      conn = Assert.notNull(cfact.newConnection(connSpec), "connection delegate", ClientRuntimeException.class);
    }
    catch (ProviderException e) {
      Log.bug("Couldn't create the handler delegate.  => " + e.getLocalizedMessage());
View Full Code Here

  // ------------------------------------------------------------------------
  // Internal ops
  // ------------------------------------------------------------------------
  final private Connection createAsyncConnection() {
    Connection.Factory cfact = (Connection.Factory) connSpec.getConnectionProperty(Property.CONNECTION_FACTORY);
    Connection   conn = null;
    try {
      conn = Assert.notNull(cfact.newConnection(connSpec), "connection delegate", ClientRuntimeException.class);
    }
    catch (ProviderException e) {
      Log.bug("Couldn't create the handler delegate.  => " + e.getLocalizedMessage());
View Full Code Here

  /* (non-Javadoc) @see org.jredis.connector.Connection.Factory#newConnection(org.jredis.connector.ConnectionSpec) */
    public Connection newConnection (ConnectionSpec spec)
            throws ClientRuntimeException, NotSupportedException
    {
      Connection conn = null;
      switch (spec.getModality()){
      case Monitor:
        throw new ProviderException("NOT IMPLEMENTED!");
      case PubSub:
        throw new ProviderException("NOT IMPLEMENTED!");
View Full Code Here

TOP

Related Classes of org.jredis.connector.Connection

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.