Java Doc for CancelController.java in  » Database-JDBC-Connection-Pool » octopus » com » internetcds » jdbc » tds » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database JDBC Connection Pool » octopus » com.internetcds.jdbc.tds 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.internetcds.jdbc.tds.CancelController

CancelController
public class CancelController (Code)
This class provides support for canceling queries.

Basically all threads can be divided into two groups, workers and cancelers. The canceler can cancel at anytime, even when there is no outstanding query to cancel. A worker can be in one of 4 states-

1) Not doing anything DB related.
2) currently sending a request to the database. (Note- any time a request is sent to the DB the DB will send a response. This means a thread in state 2 must go to state 3.)
3) waiting for a response from DB
4) reading the response from DB

I can easily make it so that only one thread at a time can be in state 2, 3, or 4.

The way that a cancel works in TDS is you send a cancel packet to server. The server will then stop whatever it might be doing and reply with END_OF_DATA packet with the cancel flag set. (It sends this packet even if it wasn't doing anything.) I will call this packet a CANCEL_ACK packet

All that I really need is to do is make sure that I try to read as many CANCEL_ACKs as I request and the I make sure that some thread is out there ready to read any CANCEL_ACKs that i request.

Clearly if all my worker threads are in state 1 then the cancel request could be just a nop.

If I have some worker thread in state 2, 3, or 4 I think I will be fine if I just make sure that the thread reads until the CANCEL_ACK packet.

I think I will just have a control object that has one boolean, readInProgress and two integers, cancelsRequested and cancelsProcessed.

The doCancel() method will- a) lock the object b) if there is no read in progress it will unlock and return. c) otherwise it will send the CANCEL packet, d) increment the cancelsRequested e) unlock object and wait until notified that the cancel was ack'd

Whenever the worker thread wants to read a response from the DB it must- a) lock the control object, b) set the queryOutstanding flag c) unlock the control object d) call the Tds.processSubPacket() method. e) lock the control object f) If the packet was a cancel ack it will increment cancelsProcessed g) notify any threads that are waiting for cancel acknowledgment h) unlock the control object.
version:
   $Id: CancelController.java,v 1.2 2007-10-19 13:21:40 sinisa Exp $



Field Summary
 booleanawaitingData
    
 intcancelsProcessed
    
 intcancelsRequested
    
final public static  StringcvsVersion
    


Method Summary
public synchronized  voiddoCancel(TdsComm comm)
    
public synchronized  voidfinishQuery(boolean wasCanceled, boolean moreResults)
    
public synchronized  voidsetQueryInProgressFlag()
    

Field Detail
awaitingData
boolean awaitingData(Code)



cancelsProcessed
int cancelsProcessed(Code)



cancelsRequested
int cancelsRequested(Code)



cvsVersion
final public static String cvsVersion(Code)





Method Detail
doCancel
public synchronized void doCancel(TdsComm comm) throws java.io.IOException(Code)



finishQuery
public synchronized void finishQuery(boolean wasCanceled, boolean moreResults)(Code)



setQueryInProgressFlag
public synchronized void setQueryInProgressFlag()(Code)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.