четверг, 28 февраля 2013 г.
вторник, 26 февраля 2013 г.
1. mongod –help
Get to know all the Windows service related commands by typing “
C:\MongoDB\bin>mongod --help Windows Service Control Manager options: --install install mongodb service --remove remove mongodb service --reinstall reinstall mongodb service (equivilant of mongod --remove followed by mongod --install) --serviceName arg windows service name --serviceDisplayName arg windows service display name --serviceDescription arg windows service description --serviceUser arg user name service executes as --servicePassword arg password used to authenticate serviceUser
--install” and “
--remove” arguments are what you need.
2. Install as Windows Service
To install as Windows service, issue “
mongod --install“, for example :
#> mongod --dbpath "c:\mymongodb" --logpath "c:\mymongodb\logs.txt" --install --serviceName "MongoDB" all output going to: c:\mymongodb\logs.txt Creating service MongoDB. Service creation successful. Service can be started from the command line via 'net start "MongoDB"'.
It means, install a MongoDB, which point to “
c:\mymongodb” data directory, log outputs to “
c:\mymongodb\logs.txt“, and a Windows service named “MongoDB“.
Figure : MongoDB is installed as Windows Service
3. Uninstall It
To uninstall above installed MongoDB service, issue “
mongod --remove“, along with the installed service name.
#> mongod --remove --serviceName "MongoDB" Deleting service MongoDB. Service deleted successfully. Fri Apr 29 18:39:06 dbexit: Fri Apr 29 18:39:06 shutdown: going to close listening sockets... Fri Apr 29 18:39:06 shutdown: going to flush diaglog... Fri Apr 29 18:39:06 shutdown: going to close sockets... Fri Apr 29 18:39:06 shutdown: waiting for fs preallocator... Fri Apr 29 18:39:06 shutdown: closing all files... Fri Apr 29 18:39:06 closeAllFiles() finished Fri Apr 29 18:39:06 dbexit: really exiting now
суббота, 9 февраля 2013 г.
This is by no means any detailed post on how to use reflection. The other day I had the need to use reflection to call a generic method. So after playing around with reflection for few minutes I figured it out. Here is how the code looks like.
Here is how the generic method looks like.
Here is how you would invoke it.
The generic method is pretty simple. I am taking a parameter of type T which makes it a generic method. I simply print that generic parameter value to the console as the method name states.
In the order to call the generic method, I first create an instance of Printing class by calling Activator.CreateInstance passing in type of object I want to instantiate. The reason I am creating an instance of Printing type is because PrintAnyThing generic method is an instance method. If the method would have been static I do not need to create an instance of it. Next from the type, I try to get method info for PrintAnyThing. Notice at this point it is still a generic method and I cannot invoke it directly. I need to convert it to closed method by specifying the value for T which I do by making a call to MakeGenericMethod. Once I have the closed method, I pass in the instance on which this method is to be invoked along with the method arguments that the method requires.