Пример #1
0
 protected void stop(RjdbcService.Client client)
 {
     if (client != null)
     {
         client.Dispose();
     }
 }
Пример #2
0
 public void Restart(string server, int port)
 {
     if (!isClosed(this.client))
     {
         stop(this.client);
     }
     this.client = start(server, port);
 }
Пример #3
0
        internal override T Execute <T>(Func <RjdbcService.Client, T> exec)
        {
            RjdbcService.Client client = this.pool.Get();
            T ret = exec(client);

            this.pool.Release(client);
            return(ret);
        }
Пример #4
0
        public override DBConnection GetNewDBConnection(string url, Dictionary <string, string> properties = null)
        {
            RjdbcService.Client client     = this.pool.Get();
            DBConnection        connection = new DBConnection(this, client.createConnection(url, properties));

            this.pool.Release(client);
            return(connection);
        }
Пример #5
0
        protected RjdbcService.Client start(string server, int port)
        {
            RjdbcService.Client client;
            TSocket             socket   = new TSocket(server, port);
            TProtocol           protocol = new TCompactProtocol(socket);

            client = new RjdbcService.Client(protocol);
            socket.Open();
            return(client);
        }
Пример #6
0
        public void Release(RjdbcService.Client client)
        {
            if (this.isDisposed)
            {
                throw new InvalidOperationException("Connection pool is disposed");
            }

            if (this.queue.Count < this.MaxQueue && client != null && client.InputProtocol.Transport.IsOpen)
            {
                this.queue.Enqueue(client);
            }
        }
Пример #7
0
 protected override void dispose()
 {
     stop(this.client);
     this.client = null;
 }
Пример #8
0
 public JDBCClient(string server, int port)
 {
     this.client = start(server, port);
 }
Пример #9
0
 internal override void Execute(Action <RjdbcService.Client> exec)
 {
     RjdbcService.Client client = this.pool.Get();
     exec(client);
     this.pool.Release(client);
 }
Пример #10
0
 protected bool isClosed(RjdbcService.Client client)
 {
     return(client == null || !client.InputProtocol.Transport.IsOpen);
 }