Could you add a little bit of documentation to the code? While I think it's a useful example, documenting the code will make it easier to understand. Not everyone is knows about the %Dictionary classes. And it's generally a good idea to add explaining comments. Thanks!
I am using https://hackmd.io/. It is open source and allows for collaborative editing of articles (like Etherpad), but with MD support. You can install it locally in your own network or even your own machine (docker images are available).
The `chown' command sometimes clears the set-user-IDorset-group-ID
permission bits. This behavior depends on the policyand functionality
of the underlying `chown' system call, which may make system-dependent
file mode modifications outside the control of the `chown' command.
For example, the `chown' command might not affect those bits when
invoked by a userwith appropriate privileges, orwhen the bits signify
somefunction other than executable permission (e.g., mandatory
locking). Whenin doubt, check the underlying system behavior.
our implementations of encryption and hash algorithms can be accessed through the %SYSTEM.Encryption class. Unfortunately we currently don't have a bcrypt implementation.
Please note that this example uses the old (deprecated) dot-syntax for the loop. It also loops through your data twice. Nowadays you would write the same more like this:
#include %occInclude
ListDir
set statement=##class(%SQL.Statement).%New()
set status=statement.%PrepareClassQuery("%File","FileSet")
if$$$ISERR(status) { do$system.OBJ.DisplayError(status) }
set resultset=statement.%Execute("c:\temp","*","",1)
while resultset.%Next() {
write:resultset.%Get("Type")="D" !, resultset.%Get("Name")
}
The problem was: with just removing the directory, the processes are still hanging around. So the 1972 port was still in use by the original cache instance.
Restarting removed that process, that's why it solved the issue. Part of Dmitry's answer was useful in such as you can use lsof to determine which process holds a handle on a port.
Please let me know if you have any further questions about this!
Other than that, I'm not aware of a single method that would export everything. You could of course write your own method to do it (and maybe steal some code from the above)
Can you elaborate what you mean by that? Every incoming request automatically gets assigned a new session, unless it carries cookies with it that tie it to an existing one.
you can use PERFMON [1] to collect statistics about which globals are being accessed. This will allow you to monitor a process and then distinguish between your globals being accessed and system globals.
That being said, I don't quite see why would would need that distinction. Where do you draw the line? When you write a sql query and it gets compiled into a routine, would you consider that being your code, or Caché's code?
There are a couple of global accesses that will happen when you run your code, such as loading a routine (classes get compiled into routines). However, as soon as that has happened once, the routine will be in the routine buffer, so no further disc access will happen. Overall, if your application handles any amount of data that goes beyond a couple of blocks, the 'system accesses' will be negligible.
In your example you are seeing the first time the routine is being loaded, hence the 4 references. A more realistic example would be to access 100000 random global nodes in your random class. There will still be a more accesses but 3/100000 really doesn't matter by any metric you might employ.
You can also run LOG^%ETN() at any point, which will create an entry in the application error log, with a lot more information than just the stacktrace. It's very useful as it also gives you the parameters passed into the functions along the stack.
There is ^%GSIZE which will give you an overview of the usage per global. However, if you have a normal size database (>1TB) this is going to take a while.
I have written statistical approaches in the past. I'll clean up one of them and post it on the community if there is enough interest. (that one actually has a graphical display of the results)
go to post
I think this is what you are looking for: http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GORIENT_ch_cos
go to post
For completeness, here's the classdoc to the method used: http://docs.intersystems.com/latest/csp/documatic/%25CSP.Documatic.cls?PAGE=CLASS&LIBRARY=%25SYS&CLASSNAME=%25Net.URLParser
go to post
Could you add a little bit of documentation to the code? While I think it's a useful example, documenting the code will make it easier to understand. Not everyone is knows about the %Dictionary classes. And it's generally a good idea to add explaining comments. Thanks!
go to post
I am using https://hackmd.io/. It is open source and allows for collaborative editing of articles (like Etherpad), but with MD support. You can install it locally in your own network or even your own machine (docker images are available).
go to post
Thanks! I fixed both:) (and updated the git repo).
Please also keep in mind that the code is using the old json syntax, so you'll need to update those too.
Cheers,
Fab
go to post
$TR removes all the spaces from the complete string, which is not what was asked for. $ZSTRIP is the way to go.
go to post
That is not how executables work.
go to post
Just for clarification, this is known behaviour:
info coreutils 'chown invocation':
The `chown' command sometimes clears the set-user-ID or set-group-ID permission bits. This behavior depends on the policy and functionality of the underlying `chown' system call, which may make system-dependent file mode modifications outside the control of the `chown' command. For example, the `chown' command might not affect those bits when invoked by a user with appropriate privileges, or when the bits signify some function other than executable permission (e.g., mandatory locking). When in doubt, check the underlying system behavior.
go to post
Hi,
our implementations of encryption and hash algorithms can be accessed through the %SYSTEM.Encryption class. Unfortunately we currently don't have a bcrypt implementation.
HTH
-Fab
go to post
Please note that this example uses the old (deprecated) dot-syntax for the loop. It also loops through your data twice. Nowadays you would write the same more like this:
#include %occInclude ListDir set statement=##class(%SQL.Statement).%New() set status=statement.%PrepareClassQuery("%File","FileSet") if $$$ISERR(status) { do $system.OBJ.DisplayError(status) } set resultset=statement.%Execute("c:\temp","*","",1) while resultset.%Next() { write:resultset.%Get("Type")="D" !, resultset.%Get("Name") }
go to post
For more flexibility/fun with parameters, also check out:
http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GCOS_usercode#GCOS_usercode_args_variable
and
http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GOBJ_methods#GOBJ_methods_args_variable
:)
go to post
Have a look at the %File class and its queries (especially FileSet). This allows you to get the information you're looking for:
http://docs.intersystems.com/latest/csp/documatic/%25CSP.Documatic.cls?PAGE=CLASS&LIBRARY=%25SYS&CLASSNAME=%25Library.File
go to post
Hi Alexander,
The problem was: with just removing the directory, the processes are still hanging around. So the 1972 port was still in use by the original cache instance.
Restarting removed that process, that's why it solved the issue. Part of Dmitry's answer was useful in such as you can use lsof to determine which process holds a handle on a port.
Please let me know if you have any further questions about this!
HTH,
Fab
go to post
If you're not 100% set on the UDL requirement, this might be interesting to you:
http://docs.intersystems.com/latest/csp/documatic/%25CSP.Documatic.cls?P...
Other than that, I'm not aware of a single method that would export everything. You could of course write your own method to do it (and maybe steal some code from the above)
go to post
Preserve mode should be avoided if at all possible. It has a negative impact on performance, and tempts people into very bad design choices!
go to post
Can you elaborate what you mean by that? Every incoming request automatically gets assigned a new session, unless it carries cookies with it that tie it to an existing one.
go to post
Hi Marc,
you can use PERFMON [1] to collect statistics about which globals are being accessed. This will allow you to monitor a process and then distinguish between your globals being accessed and system globals.
That being said, I don't quite see why would would need that distinction. Where do you draw the line? When you write a sql query and it gets compiled into a routine, would you consider that being your code, or Caché's code?
There are a couple of global accesses that will happen when you run your code, such as loading a routine (classes get compiled into routines). However, as soon as that has happened once, the routine will be in the routine buffer, so no further disc access will happen. Overall, if your application handles any amount of data that goes beyond a couple of blocks, the 'system accesses' will be negligible.
In your example you are seeing the first time the routine is being loaded, hence the 4 references. A more realistic example would be to access 100000 random global nodes in your random class. There will still be a more accesses but 3/100000 really doesn't matter by any metric you might employ.
I hope this addresses your concerns.
Best,Fab
[1]http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GCM_perfmon#GCM_perfmon_using
go to post
Generally this approach is called Fuzzing (https://en.wikipedia.org/wiki/Fuzz_testing) and is used all over the place.
I've recently used american fuzzy lop (http://lcamtuf.coredump.cx/afl/) to stress test the xml parsers in Caché to great success.
go to post
You can also run LOG^%ETN() at any point, which will create an entry in the application error log, with a lot more information than just the stacktrace. It's very useful as it also gives you the parameters passed into the functions along the stack.
go to post
There is ^%GSIZE which will give you an overview of the usage per global. However, if you have a normal size database (>1TB) this is going to take a while.
I have written statistical approaches in the past. I'll clean up one of them and post it on the community if there is enough interest. (that one actually has a graphical display of the results)
Best,
Fabian