torek, 9. oktober 2012

Convert author in Mercurial repositiories

This is a summary of StackOverflow question http://stackoverflow.com/questions/12136895/change-the-author-in-mercurial-history


- cd repo1/.hg
- vi .hgrc and add
        [extensions]
        hgext.convert=
- cd $HOME
- vi authors.convert.list
        USER1 =USER2
- hg convert --authors $HOME/authors.convert.list repo1 repo1.NEW

Merge two mercurial repositories into one

This is a summary of a StackOverflow question http://stackoverflow.com/questions/12109203/merge-different-repositories-into-one


cd repo2
mkdir repo2
hg rename * repo2
hg commit -m "Move repo2 files into a subfolder"
cd repo1
hg pull -f path\to\repo2
hg merge
... and deal with merge conflicts if any ...
hg commit -m "Merge with repo2"

Glassfish: Run asadmin from Java program

When you execute asadmin on a secure enabled server you have to provide admin username and password. This can be a bit of a PITA if you are calling asadmin from a Java program.
You have two options:

  1. Create $HOME/.asadminpass:
    asadmin://admin@localhost:4848 BASE64_ENCODED_PASSWORD
  2. Or you can pass the file with the password with every asadmin command:
    1. Create glassfisg.password file:
      AS_ADMIN_PASSWORD=PLAIN_ADMIN_PASSWORD
    2. If you are on Linux it is a good idea to make the file readable only to your user:
      chmod 600 glassfish.password
    3. Execute asadmin command:
      $com.sun.aas.installRoot/bin/asadmin --user admin --passwordfile PATH_TO_PASSWORD_FILE list-applications
$HOME is a home directory of a user under which Glassfish is running.
$com.sun.aas.installRoot is the installation directory of Glassfish. It is only set on a Glassfish process.

OpenMQ: Create queues from Java program

When you execute imqcmd command from OpenMQ you have to provide username and password, which is a bit of a PITA if you are calling the imqcmd from Java programs.
This is the recipe you can use to get around this problem:

  1. Create a file calles imqCmd.password with following content:
    imq.imqcmd.password=ADMIN_OPENMQ_PASSWORD
  2. If you are on Linux it is a good idea to make the file readable only to your user:
    chmod 600 imqCmd.password
  3. Run the commands for queue creation:
    $com.sun.aas.imqBin/imqcmd create dst -n MyQueue -t q -o "maxNumMsgs=1000" -o "limitBehavior=FLOW_CONTROL" -o "maxNumMsgs=-1" -o "localDeliveryPreferred=false" -o "useDMQ=true" -o "validateXMLSchemaEnabled=false" -u admin -passfile PATH_TO_PASSWORD_FILE
  4. You can also delete the queue:
    $com.sun.aas.imqBin/imqcmd destroy dst -n MyQueue -t q -f -u admin -passfile PATH_TO_PASSWORD_FILE
com.sun.aas.imqBin is a System property that tells you where you can find imqcmd and other OpenMQ executables. It is only set on a Glassfish process.

Interesting Glassfish system properties


Properties:

  • com.sun.aas.imqBin: here you find executables from OpenMQ
  • com.sun.aas.agentRoot: here you find directory for nodes
  • com.sun.aas.productRoot: installation directory of Glassfish
  • com.sun.aas.configRoot: directory where Glassfish keeps config files
  • com.sun.aas.imqLib: library directory of OpenMQ
  • com.sun.aas.domainsRoot: directory of Glassfish domains
  • com.sun.aas.instanceRoot: directory of the current domain