Alaska Software Inc. - Open Database List
Username: Password:
AuthorTopic: Open Database List
MichaelOpen Database List
on Fri, 18 Nov 2005 14:18:04 -0600
How do I get a list of Open Databases across all threads?

I know I can use WorkSpaceList() to get a list of databases in the current
thread, but I need to know the current state of all threads.

Any help would be appreciated.
Vladimir IahnencoRe: Open Database List
on Fri, 18 Nov 2005 17:05:49 -0500
Hi Michael,
You may use a public array and add/delete elements when you open/close 
databases.
Vladimir

"Michael" <Michael@NECUnified.com> wrote in message 
news:I2%23M30H7FHA.5608@S15147418...
> How do I get a list of Open Databases across all threads?
>
> I know I can use WorkSpaceList() to get a list of databases in the current
> thread, but I need to know the current state of all threads.
>
> Any help would be appreciated.
>
>
>
MichaelRe: Open Database List
on Fri, 18 Nov 2005 16:36:15 -0600
Hi Vladimir,

Thanks for the response.

I had thought of something like you suggest, but I need it to track an
instability.
If the Thread "Crashes" the array may or may not be accurate.

I was hoping there was a technique within the core Xbase++ / WAA to be able
to get this information.

Thanks again for your quick response.

Michael


"Vladimir Iahnenco" <iahnenco@yahoo.com> wrote in message
news:5mt7QxI7FHA.6160@S15147418...
> Hi Michael,
> You may use a public array and add/delete elements when you open/close
> databases.
> Vladimir
>
> "Michael" <Michael@NECUnified.com> wrote in message
> news:I2%23M30H7FHA.5608@S15147418...
> > How do I get a list of Open Databases across all threads?
> >
> > I know I can use WorkSpaceList() to get a list of databases in the
current
> > thread, but I need to know the current state of all threads.
> >
> > Any help would be appreciated.
> >
> >
> >
>
>
Vladimir IahnencoRe: Open Database List
on Mon, 21 Nov 2005 12:17:37 -0500
Michael,
If you can assume a thread can get creashed, you could put your source in 
BEGIN -END SEQUENCE and put some MyDbCloseAll() etc in your recovery 
statement.

Vladimir


"Michael" <Michael@NECUnified.com> wrote in message 
news:qf8GTCJ7FHA.6152@S15147418...
> Hi Vladimir,
>
> Thanks for the response.
>
> I had thought of something like you suggest, but I need it to track an
> instability.
> If the Thread "Crashes" the array may or may not be accurate.
>
> I was hoping there was a technique within the core Xbase++ / WAA to be 
> able
> to get this information.
>
> Thanks again for your quick response.
>
> Michael
>
>
> "Vladimir Iahnenco" <iahnenco@yahoo.com> wrote in message
> news:5mt7QxI7FHA.6160@S15147418...
>> Hi Michael,
>> You may use a public array and add/delete elements when you open/close
>> databases.
>> Vladimir
>>
>> "Michael" <Michael@NECUnified.com> wrote in message
>> news:I2%23M30H7FHA.5608@S15147418...
>> > How do I get a list of Open Databases across all threads?
>> >
>> > I know I can use WorkSpaceList() to get a list of databases in the
> current
>> > thread, but I need to know the current state of all threads.
>> >
>> > Any help would be appreciated.
>> >
>> >
>> >
>>
>>
>
>
MichaelRe: Open Database List
on Mon, 21 Nov 2005 12:10:25 -0600
Hi Vladimir,

I appreciate the response.  We have thought about it at one point early on.
Our system is much too complex to try to implement something like this.
Besides, this, though functionally resolving the issue, does not solve the
root problem.
Treating the symptom rather than the cause, so to speak.

Thanks,
Michael



"Vladimir Iahnenco" <iahnenco@yahoo.com> wrote in message
news:UK1Ku9r7FHA.1256@S15147418...
> Michael,
> If you can assume a thread can get creashed, you could put your source in
> BEGIN -END SEQUENCE and put some MyDbCloseAll() etc in your recovery
> statement.
>
> Vladimir
>
>
> "Michael" <Michael@NECUnified.com> wrote in message
> news:qf8GTCJ7FHA.6152@S15147418...
> > Hi Vladimir,
> >
> > Thanks for the response.
> >
> > I had thought of something like you suggest, but I need it to track an
> > instability.
> > If the Thread "Crashes" the array may or may not be accurate.
> >
> > I was hoping there was a technique within the core Xbase++ / WAA to be
> > able
> > to get this information.
> >
> > Thanks again for your quick response.
> >
> > Michael
> >
> >
> > "Vladimir Iahnenco" <iahnenco@yahoo.com> wrote in message
> > news:5mt7QxI7FHA.6160@S15147418...
> >> Hi Michael,
> >> You may use a public array and add/delete elements when you open/close
> >> databases.
> >> Vladimir
> >>
> >> "Michael" <Michael@NECUnified.com> wrote in message
> >> news:I2%23M30H7FHA.5608@S15147418...
> >> > How do I get a list of Open Databases across all threads?
> >> >
> >> > I know I can use WorkSpaceList() to get a list of databases in the
> > current
> >> > thread, but I need to know the current state of all threads.
> >> >
> >> > Any help would be appreciated.
> >> >
> >> >
> >> >
> >>
> >>
> >
> >
>
>
AUGE_OHRRe: Open Database List
on Sat, 19 Nov 2005 00:49:14 +0100
hi,

> I know I can use WorkSpaceList() to get a list of databases in the current
> thread, but I need to know the current state of all threads.

FOR i = 1 TO nMaxThreadYouHave
    aWork := WorkSpaceList(i)
    IF LEN(aWork) > 0
        ...
    ENDIF
NEXT

greetings by OHR
Jimmy
MichaelRe: Open Database List
on Fri, 18 Nov 2005 18:42:06 -0600
Hi Jimmy,

That would be a logical place to get it, but it is not how WorkSpaceList()
works.
According to the docs and a little experimenting, it only accepts parameters
of 1 or 2.
One (1) being the current Thread (WorkSpace) or Two (2) being WorkSpaceZero.

I would think there would be something that would be just as simple, but I
just can't see it.

Thanks anyway, any other thoughts would be greatly welcomed.

Michael


"AUGE_OHR" <AUGE_OHR*AT*CSI.COM> wrote in message
news:bQp1r2J7FHA.6152@S15147418...
> hi,
>
> > I know I can use WorkSpaceList() to get a list of databases in the
current
> > thread, but I need to know the current state of all threads.
>
> FOR i = 1 TO nMaxThreadYouHave
>     aWork := WorkSpaceList(i)
>     IF LEN(aWork) > 0
>         ...
>     ENDIF
> NEXT
>
> greetings by OHR
> Jimmy
>
>
AUGE_OHRRe: Open Database List
on Sun, 20 Nov 2005 22:56:06 +0100
hi,

> That would be a logical place to get it, but it is not how WorkSpaceList()
> works.
> According to the docs and a little experimenting, it only accepts
parameters
> of 1 or 2.
> One (1) being the current Thread (WorkSpace) or Two (2) being
WorkSpaceZero.

uuups, yes there are only 2 constant : DB_ZEROSPACE & DB_WORKSPACE

> Thanks anyway, any other thoughts would be greatly welcomed.

did you try F6() from Alaskas ACSN section ... perhaps that help.

greeings by OHR
Jimmy
MichaelRe: Open Database List
on Mon, 21 Nov 2005 07:39:43 -0600
Hi Jimmy,

I took a look at it but it still does not let me see Threads other than the
one I am currently in.

It did look promissing for a while though 

Thanks,
Michael


"AUGE_OHR" <AUGE_OHR*AT*CSI.COM> wrote in message
news:%23odmeCi7FHA.6152@S15147418...
> hi,
>
> > That would be a logical place to get it, but it is not how
WorkSpaceList()
> > works.
> > According to the docs and a little experimenting, it only accepts
> parameters
> > of 1 or 2.
> > One (1) being the current Thread (WorkSpace) or Two (2) being
> WorkSpaceZero.
>
> uuups, yes there are only 2 constant : DB_ZEROSPACE & DB_WORKSPACE
>
> > Thanks anyway, any other thoughts would be greatly welcomed.
>
> did you try F6() from Alaskas ACSN section ... perhaps that help.
>
> greeings by OHR
> Jimmy
>
>
Phil Ide
Re: Open Database List
on Mon, 21 Nov 2005 10:52:13 +0000
Jimmy, Michael,

>> I know I can use WorkSpaceList() to get a list of databases in the current
>> thread, but I need to know the current state of all threads.
> 
> FOR i = 1 TO nMaxThreadYouHave
>     aWork := WorkSpaceList(i)
>     IF LEN(aWork) > 0
>         ...
>     ENDIF
> NEXT

Well, you actually have to enter teh thread to query it's workspace 

You can get the number of worker threads like this:

nWThreads := Val( GetEnv('WAA_WORKERTHREADS') )

Stepping into the threads:

if !oThread:active
   aList := oThread:start("WorkSpaceList")
endif

Regards

Phil Ide

*******************************************
*   Xbase++ FAQ, Libraries and Sources:   *
*   goto: http://www.idep.org.uk/xbase    *
* --------------------------------------- *
* www.xodc.org.uk - openSource Dev-Center *
*******************************************

No, "monogamy" is NOT a type of wood!!!
MichaelRe: Open Database List
on Mon, 21 Nov 2005 07:48:08 -0600
Hi Phil,

Unfortunately, WAA keeps all threads active.

I tried:

   Local aInfo := ThreadInfo( THREADINFO_TID      + ;
                              THREADINFO_FUNCINFO + ;
                              THREADINFO_TOBJ)


   For x := 1 To Len(aInfo)
      if !aInfo[x,4]:active
         aList := aInfo[x,4]:start("WorkSpaceList")
      Else
         aList := {"Active"}
      endif
      aAdd(aMasterList, aList)
   Next
   MsgBox(Var2Char(aMasterList))

The result is an array filled with "Active".
If I try to :Start() in an active Thread, the array is filled with .F. (as
expected)

I was hoping there would be some way similar to the Call Stack, which you
can get from all Threads using:
ProcName( [<nCallStack>], [<nThreadId>] )
ProcLine( [<nCallStack>], [<nThreadId>] )
etc.

Any other thoughts?

Thanks,
Michael



"Phil Ide" <phil@xodc.org.uk> wrote in message
news:1ewi1dhklljne.dlg@xodc.org.uk...
> Jimmy, Michael,
>
> >> I know I can use WorkSpaceList() to get a list of databases in the
current
> >> thread, but I need to know the current state of all threads.
> >
> > FOR i = 1 TO nMaxThreadYouHave
> >     aWork := WorkSpaceList(i)
> >     IF LEN(aWork) > 0
> >         ...
> >     ENDIF
> > NEXT
>
> Well, you actually have to enter teh thread to query it's workspace 
>
> You can get the number of worker threads like this:
>
> nWThreads := Val( GetEnv('WAA_WORKERTHREADS') )
>
> Stepping into the threads:
>
> if !oThread:active
>    aList := oThread:start("WorkSpaceList")
> endif
>
> Regards
> -- 
> Phil Ide
>
> *******************************************
> *   Xbase++ FAQ, Libraries and Sources:   *
> *   goto: http://www.idep.org.uk/xbase    *
> * --------------------------------------- *
> * www.xodc.org.uk - openSource Dev-Center *
> *******************************************
>
> No, "monogamy" is NOT a type of wood!!!
Phil Ide
Re: Open Database List
on Mon, 21 Nov 2005 15:59:43 +0000
Michael,

> Unfortunately, WAA keeps all threads active.
> 
> Any other thoughts?

Yes - wait for WAA2.  Not much help I know, but some things are just like
that.

Another alternative that just occured to me, is you can do something like
this:

1. Create a function (form-function) in WAA to return the thread-id and
workspace db-list.

2. Create another function which calls (1) repeatedly via the web server
until it has fetched info from all worker-threads. WAA cycles through the
worker threads, so if you have 5 w-threads, 5 calls should do it (although
you'll have to account for the thread triggering the other requests).  If
other requests are being serviced, you may have to cycle though the threads
again.

Regards,

Phil Ide

*******************************************
*   Xbase++ FAQ, Libraries and Sources:   *
*   goto: http://www.idep.org.uk/xbase    *
* --------------------------------------- *
* www.xodc.org.uk - openSource Dev-Center *
*******************************************

A closed mouth gathers no feet.
MichaelRe: Open Database List
on Mon, 21 Nov 2005 12:40:00 -0600
Hi Phil,


"Phil Ide" <phil@xodc.org.uk> wrote in message
news:1ccc48iaahrl$.dlg@xodc.org.uk...
{snip}

> Yes - wait for WAA2.  Not much help I know, but some things are just like
> that.

And the release date would be when?  

>
> Another alternative that just occured to me, is you can do something like
> this:
>
> 1. Create a function (form-function) in WAA to return the thread-id and
> workspace db-list.
>
> 2. Create another function which calls (1) repeatedly via the web server
> until it has fetched info from all worker-threads. WAA cycles through the
> worker threads, so if you have 5 w-threads, 5 calls should do it (although
> you'll have to account for the thread triggering the other requests).  If
> other requests are being serviced, you may have to cycle though the
threads
> again.
>

The problem with this is that the "Caller" will always be in the same
Thread.
With 20 threads, a Javascript may take a while to hit all of them.

Realize, as I am writing this, I am trying to figure out a way to make this
work.
Perhaps a cgi that repeatedly calls the "Function" might be plausable, but
it is still hit-or-miss.

It would be better with a more direct approach.  Something along the line of
WorkSpaceList(nThread) is still what I am hoping for.

So far I cannot think of any "Clean" way of doing it.

All ideas are welcome.

Thanks,
Michael


> Regards,
> -- 
> Phil Ide
>
> *******************************************
> *   Xbase++ FAQ, Libraries and Sources:   *
> *   goto: http://www.idep.org.uk/xbase    *
> * --------------------------------------- *
> * www.xodc.org.uk - openSource Dev-Center *
> *******************************************
>
> A closed mouth gathers no feet.
Frans VermeulenRe: Open Database List
on Tue, 22 Nov 2005 11:02:32 +0100
Michael,

> So far I cannot think of any "Clean" way of doing it.
>
> All ideas are welcome.

1) Replace all occurances of dbUseArea and dbCloseArea
with myUseArea and myCloseArea, and do your own administration.

2) Open all tables in the _register function, and keep track of the open
areas there ?

HTH,
Frans Vermeulen
MichaelRe: Open Database List
on Tue, 22 Nov 2005 12:01:34 -0600
Hi Frans,

Thanks for the input.

I have been trying to avoid rewriting the application.
The application is too massive to try this approach with the limited
resources and time available.

As far as the opening of files and leaving them open, in the WAA environment
they would need to be opened in each Thread and that would put way too much
overhead on the Server.  Too many files, Threads, etc to maintain.

We were looking for more a Status Snapshot routine.

Thanks,
Michael


"Frans Vermeulen" <fransv@visspec.nl> wrote in message
news:3vX$fv07FHA.7860@S15147418...
> Michael,
>
> > So far I cannot think of any "Clean" way of doing it.
> >
> > All ideas are welcome.
>
> 1) Replace all occurances of dbUseArea and dbCloseArea
> with myUseArea and myCloseArea, and do your own administration.
>
> 2) Open all tables in the _register function, and keep track of the open
> areas there ?
>
> HTH,
> Frans Vermeulen
>
>
Phil Ide
Re: Open Database List
on Tue, 22 Nov 2005 12:57:13 +0000
Michael,

>> Yes - wait for WAA2.  Not much help I know, but some things are just like
>> that.
> 
> And the release date would be when?  

At this moment in time, I have absolutely no idea. 

> So far I cannot think of any "Clean" way of doing it.
> 
> All ideas are welcome.

Well, I don't think there is a 'clean' way of doing it at the moment.

Regards,

Phil Ide

*******************************************
*   Xbase++ FAQ, Libraries and Sources:   *
*   goto: http://www.idep.org.uk/xbase    *
* --------------------------------------- *
* www.xodc.org.uk - openSource Dev-Center *
*******************************************

Can you teach an old SysOp new tricks?
MichaelRe: Open Database List
on Tue, 22 Nov 2005 12:12:41 -0600
Hi Phil,


"Phil Ide" <phil@xodc.org.uk> wrote in message
news:kg11z5u6vx3s.dlg@xodc.org.uk...
> Michael,
>
> >> Yes - wait for WAA2.  Not much help I know, but some things are just
like
> >> that.
> >
> > And the release date would be when?  
>
> At this moment in time, I have absolutely no idea. 


Ahhh, the "In the Future" development cycle.  I'll have to try that  


> > So far I cannot think of any "Clean" way of doing it.
> >
> > All ideas are welcome.
>
> Well, I don't think there is a 'clean' way of doing it at the moment.

What I have been able to do is an HTML Redirect, passing the Array back to a
Function until the Array has been filled, then the routine branches to
another Function to fullfil the display function and report the information
back to the calling Browser.

Again, this not the cleanest approach and needs to be used with caution.
I still need to integrate Loop Limitations so it does not turn rougue, but
currently it is giving me the information I needed.

Thanks,
Michael
Rodd GrahamRe: Open Database List
on Tue, 22 Nov 2005 10:14:34 -0600
Michael,

Maybe if you elaborate on what you are trying to do with the list of 
workspaces from all threads, the goal might have an alternative approach 
that does not require listing workspaces from other threads.

-OR-

You can make thread level state visible outside of the thread by inheriting 
the thread class and adding the additional state information to exported 
instance variables.  When the thread goes, the state goes with it.  Hence, 
maintaining the workspace list in a thread instance variable will allow you 
to process the thread list to generate a list of open workspaces.

Still requires wrappers on dbUseArea, dbCloseArea to mirror the workspace 
list into the thread instance variable, but easy enough to do with #pragma 
or #command.  Wrappers have an additional advantage that they provide a hook 
point of the operation to build future features into.

Dont forget to use SYNC methods as necessary on thread instance variables 
(hidden instance variables; access/assign methods) since they can be 
accessed by all threads.

Rodd

"Michael" <Michael@NECUnified.com> wrote in message 
news:W356prs7FHA.2944@S15147418...
> Hi Phil,
>
>
> "Phil Ide" <phil@xodc.org.uk> wrote in message
> news:1ccc48iaahrl$.dlg@xodc.org.uk...
> {snip}
>
>> Yes - wait for WAA2.  Not much help I know, but some things are just like
>> that.
>
> And the release date would be when?  
>
>>
>> Another alternative that just occured to me, is you can do something like
>> this:
>>
>> 1. Create a function (form-function) in WAA to return the thread-id and
>> workspace db-list.
>>
>> 2. Create another function which calls (1) repeatedly via the web server
>> until it has fetched info from all worker-threads. WAA cycles through the
>> worker threads, so if you have 5 w-threads, 5 calls should do it 
>> (although
>> you'll have to account for the thread triggering the other requests).  If
>> other requests are being serviced, you may have to cycle though the
> threads
>> again.
>>
>
> The problem with this is that the "Caller" will always be in the same
> Thread.
> With 20 threads, a Javascript may take a while to hit all of them.
>
> Realize, as I am writing this, I am trying to figure out a way to make 
> this
> work.
> Perhaps a cgi that repeatedly calls the "Function" might be plausable, but
> it is still hit-or-miss.
>
> It would be better with a more direct approach.  Something along the line 
> of
> WorkSpaceList(nThread) is still what I am hoping for.
>
> So far I cannot think of any "Clean" way of doing it.
>
> All ideas are welcome.
>
> Thanks,
> Michael
>
>
>> Regards,
>> -- 
>> Phil Ide
>>
>> *******************************************
>> *   Xbase++ FAQ, Libraries and Sources:   *
>> *   goto: http://www.idep.org.uk/xbase    *
>> * --------------------------------------- *
>> * www.xodc.org.uk - openSource Dev-Center *
>> *******************************************
>>
>> A closed mouth gathers no feet.
>
>
MichaelRe: Open Database List
on Tue, 22 Nov 2005 12:18:29 -0600
Hi Rodd,


"Rodd Graham" <rodd@tpmco.com> wrote in message
news:Mpy0I$37FHA.3104@S15147418...
> Michael,
>
> Maybe if you elaborate on what you are trying to do with the list of
> workspaces from all threads, the goal might have an alternative approach
> that does not require listing workspaces from other threads.

What I am trying to do is to get a Snapshot of the data usage in a WAA
Application.


> -OR-
>
> You can make thread level state visible outside of the thread by
inheriting
> the thread class and adding the additional state information to exported
> instance variables.  When the thread goes, the state goes with it.  Hence,
> maintaining the workspace list in a thread instance variable will allow
you
> to process the thread list to generate a list of open workspaces.
>
> Still requires wrappers on dbUseArea, dbCloseArea to mirror the workspace
> list into the thread instance variable, but easy enough to do with #pragma
> or #command.  Wrappers have an additional advantage that they provide a
hook
> point of the operation to build future features into.
>
> Dont forget to use SYNC methods as necessary on thread instance variables
> (hidden instance variables; access/assign methods) since they can be
> accessed by all threads.
>

Because this is a WAA Application, Subclassing the Threads is not possible
(I believe) without the source code of the WAA.
It would have been simple if I could have Subclassed and used the :Execute()
Method to return the information.

It would have been my second choice (after a built in function) but without
being able to recompile the WAA, I can't see any way of doing this.

Thanks,
Michael
Phil Ide
Re: Open Database List
on Wed, 23 Nov 2005 10:22:54 +0000
Michael,

> Because this is a WAA Application, Subclassing the Threads is not possible
> (I believe) without the source code of the WAA.
> It would have been simple if I could have Subclassed and used the :Execute()
> Method to return the information.

Correct.

Here's another option for you.  On startup (e.g. in your _register()
function), open a table with the following format:

THREADNO C  4 0
ALIAS    C 10 0

When you open a table, seek for the current thread-id and alias of the
table.  If not found, add a record.

Having acquired a record, lock it (retaining existing locks).

When you close a table, release the lock.

In this fashion, you can simply scan this table to see which threads have
which tables open.  The locks on the records allow you to see which are
currently being used.

Regards,

Phil Ide

*******************************************
*   Xbase++ FAQ, Libraries and Sources:   *
*   goto: http://www.idep.org.uk/xbase    *
* --------------------------------------- *
* www.xodc.org.uk - openSource Dev-Center *
*******************************************

If the phone doesn't ring, you'll know it's me
Rodd GrahamRe: Open Database List
on Wed, 23 Nov 2005 09:51:53 -0600
To add to Phil's suggestion:

And if you put the tracking table on a ram disk (www.cenatek.com), it 
becomes an in memory structure.  Very fast relative to disk.  Great for 
temporary tables too.  I have seen disk based processes increase performance 
100x when moving to ram disk from physical disk.  Good solution for shared 
temporary data.

Note that cenatek has a software ram disk driver that is very affordable.

Rodd

"Phil Ide" <phil@xodc.org.uk> wrote in message 
news:16kq7p3ers8xa.dlg@xodc.org.uk...
> Michael,
>
>> Because this is a WAA Application, Subclassing the Threads is not 
>> possible
>> (I believe) without the source code of the WAA.
>> It would have been simple if I could have Subclassed and used the 
>> :Execute()
>> Method to return the information.
>
> Correct.
>
> Here's another option for you.  On startup (e.g. in your _register()
> function), open a table with the following format:
>
> THREADNO C  4 0
> ALIAS    C 10 0
>
> When you open a table, seek for the current thread-id and alias of the
> table.  If not found, add a record.
>
> Having acquired a record, lock it (retaining existing locks).
>
> When you close a table, release the lock.
>
> In this fashion, you can simply scan this table to see which threads have
> which tables open.  The locks on the records allow you to see which are
> currently being used.
>
> Regards,
> -- 
> Phil Ide
>
> *******************************************
> *   Xbase++ FAQ, Libraries and Sources:   *
> *   goto: http://www.idep.org.uk/xbase    *
> * --------------------------------------- *
> * www.xodc.org.uk - openSource Dev-Center *
> *******************************************
>
> If the phone doesn't ring, you'll know it's me